MultiSelect
MultiSelect lets the user search a list and pick several options, shown as chips. Use it for tags, filters and other choices with several answers. For one option, use Combobox or Select.
Installation
Run npx nxds-cli@latest init first if nxds isn’t set up in your app yet. See Install.
Usage
Composition
Examples
Grouped
Sort options under headings with MultiSelectGroup and a separator.
Wrap chips
Set overflowBehavior="wrap" to wrap every chip onto more lines.
Overflow collapse
Set overflowBehavior="cutoff" to show chips that don't fit as a +N badge.
Disabled
Disable the trigger to show the selection without letting anyone change it.
With disabled option
Disable one option so it shows in the list but cannot be picked.
Invalid field
Set aria-invalid on the trigger inside an invalid Field to show the error state.
Choose at least one framework.
This example also needs: Field.
Props
MultiSelect
| Prop | Type | Default | Description |
|---|---|---|---|
defaultValues | string[] | No default documented | Initial selected values for uncontrolled usage. |
onValuesChange | ((values: string[]) => void) | No default documented | Called with the new selected values when the selection changes. |
values | string[] | No default documented | Controlled selected values. |
MultiSelectContent
| Prop | Type | Default | Description |
|---|---|---|---|
emptyMessage | ReactNode | "No results found." | Shown when the search matches no options. |
searchPlaceholder | string | "Search…" | Placeholder for the search input. |
MultiSelectGroup
MultiSelectGroup adds no props of its own; it accepts the props of the element or primitive it wraps.
MultiSelectItem
| Prop | Type | Default | Description |
|---|---|---|---|
badgeLabel | ReactNode | No default documented | Chip text when it differs from the option content, such as an icon option. |
onSelect | ((value: string) => void) | No default documented | Called with the option's value after it is toggled. |
valueRequired | string | No default documented | No description |
MultiSelectSeparator
MultiSelectSeparator adds no props of its own; it accepts the props of the element or primitive it wraps.
MultiSelectTrigger
MultiSelectTrigger adds no props of its own; it accepts the props of the element or primitive it wraps.
MultiSelectValue
| Prop | Type | Default | Description |
|---|---|---|---|
clickToRemove | boolean | true | Shows each selected value as a removable chip. |
overflowBehavior | "wrap" | "wrap-when-open" | "cutoff" | "wrap-when-open" | What chips do when they overflow the field:
|
placeholder | ReactNode | "Select options" | Shown when nothing is selected. |
MultiSelect lets the user search a list and pick several options, shown as chips. Use it for tags, filters and other choices with several answers. For one option, use Combobox or Select.
Installation
Copy and paste the following code into your project.
components/multi-select/MultiSelect.vue components/multi-select/MultiSelectContent.vue components/multi-select/MultiSelectGroup.vue components/multi-select/MultiSelectItem.vue components/multi-select/MultiSelectSeparator.vue components/multi-select/MultiSelectTrigger.vue components/multi-select/MultiSelectValue.vue components/multi-select/index.ts Keep each file at the path shown above it.
Paths are relative to
packages/vue/src/. Keep the same folders under your@/root, and the imports between files work without edits.
Usage
Examples
Grouped
Sort options under headings with MultiSelectGroup and a separator.
Wrap chips
Set overflowBehavior="wrap" to wrap every chip onto more lines.
Overflow collapse
Set overflowBehavior="cutoff" to show chips that don't fit as a +N badge.
Disabled
Disable the trigger to show the selection without letting anyone change it.
With disabled option
Disable one option so it shows in the list but cannot be picked.
Invalid field
Set aria-invalid on the trigger inside an invalid Field to show the error state.
This example also needs: Field.
Props
MultiSelect
| Prop | Type | Default | Description |
|---|---|---|---|
defaultValues | string[] | No default documented | Initial selected values for uncontrolled usage. |
values | string[] | No default documented | Controlled selected values. |
MultiSelectContent
| Prop | Type | Default | Description |
|---|---|---|---|
searchPlaceholder | string | "Search…" | Placeholder for the search input. |
MultiSelectGroup
| Prop | Type | Default | Description |
|---|---|---|---|
forceMount | boolean | false | Shows the group whatever the search. |
heading | string | No default documented | Heading shown above the group's items. Screen readers read it as the group's name. |
MultiSelectItem
| Prop | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | Shows the item dimmed and skips it in keyboard navigation. |
forceMount | boolean | No default documented | Shows the item whatever the search. |
keywords | string[] | No default documented | More words the search matches. Defaults to the option's text. |
valueRequired | string | No default documented | No description |
MultiSelectSeparator
| Prop | Type | Default | Description |
|---|---|---|---|
alwaysRender | boolean | false | Keeps the separator while a search is active. |
MultiSelectTrigger
MultiSelectTrigger adds no props of its own; it accepts the props of the element or primitive it wraps.
MultiSelectValue
| Prop | Type | Default | Description |
|---|---|---|---|
clickToRemove | boolean | true | Shows each selected value as a removable chip. |
overflowBehavior | "wrap-when-open" | "wrap" | "cutoff" | "wrap-when-open" | What chips do when they overflow the field:
|