Chip input
Chip input or tag input component with validation, a maximum of chips, paste support and keyboard shortcuts.
How to use it
Run npx @blossomui/react add chip-input, or copy src/components/UI/ChipInput/ChipInput.tsx into your React project and import it.
import { ChipInput } from './components/ui/ChipInput'Props
ChipInputProps
| Prop | Type | Description |
|---|---|---|
| labels | { remove?: (chip: string) => string; duplicate?: (chip: string) => string } | Texts of the component. Pass only the ones you want to change, for example to translate it. |
| value | string[] | |
| defaultValue | string[] | |
| onChange | (value: string[]) => void | |
| label | string | |
| hint | string | |
| placeholder | string | |
| max | number | Maximum number of chips. |
| validate | (chip: string) => string | undefined | Return an error message to reject a chip, or nothing to accept it. |
| disabled | boolean | |
| suggestions | string[] | Values offered while typing. The user can pick one with the arrow keys and Enter, or with the mouse, and can still type anything else. |
| maxSuggestions | number | Most suggestions shown at once. |