|
| 1 | +--- |
| 2 | +title: Introduction |
| 3 | +description: Compile-time Tailwind CSS for React Native with zero runtime overhead |
| 4 | +--- |
| 5 | + |
| 6 | +Compile-time Tailwind CSS for React Native with zero runtime overhead. Transform `className` props to optimized `StyleSheet.create()` calls at build time. |
| 7 | + |
| 8 | +## Features |
| 9 | + |
| 10 | +- **⚡ Zero Runtime Overhead** - All transformations happen at compile time |
| 11 | +- **🔧 No Dependencies** - Direct-to-React-Native style generation without tailwindcss package |
| 12 | +- **🎯 Babel-only Setup** - No Metro configuration required |
| 13 | +- **📝 TypeScript-first** - Full type safety and autocomplete support |
| 14 | +- **🚀 Optimized Performance** - Compiles down to StyleSheet.create for optimal performance |
| 15 | +- **📦 Small Bundle Size** - Only includes actual styles used in your app |
| 16 | +- **🎨 Custom Colors** - Extend the default palette via tailwind.config.* |
| 17 | +- **📐 Arbitrary Values** - Use custom sizes and borders: `w-[123px]`, `rounded-[20px]` |
| 18 | +- **🔀 Dynamic className** - Conditional styles with hybrid compile-time optimization |
| 19 | +- **🏃 Runtime Option** - Optional tw template tag for fully dynamic styling (~25KB) |
| 20 | +- **🎯 State Modifiers** - `active:`, `hover:`, `focus:`, and `disabled:` modifiers for interactive components |
| 21 | +- **📱 Platform Modifiers** - `ios:`, `android:`, and `web:` modifiers for platform-specific styling |
| 22 | +- **🌓 Color Scheme Modifiers** - `dark:` and `light:` modifiers for automatic theme adaptation |
| 23 | +- **🎨 Scheme Modifier** - `scheme:` convenience modifier that expands to both dark: and light: variants |
| 24 | +- **📜 Special Style Props** - Support for `contentContainerClassName`, `columnWrapperClassName`, and more |
| 25 | +- **🎛️ Custom Attributes** - Configure which props to transform with exact matching or glob patterns |
| 26 | + |
| 27 | +## Quick Example |
| 28 | + |
| 29 | +```tsx |
| 30 | +import { View, Text } from "react-native"; |
| 31 | + |
| 32 | +export function MyComponent() { |
| 33 | + return ( |
| 34 | + <View className="flex-1 bg-gray-100 p-4"> |
| 35 | + <Text className="text-xl font-bold text-blue-500">Hello, Tailwind!</Text> |
| 36 | + </View> |
| 37 | + ); |
| 38 | +} |
| 39 | +``` |
| 40 | + |
| 41 | +**Transforms to:** |
| 42 | + |
| 43 | +```tsx |
| 44 | +import { StyleSheet } from "react-native"; |
| 45 | + |
| 46 | +export function MyComponent() { |
| 47 | + return ( |
| 48 | + <View style={_twStyles._bg_gray_100_flex_1_p_4}> |
| 49 | + <Text style={_twStyles._font_bold_text_blue_500_text_xl}>Hello, Tailwind!</Text> |
| 50 | + </View> |
| 51 | + ); |
| 52 | +} |
| 53 | + |
| 54 | +const _twStyles = StyleSheet.create({ |
| 55 | + _bg_gray_100_flex_1_p_4: { |
| 56 | + flex: 1, |
| 57 | + backgroundColor: "#F3F4F6", |
| 58 | + padding: 16, |
| 59 | + }, |
| 60 | + _font_bold_text_blue_500_text_xl: { |
| 61 | + fontWeight: "700", |
| 62 | + color: "#3B82F6", |
| 63 | + fontSize: 20, |
| 64 | + }, |
| 65 | +}); |
| 66 | +``` |
| 67 | + |
| 68 | +## Getting Started |
| 69 | + |
| 70 | +Follow the [installation guide](/react-native-tailwind/getting-started/installation/) to set up React Native Tailwind in your project, then check out the [quick start](/react-native-tailwind/getting-started/quick-start/) to learn the basics. |
0 commit comments