---
title: "Tags Input"
description: "Type a word and press Enter or a comma, or paste a list, and each word becomes a tag you can remove. It can also suggest tags."
url: https://gelatinui.com/components/tags-input
markdown_url: https://gelatinui.com/components/tags-input.md
access: free
install: "npx shadcn@latest add @gelatin-ui/tags-input"
registry_item: https://gelatinui.com/r/tags-input.json
version: "2026-11-09"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Tags Input

> Type a word and press Enter or a comma, or paste a list, and each word becomes a tag you can remove. It can also suggest tags.

Page: https://gelatinui.com/components/tags-input

## When to use it

Best for: Type free text that turns into removable tags, with optional suggestions.

- Use it when people may add any text as a value, with or without suggestions.
- Use `validate`, `max`, and `isDuplicate` to refuse a tag, and show why with `TagsInputMessage`.
- Use `name` to send one form entry per tag.

## When not to use it

- When each value must come from a fixed list, use a [Combobox](https://gelatinui.com/components/combobox.md).
- For tags that people only read, remove, or pick, use a [Tag Group](https://gelatinui.com/components/tag-group.md).

## Notes for agents

- The value is `string[]`. Enter, a comma, a paste, or leaving the field adds a tag.
- Change that behavior with `delimiters`, `addOnPaste`, `addOnBlur`, and `trim`.
- Give `TagsInputTagList` an `aria-label`, such as "Topics". It is a toolbar.
- `TagsInputTagList` renders a `TagsInputTag` for each value by default.
- Keyboard users cannot Tab to `TagsInputTagRemove` or `TagsInputClear`. Each is pointer only.
- The suggestions popup opens only with `items`. It stays closed at `max` and when read-only.
- `TagsInputMessage` is not a Field error. The field stays valid while the message shows.
- In a `Field`, a `FieldDescription` wins over the key hint of the input. Put the hint in the description text.

## Anatomy

```text
TagsInput
├─ TagsInputControl (0..n)
├─ TagsInputTagList (0..n)
├─ TagsInputTag (0..n)
├─ TagsInputTagRemove (0..n)
├─ TagsInputInput (0..n)
├─ TagsInputClear (0..n)
├─ TagsInputContent (0..n)
├─ TagsInputList (0..n)
├─ TagsInputItem (0..n)
├─ TagsInputStatus (0..n)
└─ TagsInputMessage (0..n)
```

## API reference

### TagsInput

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `readonly string[]` |  | The tags. Use with `onValueChange` for a controlled Tags Input. |
| `defaultValue` | `readonly string[]` |  | The tags of an uncontrolled Tags Input. |
| `onValueChange` | `function` |  | Called with the new tags after an add, a remove, or Clear, and the Base UI change details (the Combobox details of a pick, a chip remove, or Clear; reason `"none"` for a typed add). |
| `inputValue` | `string` |  | The typed text. Use with `onInputValueChange` for a controlled input. |
| `defaultInputValue` | `string` | "" | The typed text of an uncontrolled input. |
| `onInputValueChange` | `function` |  | Called when the typed text changes. |
| `items` | `readonly string[]` |  | Suggestions. With `items` the input is a combobox and a list opens below the frame; without them it is a plain text field. Tags already added leave the list. |
| `delimiters` | `readonly string[]` | DEFAULT_TAGS_INPUT_DELIMITERS | Characters that add the typed text, as Enter does (default: comma). Enter always adds. |
| `addOnPaste` | `boolean` | true | Split a paste on the delimiters and on line breaks, and add each part (default: true). |
| `addOnBlur` | `boolean` | true | Add the typed text when focus leaves the field (Tab, a click outside; default: true). |
| `trim` | `boolean` | true | Remove the spaces around each tag (default: true). |
| `isDuplicate` | `function` | isSameTag | When two texts are the same tag (default: the same text with case ignored). |
| `max` | `number` |  | The most tags. At the max the input stays, so Backspace still reaches the tags. |
| `validate` | `function` |  | A check of each new tag: return the message to show, or `null` to accept it. |
| `labels` | `Partial<TagsInputLabels>` |  | Every string the Tags Input says, to translate. Pass a stable object (module level or `useMemo`): a new object on each render rebuilds the context and re-renders every tag. |
| `onRefuse` | `function` |  | Called for each text that did not become a tag, with the reason and the message shown. |
| `children` | `ReactNode` |  |  |

Also takes every prop of Base UI `Combobox.Root`: https://base-ui.com/react/components/combobox

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| TagsInput | `tags-input` |  |  |  |
| TagsInputControl | `tags-input-control` | `aria-invalid`, `data-chip`, `data-input-group-control`, `data-popup-open`, `data-stage-focused`, `data-surface` |  |  |
| TagsInputTagList | `tags-input-tag-list` |  |  |  |
| TagsInputTag | `tags-input-tag` | `data-duplicate` |  | `motion-timing`, `status-colors` |
| TagsInputTagRemove | `tags-input-tag-remove` | `data-duplicate` |  | `status-colors` |
| TagsInputInput | `tags-input-input` |  |  |  |
| TagsInputClear | `tags-input-clear` | `data-disabled` |  |  |
| TagsInputContent | `tags-input-content` |  |  |  |
| TagsInputList | `tags-input-list` |  |  |  |
| TagsInputItem | `tags-input-item` |  |  |  |
| TagsInputStatus | `tags-input-status` |  |  |  |
| TagsInputMessage | `tags-input-message` |  |  | `motion-timing` |

## Usage

The value is a `string[]`. Enter, a comma, a paste, or leaving the field adds a tag. Add `items` for suggestions.

The sample also uses `field`, which this add does not write. One command adds them with this item:

```bash
npx shadcn@latest add @gelatin-ui/tags-input @gelatin-ui/field
```

```tsx title="topics-field.tsx"
import { Field, FieldLabel } from "@/components/ui/field";
import {
  TagsInput,
  TagsInputClear,
  TagsInputControl,
  TagsInputInput,
  TagsInputMessage,
  TagsInputTagList,
} from "@/components/ui/tags-input";

export function TopicsField() {
  return (
    <Field>
      <FieldLabel>Topics</FieldLabel>
      <TagsInput defaultValue={["design-systems", "react"]}>
        <TagsInputControl>
          <TagsInputTagList aria-label="Topics">
            <TagsInputInput placeholder="Add a topic" />
          </TagsInputTagList>
          <TagsInputClear />
        </TagsInputControl>
        <TagsInputMessage />
      </TagsInput>
    </Field>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/tags-input
```

It adds 45 registry items: 42 files, 8236 lines, and the npm packages `@base-ui/react`, `@phosphor-icons/react`, `clsx`, `motion`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Combobox](https://gelatinui.com/components/combobox.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Combobox](https://gelatinui.com/components/combobox.md)
- [Tag Group](https://gelatinui.com/components/tag-group.md): Pick Tag Group to show a set of tags that people read, remove, or pick as filters, with no typing.
- [Input](https://gelatinui.com/components/input.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Enter | Adds the typed text as a tag, or picks the highlighted row. In an empty input, submits the form. |
| Comma | Adds the typed text as a tag. Set other keys with `delimiters`. |
| Tab | Leaves the field and adds the typed text as a tag, while `addOnBlur` is on. |
| Backspace | In an empty input, moves focus to the last tag. |
| Left Arrow | At the start of the text, moves focus to the last tag. Right to left uses Right Arrow. |
| Left Arrow, Right Arrow | Moves focus between the tags. |
| Backspace, Delete | On a tag, removes it. A held key removes one tag. |
| Escape | With the list closed, clears the typed text. |

## Accessibility

With no `items`, the input is a plain text field. With `items`, it is a combobox with a list.

`TagsInputTagList` is a toolbar, so give it an `aria-label`, such as "Topics". The arrow keys move between tags.

Backspace or Delete removes the focused tag. The remove and clear buttons are for the pointer and stay out of the tab order.

## Motion

| Part | Motion |
| --- | --- |
| New tag | fade · 150ms · ease-out (0, 0, 0.2, 1) · the tag fades in |
