Badge

A short label in neutral or toned soft, outline and solid styles.

softDraftIn reviewShippedOver budgetBlockedNew
outlineDraftIn reviewShippedOver budgetBlockedNew
solidDraftIn reviewShippedOver budgetBlockedNew

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/badge

Usage

import { Badge } from "./ui/uicontext/components/Badge.ts"
export const PlanBadge = <M>(h: Html.H<M>) => Badge(h, { tone: "accent" }).children("Team plan")

Examples

Counts

pill and solid for counts. Give a bare number an aria-label that says what it counts.

  • Inbox3
  • Assigned to me12
  • Failed runs99+

With a dot

dot adds a small mark in the tone's color, for a state.

OnlineAway until 3 PMOffline

API reference

Options

Badge options
NameTypeDefaultDescription
tone"neutral" | "accent" | "danger" | "warning" | "success" | "info"neutralWhat it means; neutral by default
emphasis"soft" | "outline" | "solid"—Soft (a faint wash, the default), outline (a hairline) or solid (filled, for counts that must stand out)
size"sm" | "md"mdThe text size and padding; md by default.
pillboolean—Fully rounded, for counts
dotboolean—A small dot before the text in the tone's color
styleStyle—StyleX styles applied after the badge’s own.

Accessibility

  • Screen readers hear only its text, so the words must carry the meaning; color and the dot only add to it.

Source