Tag Input
A tokenizer for adding, validating, and removing string values.
Use Tag Input to add, validate, and remove string values in a text field. It uses the same surfaces, typography, and interaction styling as Input, while growing vertically when selected tags wrap. Selected tags use the red-light palette by default.
Import
Section titled “Import”import { TagInput } from "@zentara-co/zenos-ui";Variants
Section titled “Variants”Choose variant="default" for the standard bordered surface, filled for a subtle fill, or none for a transparent surface. Tag Input uses Input’s variant and size styles directly, so its radius, border, background, typography, spacing, and state colors remain identical. Focus anywhere inside the control highlights its outer surface, and the control can still grow when tags wrap.
Field states
Section titled “Field states”Tag Input follows Field’s disabled, required, invalid, description, and error relationships. Disabled controls prevent editing and disable tag actions without fading the whole surface. readOnly prevents editing and hides the default remove and clear actions. Invalid state uses Input’s danger border and fill; none keeps its unfocused surface transparent.
Add at least one owner.
These tags are managed by your organization.
Sizes and wrapping
Section titled “Sizes and wrapping”Use size="sm", md, or lg to match nearby Inputs. Their minimum heights are 36px, 40px, and 44px respectively; unlike a single-line Input, Tag Input grows as tags wrap onto more lines. The default size is md.
Controlled tags and query
Section titled “Controlled tags and query”Tag values and the pending input query can each be controlled independently. Update both callbacks when passing both controlled props.
Press Enter or comma to add a value.
Values: React
Validation and limits
Section titled “Validation and limits”Normalize before validating. Rejected candidates report duplicate, empty, invalid, or max, allowing the surrounding Field to explain what happened without coupling validation messages to TagInput.
Up to three unique tags; minimum three characters.
Delimiters, blur, and forms
Section titled “Delimiters, blur, and forms”Enter always commits the pending query. delimiters adds other commit characters and also splits pasted text. addOnBlur commits a final query when focus leaves. With name, each tag becomes a hidden form value under the same key.
Custom styling and tags
Section titled “Custom styling and tags”Use className for the outer control and inputClassName for its native text input. You do not need a variant prop to apply your own styles. The forwarded ref points to the native input.
The built-in tags use color="red-light". Use renderTag to choose another palette or customize selected tags. Its arguments are the value, index, and a removal callback. Connect that callback to your tag’s remove action. Custom renderers also own disabled and read-only presentation: omit removal actions for read-only values and disable them when the field is disabled.
Variants
defaultfillednone Sizes
smmdlg API
| Prop | Type | Default | Description |
|---|---|---|---|
value | readonly string[] | — | Controlled tags. |
defaultValue | readonly string[] | — | Initial uncontrolled tags. |
onValueChange | (tags: string[]) => void | — | Runs when tags change. |
inputValue / defaultInputValue | string | — | Controlled or initial pending query text. |
onInputValueChange | (query: string) => void | — | Runs when the pending query changes. |
maxTags | number | — | Maximum tag count. |
allowDuplicates | boolean | false | Allows repeated values. |
validateValue | (value: string) => boolean | — | Validates a pending tag. |
normalizeValue | (value: string) => string | — | Normalizes a candidate before validation and insertion. |
onValueRejected | (value, reason) => void | — | Reports duplicate, empty, invalid, or maximum-count rejection. |
delimiters | readonly string[] | [","] | Characters that commit and split pending values. |
addOnBlur / clearable | boolean | false / true | Blur commit and clear-all behavior. |
renderTag | (value, index, remove) => ReactNode | — | Custom rendering for each selected tag. |
variant | default | filled | none | default | Input surface style, including matching hover, focus, disabled, and invalid states. |
size | sm | md | lg | md | Minimum control height. Grows vertically when tags wrap. |
className / inputClassName | string | — | Style the outer surface or the native text input separately. |
clearLabel | string | "Clear all tags" | Accessible name for the clear-all button. |
disabled / readOnly | boolean | false | Prevent edits. Disabled also disables tag actions; readOnly hides the default remove and clear actions. |
native props | React.InputHTMLAttributes<HTMLInputElement> | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |
Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props,
including className, style, aria-*, and data-*.
Accessibility
Section titled “Accessibility”Associate the native text input with a visible Field label. Selected tags form a named list, and every default remove button is labeled with its value. Enter or a configured delimiter commits the query; Backspace on an empty input removes the last tag. The clear button has a configurable accessible name. Announce rejection feedback in nearby described text, and do not rely on border color alone for invalid state.