Clidey UXDocs

Badge

Badge is a compact inline label used for status indicators, categories, version tags, and counts.

Interactive example#

Badge · Live example

Ready to review

Choose a treatment and see the badge change while keeping its readable label.

The code uses shared demo presentation helpers. Their complete source and styling are included in the LLM build context.

Import#

TSX

import { Badge } from '@clidey/ux';

Variants#

TSX

<Badge>Default</Badge>
<Badge variant="secondary">Secondary</Badge>
<Badge variant="destructive">Destructive</Badge>
<Badge variant="outline">Outline</Badge>
VariantUse case
defaultPrimary category, active status
secondaryNeutral category, draft status
destructiveError, blocked, or danger status
outlineLow-emphasis label, version tag

With icons#

TSX

import { IconCheckCircle as CheckCircle2, IconClock as Clock, IconXCircle as XCircle } from '@clidey/ux';

<Badge>
  <CheckCircle2 className="size-3" />
  Active
</Badge>

<Badge variant="secondary">
  <Clock className="size-3" />
  Pending
</Badge>

<Badge variant="destructive">
  <XCircle className="size-3" />
  Failed
</Badge>

Common use cases#

Status labels

TSX

function StatusBadge({ status }: { status: string }) {
  const variants = {
    active: 'default',
    pending: 'secondary',
    failed: 'destructive',
    draft: 'outline',
  } as const;

  return (
    <Badge variant={variants[status as keyof typeof variants] ?? 'outline'}>
      {status}
    </Badge>
  );
}

Version tag

TSX

<span className="font-medium">
  Authentication API <Badge variant="outline">v2.1</Badge>
</span>

Count indicator

TSX

<div className="flex items-center gap-2">
  <span>Notifications</span>
  <Badge>12</Badge>
</div>

TSX

<Badge>
  <a href="/changelog">v1.5.0</a>
</Badge>

Props#

PropTypeDefaultDescription
variant"default" | "secondary" | "destructive" | "outline""default"Visual style.
asChildbooleanfalseRender as the child element.
classNamestring—Additional CSS classes.
childrenReactNode—Badge content.

Was this page helpful?