Select
Select
can be used with embedded Option
or OptionGroup
.
Demos
Size variants
Available size values for the ui
prop: large
/small
/tiny
/micro
.
<template>
<article>
<veui-select
v-model="license"
ui="large"
:options="options"
/>
<veui-select
v-model="license"
:options="options"
/>
<veui-select
v-model="license"
ui="small"
:options="options"
/>
<veui-select
v-model="license"
ui="tiny"
:options="options"
/>
<veui-select
v-model="license"
ui="micro"
:options="options"
/>
</article>
</template>
<script>
import { Select } from 'veui'
export default {
components: {
'veui-select': Select
},
data () {
return {
license: null,
options: [
{
label: 'MIT',
value: 'mit'
},
{
label: 'BSD',
value: 'bsd'
},
{
label: 'Apache 2.0',
value: 'apache2'
}
]
}
}
}
</script>
Using embedded OptionGroup
s & Option
s
Can be used with embedded OptionGroup
s & Option
s.
Selected: -
clearable
can be used to allow selected values to be discarded for Select
. Set position
of the embedded OptionGroup
s to popup
to display children options inside a popup menu.
<template>
<article>
<veui-select
v-model="item"
placeholder="Pick one..."
clearable
>
<veui-option-group
label="Editors"
position="popup"
>
<veui-option
value="vscode"
label="VSCode"
/>
<veui-option
value="sublime"
label="SublimeText"
/>
<veui-option
value="atom"
label="Atom"
/>
</veui-option-group>
<veui-option-group
label="Browsers"
position="popup"
>
<veui-option-group
label="Desktop"
position="popup"
>
<veui-option
value="ie"
label="IE"
/>
<veui-option
value="edge"
label="Edge"
/>
<veui-option
value="firefox"
label="Firefox"
/>
<veui-option
value="chrome"
label="Chrome"
/>
</veui-option-group>
<veui-option-group
label="Mobile"
position="popup"
>
<veui-option
value="ios_safari"
label="iOS Safari"
/>
<veui-option
value="android"
label="Android Browser"
/>
<veui-option
value="android_chrome"
label="Chrome for Android"
/>
</veui-option-group>
</veui-option-group>
</veui-select>
<p>Selected: {{ item || '-' }}</p>
</article>
</template>
<script>
import { Select, OptionGroup, Option } from 'veui'
export default {
components: {
'veui-select': Select,
'veui-option-group': OptionGroup,
'veui-option': Option
},
data () {
return {
item: null
}
}
}
</script>
Filterable options
Use the filter
prop to filter options.
<template>
<article>
<veui-select
v-model="license"
:filter="filter"
:options="options"
>
<div slot="before">
<veui-input
v-model="keyword"
class="filter"
ui="tiny"
/>
</div>
</veui-select>
</article>
</template>
<script>
import { Select, Input } from 'veui'
export default {
components: {
'veui-select': Select,
'veui-input': Input
},
data () {
return {
keyword: '',
license: null,
options: [
{
label: 'MIT',
value: 'mit'
},
{
label: 'BSD',
value: 'bsd'
},
{
label: 'Apache 2.0',
value: 'apache2'
}
],
filter: ({ label }) => {
return label.toLowerCase().indexOf(this.keyword.toLowerCase()) !== -1
}
}
}
}
</script>
API
Props
Name | Type | Default | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ui | string | - | Style variants.
| ||||||||||||
options | Array<Object>= | - | The list of options with the option type being
| ||||||||||||
value | * | - |
The value of the selected option. | ||||||||||||
placeholder | string= | select.placeholder | Placeholder text when no option is selected. | ||||||||||||
clearable | boolean | false | Whether the select is clearable. | ||||||||||||
filter | function | - | Filter function for the options. The type is function(option: Object): boolean . The type of option is the same as the options prop. The return value denotes whether the option is shown inside the options dropdown. | ||||||||||||
disabled | boolean | false | Whether the select is disabled. | ||||||||||||
readonly | boolean | false | Whether the select is read-only. | ||||||||||||
overlay-class | string|Array|Object | - | See the overlay-class prop of Overlay . |
Slots
Name | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
default | The content of the options dropdown layer. Can be used to place Option s or OptionGroups s when the options prop is not specified. | |||||||||||||||
before | The content before the options in the dropdown layer. | |||||||||||||||
after | The content after the options in the dropdown layer. | |||||||||||||||
label | The content of the select button. Displays the
Additionally, custom properties apart from the listed ones will also be passes into the scope object via | |||||||||||||||
group-label | The label text of each option group (option with child
Additionally, custom properties in current option, apart from the listed ones, will also be passes into the scope object via | |||||||||||||||
option-label | The label text of each option (option without child
Additionally, custom properties in current option, apart from the listed ones, will also be passes into the scope object via | |||||||||||||||
option | The entire content area of each option (option without child
Additionally, custom properties in current option, apart from the listed ones, will also be passes into the scope object via |
Events
Name | Description |
---|---|
change |
Triggers when the selected option changed. The callback parameter list is |
Global config
Key | Type | Default | Description |
---|---|---|---|
select.placeholder | string | @@select.placeholder | The placeholder text when no option is selected. |
@@
prefixed values denote corresponding properties in the locale settings.
Icons
Name | Description |
---|---|
expand | Expand the dropdown layer. |
collapse | Collapse the dropdown layer. |