Skip to content
HomeCobalt

Badge

Marks a thing with one word or a count that you read and do not press: new, draft, overdue, 12 unread.

Examples

The accent, the grey fill and the red text.
NewDraftOverdue
In a cardA count beside a card's title.
Reading list 3
Three items are unread.
Updated this morning.
In an itemCounts beside the views in a sidebar, digits only, and no badge on a view with nothing new.

Variants

DraftArchived
SecondaryA fact about the thing, such as "Draft", or a count, the grey fill.
Overdue
DestructiveSomething gone wrong, such as "Overdue", red text on a light red background.

Usage

Use it when

  • A thing has a state you read at a glance, and that state is the exception in its list: new, draft, overdue.
  • A heading or a row carries a count, such as the unread items in a list.

Use something else when

  • The label is a category or a topic that should be the same colour everywhere it appears. Use Tag instead, which takes its hue from the key.
  • The label is a filter that is on or off. Use Pill instead.
  • The label is an action. Use Button instead.
  • The label marks someone's presence on a picture. Use Avatar with its badge part instead.
  • Every row in a list would carry the same word, such as "Active". Use a Tag in a table column instead, or leave the usual state unmarked and badge only the rows that differ.

Rules

General

Content

Avoid

Limits

Install

npx shadcn@latest add https://kaanarici.com/r/cobalt/badge.json
import { Badge, badgeVariants } from "@/components/cobalt/ui/badge"