Components
Tags input

Tags Input

Tag inputs render tags inside an input, followed by an actual text input. By default, tags are added when text is typed in the input field and the Enter or Comma key is pressed. Throughout the interaction, DOM focus remains on the input element.

API reference docs for the component. Learn about the props, CSS, and other APIs of this exported module.

TagProps

index

string | number

value

string

disabled

boolean

TagInputProps

index

string | number

value

string

disabled

boolean

TagsInputProps

addOnPaste

boolean

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

allowEditTag

boolean

Whether a tag can be edited after creation. If `true` and focus is on a tag, pressing `Enter`or double clicking will edit the tag.

allowOverflow

boolean

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

autoFocus

boolean

Whether the input should be auto-focused

blurBehavior

'clear' | 'add'

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

defaultValue

string[]

delimiter

string

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

dir

'ltr' | 'rtl'

The document's text/writing direction.

disabled

boolean

Whether the tags input should be disabled

form

string

The associate form of the underlying input element.

getRootNode

() => ShadowRoot | Node | Document

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

id

string

The unique identifier of the machine.

ids

Partial<{ root: string input: string clearBtn: string label: string control: string tag(opts: TagProps): string tagDeleteTrigger(opts: TagProps): string tagInput(opts: TagProps): string }>

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

inputValue

string

The tag input's value

invalid

boolean

Whether the tags input is invalid

max

number

The max number of tags

maxLength

number

The max length of the input.

name

string

The name attribute for the input. Useful for form submissions

onFocusOutside

(event: FocusOutsideEvent) => void

Function called when the focus is moved outside the combobox

onHighlightChange

(details: HighlightChangeDetails) => void

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

onInteractOutside

(event: InteractOutsideEvent) => void

Function called when an interaction happens outside the combobox

onPointerDownOutside

(event: PointerDownOutsideEvent) => void

Function called when the pointer is pressed down outside the combobox

onValueChange

(details: ValueChangeDetails) => void

Callback fired when the tag values is updated

onValueInvalid

(details: ValidityChangeDetails) => void

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

readOnly

boolean

Whether the tags input should be read-only

translations

IntlTranslations

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

validate

(details: ValidateArgs) => boolean

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

value

string[]

The tag values

TagsInputContext

addValue

(value: string) => void

Function to add a tag to the tags.

clearInputValue

() => void

Function to clear the value of the tags entry input.

clearTriggerProps

Dict<any>

clearValue

(id?: string | undefined) => void

Function to clear the value of the tags.

controlProps

Dict<any>

count

number

The number of the tags.

focus

() => void

Function to focus the tags entry input.

getTagDeleteTriggerProps

(options: TagProps) => Dict<any>

getTagInputProps

(options: TagProps) => Dict<any>

getTagProps

(options: TagProps) => Dict<any>

getTagState

(props: TagProps) => TagState

Returns the state of a tag

hiddenInputProps

Dict<any>

inputProps

Dict<any>

inputValue

string

The value of the tags entry input.

isAtMax

boolean

Whether the tags have reached the max limit.

isEmpty

boolean

Whether the tags are empty

labelProps

Dict<any>

rootProps

Dict<any>

setInputValue

(value: string) => void

Function to set the value of the tags entry input.

setValue

(value: string[]) => void

Function to set the value of the tags.

setValueAtIndex

(index: number, value: string) => void

Function to set the value of a tag at the given index.

value

string[]

The value of the tags as an array of strings.

valueAsString

string

The value of the tags as a string.

TagDeleteTriggerProps

index

string | number

value

string

disabled

boolean