{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "control-segmented",
  "title": "Control segmented",
  "description": "2–4 short choices in a panel row · a radio group, arrows move",
  "dependencies": [
    "cn@^0.5.2"
  ],
  "registryDependencies": [
    "@halftone-web/kit-setup"
  ],
  "files": [
    {
      "path": "components/controls/segmented.tsx",
      "content": "'use client';\nimport { cn } from 'cn';\nimport * as React from 'react';\n\nexport type SegmentedOption<T extends string = string> = { value: T; label: string; title?: string };\n\n/**\n * Two to four short, mutually exclusive choices in a panel row: a radio group with a neutral thumb (selected reads by\n * its raised fill, weight and shadow, never a brand colour). Arrows move and choose, as a radio group does. Longer\n * lists are a ControlSelect.\n */\nexport function ControlSegmented<T extends string>({\n  label,\n  value,\n  options,\n  onChange,\n  className,\n}: {\n  /** Names the group for screen readers. */\n  label: string;\n  value: T;\n  options: readonly SegmentedOption<T>[];\n  onChange: (value: T) => void;\n  className?: string;\n}) {\n  const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n  const at = options.findIndex((o) => o.value === value);\n  const move = (from: number, by: number) => {\n    const i = (from + by + options.length) % options.length;\n    onChange(options[i].value);\n    refs.current[i]?.focus();\n  };\n  return (\n    <div role=\"radiogroup\" aria-label={label} className={cn('bg-muted flex min-w-0 gap-0.5 rounded-md p-0.5', className)}>\n      {options.map((o, i) => {\n        const selected = o.value === value;\n        return (\n          <button\n            key={o.value}\n            ref={(el) => {\n              refs.current[i] = el;\n            }}\n            type=\"button\"\n            role=\"radio\"\n            aria-checked={selected}\n            title={o.title}\n            tabIndex={selected || (at < 0 && i === 0) ? 0 : -1}\n            onClick={() => onChange(o.value)}\n            onKeyDown={(e) => {\n              if (e.key === 'ArrowRight' || e.key === 'ArrowDown') {\n                e.preventDefault();\n                move(i, 1);\n              } else if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') {\n                e.preventDefault();\n                move(i, -1);\n              }\n            }}\n            className={cn(\n              'focus-visible:ring-ring/50 h-6 min-w-0 flex-1 truncate rounded px-2 text-xs whitespace-nowrap outline-none focus-visible:ring-[3px]',\n              selected ? 'bg-card text-foreground font-semibold shadow-sm' : 'text-muted-foreground hover:text-foreground font-medium'\n            )}>\n            {o.label}\n          </button>\n        );\n      })}\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/controls/segmented.tsx"
    }
  ],
  "meta": {
    "exports": [
      "ControlSegmented"
    ],
    "api": "<ControlSegmented label value options={[{value,label}]} onChange />"
  },
  "categories": [
    "controls"
  ],
  "type": "registry:component"
}