Forms

Tag Field

An input component that allows users to enter, display, and manage multiple tags or keywords dynamically.

Basic

The basic tag field lets you add tags to your content.

Loading...

Installation

To install, run the following command:

npx shadcn@latest add @intentui/tag-field

Composed components

This tag field integrates with components like:

When you install this component via the CLI, it automatically loads all composed components, so you don’t need to add them individually.

This component comes packed with several components to enhance functionality and provide a seamless experience.

Manual installation

For manual installation, use:

npm i react-aria-components

Anatomy

Import the components and use them as shown below, adapting the structure to fit each component.

import { TagField } from '@/components/ui/tag-field'

const selectedItems = useListData({
  initialItems: [
    {
      id: 1,
      name: "Laravel"
    },
    // ...
  ]
})

<TagField className="max-w-xs" label="Add tag" list={selectedItems} />

Appearance

Customize the tag field’s appearance using the appearance prop.

Loading...

Max entry

Set a limit on the number of tags that can be added.

Loading...

Controlled

The tag field is controlled by default. This example demonstrates how to access its value.

Loading...

Disabled

Disable the tag field by using the isDisabled prop.

Loading...

Props

Here's the fixed table:

PropTypeDefaultDescription
labelstring-The label of the tag field
descriptionstring-The description of the tag field
placeholderstring-The placeholder of the tag field
maxnumber-The maximum number of tags that can be added
classNamestring-The class name of the tag field
namestring-The name of the tag field
listListData-The list of tags
onItemInserted(tag: TagItemProps) => void-The callback function when a tag is inserted
onItemCleared(tag: TagItemProps) => void-The callback function when a tag is cleared
isDisabledboolean-The disabled state of the tag field
Unlock the full power of
Design Intent UI
Build modern web apps faster with 350+ blocks and polished templates crafted for professionals.
Explore