---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Tags input

A field a person types several short values into, each one a removable tag — labels, keywords, the emails to invite, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `TagsInput`.

## Try it

Type a label and press Enter or a comma, paste several separated by commas, type one that is there already, press Backspace twice in the empty field to remove the last; invite up to five people by email, a word that is no address refused.

Nothing is saved and no invitation is sent.

## When to use

- A field a person types several short values into, each one a removable tag — labels, keywords, the emails to invite.
- Use TagsInput for values a person makes up; for values picked from a list use MultiSelect. Hand a refused value's reason to a FieldInvalid round it: the field marks itself invalid, the sentence is yours.
- Also called: chips input or token input.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Tags input on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-tags-input.json --yes
```

```text
Add the Goop Tags input to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { useState } from 'react';
import { Field } from '@/components/ui/goop/field';
import { TagsInput } from '@/components/ui/goop/tags-input';

function Labels() {
  const [labels, setLabels] = useState<string[]>(['interview']);
  return (
    <Field label="Labels" orientation="vertical" className="w-full">
      <TagsInput value={labels} onValueChange={setLabels} placeholder="Add a label" max={5} />
    </Field>
  );
}

function Invitees() {
  const [emails, setEmails] = useState<string[]>(['fatou@example.org', 'lupe@example']);
  return (
    <Field label="Invite" orientation="vertical" className="w-full">
      <TagsInput
        value={emails}
        onValueChange={setEmails}
        placeholder="Add an email"
        markInvalid={(address) => !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(address)}
      />
    </Field>
  );
}
```

- Fits: settings, record: field.
- Also known as: TagInput, ChipInput, TokenInput, KeywordInput, EmailChips.
- height, width, padding, gap, corner, background, text: add no class for these.

## API reference

### Options

- `size?: 'sm' | 'md' | 'lg' | null` — The field's height: `sm` 36 px, `md` 40 px (the default, the text input's), `lg` 44 px.
- `value?: readonly string[]` — The tags, controlled.
- `defaultValue?: readonly string[]` — The tags at first, uncontrolled (none if left out).
- `onValueChange?: (value: string[]) => void` — Called with the tags each time one is added or removed.
- `max?: number` — The most tags it holds; past it nothing more is added (no limit by default).
- `validate?: (text: string, tags: readonly string[]) => boolean` — Whether a typed value may be a tag: refused, the text stays in the field, marked invalid until it changes.
- `markInvalid?: (tag: string) => boolean` — Marks a tag that is in the field but not valid (such as an address your server refused): its chip takes the danger ring and a screen reader reads it as not valid.
- `addOnBlur?: boolean = true` — Adds what is typed when the field loses the focus.
- `removeLabel?: (tag: string) => string` — A tag's cross's spoken name, from the tag (default `Remove <tag>`).
- `onInputChange?: (text: string) => void` — Called when the typed text changes, with the text.
- `messages?: Partial<TagsInputMessages>` — What it says to a reader as its tags change; English by default.
- `name?: string`
- `required?: boolean`
- `disabled?: boolean`
- `form?: string`

- State: value (value / defaultValue / onValueChange); drawn by data-selected, data-invalid

## Keyboard

- Enter / ,: add the typed words as a tag (one already there is not added again; a refused value stays, the field marked invalid); a pasted list adds every entry, a refused one as a tag marked invalid
- Backspace: in the empty field: select the last tag; again: remove it
- Delete: remove the selected tag
- ArrowLeft / ArrowRight: walk from the field to the tags and back
- Escape: drop the selection

## Accessibility

- The native element answers the keyboard.
- hover, focus: the browser's own (:hover, :focus): write nothing
- selected: the attribute data-selected
- disabled: the prop disabled
- invalid: the attribute data-invalid

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

## Related

- [Field](/themes/meadow/components/field): A form row that ties one control to its label and its description, as a settings row or a stacked form field.
- [Slider](/themes/meadow/components/slider): A value or a span chosen by dragging a thumb along a track or with the keys, such as a recording's place, a volume or a price limit.
- [Segmented control](/themes/meadow/components/segmented-control): One choice of two to five short options that applies at once — a view or a mode — drawn as touching segments in one framed row.
- [Rating](/themes/meadow/components/rating): A row of stars to give a score, or to show an average with halves, for reviews, testimonials and feedback.
