{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"badge","type":"registry:ui","title":"Badge","description":"A small label for status, category or count.","dependencies":["clsx","tailwind-merge"],"registryDependencies":["https://caliperui.site/r/styles.json"],"files":[{"path":"ui/badge.tsx","type":"registry:ui","target":"components/ui/badge.tsx","content":"import type { ComponentProps, CSSProperties } from \"react\";\nimport { cn } from \"./lib/cn\";\n\nconst variants = {\n  neutral: \"bg-muted text-muted-foreground\",\n  info: \"bg-brand-subtle text-[color-mix(in_srgb,var(--accent-text)_82%,var(--foreground))]\",\n  success: \"bg-success-subtle text-success\",\n  warning: \"bg-warning-subtle text-warning\",\n  error: \"bg-destructive-subtle text-destructive\",\n};\n\n/* Status survives without colour: each variant has its own shape. */\nconst shapes = {\n  neutral: <path d=\"M2 5h6\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" />,\n  info: <circle cx=\"5\" cy=\"5\" r=\"3.6\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" />,\n  success: <circle cx=\"5\" cy=\"5\" r=\"4\" fill=\"currentColor\" />,\n  warning: (\n    <>\n      <path d=\"M5 1a4 4 0 0 1 0 8z\" fill=\"currentColor\" />\n      <circle cx=\"5\" cy=\"5\" r=\"4\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" />\n    </>\n  ),\n  error: <path d=\"M2 2l6 6M8 2 2 8\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" />,\n};\n\n/* Categorical hues for labels that name a kind, not a status (a deal stage, a team, a type): OKLCH hue angles.\n   Lightness and chroma come per theme from tokens.css (--tone-*), so the text holds 4.5:1 on its wash in both. */\nexport const toneHues = { blue: 255, violet: 295, rose: 2, orange: 50, amber: 82, green: 150, teal: 195, slate: 260 } as const;\nexport type BadgeTone = keyof typeof toneHues;\n\nexport type BadgeProps = ComponentProps<\"span\"> & {\n  variant?: keyof typeof variants;\n  /** A categorical hue with a dot, for kinds rather than statuses. Overrides the variant's colour. */\n  tone?: BadgeTone;\n  /** The status shape before the word. On for status variants, off for neutral labels and counts. */\n  shape?: boolean;\n};\n\nexport function Badge({\n  className,\n  variant = \"neutral\",\n  tone,\n  shape = variant !== \"neutral\" && !tone,\n  children,\n  style,\n  ...props\n}: BadgeProps) {\n  return (\n    <span\n      data-slot=\"badge\"\n      data-variant={variant}\n      data-tone={tone}\n      className={cn(\n        \"inline-flex h-[22px] shrink-0 items-center gap-1.5 whitespace-nowrap rounded-full px-2 text-xs leading-4 font-medium [&_svg]:size-3\",\n        (shape || tone) && \"pl-[7px]\",\n        tone\n          ? \"bg-[oklch(var(--tone-bg-l)_var(--tone-bg-c)_var(--tone-h))] text-[oklch(var(--tone-fg-l)_var(--tone-fg-c)_var(--tone-h))]\"\n          : variants[variant],\n        className,\n      )}\n      style={tone ? ({ \"--tone-h\": toneHues[tone], ...style } as CSSProperties) : style}\n      {...props}\n    >\n      {tone && <span data-slot=\"badge-dot\" aria-hidden=\"true\" className=\"size-1.5 shrink-0 rounded-full bg-current\" />}\n      {shape && (\n        <svg data-slot=\"badge-shape\" viewBox=\"0 0 10 10\" aria-hidden=\"true\" className=\"!size-2.5\">\n          {shapes[variant]}\n        </svg>\n      )}\n      {children}\n    </span>\n  );\n}\n"},{"path":"ui/lib/cn.ts","type":"registry:ui","target":"components/ui/lib/cn.ts","content":"import { clsx, type ClassValue } from \"clsx\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\nconst twMerge = extendTailwindMerge({\n  extend: { theme: { radius: [\"control\", \"surface\", \"overlay\"], shadow: [\"overlay\"] } },\n});\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n"}],"categories":["feedback"],"meta":{"tier":"free","license":"MIT","family":"status","docs":"/docs/components/badge"}}