Badge

Web/Mobile

Displays a badge or a component that looks like a badge.

نشانثانویهمخربحاشیه‌دار

Installation

pnpm dlx cubix-ui@latest add badge

Usage

Import
import { Badge } from "@/components/cubix/badge"
Example
<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.

PropTypeDefaultDescription
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.
renderReact.ReactElement-Render the badge as another element, such as a link. The badge children are passed to it.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).
childrenReact.ReactNode-Badge label, optional icon, or spinner.