{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "segmented-control",
  "title": "Segmented Control",
  "type": "registry:ui",
  "files": [
    {
      "path": "packages/registry-native/components/segmented-control/SegmentedControl.tsx",
      "content": "import * as React from 'react'\nimport { View, type ViewProps } from 'react-native'\nimport * as ToggleGroupPrimitive from '@rn-primitives/toggle-group'\nimport { cssInterop } from 'react-native-css-interop'\nimport { renderTextChildren } from '@/lib/label-children'\nimport { cn } from '@/lib/utils'\n\ncssInterop(ToggleGroupPrimitive.Root, { className: 'style' })\ncssInterop(ToggleGroupPrimitive.Item, { className: 'style' })\n\nconst SegmentedContext = React.createContext<{ value: string | undefined; disabled: boolean } | null>(null)\n\nexport interface SegmentedControlProps extends ViewProps {\n  className?: string\n  value?: string\n  defaultValue?: string\n  onValueChange?: (value: string) => void\n  disabled?: boolean\n}\n\nexport const SegmentedControl = React.forwardRef<React.ComponentRef<typeof View>, SegmentedControlProps>(\n  ({ value, defaultValue, onValueChange, disabled = false, className, children, ...props }, ref) => {\n    const [internal, setInternal] = React.useState(defaultValue)\n    const resolved = value ?? internal\n    return (\n      <SegmentedContext.Provider value={{ value: resolved, disabled }}>\n        <ToggleGroupPrimitive.Root\n          ref={ref}\n          {...props}\n          type=\"single\"\n          value={resolved}\n          disabled={disabled}\n          onValueChange={(next) => {\n            if (disabled || next === undefined || next === resolved) return\n            if (value === undefined) setInternal(next)\n            onValueChange?.(next)\n          }}\n          className={cn('flex-row flex-wrap gap-[4px] rounded-lg bg-muted p-[4px]', className)}\n        >\n          {children}\n        </ToggleGroupPrimitive.Root>\n      </SegmentedContext.Provider>\n    )\n  },\n)\nSegmentedControl.displayName = 'SegmentedControl'\n\nexport type SegmentedControlItemProps = Omit<ToggleGroupPrimitive.ItemProps, 'children'> & {\n  children?: React.ReactNode\n  className?: string\n}\n\nexport const SegmentedControlItem = React.forwardRef<ToggleGroupPrimitive.ItemRef, SegmentedControlItemProps>(\n  ({ className, children, disabled, ...props }, ref) => {\n    const group = React.useContext(SegmentedContext)\n    if (!group) throw new Error('SegmentedControlItem must be inside SegmentedControl')\n    const isDisabled = group.disabled || !!disabled\n    return (\n      <ToggleGroupPrimitive.Item\n        ref={ref}\n        {...props}\n        disabled={isDisabled}\n        className={cn(\n          'min-h-[48px] min-w-[80px] max-w-full shrink-0 grow items-center justify-center rounded-md px-3 py-2',\n          group.value === props.value && 'bg-card',\n          isDisabled && 'opacity-50',\n          className,\n        )}\n      >\n        {renderTextChildren(children)}\n      </ToggleGroupPrimitive.Item>\n    )\n  },\n)\nSegmentedControlItem.displayName = 'SegmentedControlItem'\n",
      "type": "registry:ui",
      "target": "~/components/ui/segmented-control/SegmentedControl.tsx"
    },
    {
      "path": "packages/registry-native/components/segmented-control/index.ts",
      "content": "export * from './SegmentedControl'\n",
      "type": "registry:ui",
      "target": "~/components/ui/segmented-control/index.ts"
    }
  ],
  "dependencies": [
    "@rn-primitives/toggle-group",
    "react-native-css-interop"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/label-children.json"
  ],
  "description": "Single-choice segmented control with explicit items, disabled states, and controlled or default selection.",
  "categories": [
    "control"
  ]
}