{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "toggle", "type": "registry:ui", "title": "Toggle", "description": "Two-state pressable.", "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" ], "dependencies": [ "tailwind-variants" ], "files": [ { "path": "registry/shared/ui/toggle.tsx", "type": "registry:ui", "target": "components/ui/toggle.tsx", "content": "import { Pressable, type PressableProps } from 'react-native';\nimport { tv } from 'tailwind-variants';\nimport { Text } from '@/components/ui/text';\nimport { cn, useThemeColor } from '@/lib/utils';\n\nconst toggleVariants = tv({\n base: 'flex-row items-center justify-center gap-2 rounded-md active:bg-accent',\n variants: {\n variant: {\n default: 'bg-transparent',\n outline: 'border border-input bg-transparent',\n },\n size: {\n default: 'h-10 px-3',\n sm: 'h-9 px-2.5',\n lg: 'h-11 px-5',\n },\n },\n defaultVariants: { variant: 'default', size: 'default' },\n});\n\nexport interface ToggleProps extends PressableProps {\n pressed?: boolean;\n onPressedChange?: (pressed: boolean) => void;\n variant?: 'default' | 'outline';\n size?: 'default' | 'sm' | 'lg';\n className?: string;\n}\n\nexport function Toggle({\n pressed = false,\n onPressedChange,\n variant = 'default',\n size = 'default',\n className,\n disabled,\n style,\n ...props\n}: ToggleProps) {\n const colors = useThemeColor();\n return (\n onPressedChange?.(!pressed)}\n className={cn(\n toggleVariants({ variant, size }),\n disabled && 'opacity-50',\n className\n )}\n style={(state) => [\n { borderCurve: 'continuous' },\n // pressed bg via style prop — toggling var-classes dynamically\n // triggers a css-interop upgrade warning (OOM risk).\n pressed && { backgroundColor: colors.accent },\n typeof style === 'function' ? style(state) : style,\n ]}\n {...props}\n >\n {typeof props.children === 'string' ? (\n \n {props.children}\n \n ) : (\n props.children\n )}\n \n );\n}\n" } ] }