Skip to content
New

Badge

A short label for a status or a count. Renders a link or any element through render.

DefaultSecondaryOutlineFailedLivev2.0

Installation

Terminal
npx rasengan-ui add badge

Or with the shadcn CLI, from the registry:

Terminal
npx shadcn@latest add https://ui.rasengan.dev/r/base/badge.json

Usage

app/status.tsx
import { Badge } from "@/components/ui/badge";
 
export function Status() {
  return <Badge variant="secondary">Beta</Badge>;
}

Variants

default filled, soft as a wash, outline as a border, secondary in grey, and destructive for errors (shorthand for tone="destructive"). tone is the colour: primary by default, or neutral, success, warning, info, destructive; outline stays neutral in primary.

NeutralPrimarySuccessWarningInfoDestructive
NeutralPrimarySuccessWarningInfoDestructive
NeutralPrimarySuccessWarningInfoDestructive
<Badge variant="soft" tone="success">Live</Badge>

Sizes

sm, default and lg set the padding, the text and the icon.

SmallDefaultLarge
<Badge render={<a href="/changelog" />}>New</Badge>

Villages

Its radius is --badge-radius: soft in Konoha, a pill in Kiri, square in Iwa, where it is also set in mono capitals.

Konoha · light
DefaultSecondaryOutlineFailedLivev2.0
Konoha · dark
DefaultSecondaryOutlineFailedLivev2.0
Kiri · light
DefaultSecondaryOutlineFailedLivev2.0
Kiri · dark
DefaultSecondaryOutlineFailedLivev2.0
Iwa · light
DefaultSecondaryOutlineFailedLivev2.0
Iwa · dark
DefaultSecondaryOutlineFailedLivev2.0

Accessibility

  • A <span>: its text is read in place. A badge that only shows a count needs the thing counted in the text around it, or an aria-label.

API reference

The props of <span>, plus render (any element, through Base UI's useRender) and:

PropTypeDefault
variant"default" | "secondary" | "outline" | "soft" | "destructive""default"
tone"neutral" | "primary" | "success" | "warning" | "info" | "destructive""primary"
size"sm" | "default" | "lg""default"

badgeVariants({ variant, tone, size }) returns the same classes.