{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "gradient", "type": "registry:ui", "title": "Gradient", "description": "Linear gradient container (expo-linear-gradient with fallback).", "registryDependencies": [ "https://raw.githubusercontent.com/truongnat/rnui/main/registry/dist/nativewind/utils.json" ], "files": [ { "path": "registry/shared/ui/gradient.tsx", "type": "registry:ui", "target": "components/ui/gradient.tsx", "content": "import type { ComponentType, ReactNode } from 'react';\nimport { View, type ViewProps } from 'react-native';\nimport { cn } from '@/lib/utils';\n\n// Optional peer: expo-linear-gradient enables real gradients. Without it,\n// Gradient renders a solid background using the first color.\n// Expo: npx expo install expo-linear-gradient\nlet ExpoLinearGradient: ComponentType> | null = null;\ntry {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n ExpoLinearGradient = require('expo-linear-gradient').LinearGradient;\n} catch {\n // expo-linear-gradient not installed — solid fallback below\n}\n\nexport interface GradientProps extends ViewProps {\n /** Color stops. Requires at least 2 for a real gradient. */\n colors?: readonly string[];\n /** Start point {x, y} — 0–1 range. Default {x:0, y:0}. */\n start?: { x: number; y: number };\n /** End point {x, y} — 0–1 range. Default {x:1, y:1}. */\n end?: { x: number; y: number };\n /** Color stop positions (0–1), same length as `colors`. expo-linear-gradient only. */\n locations?: readonly number[];\n className?: string;\n children?: ReactNode;\n}\n\nconst DEFAULT_COLORS = ['#18181b', '#71717a'] as const;\n\n/**\n * Linear gradient container. Uses `expo-linear-gradient` when installed and\n * falls back to a solid background (first color) otherwise.\n */\nexport function Gradient({\n colors = DEFAULT_COLORS,\n start = { x: 0, y: 0 },\n end = { x: 1, y: 1 },\n locations,\n className,\n style,\n children,\n ...props\n}: GradientProps) {\n if (ExpoLinearGradient && colors.length >= 2) {\n const LinearGradient = ExpoLinearGradient;\n return (\n \n {children}\n \n );\n }\n\n return (\n \n {children}\n \n );\n}\n" } ] }