TokenField
Components

TokenField

Enter multiple string values as tokens with suggestions and custom values.

Props

TokenFieldProps props
PropTypeDefaultDescription
valuesstring[]—Controlled values.
defaultValuesstring[]—Initial uncontrolled values.
onChange(values: string[]) => void—Change handler.
suggestionsstring[]—Dropdown suggestions as the user types. Already-added values are hidden.
placeholderstring"Add…"Placeholder text.
allowCustombooleantrueAllow values not present in suggestions.
monoboolean—Monospace font for tokens and input.
size"sm" | "md""sm"Minimum control height, using Input and Select sizes. Wrapped tokens can increase the height.
disabledboolean—Prevents interaction.
classNamestring—Additional CSS class.
aria-labelstring—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.

TokenField

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.

TokenField: custom values

Monospace

Set mono for a monospace token style, useful for identifiers, keys, or environment codes.

TokenField: mono

Import

ImportTSX
import { TokenField } from "@solarius/onset";