Badge

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

BadgeSecondaryDestructiveOutline

Installation

pnpm dlx cubix@latest add badge --base radix

Usage

Import
import { Badge } from "@/components/cubix/badge"
Example
<Badge variant="default | secondary | destructive | outline | ghost | link">
  Badge
</Badge>

Examples

Variants

Use the variant prop to change the look of the badge.

DefaultSecondaryDestructiveOutlineGhostLink

With Icon

Render an icon inside the badge. Use data-icon="inline-start" and data-icon="inline-end" so padding follows reading direction in LTR and RTL.

DefaultDefault

With Spinner

Render a spinner inside the badge. Add data-icon so padding matches the icon examples.

DeletingGenerating

Link

Use the render prop (Base UI / React Aria) or asChild (Radix) to render a link as a badge.

Custom Colors

Override colors with classes such as bg-green-50 dark:bg-green-950.

BlueGreenSkyPurpleRed

RTL

To enable RTL support, see the Direction guide. Icon padding uses inline-start / inline-end so it stays correct under dir="rtl".

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

API Reference

Note: Put icons and spinners inside the badge and mark them with data-icon so spacing stays correct.

Badge

The control that displays a badge or a component that looks like a badge.

PropTypeDefaultDescription
variant"default" | "secondary" | "destructive" | "outline" | "ghost" | "link""default"The visual style of the badge.
renderReact.ReactElement-Render the badge as another element, such as a link. On Radix, use asChild instead.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).
childrenReact.ReactNode-Badge label, optional icon, or spinner.