TokenField
Enter multiple string values as tokens with suggestions and custom values.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
values | string[] | — | Controlled values. |
defaultValues | string[] | — | Initial uncontrolled values. |
onChange | (values: string[]) => void | — | Change handler. |
suggestions | string[] | — | Dropdown suggestions as the user types. Already-added values are hidden. |
placeholder | string | "Add…" | Placeholder text. |
allowCustom | boolean | true | Allow values not present in suggestions. |
mono | boolean | — | Monospace font for tokens and input. |
size | "sm" | "md" | "sm" | Minimum control height, using Input and Select sizes. Wrapped tokens can increase the height. |
disabled | boolean | — | Prevents interaction. |
className | string | — | Additional CSS class. |
aria-label | string | — | Accessibility label for the inner input. |
Specimens
Basic with suggestions
Type to filter the suggestion dropdown. Suggestions that are already added are hidden from the list.
Custom token values
When allowCustom is true (the default), the user can type any value and press Enter to add it, even if it's not in the suggestions list.
Monospace
Set mono for a monospace token style, useful for identifiers, keys, or environment codes.
Import
import { TokenField } from "@solarius/onset";