Primitives

Tag

A short label on content: a category, a status word, a chosen value; optionally removable or clickable

Markdown version for agents · 8 stories in Storybook(opens in a new tab)

Import
import { Tag } from '@amezquita/design-system/components/primitives/Tag'

Live render

basetokensreacta11y

    Props

    PropTypeDescription
    variant?'default' | 'accent' | 'muted'
    childrenReact.ReactNode
    label?stringAccessible label for the outer clickable element. Required when onClick is set and children is not a plain string.
    icon?React.ReactNode
    removable?boolean
    onRemove?() => void
    onClick?() => void

    Tokens

    TokenTypeValue
    --tag-font-weightfontWeight500
    --tag-muted-backgroundcolortransparent
    --tag-padding-xdimension12px
    --tag-padding-ydimension4px

    Usage example

    tsx
    <Tag
      variant="default"
    >Default</Tag>

    Best practices

    Do

    • Keep tag text to a word or two.
    • Use removable tags for values people chose (MultiSelect, TagInput), so each can be taken back.

    Don't

    • Don't use a tag as the only way to reach something; tags are small targets in a row.
    • Don't use colour alone to tell tags apart; say it in the text.

    Accessibility

    • A plain tag is a <span> with no role
    • The Remove button is named after the tag, draws in the tag's own text colour at full strength (4.5:1, so over the 3:1 an icon needs) and has a 24px target (WCAG 2.5.8)
    • A clickable and removable tag is a span role="button" so the Remove <button> inside stays valid HTML; Enter and Space activate it