{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tag",
  "title": "Tag",
  "description": "A compact label tag with soft, solid and outline variants, 6 colors, 3 sizes, an optional pulsing dot, icon, count, selectable toggle state and an animated remove button.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/tag/tag.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence } from \"motion/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 TagColor = \"neutral\" | \"amber\" | \"mint\" | \"coral\" | \"blue\" | \"lavender\";\nexport type TagVariant = \"soft\" | \"solid\" | \"outline\";\nexport type TagSize = \"sm\" | \"md\" | \"lg\";\n\nexport interface TagProps {\n  children?: React.ReactNode;\n  variant?: TagVariant;\n  color?: TagColor;\n  size?: TagSize;\n  theme?: \"dark\" | \"light\";\n  dot?: boolean;\n  pulse?: boolean;\n  icon?: React.ReactNode;\n  count?: number;\n  selected?: boolean;\n  defaultSelected?: boolean;\n  onSelectedChange?: (selected: boolean) => void;\n  removable?: boolean;\n  onRemove?: () => void;\n  disabled?: boolean;\n  radius?: number;\n  className?: string;\n}\n\nconst COLORS: Record<\"dark\" | \"light\", Record<TagColor, string>> = {\n  dark: { neutral: \"#F5F4F1\", amber: \"#F2A841\", mint: \"#87FFE3\", coral: \"#FF7A6B\", blue: \"#8FB8FF\", lavender: \"#B8A6FF\" },\n  light: { neutral: \"#0A0A0A\", amber: \"#D9822B\", mint: \"#0E9F80\", coral: \"#E5484D\", blue: \"#3B6FD8\", lavender: \"#7C5CE0\" },\n};\n\nconst SIZES: Record<TagSize, { height: number; padX: number; font: number; gap: number; icon: number }> = {\n  sm: { height: 22, padX: 8, font: 11.5, gap: 5, icon: 11 },\n  md: { height: 28, padX: 11, font: 13, gap: 6, icon: 13 },\n  lg: { height: 34, padX: 14, font: 14.5, gap: 8, icon: 15 },\n};\n\nfunction readableTextOn(hex: string): string {\n  const h = hex.replace(\"#\", \"\");\n  const full = h.length === 3 ? h.split(\"\").map((c) => c + c).join(\"\") : h;\n  const r = parseInt(full.slice(0, 2), 16);\n  const g = parseInt(full.slice(2, 4), 16);\n  const b = parseInt(full.slice(4, 6), 16);\n  return 0.299 * r + 0.587 * g + 0.114 * b > 150 ? \"#0A0A0A\" : \"#FFFFFF\";\n}\n\nexport function Tag({\n  children,\n  variant = \"soft\",\n  color = \"amber\",\n  size = \"md\",\n  theme = \"dark\",\n  dot = false,\n  pulse = false,\n  icon,\n  count,\n  selected,\n  defaultSelected = false,\n  onSelectedChange,\n  removable = false,\n  onRemove,\n  disabled = false,\n  radius = 999,\n  className,\n}: TagProps) {\n  const s = SIZES[size];\n  const accent = COLORS[theme][color];\n  const isNeutral = color === \"neutral\";\n  const [internalSelected, setInternalSelected] = React.useState(defaultSelected);\n  const [hidden, setHidden] = React.useState(false);\n  const interactive = selected !== undefined || onSelectedChange !== undefined;\n  const isSelected = selected !== undefined ? selected : internalSelected;\n\n  const asSolid = variant === \"solid\" || (interactive && isSelected);\n  const background = asSolid ? accent : variant === \"outline\" ? \"transparent\" : isNeutral ? (theme === \"dark\" ? \"rgba(255,255,255,0.08)\" : \"rgba(10,10,10,0.06)\") : `color-mix(in srgb, ${accent} 14%, transparent)`;\n  const textColor = asSolid ? readableTextOn(accent) : accent;\n  const borderColor = asSolid ? accent : variant === \"outline\" ? `color-mix(in srgb, ${accent} ${isNeutral ? 32 : 45}%, transparent)` : `color-mix(in srgb, ${accent} ${isNeutral ? 12 : 22}%, transparent)`;\n\n  const toggle = () => {\n    if (disabled || !interactive) return;\n    const next = !isSelected;\n    if (selected === undefined) setInternalSelected(next);\n    onSelectedChange?.(next);\n  };\n\n  const handleRemove = (e: React.MouseEvent) => {\n    e.stopPropagation();\n    if (disabled) return;\n    setHidden(true);\n    onRemove?.();\n  };\n\n  return (\n    <AnimatePresence>\n      {!hidden && (\n        <motion.span\n          layout\n          role={interactive ? \"button\" : undefined}\n          aria-pressed={interactive ? isSelected : undefined}\n          aria-disabled={disabled || undefined}\n          tabIndex={interactive && !disabled ? 0 : undefined}\n          onClick={toggle}\n          onKeyDown={(e) => {\n            if (interactive && (e.key === \"Enter\" || e.key === \" \")) {\n              e.preventDefault();\n              toggle();\n            }\n          }}\n          className={cn(\"inline-flex items-center whitespace-nowrap font-semibold tracking-[-0.005em] outline-none select-none\", interactive && !disabled && \"cursor-pointer\", className)}\n          style={{\n            height: s.height,\n            gap: s.gap,\n            padding: `0 ${s.padX}px`,\n            fontSize: s.font,\n            fontFamily: \"Inter, sans-serif\",\n            borderRadius: radius,\n            background,\n            color: textColor,\n            border: `1px solid ${borderColor}`,\n            opacity: disabled ? 0.45 : 1,\n            transition: \"background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease\",\n          }}\n          initial={{ opacity: 0, scale: 0.85 }}\n          animate={{ opacity: disabled ? 0.45 : 1, scale: 1 }}\n          exit={{ opacity: 0, scale: 0.8 }}\n          whileTap={interactive && !disabled ? { scale: 0.94 } : undefined}\n          transition={{ type: \"spring\", stiffness: 420, damping: 28 }}\n        >\n          {dot && (\n            <span className=\"relative flex shrink-0\" style={{ width: s.icon * 0.55, height: s.icon * 0.55 }}>\n              {pulse && (\n                <motion.span className=\"absolute inset-0 rounded-full\" style={{ background: textColor }} animate={{ scale: [1, 2.4], opacity: [0.5, 0] }} transition={{ duration: 1.4, ease: \"easeOut\", repeat: Infinity }} />\n              )}\n              <span className=\"relative rounded-full\" style={{ width: \"100%\", height: \"100%\", background: textColor }} />\n            </span>\n          )}\n          {icon && (\n            <span className=\"flex shrink-0 items-center justify-center\" style={{ width: s.icon, height: s.icon }}>\n              {icon}\n            </span>\n          )}\n          {children}\n          {count !== undefined && (\n            <span className=\"rounded-full font-bold tabular-nums\" style={{ padding: \"0 5px\", minWidth: s.icon * 1.25, textAlign: \"center\", fontSize: s.font * 0.85, lineHeight: `${s.icon * 1.25}px`, background: asSolid ? \"rgba(0,0,0,0.14)\" : `color-mix(in srgb, ${accent} 20%, transparent)` }}>\n              {count}\n            </span>\n          )}\n          {removable && (\n            <button\n              type=\"button\"\n              aria-label=\"Remove\"\n              onClick={handleRemove}\n              disabled={disabled}\n              className=\"-mr-1 flex shrink-0 cursor-pointer items-center justify-center rounded-full border-none bg-transparent p-0 opacity-70 transition-opacity hover:opacity-100\"\n              style={{ width: s.icon + 2, height: s.icon + 2, color: textColor }}\n            >\n              <svg width={s.icon * 0.7} height={s.icon * 0.7} viewBox=\"0 0 12 12\" fill=\"none\" aria-hidden=\"true\">\n                <path d=\"M3 3L9 9M9 3L3 9\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" />\n              </svg>\n            </button>\n          )}\n        </motion.span>\n      )}\n    </AnimatePresence>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}