Forms
ChipsSelect
Multi-select with chips and a filterable dropdown, optionally creatable.
import { ChipsSelect } from "datui";Playground
<ChipsSelect placeholder="Pick colors" selectedBehavior="highlight" closeAfterSelect />Examples
Basic
- TypeScript
Creatable
Typed text that matches no option can be added.
Accessibility
- The input is a
role="combobox"witharia-autocomplete="list",aria-expandedandaria-activedescendant; the listbox isaria-multiselectable. - Down/Up open the list and move the highlight, Enter adds (or removes an already selected option), Escape closes; typing filters.
- Chips behave as in ChipsInput: Backspace in the empty input removes the last one, each has a labelled remove button.
- The empty text is announced through a polite status region.
API
ChipsSelect
Multi-select with chips and a filterable dropdown, optionally creatable. The input is a combobox: Down/Up open and move, Enter picks the highlighted option (or creates), Escape closes. Chips behave as in ChipsInput. `ref` points at the input.
| Prop | Type | Default | Description |
|---|---|---|---|
| allowClearButton | boolean | false | Shows a button that removes every chip and the typed text. |
| before | ReactNode | — | Content before the control, usually an icon. |
| chipsListLabel | string | "Selected" | Accessible name of the chips list. |
| className | string | — | |
| clearLabel | string | "Clear" | |
| closeAfterSelect | boolean | true | Close the dropdown after picking an option. |
| creatable | string | boolean | false | Lets the user add typed text that matches no option. A string sets the label of the "create" row, shown before the quoted text. |
| defaultInputValue | string | ||
| defaultValue | ChipOption[] | [] | |
| dropdownAutoWidth | boolean | — | |
| emptyText | string | Nothing found | |
| fetching | boolean | false | |
| fetchingLabel | string | Loading… | |
| filterFn | false | ((query: string, option: ChipOption) => boolean) | — | Custom filter, or `false` to show options as given. |
| forcePortal | boolean | — | |
| inputValue | string | — | Text typed after the chips. |
| listLabel | string | Options | Accessible name of the listbox. |
| maxHeight | number | — | Caps the field height in px; content scrolls beyond it. |
| noMaxHeight | boolean | — | |
| onChange | ((value: ChipOption[]) => void) | — | |
| onChangeStart | ((event: SyntheticEvent<Element, Event>, option: ChipOption) => void) | — | Called before an option is added or removed; call `event.preventDefault()` to cancel. |
| onClose | (() => void) | — | |
| onInputChange | ((value: string) => void) | — | |
| onOpen | (() => void) | — | |
| options | ChipOption[] | [] | |
| placement | "top" | "bottom" | bottom | |
| removeLabel | string | "Remove" | Prefix of each chip's remove-button label. |
| renderChip | ((props: ChipProps, option: ChipOption) => ReactNode) | — | Custom chip. Spread the given props onto `Chip` to keep removal working. |
| renderOption | ((props: CustomSelectOptionProps, option: ChipOption) => ReactNode) | — | Custom option row; spread the props onto `CustomSelectOption`. |
| selectedBehavior | "hide" | "highlight" | highlight | `hide` removes selected options from the list, `highlight` keeps them checked (choosing again removes). |
| slotProps | { root?: (FormFieldProps & { ref?: Ref<HTMLDivElement>; }); } | undefined | — | Props for the FormField shell. |
| status | FormFieldStatus | "default" | Visual validation state. Pair `error` with `aria-invalid` on the control (FormItem does this). |
| value | ChipOption[] | — | Chips. |