COMPONENT · 06NEW

Badge

A status chip or pill built from parts: a Badge, an optional BadgeTag chip in front, an optional BadgeDot, text and icons. Variant, color, size, radius and font are props; the tag and the dot pick their own colors. An optional tooltip makes it focusable.

  • @ui-sdk/react
  • class-variance-authority

Variants

SolidSoftOutlineSurface

Colors

color takes every intent color. A BadgeTag has its own color and variant, so the chip and the badge can differ.

PrimarySecondaryMutedInfoSuccessWarningError
Stablev2.4.0BetaAgents APIDeprecatedLegacy themes

Shape and size

radius goes from square corners to a pill, and a BadgeTag inside follows it. size="sm" is the compact chip the docs use next to new components; font="mono" suits versions and codes.

NoneSmallMediumFull
NEWBETAv0.13.0

Composition

Put a BadgeTag first and the badge tightens its start padding around it. Text, a BadgeDot and icons go in any order; icons are sized for you. render turns the whole badge into a link.

Newv0.13.0 · Badge is herev0.13.0All operating systemsOperational

Status dot

pulse rings the dot for live states, like a deploy in progress. The ring is off when the person prefers reduced motion, and the dot is always decorative: the text says the state.

IdleDeployingLive

Tooltip

tooltip wraps the badge in the registry Tooltip, and tooltipOptions sets its side, alignment, offset, arrow and delay. A tooltip needs something focusable, so a badge without render becomes a button, and pressing it also shows the tip on touch screens. A link badge stays a link and is its own trigger.

Link with a tip

For full control, compose the parts: <TooltipTrigger render={<Badge render={<button type="button" />} />}>.

Installation

npx shadcn@latest add https://lanzate-ui.vercel.app/r/badge.json

Usage

import { Badge, BadgeDot, BadgeTag } from "@/components/ui/badge"

// Compact chip
<Badge size="sm" radius="sm" font="mono">NEW</Badge>

// Announcement pill that links somewhere
<Badge variant="surface" color="muted" render={<a href="/changelog" />}>
  <BadgeTag>New</BadgeTag>
  v0.13.0 · Badge is here
</Badge>

// Live status
<Badge color="error">
  <BadgeDot color="error" pulse />
  Live
</Badge>

// With a tooltip
<Badge color="warning" tooltip="May change before 1.0">Beta</Badge>

API

PropTypeDefaultDescription
Badge variant"solid" | "soft" | "outline" | "surface""soft"Fill style. surface is the neutral card pill (border, card fill, soft shadow); color only tints its text.
Badge color"primary" | "secondary" | "muted" | "info" | "success" | "warning" | "error""primary"Intent color of the badge. A BadgeTag or BadgeDot inside keeps its own.
Badge size"sm" | "md""md"sm is a compact chip, like a "New" next to a nav item; md is a pill with room for a tag, text and an icon.
Badge radius"none" | "sm" | "md" | "full""full"Corner radius. A BadgeTag inside follows it.
Badge font"sans" | "mono"Font family. Without it, the badge inherits the parent's.
Badge renderReactElement | (props) => ReactElement<span />Element to render instead of <span>, like render={<a href="…" />}. As a link or button it gets a hover fill and a focus ring.
Badge tooltipReactNodeWraps the badge in a Tooltip. Without render, the badge becomes a focusable button and the tip also toggles on press, for touch screens.
Badge tooltipOptions{ side, align, sideOffset, arrow, delay, toggleable, type, className }Settings passed to the Tooltip and its content. For anything else, compose Tooltip and TooltipTrigger yourself.
Badge classNamestringClasses merged after the variants, so they can override any base style.
BadgeTag color"primary" | "secondary" | "muted" | "info" | "success" | "warning" | "error""primary"Color of the leading chip, independent of the badge's.
BadgeTag variant"solid" | "soft" | "outline""solid"Fill style of the chip.
BadgeDot color"primary" | "secondary" | "muted" | "info" | "success" | "warning" | "error""primary"Color of the dot.
BadgeDot pulsebooleanfalsePulses a ring around the dot, for live states. Off when the person prefers reduced motion.