Badge
Web/MobileDisplays a badge or a component that looks like a badge.
Installation
pnpm dlx cubix-ui@latest add badge --base radixUsage
import { Badge } from "@/components/cubix/badge"
<div className="flex flex-wrap items-center justify-center gap-2">
<Badge>نشان</Badge>
<Badge variant="secondary">ثانویه</Badge>
<Badge variant="destructive">مخرب</Badge>
<Badge variant="outline">حاشیهدار</Badge>
</div>
Examples
Variants
Use the variant prop to change the look of the badge.
Sizes
Use the size prop to pick default (20px) or lg (24px).
Dot
Use variant="dot" for a small round status indicator with no visible label. It is 8px by default and 12px with size="lg". Give it role="img" and an aria-label so screen readers announce the status, and change its color with a token class such as bg-destructive.
With icon
Render an icon inside the badge. Use data-icon="inline-start" and data-icon="inline-end" so padding follows the reading direction. In RTL, inline-end is the left side, so use a left-pointing arrow.
With spinner
Put a Cubix Spinner inside the badge. Add data-icon so padding matches the icon examples.
Link
Use the render prop to render the badge as a link. It works the same on Base UI, React Aria, and Radix.
Custom styling
Badge accepts a className merged with the shipped cn helper, so override colors with classes such as bg-green-50 dark:bg-green-950.
API Reference
Note: Put icons and spinners inside the badge and mark them with data-icon so spacing stays correct in both directions.
Badge
Displays a badge or a component that looks like a badge.
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "secondary" | "destructive" | "outline" | "ghost" | "link" | "dot" | "default" | The visual style of the badge. |
| size | "default" | "lg" | "default" | The size of the badge: default is 20px tall, lg is 24px tall. |
| render | React.ReactElement | - | Render the badge as another element, such as a link. The badge children are passed to it. |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
| children | React.ReactNode | - | Badge label, optional icon, or spinner. |