Badge
Displays a badge or a component that looks like a badge.
The Badge component is built on top of Kobalte Badge, which provides the accessible badge primitive.
import { Badge } from "~/components/ui/badge";
export default function BadgeDemo() { return ( <div class="flex w-full flex-wrap justify-center gap-2"> <Badge>Badge</Badge> <Badge variant="secondary">Secondary</Badge> <Badge variant="destructive">Destructive</Badge> <Badge variant="outline">Outline</Badge> </div> );}Installation
Usage
import { Badge } from "~/components/ui/badge";<Badge variant="default | outline | secondary | destructive">Badge</Badge>Variants
Use the variant prop to change the variant of the badge.
import { Badge } from "~/components/ui/badge";
export default function BadgeVariants() { return ( <div class="flex flex-wrap gap-2"> <Badge>Default</Badge> <Badge variant="secondary">Secondary</Badge> <Badge variant="destructive">Destructive</Badge> <Badge variant="outline">Outline</Badge> <Badge variant="ghost">Ghost</Badge> </div> );}Status Variants
Each semantic color ships in two treatments. *-light fills the badge with a tinted surface, and *-outline keeps the badge on the page background with only the border and the label carrying the color. Both read against the same --primary, --destructive, --success, --warning and --info tokens, so they follow the active theme.
import { Badge } from "~/components/ui/badge";
export default function BadgeStatus() { return ( <div class="flex flex-col gap-3"> <div class="flex flex-wrap gap-2"> <Badge variant="primary-light">Primary</Badge> <Badge variant="destructive-light">Destructive</Badge> <Badge variant="success-light">Success</Badge> <Badge variant="warning-light">Warning</Badge> <Badge variant="info-light">Info</Badge> </div> <div class="flex flex-wrap gap-2"> <Badge variant="primary-outline">Primary</Badge> <Badge variant="destructive-outline">Destructive</Badge> <Badge variant="success-outline">Success</Badge> <Badge variant="warning-outline">Warning</Badge> <Badge variant="info-outline">Info</Badge> </div> </div> );}With Icon
You can render an icon inside the badge. Use data-icon="inline-start" to render the icon on the left and data-icon="inline-end" to render the icon on the right.
import { BadgeCheck, BookmarkIcon } from "lucide-solid";import { Badge } from "~/components/ui/badge";
export default function BadgeIcon() { return ( <div class="flex flex-wrap gap-2"> <Badge variant="secondary"> <BadgeCheck data-icon="inline-start" /> Verified </Badge> <Badge variant="outline"> Bookmark <BookmarkIcon data-icon="inline-end" /> </Badge> </div> );}With Spinner
You can render a spinner inside the badge. Remember to add the data-icon="inline-start" or data-icon="inline-end" prop to the spinner.
import { Badge } from "~/components/ui/badge";import { Spinner } from "~/components/ui/spinner";
export default function BadgeSpinner() { return ( <div class="flex flex-wrap gap-2"> <Badge variant="destructive"> <Spinner data-icon="inline-start" /> Deleting </Badge> <Badge variant="secondary"> Generating <Spinner data-icon="inline-end" /> </Badge> </div> );}Link
Use the as prop to render a link as a badge.
/** biome-ignore-all lint/a11y/useValidAnchor: <example file> */import { ArrowUpRightIcon } from "lucide-solid";import { Badge } from "~/components/ui/badge";
export default function BadgeLink() { return ( <Badge as="a" href="#link"> Open Link <ArrowUpRightIcon data-icon="inline-end" /> </Badge> );}Custom Colors
You can customize the colors of a badge by adding custom classes such as bg-green-50 dark:bg-green-800 to the Badge component.
import { Badge } from "~/components/ui/badge";
export default function BadgeColors() { return ( <div class="flex flex-wrap gap-2"> <Badge class="bg-blue-50 text-blue-700 dark:bg-blue-950 dark:text-blue-300">Blue</Badge> <Badge class="bg-green-50 text-green-700 dark:bg-green-950 dark:text-green-300">Green</Badge> <Badge class="bg-sky-50 text-sky-700 dark:bg-sky-950 dark:text-sky-300">Sky</Badge> <Badge class="bg-purple-50 text-purple-700 dark:bg-purple-950 dark:text-purple-300"> Purple </Badge> <Badge class="bg-red-50 text-red-700 dark:bg-red-950 dark:text-red-300">Red</Badge> </div> );}API Reference
Badge
The Badge component displays a badge or a component that looks like a badge.
For primitive props, see the Kobalte Badge API reference.