{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "radio-group", "type": "registry:ui", "title": "Radio Group", "description": "Context-based radio group + item.", "registryDependencies": [ "https://raw.githubusercontent.com/truongnat/rnui/main/registry/dist/nativewind/utils.json", "https://raw.githubusercontent.com/truongnat/rnui/main/registry/dist/nativewind/theme.json" ], "files": [ { "path": "registry/shared/ui/radio-group.tsx", "type": "registry:ui", "target": "components/ui/radio-group.tsx", "content": "import { createContext, useContext } from 'react';\nimport {\n Pressable,\n View,\n type PressableProps,\n type ViewProps,\n} from 'react-native';\nimport { cn, FormFieldContext, useThemeColor } from '@/lib/utils';\n\ninterface RadioGroupContextValue {\n value: string;\n onValueChange?: (value: string) => void;\n}\n\nconst RadioGroupContext = createContext({\n value: '',\n});\n\nexport interface RadioGroupProps extends ViewProps {\n value?: string;\n onValueChange?: (value: string) => void;\n className?: string;\n}\n\nexport function RadioGroup({\n value = '',\n onValueChange,\n className,\n ...props\n}: RadioGroupProps) {\n return (\n \n \n \n );\n}\n\nexport interface RadioGroupItemProps extends Omit {\n value: string;\n /** Mirrors shadcn `aria-invalid` — destructive border. Auto-detected from FormField error. */\n invalid?: boolean;\n className?: string;\n}\n\nexport function RadioGroupItem({\n value,\n invalid,\n className,\n disabled,\n style,\n ...props\n}: RadioGroupItemProps) {\n const group = useContext(RadioGroupContext);\n const field = useContext(FormFieldContext);\n const colors = useThemeColor();\n const checked = group.value === value;\n const isInvalid = invalid ?? !!field?.error;\n\n return (\n group.onValueChange?.(value)}\n className={cn(\n 'h-5 w-5 items-center justify-center rounded-full border border-input bg-background dark:bg-input/30',\n disabled && 'opacity-50',\n className\n )}\n style={(state) => [\n { borderCurve: 'continuous' },\n isInvalid && { borderColor: colors.destructive },\n typeof style === 'function' ? style(state) : style,\n ]}\n {...props}\n >\n {checked && }\n \n );\n}\n" } ] }