{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "badges-kit",
  "title": "Badges Kit",
  "description": "A status badge with 8 tone presets, light/dark variants, 3 sizes, 6 icon styles (check, cross, minus, dot, spinner, custom), and an optional dismiss button.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/badges-kit/badges-kit.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion } from \"motion/react\";\nimport { X } from \"lucide-react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport type BadgeTone = \"neutral\" | \"success\" | \"error\" | \"warning\" | \"info\" | \"purple\" | \"orange\" | \"indigo\" | \"custom\";\ntype BadgePaletteTone = Exclude<BadgeTone, \"custom\">;\nexport type BadgeIconType = \"none\" | \"check\" | \"cross\" | \"minus\" | \"dot\" | \"spinner\" | \"custom\";\nexport type BadgeSize = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\";\nexport type BadgeTheme = \"light\" | \"dark\";\n\ninterface ColorSet {\n  bg: string;\n  text: string;\n  border: string;\n}\n\nexport interface BadgeProps {\n  label: string;\n  icon?: BadgeIconType;\n  customIcon?: React.ReactNode;\n  tone?: BadgeTone;\n  /** Used when `tone=\"custom\"`; falls back to the neutral palette if omitted. */\n  customColors?: ColorSet;\n  size?: BadgeSize;\n  theme?: BadgeTheme;\n  fontFamily?: string;\n  fontWeight?: number | string;\n  closable?: boolean;\n  onClose?: () => void;\n  className?: string;\n}\n\nconst TONE_PALETTES: Record<BadgePaletteTone, { light: ColorSet; dark: ColorSet }> = {\n  neutral: { light: { bg: \"#F4F4F5\", text: \"#52525B\", border: \"#E4E4E7\" }, dark: { bg: \"#27272A\", text: \"#D4D4D8\", border: \"#3F3F46\" } },\n  success: { light: { bg: \"#EAFBF0\", text: \"#16A34A\", border: \"#D1F4DF\" }, dark: { bg: \"#0F2A1C\", text: \"#6EE7B7\", border: \"#1C4A30\" } },\n  error: { light: { bg: \"#FDF1F4\", text: \"#D6336C\", border: \"#FBD9E3\" }, dark: { bg: \"#321019\", text: \"#FB91B5\", border: \"#56202E\" } },\n  warning: { light: { bg: \"#FFF9E6\", text: \"#B45309\", border: \"#FCEFC7\" }, dark: { bg: \"#2E2410\", text: \"#FCD34D\", border: \"#4D3D14\" } },\n  info: { light: { bg: \"#EFF6FF\", text: \"#2563EB\", border: \"#DBEAFE\" }, dark: { bg: \"#0E1F36\", text: \"#93C5FD\", border: \"#1E3A5F\" } },\n  purple: { light: { bg: \"#FAF5FF\", text: \"#9333EA\", border: \"#F3E8FF\" }, dark: { bg: \"#271A38\", text: \"#D8B4FE\", border: \"#3E2A57\" } },\n  orange: { light: { bg: \"#FFF4ED\", text: \"#C2410C\", border: \"#FFE4D5\" }, dark: { bg: \"#2E1A0E\", text: \"#FDBA86\", border: \"#4A2A15\" } },\n  indigo: { light: { bg: \"#EEF1FF\", text: \"#4338CA\", border: \"#E0E4FF\" }, dark: { bg: \"#1A1F3A\", text: \"#A5B4FC\", border: \"#2E335C\" } },\n};\n\nconst SIZE_PRESETS: Record<BadgeSize, { height: number; fontSize: number; paddingX: number; iconSize: number; gap: number }> = {\n  sm: { height: 22, fontSize: 11, paddingX: 9, iconSize: 11, gap: 4 },\n  md: { height: 27, fontSize: 12.5, paddingX: 11, iconSize: 12.5, gap: 5 },\n  lg: { height: 33, fontSize: 14, paddingX: 14, iconSize: 14, gap: 6 },\n  xl: { height: 46, fontSize: 19, paddingX: 20, iconSize: 19, gap: 8 },\n  \"2xl\": { height: 62, fontSize: 26, paddingX: 28, iconSize: 26, gap: 11 },\n};\n\nconst ICON_PATHS: Record<\"check\" | \"cross\" | \"minus\", string> = {\n  check: \"M3 8.3L6.3 11.6L13 4.3\",\n  cross: \"M4 4L12 12M12 4L4 12\",\n  minus: \"M3.5 8H12.5\",\n};\n\nfunction usePrefersReducedMotion() {\n  const [reduced, setReduced] = React.useState(false);\n\n  React.useEffect(() => {\n    const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n    setReduced(query.matches);\n    const handler = (e: MediaQueryListEvent) => setReduced(e.matches);\n    query.addEventListener(\"change\", handler);\n    return () => query.removeEventListener(\"change\", handler);\n  }, []);\n\n  return reduced;\n}\n\nfunction SpinnerIcon({ size, color }: { size: number; color: string }) {\n  const r = size * 0.4;\n  const c = 2 * Math.PI * r;\n  const dash = c * 0.28;\n  const reducedMotion = usePrefersReducedMotion();\n  return (\n    <motion.svg\n      width={size}\n      height={size}\n      viewBox={`0 0 ${size} ${size}`}\n      className=\"shrink-0\"\n      animate={reducedMotion ? { rotate: 0 } : { rotate: 360 }}\n      transition={reducedMotion ? { duration: 0 } : { duration: 0.85, repeat: Infinity, ease: \"linear\" }}\n    >\n      <circle cx={size / 2} cy={size / 2} r={r} fill=\"none\" stroke={color} strokeWidth={1.6} strokeOpacity={0.25} />\n      <circle cx={size / 2} cy={size / 2} r={r} fill=\"none\" stroke={color} strokeWidth={1.6} strokeLinecap=\"round\" strokeDasharray={`${dash} ${c - dash}`} />\n    </motion.svg>\n  );\n}\n\nfunction BadgeIcon({ icon, customIcon, size, color }: { icon: BadgeIconType; customIcon?: React.ReactNode; size: number; color: string }) {\n  switch (icon) {\n    case \"none\":\n      return null;\n    case \"dot\":\n      return <span className=\"shrink-0 rounded-full\" style={{ width: size * 0.5, height: size * 0.5, backgroundColor: color }} />;\n    case \"spinner\":\n      return <SpinnerIcon size={size} color={color} />;\n    case \"custom\":\n      return (\n        <span className=\"inline-flex shrink-0 items-center leading-none\" style={{ fontSize: size * 1.1 }}>\n          {customIcon}\n        </span>\n      );\n    default:\n      return (\n        <svg width={size} height={size} viewBox=\"0 0 16 16\" fill=\"none\" className=\"shrink-0\">\n          <path d={ICON_PATHS[icon]} stroke={color} strokeWidth={1.8} strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n        </svg>\n      );\n  }\n}\n\nexport function Badge({\n  label,\n  icon = \"none\",\n  customIcon,\n  tone = \"neutral\",\n  customColors,\n  size = \"md\",\n  theme = \"light\",\n  fontFamily = \"Inter, sans-serif\",\n  fontWeight = 600,\n  closable = false,\n  onClose,\n  className,\n}: BadgeProps) {\n  const [visible, setVisible] = React.useState(true);\n  const [hover, setHover] = React.useState(false);\n  const [focused, setFocused] = React.useState(false);\n  const palette = tone === \"custom\" ? (customColors ?? TONE_PALETTES.neutral[theme]) : TONE_PALETTES[tone][theme];\n  const dims = SIZE_PRESETS[size];\n\n  const dismiss = () => {\n    setVisible(false);\n    onClose?.();\n  };\n\n  return (\n    <AnimatePresence>\n      {visible && (\n        <motion.span\n          initial={{ opacity: 1, scale: 1 }}\n          exit={{ opacity: 0, scale: 0.85 }}\n          transition={{ duration: 0.15, ease: \"easeOut\" }}\n          className={cn(\"inline-flex items-center justify-center whitespace-nowrap rounded-full border leading-none\", className)}\n          style={{\n            gap: dims.gap,\n            height: dims.height,\n            padding: `0 ${dims.paddingX}px`,\n            backgroundColor: palette.bg,\n            borderColor: palette.border,\n            color: palette.text,\n            fontSize: dims.fontSize,\n            fontFamily,\n            fontWeight,\n          }}\n        >\n          <BadgeIcon icon={icon} customIcon={customIcon} size={dims.iconSize} color={palette.text} />\n          {label}\n          {closable && (\n            <button\n              type=\"button\"\n              onClick={(e) => {\n                e.stopPropagation();\n                dismiss();\n              }}\n              onMouseEnter={() => setHover(true)}\n              onMouseLeave={() => setHover(false)}\n              onFocus={() => setFocused(true)}\n              onBlur={() => setFocused(false)}\n              aria-label=\"Dismiss\"\n              className=\"-mr-0.5 inline-flex shrink-0 items-center justify-center rounded-full border-0 p-0 transition-[opacity,background-color,box-shadow] duration-150\"\n              style={{\n                width: dims.iconSize + 8,\n                height: dims.iconSize + 8,\n                opacity: hover || focused ? 1 : 0.55,\n                backgroundColor: hover || focused ? \"rgba(128,128,128,0.18)\" : \"transparent\",\n                boxShadow: focused ? `0 0 0 2px ${palette.text}` : \"none\",\n              }}\n            >\n              <X style={{ width: dims.iconSize * 0.85, height: dims.iconSize * 0.85 }} color={palette.text} />\n            </button>\n          )}\n        </motion.span>\n      )}\n    </AnimatePresence>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}