Input
Basic usage
Value is:
<script>
let value = ''
</script>
<CInput bind:value placeholder="Input something" />
<h3>
Value is: {value}
</h3>
<script>
let value = ''
</script>
<CInput bind:value placeholder="Input something" />
<h3>
Value is: {value}
</h3>
Shapes
<script>
let value = ''
</script>
<CInput bind:value placeholder="Normal input" />
<CInput bind:value rounded placeholder="Rounded input" />
<script>
let value = ''
</script>
<CInput bind:value placeholder="Normal input" />
<CInput bind:value rounded placeholder="Rounded input" />
Sizes
<script lang="ts">
let value = ''
</script>
<div class="c-flex c-gutter-md c-wrap c-items-center">
<div>
<CInput bind:value placeholder="xs" size="xs" />
</div>
<div>
<CInput bind:value placeholder="sm" size="sm" />
</div>
<div>
<CInput bind:value placeholder="md (default)" />
</div>
<div>
<CInput bind:value placeholder="lg" size="lg" />
</div>
<div>
<CInput bind:value placeholder="xl" size="xl" />
</div>
<div>
<CInput bind:value placeholder="xs" rounded size="xs" />
</div>
<div>
<CInput bind:value placeholder="sm" size="sm" rounded />
</div>
<div>
<CInput bind:value placeholder="md (default)" rounded />
</div>
<div>
<CInput bind:value placeholder="lg" size="lg" rounded />
</div>
<div>
<CInput bind:value placeholder="xl" size="xl" rounded />
</div>
</div>
<script lang="ts">
let value = ''
</script>
<div class="c-flex c-gutter-md c-wrap c-items-center">
<div>
<CInput bind:value placeholder="xs" size="xs" />
</div>
<div>
<CInput bind:value placeholder="sm" size="sm" />
</div>
<div>
<CInput bind:value placeholder="md (default)" />
</div>
<div>
<CInput bind:value placeholder="lg" size="lg" />
</div>
<div>
<CInput bind:value placeholder="xl" size="xl" />
</div>
<div>
<CInput bind:value placeholder="xs" rounded size="xs" />
</div>
<div>
<CInput bind:value placeholder="sm" size="sm" rounded />
</div>
<div>
<CInput bind:value placeholder="md (default)" rounded />
</div>
<div>
<CInput bind:value placeholder="lg" size="lg" rounded />
</div>
<div>
<CInput bind:value placeholder="xl" size="xl" rounded />
</div>
</div>
Clearable
<script lang="ts">
let value = ''
</script>
<CInput
bind:value
placeholder="Enter something and see the clear icon"
clearable
/>
<script lang="ts">
let value = ''
</script>
<CInput
bind:value
placeholder="Enter something and see the clear icon"
clearable
/>
Status
<script lang="ts">
let value = ''
</script>
<CInput bind:value disabled placeholder="Disabled" />
<CInput rounded bind:value loading placeholder="Loading..." />
<CInput rounded bind:value placeholder="Readonly" readonly />
<script lang="ts">
let value = ''
</script>
<CInput bind:value disabled placeholder="Disabled" />
<CInput rounded bind:value loading placeholder="Loading..." />
<CInput rounded bind:value placeholder="Readonly" readonly />
Custom loading instance
<script lang="ts">
let value = ''
</script>
<CInput bind:value placeholder="Custom loading" loading>
<div slot="loading" class="c-text-primary">
<CLoadingWifi />
</div>
</CInput>
<CInput bind:value placeholder="Custom loading" loading>
<div slot="loading" class="c-text-warning">
<CLoadingCircleBars slot="loading" />
</div>
</CInput>
<script lang="ts">
let value = ''
</script>
<CInput bind:value placeholder="Custom loading" loading>
<div slot="loading" class="c-text-primary">
<CLoadingWifi />
</div>
</CInput>
<CInput bind:value placeholder="Custom loading" loading>
<div slot="loading" class="c-text-warning">
<CLoadingCircleBars slot="loading" />
</div>
</CInput>
Prefix & Suffix
<script lang="ts">
let value = ''
</script>
<div class="c-wrap c-flex c-gutter-md c-items-center">
<div>
<CInput rounded bind:value placeholder="With prefix">
<svelte:fragment slot="prefix">+234</svelte:fragment>
</CInput>
</div>
<div>
<CInput rounded bind:value placeholder="With suffix">
<svelte:fragment slot="suffix">@gmail.com</svelte:fragment>
</CInput>
</div>
<div>
<CInput rounded bind:value placeholder="With prefix and suffix">
<svelte:fragment slot="prefix">to:</svelte:fragment>
<svelte:fragment slot="suffix">@gmail.com</svelte:fragment>
</CInput>
</div>
<div>
<CInput
rounded
bind:value
placeholder="No divider"
prefixDivider={false}
suffixDivider={false}
>
<svelte:fragment slot="prefix">to:</svelte:fragment>
<svelte:fragment slot="suffix">@gmail.com</svelte:fragment>
</CInput>
</div>
<div>
<CInput bind:value placeholder="Use icons">
<div slot="prefix" class="text-6 i-ph-address-book-thin" />
<div slot="suffix" class="text-6 i-material-symbols-face-retouching-natural" />
</CInput>
</div>
</div>
<script lang="ts">
let value = ''
</script>
<div class="c-wrap c-flex c-gutter-md c-items-center">
<div>
<CInput rounded bind:value placeholder="With prefix">
<svelte:fragment slot="prefix">+234</svelte:fragment>
</CInput>
</div>
<div>
<CInput rounded bind:value placeholder="With suffix">
<svelte:fragment slot="suffix">@gmail.com</svelte:fragment>
</CInput>
</div>
<div>
<CInput rounded bind:value placeholder="With prefix and suffix">
<svelte:fragment slot="prefix">to:</svelte:fragment>
<svelte:fragment slot="suffix">@gmail.com</svelte:fragment>
</CInput>
</div>
<div>
<CInput
rounded
bind:value
placeholder="No divider"
prefixDivider={false}
suffixDivider={false}
>
<svelte:fragment slot="prefix">to:</svelte:fragment>
<svelte:fragment slot="suffix">@gmail.com</svelte:fragment>
</CInput>
</div>
<div>
<CInput bind:value placeholder="Use icons">
<div slot="prefix" class="text-6 i-ph-address-book-thin" />
<div slot="suffix" class="text-6 i-material-symbols-face-retouching-natural" />
</CInput>
</div>
</div>
CInput Props
- valuedefault:
string | number
The input value. It is recommended to use
bind:value
. - disableddefault:
boolean
false
Determine the input disabled status.
- sizedefault:
'xs' | 'sm' | 'md' | 'lg' | 'xl'=
undefined
The size of input. Notice that the default value is
md
notundefined
. - placeholderdefault:
string=
The placeholder of input dom.
- roundeddefault:
boolean
false
Determine whether the input has a rounded border or not.
TIPNotice that rounded border size will be along with input
size
prop. - loadingdefault:
boolean
false
Determien whether the input is in loading status or not.
- clearabledefault:
boolean
false
Determine the input has a clear icon which can be clicked to clear the input value.
- readonlydefault:
boolean
false
Determine whether the input is readonly or not.
- prefixDividerdefault:
boolean
true
Determine whether the input has a divider between prefix content and value or not.
- suffixDividerdefault:
boolean
true
Determine whether the input has a divider between suffix content and value or not.
- focuseddefault:
boolean
false
Determine whethter the input is focused or not. It is recommended to use
bind:focus
* - autoBlurdefault:
boolean
true
Dose input auto blur.
- typedefault:
'text' | 'password'
text
The type of input.
- customColordefault:
boolean
false
If set to
true
. The input will not change its' border, background, text color when focused , hover or blur.
It is useful when you want to customize the input color style. - validateTriggerdefault:
'change' | 'blur' | 'focus' | 'manual'
blur
The validate timing of input. It is only used when CInput is used in CForm and CFormItem context.
- clearValidateOnFocusdefault:
boolean
true
Determine whether the input would clear validate status when focused or not.
CInput Events
- clear
Clear icon click emit.
CInput Slots
- prefix
Customize prefix content
- suffix
Customize suffix content
- loading
Customize loading content