Park UI

Tags Input

A form control for adding and removing multiple tags or labels.

React
Solid
Vue
Press Enter or Return to add tag

Installation

Usage

Shortcuts

The TagsInput component also provides a set of shortcuts for common use cases.

TagsInputItems

The TagsInputItems shortcut renders all tag items automatically based on the current value.

This might be more concise, if you don't need to customize the items:

Examples

Sizes

Use the size prop to adjust the size of the tags input.

React
Solid
Vue
React
Solid
Vue
React
Solid
Vue
React
Solid
Vue

Variants

Use the variant prop to change the visual style of the tags input.

React
Solid
Vue
React
Solid
Vue
React
Solid
Vue

Props

Root

PropDefaultType
size'md'
'md'
addOnPastefalse
boolean

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

delimiter\,\
string | RegExp

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

editabletrue
boolean

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

maxInfinity
number

The max number of tags

allowOverflow
boolean

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

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

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 - `"clear"`: clear the input value

defaultInputValue
string

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

defaultValue
string[]

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

disabled
boolean

Whether the tags input should be disabled

form
string

The associate form of the underlying input element.

id
string

The unique identifier of the machine.

ids
Partial<{ root: string input: string hiddenInput: string clearBtn: string label: string control: string item: (opts: ItemProps) => string itemDeleteTrigger: (opts: ItemProps) => string itemInput: (opts: ItemProps) => string }>

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

inputValue
string

The controlled tag input's value

invalid
boolean

Whether the tags input is invalid

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 component

onHighlightChange
(details: HighlightChangeDetails) => void

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

onInputValueChange
(details: InputValueChangeDetails) => void

Callback fired when the input value is updated

onInteractOutside
(event: InteractOutsideEvent) => void

Function called when an interaction happens outside the component

onPointerDownOutside
(event: PointerDownOutsideEvent) => void

Function called when the pointer is pressed down outside the component

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

required
boolean

Whether the tags input is required

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 controlled tag value

Item

PropDefaultType
index*
string | number
value*
string
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

disabled
boolean