{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "color-swatches",
  "title": "Color Swatches",
  "description": "Pick one colour from a row of swatches: a radio group with arrow keys and form support.",
  "dependencies": [
    "@radix-ui/react-radio-group"
  ],
  "registryDependencies": [
    "@corsair-ui/utils"
  ],
  "files": [
    {
      "path": "registry/default/ui/color-swatches.tsx",
      "content": "\"use client\";\n\nimport * as RadioGroupPrimitive from \"@radix-ui/react-radio-group\";\nimport type { ComponentProps, CSSProperties } from \"react\";\n\nimport { cn } from \"@/registry/default/lib/utils\";\n\ninterface ColorSwatch {\n  /** What the group reports and submits. */\n  value: string;\n  /** Any CSS colour; defaults to `value`. Theme variables work. */\n  color?: string;\n  /** Accessible name; defaults to `value`. */\n  label?: string;\n  disabled?: boolean;\n}\n\nconst SIZES = { sm: \"size-5\", default: \"size-6\", lg: \"size-8\" };\n\ninterface ColorSwatchesProps extends Omit<\n  ComponentProps<typeof RadioGroupPrimitive.Root>,\n  \"children\"\n> {\n  /** CSS colours, or swatches with their own value, label and colour. */\n  colors: (string | ColorSwatch)[];\n  size?: keyof typeof SIZES;\n}\n\n/**\n * Picks one colour from a row of swatches. It is a radio group underneath:\n * arrow keys move between swatches, `name` submits the value with a native\n * form, and `value` / `onValueChange` work inside FormField. Give the group\n * an accessible name with `aria-label` or a FieldLegend.\n *\n * @example\n * <ColorSwatches\n *   aria-label=\"Sail colour\"\n *   defaultValue=\"brass\"\n *   colors={[\n *     { value: \"brass\", color: \"#d9b06a\" },\n *     { value: \"sea\", color: \"#6fb3c2\" },\n *   ]}\n * />\n */\nfunction ColorSwatches({ colors, size = \"default\", className, ...props }: ColorSwatchesProps) {\n  return (\n    <RadioGroupPrimitive.Root\n      data-slot=\"color-swatches\"\n      orientation=\"horizontal\"\n      className={cn(\"flex flex-wrap items-center gap-2.5\", className)}\n      {...props}\n    >\n      {colors.map((entry) => {\n        const swatch = typeof entry === \"string\" ? { value: entry } : entry;\n        const color = swatch.color ?? swatch.value;\n        return (\n          <RadioGroupPrimitive.Item\n            key={swatch.value}\n            value={swatch.value}\n            disabled={swatch.disabled}\n            aria-label={swatch.label ?? swatch.value}\n            data-slot=\"color-swatch\"\n            className={cn(\n              \"relative shrink-0 cursor-pointer rounded-full bg-[color:var(--swatch)] outline-none\",\n              // A hairline inside the edge keeps pale swatches visible on pale backgrounds.\n              \"shadow-[inset_0_0_0_1px_rgb(0_0_0/0.12)]\",\n              \"transition-[transform,box-shadow] duration-200 ease-out active:scale-90 motion-reduce:transition-none\",\n              // The picked swatch gets a ring in its own colour, with a gap of page colour.\n              \"data-[state=checked]:shadow-[0_0_0_2px_var(--background),0_0_0_4px_var(--swatch)]\",\n              // Focus sits outside that ring rather than on top of it.\n              \"focus-visible:[outline:2px_solid_var(--ring)] focus-visible:[outline-offset:6px]\",\n              \"disabled:cursor-not-allowed disabled:opacity-40\",\n              SIZES[size]\n            )}\n            style={{ \"--swatch\": color } as CSSProperties}\n          />\n        );\n      })}\n    </RadioGroupPrimitive.Root>\n  );\n}\n\nexport { ColorSwatches, type ColorSwatch, type ColorSwatchesProps };\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}