{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "badge",
  "title": "Badge",
  "description": "A status, a count or a tag, with the type and corner of the Tag input's chips. A new label or variant crossfades, and a count rolls to its new value inside an Animated number.",
  "dependencies": [
    "@ui-sdk/react",
    "@ui-sdk/core",
    "class-variance-authority"
  ],
  "registryDependencies": [
    "https://kinoui.com/r/swap.json",
    "https://kinoui.com/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/components/kino/badge.tsx",
      "content": "'use client'\n\nimport { SwapText, flattenChildren } from '@/registry/lib/swap'\nimport { mergeProps, type PartProps, renderElement } from '@ui-sdk/react/primitive'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport type { ReactNode } from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * A status, a count or a tag. It has the type and corner of the Tag input's\n * chips, a little shorter since nothing in it is pressed. A label that changes\n * crossfades as the Button's does, and a count that changes rolls to its new\n * value when it is an AnimatedNumber.\n */\n\nconst badgeVariants = cva(\n  // As tall as a line of small body text at every density, so a row with a badge is as tall\n  // as one without; only its sides follow the density. A change of variant, such as a status\n  // that moves on, crossfades on `press`, as the chips do.\n  \"inline-flex h-5 max-w-full min-w-5 shrink-0 items-center justify-center gap-1 overflow-hidden rounded-(--control-radius-xs) border px-[calc(var(--control-padding)*0.6)] text-xs leading-none font-medium whitespace-nowrap tabular-nums transition-[color,background-color,border-color,box-shadow] duration-(--motion-press-duration) ease-(--motion-press-fade-easing) focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-hidden [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3\",\n  {\n    variants: {\n      // Each variant names its own border colour, as the Button's do, so the\n      // classes also work on a link. A link darkens on hover as a Button does.\n      variant: {\n        default:\n          'border-transparent bg-primary text-primary-foreground [a]:hover:bg-primary/80',\n        // These two take a tint of the text they sit in, as the Kbd does, so a count reads the\n        // same on a page, in a muted tab list and in a picked tab's primary pill.\n        secondary: 'border-transparent bg-current/8 [a]:hover:bg-current/14',\n        outline: 'border-current/20 [a]:hover:bg-current/8',\n        // The Button's destructive tint, with a fifth of the foreground in the text for 4.5:1.\n        destructive:\n          'border-transparent bg-destructive/10 text-[color-mix(in_oklch,var(--destructive),var(--foreground)_20%)] focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20 dark:[a]:hover:bg-destructive/30',\n        // The same tint in green and amber, with their foreground colour for 4.5:1.\n        success:\n          'border-transparent bg-success/10 text-success-foreground focus-visible:ring-success/20 dark:bg-success/20 dark:focus-visible:ring-success/40 [a]:hover:bg-success/20 dark:[a]:hover:bg-success/30',\n        warning:\n          'border-transparent bg-warning/10 text-warning-foreground focus-visible:ring-warning/20 dark:bg-warning/20 dark:focus-visible:ring-warning/40 [a]:hover:bg-warning/20 dark:[a]:hover:bg-warning/30',\n      },\n    },\n    defaultVariants: {\n      variant: 'default',\n    },\n  },\n)\n\nfunction Badge({\n  className,\n  variant,\n  render,\n  children,\n  ...props\n}: Omit<PartProps<'span'>, 'className' | 'children'> & {\n  className?: string\n  children?: ReactNode\n} & VariantProps<typeof badgeVariants>) {\n  return renderElement(\n    'span',\n    mergeProps(\n      {\n        'data-slot': 'badge',\n        'data-variant': variant ?? 'default',\n        className: cn(badgeVariants({ variant }), className),\n        children: <Label>{children}</Label>,\n      },\n      props,\n    ),\n    render,\n  )\n}\n\n/** A label of words or a number crossfades to the next one, and the badge glides to its width. */\nfunction Label({ children }: { children: ReactNode }) {\n  const parts = flattenChildren(children)\n  if (\n    parts.length > 0 &&\n    parts.every((part) => typeof part === 'string' || typeof part === 'number')\n  )\n    return <SwapText text={parts.join('')} />\n  return children\n}\n\nexport { Badge, badgeVariants }\n",
      "type": "registry:component",
      "target": "@components/kino/badge.tsx"
    }
  ],
  "type": "registry:component"
}