{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "segmented",
  "title": "Segmented",
  "description": "Ruled buttons for choosing one option from a few.",
  "dependencies": [
    "@base-ui/react"
  ],
  "registryDependencies": [
    "https://spotcheckui.com/r/spotcheck-base.json"
  ],
  "files": [
    {
      "path": "registry/spotcheck/components/spotcheck/segmented.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Toggle } from \"@base-ui/react/toggle\"\nimport { ToggleGroup } from \"@base-ui/react/toggle-group\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype SegmentedProps = {\n  /** Names the group for screen readers. */\n  label: string\n  options: string[]\n  /** The selected option, when you control it. */\n  value?: string\n  /** The starting option, when it manages itself. */\n  defaultValue?: string\n  onValueChange?: (value: string) => void\n  className?: string\n}\n\nexport function Segmented({ label, options, value, defaultValue, onValueChange, className }: SegmentedProps) {\n  const [internal, setInternal] = React.useState(defaultValue ?? options[0] ?? \"\")\n  const current = value ?? internal\n\n  return (\n    <ToggleGroup\n      aria-label={label}\n      value={[current]}\n      onValueChange={(pressed) => {\n        // Pressing the selected option empties the group, but one option must stay selected.\n        const next = pressed[0]\n        if (next === undefined) return\n        setInternal(next)\n        onValueChange?.(next)\n      }}\n      className={cn(\"border-ink inline-flex border-(length:--rule)\", className)}\n    >\n      {options.map((option) => (\n        <Toggle\n          key={option}\n          value={option}\n          className=\"spotcheck-focus border-ink data-pressed:bg-ink data-pressed:text-paper cursor-pointer border-l-(length:--rule) px-2.5 py-1 font-(family-name:--f-mono) text-xs first:border-l-0\"\n        >\n          {option}\n        </Toggle>\n      ))}\n    </ToggleGroup>\n  )\n}\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "core"
  ],
  "type": "registry:component"
}