# Tag

> Small pill that names a state such as Paid, Past due or Failed, in five variants and three appearances with an optional dot.

- Kind: ui · Category: Data display · Interactivity: none
- Install: `npx shadcn@latest add @haze/tag`
- File: `src/components/haze/ui/tag.astro`
- npm dependencies: none
- Registry dependencies: @haze/utils
- Docs page: https://hazeui.com/ui/tag

## Use when
- Showing the state of a row or record: paid, syncing, failed
- A state label next to a title in a card header or an item row
- Short status words where the color adds to the text, not replaces it

## Avoid when
- Neutral metadata such as a version number or a category; badge is quieter and has no status colors
- A status the user must act on right away; use alert, which can carry a message and a button

## Alternatives
- [badge](https://hazeui.com/ui/badge.md)
- [status](https://hazeui.com/ui/status.md)
- [alert](https://hazeui.com/ui/alert.md)

## Props

| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| variant | `"default" \| "info" \| "success" \| "warning" \| "destructive"` | "default" | no | Color. default is neutral; the other four use the brand and status colors. |
| appearance | `"soft" \| "outline" \| "solid"` | "soft" | no | soft is a tinted fill with no border. outline is a hairline in the tag's own color. solid is a full fill, for the one tag that must stand out. |
| size | `"sm" \| "md"` | "md" | no | Text 11 px or 12 px. |
| dot | `boolean` | false | no | Adds a small colored dot before the text. |
| class | `string` |  | no | Extra classes. |
| default slot | `slot` |  | yes | The status word. Keep it to one or two words. |

## Accessibility
- The text is the status; the tint and the aria-hidden dot only reinforce it, so a user who cannot tell the colors apart loses nothing (WCAG 1.4.1).
- Soft tags use a 14% tint with no border, and their text color is tuned for the dark theme; check the contrast again if you change the tokens.
- Tag is a plain span with no live region, so a status that changes on screen needs its own announcement.

## Agent prompts

### Install and use

Install the Haze UI component "Tag" with `npx shadcn@latest add @haze/tag`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "https://hazeui.com/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import Tag from "@/components/haze/ui/tag.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: https://hazeui.com/ui/tag.md

### Customize with real content

Adapt the Haze tag ui for our product. Replace the demo values of these props with our real content: variant, appearance, size, dot, class, default slot. Keep the layout, the heading level rules and these accessibility details: The text is the status; the tint and the aria-hidden dot only reinforce it, so a user who cannot tell the colors apart loses nothing (WCAG 1.4.1). Soft tags use a 14% tint with no border, and their text color is tuned for the dark theme; check the contrast again if you change the tokens. Tag is a plain span with no live region, so a status that changes on screen needs its own announcement. Do not add raw color classes; use the Haze tokens.

### Choose the right block

Before using tag, check it fits: use it when showing the state of a row or record: paid, syncing, failed; a state label next to a title in a card header or an item row; short status words where the color adds to the text, not replaces it. Avoid it when neutral metadata such as a version number or a category; badge is quieter and has no status colors; a status the user must act on right away; use alert, which can carry a message and a button. Alternatives: @haze/badge, @haze/status, @haze/alert.

## Example requests that should lead here
- Add a green Paid tag with a dot next to the invoice number
- Show a warning tag that says Past due
- Mark the newest release with a solid tag and the others with outline tags

## Source

```astro
---
import { cn } from "../../../lib/haze/utils";

interface Props {
  variant?: "default" | "info" | "success" | "warning" | "destructive";
  /** soft: tinted fill. outline: hairline in the tag's own color. solid: full fill, for the one tag that must stand out. */
  appearance?: "soft" | "outline" | "solid";
  size?: "sm" | "md";
  /** Small leading dot. Decorative; the text still carries the status. */
  dot?: boolean;
  class?: string;
}

const { variant = "default", appearance = "soft", size = "md", dot = false, class: className } = Astro.props;

const soft = {
  default: "bg-muted text-foreground inset-ring inset-ring-frame",
  info: "bg-brand/14 text-brand",
  success: "bg-success/14 text-success",
  warning: "bg-warning/14 text-warning",
  destructive: "bg-destructive/14 text-destructive",
};
const outline = {
  default: "text-muted-foreground inset-ring inset-ring-frame-strong",
  info: "text-brand inset-ring inset-ring-frame-brand",
  success: "text-success inset-ring inset-ring-frame-success",
  warning: "text-warning inset-ring inset-ring-frame-warning",
  destructive: "text-destructive inset-ring inset-ring-frame-destructive",
};
const solid = {
  default: "bg-foreground text-background",
  info: "bg-brand text-brand-foreground",
  success: "bg-success text-success-foreground",
  warning: "bg-warning text-warning-foreground",
  destructive: "bg-destructive text-destructive-foreground",
};
const looks = { soft, outline, solid };
const sizes = { sm: "h-5 gap-1 px-2 text-[0.6875rem]/4", md: "h-6 gap-1.5 px-2.5 text-xs/4" };
---

<span class={cn("inline-flex shrink-0 items-center whitespace-nowrap rounded-full font-medium", looks[appearance][variant], sizes[size], className)}>
  {dot && <span aria-hidden="true" class="size-1.5 rounded-full bg-current"></span>}
  <slot />
</span>
```
