Skip to content

Tag

Labels for categories, filters and statuses. Tag and Status Tag, filled or outlined, three sizes, optionally removable.

Version 0.2.0 ·

Tag
Direction
Theme
Viewport

Installation

bunx --bun shadcn@latest add @dga/tag

Usage

page.tsx
tsx
import { StatusTag, Tag } from "@/components/ui/tag";

<Tag variant="info">تقنية</Tag>
<StatusTag variant="success">مكتمل</StatusTag>

Tags label content by category or show the filters a user has picked. Status tags show the state of an item, task or request.

Anatomy

  • Tag: a <span> with optional icon and close button.
  • StatusTag: a <span> with a coloured dot and the label.
  • Close button (optional): a real <button> with a 24px hit area.

Examples

Removable

Pass onDismiss to add a close button. Give it a specific name with dismissLabel, such as "إزالة الرياض", and move focus somewhere sensible after the tag is removed.

Removable

Status Tag

subtle (default) sits on a tint, inverted on a solid fill and ghost has no fill. All three start with a coloured dot.

Status Tag

RTL

The dot, icon and close button sit on the logical start and end sides.

LTR (English)
RTL (Arabic)

Accessibility

KeyAction
TabMoves focus to the close button of a removable tag.
Enter or SpaceRemoves the tag.
  • Tags are <span>s and are read as text. Put the meaning in the label; the colour and dot are extras (WCAG 1.4.1).
  • The close button has its own name and a 24px hit area (WCAG 2.5.8).
  • Use Button with aria-pressed for tags the user can toggle.

API Reference

StatusTag

The status of an item, task or request, with a coloured dot.

StatusTag props
PropTypeDefault
"neutral" | "success" | "error" | "warning" | "info"

Colour family. `on-color` is for tags on brand fills.

"neutral"
"xs" | "sm" | "md"

Height: `xs` 20px, `sm` 24px, `md` 32px.

"sm"
"subtle" | "inverted" | "ghost"

`subtle` is a tinted fill, `inverted` a solid one and `ghost` has no fill.

"subtle"

Also accepts the props of the element it renders.

Tag

A label for a category or a selected filter. Optionally removable.

Tag props
PropTypeDefault
"on-color" | "neutral" | "success" | "error" | "warning" | "info"

Colour family. `on-color` is for tags on brand fills.

"neutral"
"xs" | "sm" | "md"

Height: `xs` 20px, `sm` 24px, `md` 32px.

"sm"
boolean

Outlined instead of filled.

false
boolean

Fully rounded (pill) corners.

false
boolean

Square, icon only. Needs an `aria-label`.

false
() => void

Adds a trailing close button.

No default
string

Accessible name of the close button. Translate it on Arabic pages.

"Remove"

Also accepts the props of the element it renders.

Deviations from DGA

ChangeReason
--tag-background-on-color (light) and 1 moreWhite label on white-20 over the brand fill is 3.34:1. A black-20 tint keeps the tag visible and gives 6.30:1.
Tag: text sizeThe export lists one sample text style. A 10px label in a 32px tag is hard to read; the sizes follow the site CSS (.tag--lg uses 14px).
Tag: dismissRemovable filter tags need a real button for keyboard and screen-reader users.
Status Tag: ghost and dotGhost tags would otherwise all look the same; the dot is decorative and the label carries the status.

View all 5 deviations for this component

Contrast

248 pairs checked · all pass WCAG 2.1 AAShow 42 states
Variant / stateLightDark
neutral / filled13.91:1 AAA11.57:1 AAA
neutral / filled (icon)17.31:1 3:112.71:1 3:1
neutral / outlined13.91:1 AAA14.45:1 AAA
neutral / outlined (icon)17.31:1 3:115.87:1 3:1
status neutral / subtle13.91:1 AAA11.57:1 AAA
status neutral / ghost13.91:1 AAA14.45:1 AAA
status neutral / ghost (dot)17.31:1 3:115.87:1 3:1
status neutral / inverted7.36:1 AAA7.66:1 AAA
success / filled7.55:1 AAA7.88:1 AAA
success / filled (icon)7.55:1 3:17.88:1 3:1
success / outlined7.62:1 AAA10.80:1 AAA
success / outlined (icon)7.62:1 3:110.80:1 3:1
status success / subtle7.55:1 AAA7.88:1 AAA
status success / ghost13.91:1 AAA14.45:1 AAA
status success / ghost (dot)7.62:1 3:110.80:1 3:1
status success / inverted5.69:1 AA8.72:1 AAA
info / filled7.61:1 AAA7.49:1 AAA
info / filled (icon)7.61:1 3:17.49:1 3:1
info / outlined7.83:1 AAA9.88:1 AAA
info / outlined (icon)7.83:1 3:19.88:1 3:1
status info / subtle7.61:1 AAA7.49:1 AAA
status info / ghost13.91:1 AAA14.45:1 AAA
status info / ghost (dot)7.83:1 3:19.88:1 3:1
status info / inverted4.56:1 AA9.24:1 AAA
warning / filled7.20:1 AAA8.57:1 AAA
warning / filled (icon)7.20:1 3:18.57:1 3:1
warning / outlined7.19:1 AAA11.30:1 AAA
warning / outlined (icon)7.19:1 3:111.30:1 3:1
status warning / subtle7.20:1 AAA8.57:1 AAA
status warning / ghost13.91:1 AAA14.45:1 AAA
status warning / ghost (dot)7.19:1 3:111.30:1 3:1
status warning / inverted5.42:1 AA9.32:1 AAA
error / filled7.96:1 AAA7.04:1 AAA
error / filled (icon)7.96:1 3:17.04:1 3:1
error / outlined8.29:1 AAA9.01:1 AAA
error / outlined (icon)8.29:1 3:19.01:1 3:1
status error / subtle7.96:1 AAA7.04:1 AAA
status error / ghost13.91:1 AAA14.45:1 AAA
status error / ghost (dot)8.29:1 3:19.01:1 3:1
status error / inverted4.83:1 AA9.68:1 AAA
on-color / filled6.30:1 AA6.30:1 AA
on-color / outlined4.74:1 AA4.74:1 AA

Text needs 4.5:1, icons and focus rings 3:1. Disabled states are exempt. Full contrast report