> For AI agents: the complete documentation index is available at https://rickyshin93.github.io/tao-ui/llms.txt, the full documentation bundle is available at https://rickyshin93.github.io/tao-ui/llms-full.txt.

# Tag

Data Display`@rockshin/tao-ui`

[Examples](#examples)[API](#api)

Displays compact labels, statuses, categories, or checkable chips.

## When to use

Use Tag for lightweight metadata or status markers. Use CheckableTag for compact filter choices.

**Recommended**

- Use semantic colors consistently.
- Keep tag text short.

**Avoid**

- Do not encode critical state by color alone.

## Examples


### Basic usage
```tsx preview
import { Stack, Tag } from '@rockshin/tao-ui';

function TagExample() {
  return (
    <Stack direction="horizontal" gap="sm">
      <Tag>Default</Tag>
      <Tag color="primary">Primary</Tag>
      <Tag color="success">Success</Tag>
      <Tag color="warning">Warning</Tag>
      <Tag color="error">Error</Tag>
    </Stack>
  );
}

export default TagExample;
```

### Variants
```tsx preview
import { Stack, Tag } from '@rockshin/tao-ui';

function TagVariants() {
  return (
    <Stack gap="md">
      <Stack direction="horizontal" gap="sm">
        <Tag variant="filled" color="primary">
          Filled
        </Tag>
        <Tag variant="filled" color="success">
          Success
        </Tag>
        <Tag variant="filled" color="warning">
          Warning
        </Tag>
      </Stack>
      <Stack direction="horizontal" gap="sm">
        <Tag variant="solid" color="primary">
          Solid
        </Tag>
        <Tag variant="solid" color="success">
          Success
        </Tag>
        <Tag variant="solid" color="error">
          Error
        </Tag>
      </Stack>
      <Stack direction="horizontal" gap="sm">
        <Tag variant="outlined" color="primary">
          Outlined
        </Tag>
        <Tag variant="outlined" color="warning">
          Warning
        </Tag>
      </Stack>
    </Stack>
  );
}

export default TagVariants;
```

### Custom colors and closable tags
```tsx preview
import { useState } from 'react';
import { Stack, Tag } from '@rockshin/tao-ui';

function CustomTags() {
  const [feedback, setFeedback] = useState('');
  return (
    <>
      <Stack direction="horizontal" gap="sm">
        <Tag color="#245b57" variant="solid">
          Custom teal
        </Tag>
        <Tag color="#8a5a21" variant="outlined">
          Custom ochre
        </Tag>
        {feedback !== 'closed' && (
          <Tag color="primary" closeIcon onClose={() => setFeedback('closed')}>
            Closable
          </Tag>
        )}
        <Tag disabled color="primary" variant="solid">
          Disabled
        </Tag>
      </Stack>
      <output
        aria-live="polite"
        style={{
          display: 'block',
          marginTop: 12,
          whiteSpace: 'pre-wrap',
          overflowWrap: 'anywhere',
        }}
      >
        {feedback}
      </output>
    </>
  );
}

export default CustomTags;
```

### Checkable tags
```tsx preview
import { CheckableTag, Stack } from '@rockshin/tao-ui';
import { useState } from 'react';

function CheckableTags() {
  const [selected, setSelected] = useState(['Design']);

  return (
    <Stack direction="horizontal" gap="sm">
      {['Design', 'Engineering', 'Research'].map((label) => (
        <CheckableTag
          key={label}
          checked={selected.includes(label)}
          onChange={(checked) =>
            setSelected((items) =>
              checked
                ? [...items, label]
                : items.filter((item) => item !== label),
            )
          }
        >
          {label}
        </CheckableTag>
      ))}
    </Stack>
  );
}

export default CheckableTags;
```

### Custom colors
Use custom colors for categories while keeping their meaning in readable text.
```tsx preview
import { Stack, Tag } from '@rockshin/tao-ui';

export default function TagCustomColor() {
  return (
    <Stack gap="md">
      <Stack direction="horizontal" gap="sm">
        <Tag color="#6366f1">Indigo</Tag>
        <Tag color="#ec4899">Pink</Tag>
        <Tag color="#14b8a6">Teal</Tag>
        <Tag color="#f97316">Orange</Tag>
        <Tag color="#8b5cf6">Violet</Tag>
      </Stack>
      <Stack direction="horizontal" gap="sm">
        <Tag color="#6366f1" variant="solid">
          Indigo
        </Tag>
        <Tag color="#ec4899" variant="solid">
          Pink
        </Tag>
        <Tag color="#14b8a6" variant="solid">
          Teal
        </Tag>
        <Tag color="#f97316" variant="solid">
          Orange
        </Tag>
        <Tag color="#8b5cf6" variant="solid">
          Violet
        </Tag>
      </Stack>
      <Stack direction="horizontal" gap="sm">
        <Tag color="#6366f1" variant="outlined">
          Indigo
        </Tag>
        <Tag color="#ec4899" variant="outlined">
          Pink
        </Tag>
        <Tag color="#14b8a6" variant="outlined">
          Teal
        </Tag>
        <Tag color="#f97316" variant="outlined">
          Orange
        </Tag>
        <Tag color="#8b5cf6" variant="outlined">
          Violet
        </Tag>
      </Stack>
    </Stack>
  );
}
```

### Tags with icons
Icons assist recognition while text retains the full meaning.
```tsx preview
import { Stack, Tag } from '@rockshin/tao-ui';

export default function TagWithIcon() {
  return (
    <Stack direction="horizontal" gap="sm">
      <Tag icon={<span>🔥</span>} color="error">
        Hot
      </Tag>
      <Tag icon={<span>✅</span>} color="success">
        Done
      </Tag>
      <Tag icon={<span>⚡</span>} color="warning">
        Fast
      </Tag>
      <Tag icon={<span>🏷️</span>}>Label</Tag>
    </Stack>
  );
}
```

### Checkable tags
Use `checked` and its change callback for lightweight category filtering.
```tsx preview
import { CheckableTag, Stack } from '@rockshin/tao-ui';

import { useState } from 'react';

export default function TagCheckable() {
  function Demo() {
    const [selected, setSelected] = useState<string[]>(['react']);
    const options = ['react', 'vue', 'angular', 'svelte', 'solid'];
    return (
      <Stack direction="horizontal" gap="sm">
        {options.map((opt) => (
          <CheckableTag
            key={opt}
            checked={selected.includes(opt)}
            onChange={(checked) =>
              setSelected((prev) =>
                checked ? [...prev, opt] : prev.filter((x) => x !== opt),
              )
            }
          >
            {opt}
          </CheckableTag>
        ))}
      </Stack>
    );
  }
  return <Demo />;
}
```

### Disabled tags
Disable selection or removal while retaining the label for reading.
```tsx preview
import { CheckableTag, Stack, Tag } from '@rockshin/tao-ui';

export default function TagDisabled() {
  return (
    <Stack direction="horizontal" gap="sm">
      <Tag disabled>Disabled</Tag>
      <Tag disabled color="primary" variant="solid">
        Disabled Solid
      </Tag>
      <Tag disabled onClose={() => {}}>
        Can't Close
      </Tag>
      <CheckableTag disabled>Can't Check</CheckableTag>
    </Stack>
  );
}
```

## API


### [#](#tag)Tag



| Property | Description | Type | Default Value |
| --- | --- | --- | --- |
| disabled | Whether to disable | `boolean | undefined` | `-` |
| className | Additional css class | `string | undefined` | `-` |
| style | Additional style | `CSSProperties | undefined` | `-` |



### [#](#tagcheckabletag)Tag.CheckableTag



| Property | Description | Type | Default Value |
| --- | --- | --- | --- |
| disabled | Whether to disable | `boolean | undefined` | `-` |
| className | Additional css class | `string | undefined` | `-` |
| style | Additional style | `CSSProperties | undefined` | `-` |



### [#](#checkabletag)CheckableTag



| Property | Description | Type | Default Value |
| --- | --- | --- | --- |
| disabled | Whether to disable | `boolean | undefined` | `-` |
| className | Additional css class | `string | undefined` | `-` |
| style | Additional style | `CSSProperties | undefined` | `-` |

