Skip to content
HomeCobalt

Tag

Names a category or a topic in a colour that follows the name, so the same key wears the same tint on every page and every visit, and leads to its topic when given a link.

Examples

A report's topics, each a link to the topic's other reports, in the tint the topic has on every page.

Private credit launches in Europe, third quarter

In a data tableThe tags column keeps each cell to one line and counts the rest, with bug pinned to red and None for a row with no tags.
Export fails on large filesbugexport
Dark theme for the report viewdesigntheme
Invoice totals round upbillingbuginvoicesroundingexport
Rename the saved views menuNone

Variants

Hue

designbillingsearchmobile
Hue from the keyA hue on the OKLCH wheel from hueFor(key), hashed from the key or pinned in a map, so a key is the same colour everywhere.
archiveduntagged
No hueGrey, zero chroma, the colour that means none, for "archived" or a key with no meaning.

Size

Quarterly reportfinance
Small20px tall, one step under, for a row that is already dense.

States

designbillingsearchmobileaccountsexporttheme
OverflowTags past the row become a grey +N naming them.
Research and development, long term
TruncatedCut with an ellipsis; the full label is the title.

Usage

Use it when

  • A thing belongs to a category or a topic that appears on more than one screen, and you find it by colour before reading it.
  • A list filters or groups by the same keys, and the tag leads to the filtered list.

Use something else when

  • The label is a state you read, such as "Draft", or a count. Use Badge instead, which has the same box without a hue.
  • The label is a filter that is on or off. Use Pill instead.
  • The label is an action with an effect other than navigation. Use Button instead.

Rules

General

Content

Avoid

Limits

Install

npx shadcn@latest add https://kaanarici.com/r/cobalt/tag.json
import { Tag, TagRow, tagHueClassName, type TagProps, type TagRowProps } from "@/components/cobalt/ui/tag"