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 | numberThe input value. It is recommended to use
bind:value. - disableddefault:
booleanfalseDetermine the input disabled status.
- sizedefault:
'xs' | 'sm' | 'md' | 'lg' | 'xl'=undefinedThe size of input. Notice that the default value is
mdnotundefined. - placeholderdefault:
string=The placeholder of input dom.
- roundeddefault:
booleanfalseDetermine whether the input has a rounded border or not.
TIPNotice that rounded border size will be along with input
sizeprop. - loadingdefault:
booleanfalseDetermien whether the input is in loading status or not.
- clearabledefault:
booleanfalseDetermine the input has a clear icon which can be clicked to clear the input value.
- readonlydefault:
booleanfalseDetermine whether the input is readonly or not.
- prefixDividerdefault:
booleantrueDetermine whether the input has a divider between prefix content and value or not.
- suffixDividerdefault:
booleantrueDetermine whether the input has a divider between suffix content and value or not.
- focuseddefault:
booleanfalseDetermine whethter the input is focused or not. It is recommended to use
bind:focus* - autoBlurdefault:
booleantrueDose input auto blur.
- typedefault:
'text' | 'password'textThe type of input.
- customColordefault:
booleanfalseIf 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'blurThe validate timing of input. It is only used when CInput is used in CForm and CFormItem context.
- clearValidateOnFocusdefault:
booleantrueDetermine 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