Select
Select provides an anchored menu for choosing one or many options, with optional icons, filtering, and validation text.
Anatomy
| Element | Part | Selector |
|---|---|---|
<div> | root | [data-scope="select"][data-part="root"]LMBCopy |
<div> | trigger | [data-scope="select"][data-part="trigger"]LMBCopy |
<button> | clear-buttonconditional | [data-scope="select"][data-part="clear-button"]LMBCopy |
<Icon> | clear-icon | [data-scope="select"][data-part="clear-icon"]LMBCopy |
<span> | indicator | [data-scope="select"][data-part="indicator"]LMBCopy |
<Menu> | menu | [data-scope="select"][data-part="menu"] |
<TransitionGroup> | options | [data-scope="select"][data-part="options"]LMBCopy |
<MenuItem> | option | [data-scope="select"][data-part="option"]LMBCopy |
<span> | option-leading-content | [data-scope="select"][data-part="option-leading-content"]LMBCopy |
<span> | option-check | [data-scope="select"][data-part="option-check"]LMBCopy |
<span> | option-iconconditional | [data-scope="select"][data-part="option-icon"]LMBCopy |
<div> | emptyconditional | [data-scope="select"][data-part="empty"]LMBCopy |
Props
| Name | Description | Default | Control |
|---|---|---|---|
labelOptional | Visible label. If omitted, provide aria-label via attrs. string | undefined | undefined | |
idOptional | Optional explicit id for the trigger element. string | undefined | undefined | |
optionsRequired | Selectable options rendered in the menu. SelectOption[] | - | - |
descriptionOptional | Supporting text shown below the field when not in error state. string | undefined | undefined | |
errorOptional | Error text shown below the field. When provided, field is invalid. string | undefined | undefined | |
disabledOptional | Whether the control is disabled. boolean | undefined | false | |
requiredOptional | Whether the control is required. boolean | undefined | false | |
nameOptional | Name used for hidden inputs during form submission. string | undefined | undefined | |
placeholderOptional | Placeholder shown when nothing is selected. string | undefined | undefined | |
multipleOptional | Enables multi-select behavior. boolean | undefined | false | - |
clearableOptional | Shows a trailing button that clears the current selection. boolean | undefined | false | |
clearLabelOptional | Accessible label for the clear button. string | undefined | "Clear selection" | |
menuColorOptional | Visual color style of the dropdown menu. MenuColor | undefined | "standard" | - |
displaySeparatorOptional | Separator used when showing multiple selected labels. string | undefined | ", " | |
filterableOptional | Enables a filter field inside the menu to narrow long option lists. boolean | undefined | false | |
filterPlaceholderOptional | Placeholder shown in the menu filter field. string | undefined | "Filter options" | |
filterNoResultsTextOptional | Message shown when filtering returns no matching options. string | undefined | "No matching options" | |
modelValueOptional | - SelectModelValue | - | - |
openOptional | - boolean | undefined | false |
Events5
| Name | Type | Description |
|---|---|---|
update:open | [value: boolean] | - |
update:modelValue | [value: SelectModelValue] | - |
change | [value: SelectModelValue] | - |
focus | [event: FocusEvent] | - |
blur | [event: FocusEvent] | - |
Slots6
| Name | Parameters | Description |
|---|---|---|
leading | - | - |
prefix | - | - |
suffix | - | - |
trailing | - | - |
optionLeading | - | - |
optionTrailing | - | - |
Examples
Default
Without Icons
Filtering
Configurations
Composable
useSelect
function useSelect(opts: UseSelectOptions): UseSelectReturn Source: src/composables/useSelect.ts
| Field | Type | Required | Description | Default |
|---|---|---|---|---|
options | () => UseSelectOption[] | Yes | The selectable options. | - |
multiple | () => boolean | Yes | Whether multi-select is enabled. | - |
filterable | () => boolean | Yes | Whether filtering is enabled. | - |
disabled | () => boolean | Yes | Whether the control is disabled. | - |
displaySeparator | () => string | Yes | Separator for display text in multi-select mode. | - |
modelValue | Ref<UseSelectModelValue, UseSelectModelValue> | Yes | Model value ref (external). | - |
open | Ref<boolean, boolean> | Yes | Open state ref (external). | - |
onChange | ((value: UseSelectModelValue) => void) | undefined | No | Called when value changes. | - |
menuRef | Ref<{ show: (focusFirst?: boolean, source?: HTMLElement) => Promise<void>; hide: () => void; toggle: () => void; menuRef?: HTMLElement; } | undefined, { show: (focusFirst?: boolean, source?: HTMLElement) => Promise<void>; hide: () => void; toggle: () => void; menuRef?: HTMLElement; } | undefined> | Yes | Ref to the menu exposed API. | - |
triggerRef | Ref<HTMLElement | undefined, HTMLElement | undefined> | Yes | Ref to the trigger element. | - |
textFieldRef | Ref<{ focus: () => void; blur: () => void; } | undefined, { focus: () => void; blur: () => void; } | undefined> | Yes | Ref to the text field exposed API. | - |
| Field | Type | Required | Description | Default |
|---|---|---|---|---|
filterQuery | Ref<string, string> | Yes | Current filter query string. | - |
selectedOptions | ComputedRef<UseSelectOption[]> | Yes | Options selected based on current model value. | - |
hasValue | ComputedRef<boolean> | Yes | Whether any value is selected. | - |
displayText | ComputedRef<string> | Yes | Display text for the current selection. | - |
submittedValues | ComputedRef<string[]> | Yes | Values to submit in hidden form inputs. | - |
filteredOptionEntries | ComputedRef<{ option: UseSelectOption; index: number; }[]> | Yes | Filtered option entries with original indices. | - |
hasFilteredOptions | ComputedRef<boolean> | Yes | Whether there are any filtered options. | - |
isOptionSelected | (option: UseSelectOption) => boolean | Yes | Check if an option is currently selected. | - |
toggleOption | (option: UseSelectOption) => void | Yes | Toggle an option in the selection. | - |
clearValue | () => void | Yes | Clear the current selection. | - |
handleMenuSelect | (event: MouseEvent, itemElement: HTMLElement) => void | Yes | Handle menu item selection event. | - |
focus | () => void | Yes | Focus the text field. | - |
blur | () => void | Yes | Blur the text field. | - |
show | () => Promise<void> | Yes | Show the menu. | - |
hide | () => void | Yes | Hide the menu. | - |
toggle | () => void | Yes | Toggle the menu. | - |
openMenu | (focus?: "first" | "last") => void | Yes | Open menu with optional focus target. | - |
closeMenu | () => void | Yes | Close the menu. | - |
handleFieldClick | () => void | Yes | Handle click on the trigger field. | - |
handleFieldInput | () => void | Yes | Handle input on the filter field. | - |
handleFilterKeydown | (event: KeyboardEvent) => void | Yes | Handle keydown on the filter field. | - |