React Native CLI Integration
NativeWind works with React Native CLI projects, providing Tailwind CSS styling for native iOS and Android applications. This guide covers setup for React Native 0.81.4 and newer.This guide is for projects using React Native CLI. If you’re using Expo, see the Expo Setup Guide.
Prerequisites
Before starting, ensure you have:- Node.js 20+ installed
- React Native CLI environment set up (Setup Guide)
- iOS development environment (macOS only) with Xcode
- Android development environment with Android Studio
Installation
Install Additional Dependencies
Install required React Native packages:These packages enable:
- react-native-reanimated: Smooth animations and transitions
- react-native-worklets: Background thread execution for better performance
Configuration
Configure Metro Bundler
Create or update The
metro.config.js in your project root:metro.config.js
withNativewind wrapper:- Processes CSS files through the NativeWind compiler
- Generates TypeScript definitions automatically
- Enables className prop on all React Native components
Create Global CSS File
Create This imports all necessary Tailwind CSS layers and NativeWind theme extensions.
global.css in your project root:global.css
Platform-Specific Configuration
iOS Configuration
Android Configuration
Update MainActivity for Reanimated
If using React Native Reanimated, update
android/app/src/main/java/.../MainActivity.java:MainActivity.java
Usage
Start using Tailwind classes in your components:App.tsx
Running Your App
Platform-Specific Styling
iOS Specific Features
Android Specific Features
Useelevation-* for better shadows on Android:
Troubleshooting
Styles not appearing
Styles not appearing
- Verify
global.cssis imported at the top of your app entry - Clear Metro cache:
npm start -- --reset-cache - Rebuild the app completely (clean build folders)
- Check
metro.config.jsincludeswithNativewind - Ensure
postcss.config.mjsexists and is configured correctly
TypeScript errors with className
TypeScript errors with className
- Verify
nativewind-env.d.tsexists - Add
"types": ["react-native-css/types"]totsconfig.json - Restart TypeScript server in your editor
- Check that
react-native-cssis installed
iOS build failures
iOS build failures
- Clean build folder:
cd ios && rm -rf build && cd .. - Reinstall pods:
cd ios && pod deintegrate && pod install && cd .. - Clean Xcode derived data
- Ensure CocoaPods version is up to date:
pod --version
Android build failures
Android build failures
- Clean Gradle cache:
cd android && ./gradlew clean && cd .. - Delete
android/.gradleandandroid/app/buildfolders - Invalidate caches in Android Studio
- Check minimum SDK version is set correctly
Reanimated errors
Reanimated errors
- Ensure
react-native-reanimated/pluginis last inbabel.config.js - Rebuild the app after adding the plugin
- Clear Metro cache:
npm start -- --reset-cache - Verify correct Reanimated version is installed
Dark mode not working
Dark mode not working
- Check
useColorScheme()hook returns correct value - Use
dark:prefix for dark mode classes - Configure platform-specific dark mode settings (Info.plist for iOS, styles.xml for Android)
- Test on physical device with dark mode enabled
Advanced Configuration
Custom Metro Configuration
For monorepo or advanced setups:metro.config.js
Hermes Configuration
NativeWind works with Hermes (React Native’s default JavaScript engine). Ensure Hermes is enabled in your project:ios/Podfile
android/app/build.gradle
Brownfield Integration
For integrating NativeWind into existing native apps:- Follow all setup steps above
- Ensure React Native is properly integrated
- Import
global.cssin your React Native root component - Rebuild native code after configuration changes
Next Steps
Styling Guide
Learn how to style components with NativeWind
Dark Mode
Implement dark mode in your app
Custom Configuration
Customize NativeWind for your needs
Migration Guide
Migrate from other styling solutions