# @masumdev/rn-ui — AI Developer & Context Guide > Production-ready, typed, flat-aesthetic React Native & Expo component library. > Version: 0.4.2 | 61 Components | Monorepo: Masum Dev This document is optimized for LLMs and AI coding assistants writing React Native / Expo applications using `@masumdev/rn-ui`. --- ## 🏛️ Core Design Philosophy & Architectural Rules 1. **Flat Aesthetic (Zero Elevation Default)**: - Components use clean borders, subtle tonal tinting, and translucent surfaces instead of drop shadows or heavy skeuomorphic elevations. - Avoid adding random shadow styles unless explicitly instructed. 2. **Strict Orthogonal `tone` vs `variant`**: - **`tone` (Semantic Intent)**: `"default"` | `"primary"` | `"secondary"` | `"accent"` | `"success"` | `"warning"` | `"danger"` | `"info"`. - **`variant` (Visual Treatment)**: `"filled"` | `"outline"` | `"ghost"` | `"soft"`. - ⚠️ **CRITICAL GOTCHA**: - Do **NOT** use `variant="solid"` (use `"filled"`). - Do **NOT** use `tone="neutral"` (use `"default"`). 3. **Zero-Bounce Animation Policy**: - All Reanimated transitions MUST use linear or cubic easing (e.g., `Easing.bezier(0.25, 0.1, 0.25, 1)` or `withTiming` duration 150–250ms). - Spring overshoots and bounces are strictly disallowed. 4. **Zero Dependency on `@gorhom/bottom-sheet`**: - In `v0.4.0+`, `BottomSheet`, `Sheet`, and `Tabs` have been completely removed. - For bottom sheets / modals, use React Native's native `` or ``. - For tab switching, use ``. 5. **Pluggable Iconography (`renderIcon`)**: - Icons are not hardcoded to any icon library. - When passing icons (e.g. from `lucide-react-native`), use the `renderIcon` helper or standard render prop: `({ color, size }) => `. - ⚠️ Never pass a Lucide icon component directly as raw JSX children (e.g. ``), as it causes React child object errors. --- ## 📦 Installation & Setup ### Required Peer Dependencies ```bash # Expo npx expo install react-native-reanimated react-native-worklets react-native-gesture-handler react-native-safe-area-context bun add @masumdev/rn-ui # React Native CLI bun add @masumdev/rn-ui react-native-reanimated react-native-worklets react-native-gesture-handler react-native-safe-area-context ``` ### App Root Configuration (`app/_layout.tsx` / `App.tsx`) Always wrap the application root with `GestureHandlerRootView`, `ThemeProvider`, and `ToastProvider`: ```tsx import React from 'react'; import { Stack } from 'expo-router'; import { GestureHandlerRootView } from 'react-native-gesture-handler'; import * as SecureStore from 'expo-secure-store'; import { ThemeProvider, ToastProvider, defaultThemes, type ThemeStorage, } from '@masumdev/rn-ui'; // Optional: Persistent theme storage via SecureStore or AsyncStorage const themeStorage: ThemeStorage = { getItem: (key: string) => SecureStore.getItemAsync(key), setItem: (key: string, value: string) => SecureStore.setItemAsync(key, value), }; export default function RootLayout() { return ( ); } ``` --- ## 🎨 Theme Engine & Design Tokens Access theme colors, spacing, typography, and color schemes via `useTheme()`: ```tsx import React from 'react'; import { View, StyleSheet } from 'react-native'; import { useTheme, useThemeStyles, Text } from '@masumdev/rn-ui'; export function ThemedCard() { const { colors, radii, spacing, typography, isDark, setColorScheme } = useTheme(); // Or use memoized theme styles factory: const styles = useThemeStyles((theme) => ({ card: { backgroundColor: theme.colors.surface, borderColor: theme.colors.border, borderWidth: 1, borderRadius: theme.radii.xl, padding: theme.spacing.lg, gap: theme.spacing.sm, }, })); return ( Themed Surface Current mode: {isDark ? 'Dark' : 'Light'} ); } ``` ### Token Palette Reference - **Colors**: `primary`, `primarySoft`, `secondary`, `accent`, `success`, `warning`, `danger`, `info`, `background`, `backgroundMuted`, `surface`, `surfaceMuted`, `surfaceRaised`, `border`, `borderMuted`, `text`, `textMuted`, `textSubtle`, `textInverse`. - **Spacing**: `none` (0), `xxs` (2), `xs` (4), `sm` (8), `md` (12), `lg` (16), `xl` (24), `xxl` (32), `xxxl` (40). - **Radii**: `none` (0), `xs` (4), `sm` (6), `md` (8), `lg` (12), `xl` (16), `xxl` (24), `full` (9999). - **Typography Variants**: `display`, `h1`, `h2`, `h3`, `title`, `subtitle`, `body`, `bodySmall`, `label`, `labelSmall`, `caption`. --- ## 🛠️ Real Native Production Recipes ### 1. Interactive Buttons with Lucide Icons ```tsx import React from 'react'; import { View } from 'react-native'; import { Button, IconButton, ButtonGroup } from '@masumdev/rn-ui'; import { ArrowRight, Trash2, Send } from 'lucide-react-native'; export function ButtonExamples() { const [loading, setLoading] = React.useState(false); return ( {/* Standard Filled Button with Right Icon */} {/* Danger Outline with Left Icon */} {/* Standalone Icon Button */} } tone="primary" variant="soft" size="md" accessibilityLabel="Send message" onPress={() => console.log('Sent')} /> ); } ``` ### 2. Comprehensive Form Validation Recipe ```tsx import React, { useState } from 'react'; import { View } from 'react-native'; import { FormField, Label, Input, InputGroup, Select, Checkbox, Switch, Button, } from '@masumdev/rn-ui'; import { Mail } from 'lucide-react-native'; export function LoginForm() { const [email, setEmail] = useState(''); const [role, setRole] = useState('developer'); const [remember, setRemember] = useState(true); const [notifications, setNotifications] = useState(false); const [emailError, setEmailError] = useState(); const handleSubmit = () => { if (!email.includes('@')) { setEmailError('Please enter a valid email address'); return; } setEmailError(undefined); console.log({ email, role, remember, notifications }); }; return ( {/* Input inside FormField with error helper */} } > { setEmail(text); if (emailError) setEmailError(undefined); }} placeholder="you@example.com" keyboardType="email-address" autoCapitalize="none" /> {/* Dropdown Select */}