Select
Basic usage
Apple
Banana
Orange
Peach
Apple
Banana
Orange
Peach
<script>
let selectedValue = ''
const options = [
{ label: 'Apple', value: 'Apple' },
{ label: 'Banana', value: 'Banana' },
{ label: 'Orange', value: 'Orange' },
{ label: 'Peach', value: 'Peach' },
]
</script>
<CSelect bind:value={selectedValue} {options} placeholder="Normal select" />
<CSelect bind:value={selectedValue} {options} disabled placeholder="Disabled select" />
svelte
Click fold/expand code
Clearable
Selected value:
Apple
Banana
Orange
Peach
<script lang="ts">
let selectedValue = ''
const options = [
{ label: 'Apple', value: 'Apple' },
{ label: 'Banana', value: 'Banana' },
{ label: 'Orange', value: 'Orange' },
{ label: 'Peach', value: 'Peach' },
]
</script>
<p>
<b> Selected value: </b>
{selectedValue}
</p>
<CSelect
clearable
placeholder="Clearable"
bind:value={selectedValue}
{options}
/>
svelte
Click fold/expand code
Shape
Apple
Banana
Orange
Peach
Apple
Banana
Orange
Peach
<script lang="ts">
let selectedValue = ''
const options = [
{ label: 'Apple', value: 'Apple' },
{ label: 'Banana', value: 'Banana' },
{ label: 'Orange', value: 'Orange' },
{ label: 'Peach', value: 'Peach' },
]
</script>
<CSelect bind:value={selectedValue} {options} placeholder="Normal select" />
<CSelect bind:value={selectedValue} {options} placeholder="Rounded select" rounded />
svelte
Click fold/expand code
Sizes
Selected value:
Apple
Banana
Orange
Peach
Apple
Banana
Orange
Peach
Apple
Banana
Orange
Peach
Apple
Banana
Orange
Peach
Apple
Banana
Orange
Peach
<script lang="ts">
let selectedValue = ''
const options = [
{ label: 'Apple', value: 'Apple' },
{ label: 'Banana', value: 'Banana' },
{ label: 'Orange', value: 'Orange' },
{ label: 'Peach', value: 'Peach' },
]
</script>
<p>
<b> Selected value: </b>
{selectedValue}
</p>
<div class="c-flex c-gutter-md c-wrap c-items-center">
<div>
<CSelect bind:value={selectedValue} {options} placeholder="xs" size="xs" />
</div>
<div>
<CSelect bind:value={selectedValue} {options} placeholder="sm" size="sm" />
</div>
<div>
<CSelect bind:value={selectedValue} {options} placeholder="md (default)" />
</div>
<div>
<CSelect bind:value={selectedValue} {options} placeholder="lg" size="lg" />
</div>
<div>
<CSelect bind:value={selectedValue} {options} placeholder="xl" size="xl" />
</div>
</div>
svelte
Click fold/expand code
Multiple
Selected values:
Select something
Apple
Banana
Orange
Peach
<script lang="ts">
let selectedValue: any[] = []
const options = [
{ label: 'Apple', value: 'Apple' },
{ label: 'Banana', value: 'Banana' },
{ label: 'Orange', value: 'Orange' },
{ label: 'Peach', value: 'Peach' },
]
</script>
<p>
<b> Selected values: </b>
{selectedValue}
</p>
<CSelect
multiple
placeholder="Select something"
bind:value={selectedValue}
{options}
/>
svelte
Click fold/expand code
CSelect Props
- sizedefault:
'xs' | 'sm' | 'md' | 'lg' | 'xl'=
undefined
The size of select. Notice that default value is
'md'
instead ofundefined
- valuedefault:
number | string | Array<string | number>
The selected value(s).
- optionsdefault:
{ label: string; value: string | number; [key: string]: any }[]
undefined
The select options
- multipledefault:
boolean
false
Determine the select can select muliple choices
- clearabledefault:
boolean
false
Determine whether the select has a clear icon when selected selection is not empty
- disableddefault:
boolean
false
Determine whether the select is diabled or not.
- roundeddefault:
boolean
false
Determine whether the select has a rounded border or not.
- validateOnFolddefault:
boolean
true
Determine whether validate current form item on dropdown fold.
CSelect Events
No data
CSelect Slots
No data
CSelect Exports
No data