Installation
Add Component
Copy the code snippet below into you components folder.
Integrate Recipe
Integrate this recipe in to your Panda config.
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.
Variants
Use the variant prop to change the visual style of the tags input.
Props
Root
| Prop | Default | Type | 
|---|---|---|
| size | 'md' | 'md' | 
| addOnPaste | false | booleanWhether to add a tag when you paste values into the tag input | 
| delimiter | \,\ | string | RegExpThe character that serves has: - event key to trigger the addition of a new tag - character used to split tags when pasting into the input | 
| editable | true | booleanWhether a tag can be edited after creation, by pressing `Enter` or double clicking. | 
| max | Infinity | numberThe max number of tags | 
| allowOverflow | booleanWhether to allow tags to exceed max. In this case, we'll attach `data-invalid` to the root | |
| asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | |
| autoFocus | booleanWhether 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 | stringThe 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 | booleanWhether the tags input should be disabled | |
| form | stringThe associate form of the underlying input element. | |
| id | stringThe 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 | stringThe controlled tag input's value | |
| invalid | booleanWhether the tags input is invalid | |
| maxLength | numberThe max length of the input. | |
| name | stringThe name attribute for the input. Useful for form submissions | |
| onFocusOutside | (event: FocusOutsideEvent) => voidFunction called when the focus is moved outside the component | |
| onHighlightChange | (details: HighlightChangeDetails) => voidCallback fired when a tag is highlighted by pointer or keyboard navigation | |
| onInputValueChange | (details: InputValueChangeDetails) => voidCallback fired when the input value is updated | |
| onInteractOutside | (event: InteractOutsideEvent) => voidFunction called when an interaction happens outside the component | |
| onPointerDownOutside | (event: PointerDownOutsideEvent) => voidFunction called when the pointer is pressed down outside the component | |
| onValueChange | (details: ValueChangeDetails) => voidCallback fired when the tag values is updated | |
| onValueInvalid | (details: ValidityChangeDetails) => voidCallback fired when the max tag count is reached or the `validateTag` function returns `false` | |
| readOnly | booleanWhether the tags input should be read-only | |
| required | booleanWhether the tags input is required | |
| translations | IntlTranslationsSpecifies the localized strings that identifies the accessibility elements and their states | |
| validate | (details: ValidateArgs) => booleanReturns 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
| Prop | Default | Type | 
|---|---|---|
| index* | string | number | |
| value* | string | |
| asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | |
| disabled | boolean |