1. framework components
  2. tags input

Tags Input

Allows input of multiple values.

Vanilla
Chocolate
Strawberry

Controlled

Vanilla
Chocolate
Strawberry

Custom Icon

Vanilla
Chocolate
Strawberry

Color

Vanilla
Chocolate
Strawberry

Provider Pattern

Use the Provider Pattern to gain access to the inner component APIs.

Vanilla
Chocolate
Strawberry

Direction

Vanilla
Chocolate
Strawberry

API Reference

Root

txt
w-full space-y-2
PropDefaultType
idsPartial<{ root: string; input: string; hiddenInput: string; clearBtn: string; label: string; control: string; item: (opts: ItemProps) => string; itemDeleteTrigger: (opts: ItemProps) => string; itemInput: (opts: ItemProps) => string; }> | undefined

The ids of the elements in the tags input. Useful for composition.

translationsIntlTranslations | undefined

Specifies the localized strings that identifies the accessibility elements and their states

maxLengthnumber | undefined

The max length of the input.

delimiter","string | RegExp | undefined

The character that serves has: - event key to trigger the addition of a new tag - character used to split tags when pasting into the input

autoFocusboolean | undefined

Whether the input should be auto-focused

disabledboolean | undefined

Whether the tags input should be disabled

readOnlyboolean | undefined

Whether the tags input should be read-only

invalidboolean | undefined

Whether the tags input is invalid

requiredboolean | undefined

Whether the tags input is required

editabletrueboolean | undefined

Whether a tag can be edited after creation, by pressing `Enter` or double clicking.

inputValuestring | undefined

The controlled tag input's value

defaultInputValuestring | undefined

The initial tag input value when rendered. Use when you don't need to control the tag input value.

valuestring[] | undefined

The controlled tag value

defaultValuestring[] | undefined

The initial tag value when rendered. Use when you don't need to control the tag value.

onValueChange((details: ValueChangeDetails) => void) | undefined

Callback fired when the tag values is updated

onInputValueChange((details: InputValueChangeDetails) => void) | undefined

Callback fired when the input value is updated

onHighlightChange((details: HighlightChangeDetails) => void) | undefined

Callback fired when a tag is highlighted by pointer or keyboard navigation

onValueInvalid((details: ValidityChangeDetails) => void) | undefined

Callback fired when the max tag count is reached or the `validateTag` function returns `false`

validate((details: ValidateArgs) => boolean) | undefined

Returns a boolean that determines whether a tag can be added. Useful for preventing duplicates or invalid tag values.

blurBehavior"clear" | "add" | undefined

The behavior of the tags input when the input is blurred - `"add"`: add the input value as a new tag - `"clear"`: clear the input value

addOnPastefalseboolean | undefined

Whether to add a tag when you paste values into the tag input

maxInfinitynumber | undefined

The max number of tags

allowOverflowboolean | undefined

Whether to allow tags to exceed max. In this case, we'll attach `data-invalid` to the root

namestring | undefined

The name attribute for the input. Useful for form submissions

formstring | undefined

The associate form of the underlying input element.

dir"ltr""ltr" | "rtl" | undefined

The document's text/writing direction.

getRootNode(() => ShadowRoot | Node | Document) | undefined

A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron.

onPointerDownOutside((event: PointerDownOutsideEvent) => void) | undefined

Function called when the pointer is pressed down outside the component

onFocusOutside((event: FocusOutsideEvent) => void) | undefined

Function called when the focus is moved outside the component

onInteractOutside((event: InteractOutsideEvent) => void) | undefined

Function called when an interaction happens outside the component

elementSnippet<[HTMLAttributes<"div">]> | undefined

Render the element yourself

Provider

PropDefaultType
value() => TagsInputApi<PropTypes>

elementSnippet<[HTMLAttributes<"div">]> | undefined

Render the element yourself

Context

PropDefaultType
childrenSnippet<[() => TagsInputApi<PropTypes>]>

Label

txt
label-text
PropDefaultType
elementSnippet<[HTMLAttributes<"label">]> | undefined

Render the element yourself

Control

txt
input flex flex-wrap gap-2 p-2
PropDefaultType
elementSnippet<[HTMLAttributes<"div">]> | undefined

Render the element yourself

Item

PropDefaultType
indexstring | number

valuestring

disabledboolean | undefined

elementSnippet<[HTMLAttributes<"span">]> | undefined

Render the element yourself

ItemPreview

txt
chip flex gap-0 p-0 preset-filled hover:brightness-100 w-fit data-highlighted:ring data-highlighted:ring-primary-500
PropDefaultType
elementSnippet<[HTMLAttributes<"div">]> | undefined

Render the element yourself

ItemText

txt
leading-none px-2 py-1
PropDefaultType
elementSnippet<[HTMLAttributes<"span">]> | undefined

Render the element yourself

ItemDeleteTrigger

txt
hover:preset-tonal px-2 py-1
PropDefaultType
elementSnippet<[HTMLAttributes<"button">]> | undefined

Render the element yourself

ItemInput

txt
input text-xs
PropDefaultType
elementSnippet<[HTMLAttributes<"input">]> | undefined

Render the element yourself

Input

txt
input-ghost
PropDefaultType
elementSnippet<[HTMLAttributes<"input">]> | undefined

Render the element yourself

ClearTrigger

txt
btn btn-sm preset-tonal hover:preset-filled-error-500
PropDefaultType
elementSnippet<[HTMLAttributes<"button">]> | undefined

Render the element yourself

HiddenInput

PropDefaultType
elementSnippet<[HTMLAttributes<"input">]> | undefined

Render the element yourself

View page on GitHub