# Tag
A small label component for categorizing or annotating content. Supports a wide range of color variants, three sizes, and an optional leading icon.
```tsx demo
import { Tag } from "@tenstorrent/vesper/tag";
export default function TagDemo() {
return Design;
}
```
## Options
| Prop | Type | Description | Default |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | ----------- |
| `size` | `"sm" \| "md" \| "lg"` | The size of the tag. Affects height, padding, and icon size. | `"md"` |
| `variant` | `"default" \| "contrast" \| "accent-bold" \| "accent-subtle" \| "danger-bold" \| "danger-subtle" \| "success-bold" \| "success-subtle" \| "info-bold" \| "info-subtle" \| "warning-bold" \| "warning-subtle"` | The color variant of the tag. | `"default"` |
| `disabled` | `boolean` | When `true`, renders the tag in a disabled state and prevents interaction. | `false` |
| `icon` | `ReactNode` | An optional icon element rendered to the left of the tag text. | — |
| `as` | `ElementType` | The root element type for polymorphic rendering. | `"div"` |
| `children` | `ReactNode` | The text content of the tag. | — |
All other props are forwarded to the underlying `
` element, or whichever root element is specified via the `as` prop.
Use a `Tag` to classify content into categories, such as topics on an article or labels on an issue. Reach for [the `Badge` component](./badge.mdx) when describing the content next to it (a plan tier, a role, a status), or [the `Chip` component](./chip.mdx) when the label represents a selection the user can toggle on and off.
## Examples
### Basic usage
Render a `Tag` by giving it some children:
```tsx demo
import { Tag } from "@tenstorrent/vesper/tag";
export default function BasicTag() {
return
Documentation;
}
```
### Variants
`Tag` ships with two neutral variants and five colored variants. Each colored variant has both a bold and a subtle version (eg. `"accent-bold"`, `"accent-subtle"`). The default variant is `"default"`.
Use bold color variants or the `"contrast"` variant when the tag should stand out from its surroundings. Use subtle color variants or the `"default"` variant when it should sit quietly alongside other content:
```tsx demo
import { Tag } from "@tenstorrent/vesper/tag";
export default function TagVariants() {
return (
Default
Contrast
Accent bold
Accent subtle
Success bold
Success subtle
Warning bold
Warning subtle
Danger bold
Danger subtle
Info bold
Info subtle
);
}
```
### Different sizes
A `Tag` can be rendered in one of three sizes; `"sm"`, `"md"`, or `"lg"`. The default size is `"md"`. Size affects the height and padding of the tag, as well as the dimensions of its icon:
```tsx demo
import { Tag } from "@tenstorrent/vesper/tag";
export default function TagSizes() {
return (
Small
Medium
Large
);
}
```
### Rendering an icon
Pass an icon as a `ReactNode` to the `icon` prop to render it to the left of the tag's text:
```tsx demo
import { Bolt, Bug } from "@tenstorrent/vesper/icons";
import { Tag } from "@tenstorrent/vesper/tag";
export default function TagsWithIcons() {
return (
} variant="accent-bold">
Performance
} variant="danger-subtle">
Bug
);
}
```
### Disabling a tag
You can disable a `Tag` by passing `disabled={true}` or just `disabled` as a prop. A disabled tag renders with a muted color scheme that takes precedence over its `variant`, and prevents interaction when rendered as an interactive element:
```tsx demo
import { Tag } from "@tenstorrent/vesper/tag";
export default function DisabledTag() {
return (
Enabled
Disabled
);
}
```
### Polymorphic usage
You can use the `as` prop to specify what underlying element to render. In this case, we are passing `as="a"` to render the `Tag` as an anchor link, which is useful when a tag navigates to a filtered list of everything sharing that category:
```tsx demo
import { Tag } from "@tenstorrent/vesper/tag";
export default function TagAsLink() {
return (
Design
);
}
```