Forms
ChipsInput
Free-form tag input: Enter or a delimiter turns typed text into chips.
import { ChipsInput } from "datui";Playground
<ChipsInput placeholder="Add a tag" status="default" />Examples
Basic
- react
- tailwind
Press Enter or type a comma to add
Controlled with delimiters
Split on comma, semicolon or space; add on blur.
0 recipient(s)
Accessibility
- The text input takes its label from FormItem or
aria-label; chips are a list namedchipsListLabel. - Enter adds the typed text, typing or pasting a delimiter splits it into chips, Backspace in the empty input removes the last chip.
- Each chip's remove button is a labelled native button ("Remove alpha"); removing returns focus to the input.
disabled/readOnlyblock adding and removing.
API
ChipsInput
Free-form tag input. Enter or a delimiter (`,` by default; pasting splits too) turns the typed text into a chip, Backspace in the empty input removes the last chip, each chip has a remove button. Duplicate values are ignored. `ref` points at the text input.
| Prop | Type | Default | Description |
|---|---|---|---|
| addOnBlur | boolean | false | Turn leftover text into a chip when the field loses focus. |
| after | ReactNode | — | Content after the control, e.g. an icon, clear button or unit. |
| 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" | |
| defaultInputValue | string | — | |
| defaultValue | ChipOption[] | — | |
| delimiter | string | RegExp | string[] | "," | Typing or pasting a delimiter turns the text before it into chips. `[]` disables splitting. |
| getNewOptionData | ((label: string) => ChipOption) | label => ({ value: label, label }) | Builds a chip from typed text. |
| inputValue | string | — | Text typed after the chips. |
| maxHeight | number | — | Caps the field height in px; content scrolls beyond it. |
| onChange | ((value: ChipOption[]) => void) | — | |
| onInputChange | ((value: string) => void) | — | |
| 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. |
| 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. |