{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "alert", "type": "registry:ui", "title": "Alert", "description": "Inline alert with icon, title, description.", "registryDependencies": [ "https://raw.githubusercontent.com/truongnat/rnui/main/registry/dist/nativewind/utils.json", "https://raw.githubusercontent.com/truongnat/rnui/main/registry/dist/nativewind/text.json", "https://raw.githubusercontent.com/truongnat/rnui/main/registry/dist/nativewind/theme.json" ], "dependencies": [ "lucide-react-native" ], "files": [ { "path": "registry/shared/ui/alert.tsx", "type": "registry:ui", "target": "components/ui/alert.tsx", "content": "import {\n createContext,\n useContext,\n type ReactNode,\n} from 'react';\nimport { StyleSheet, View, type ViewProps, type ViewStyle } from 'react-native';\nimport { AlertCircle, Info } from 'lucide-react-native';\nimport { Text, type TextProps } from '@/components/ui/text';\nimport { cn, useThemeColor } from '@/lib/utils';\n\nexport type AlertVariant = 'default' | 'destructive';\n\nconst AlertContext = createContext<{ variant: AlertVariant }>({\n variant: 'default',\n});\n\nexport interface AlertProps extends ViewProps {\n variant?: AlertVariant;\n /** Custom icon component or node to replace the default icon. */\n icon?: ReactNode;\n /** Hide the leading status icon completely. */\n hideIcon?: boolean;\n className?: string;\n children?: ReactNode;\n}\n\n/**\n * Standard shadcn/ui Alert banner with solid surface background,\n * sharp high-contrast typography, and clean borders.\n */\nexport function Alert({\n variant = 'default',\n icon,\n hideIcon = false,\n className,\n style,\n children,\n ...props\n}: AlertProps) {\n const colors = useThemeColor();\n const isDestructive = variant === 'destructive';\n\n const dynamicStyle: ViewStyle = {\n backgroundColor: colors.card,\n borderColor: isDestructive ? colors.destructive : colors.border,\n borderWidth: 1,\n borderCurve: 'continuous',\n };\n\n const defaultIconColor = isDestructive\n ? colors.destructive\n : colors.foreground;\n const DefaultIcon = isDestructive ? AlertCircle : Info;\n\n return (\n \n \n {!hideIcon && (\n \n {icon ?? }\n \n )}\n {children}\n \n \n );\n}\n\nexport function AlertTitle({ className, style, ...props }: TextProps) {\n const { variant } = useContext(AlertContext);\n const colors = useThemeColor();\n const isDestructive = variant === 'destructive';\n\n return (\n \n );\n}\n\nexport function AlertDescription({ className, style, ...props }: TextProps) {\n const { variant } = useContext(AlertContext);\n const colors = useThemeColor();\n const isDestructive = variant === 'destructive';\n\n return (\n \n );\n}\n\nconst styles = StyleSheet.create({\n baseAlert: {\n width: '100%',\n },\n iconWell: {\n marginTop: 1,\n alignItems: 'center',\n justifyContent: 'center',\n },\n contentStack: {\n flex: 1,\n gap: 2,\n },\n});\n" } ] }