Expo Integration
NativeWind works seamlessly with Expo, providing the fastest way to build cross-platform applications with Tailwind CSS styling. This guide covers setup for Expo SDK 54 and newer.This guide assumes you’re using Expo SDK 54+ and NativeWind v5 (preview). For v4.1 setup, see the official NativeWind documentation.
Prerequisites
Before starting, ensure you have:- Node.js 20+ installed
- Expo CLI installed globally or use
npx - Basic familiarity with React Native and Expo
Installation
Create a New Expo Project (Optional)
If you don’t have an existing project, create one:Or use the pre-configured starter:
Configuration
Configure Metro Bundler
Create or update The
metro.config.js in your project root:metro.config.js
withNativewind wrapper configures Metro to:- Process CSS files through the NativeWind compiler
- Generate TypeScript definitions
- Enable global className support
Configure Babel
Create or update
babel.config.js:babel.config.js
The
babel-preset-expo preset includes necessary transformations for NativeWind. No additional Babel plugins are required.Configure PostCSS
Create This configures Tailwind CSS v4’s PostCSS plugin to process your styles.
postcss.config.mjs in your project root:postcss.config.mjs
Create Global CSS File
Create This imports:
global.css in your project root:global.css
- Tailwind’s theme configuration
- Base styles (Preflight)
- Utility classes
- NativeWind-specific theme extensions
Import Global CSS
Import the CSS file in your app entry point (e.g.,
App.tsx or src/App.tsx):App.tsx
App Configuration
Update yourapp.config.ts or app.json to support dark mode:
userInterfaceStyle: 'automatic' setting enables automatic dark mode support.
Usage
Start using Tailwind classes in your components:Running Your App
Start the Expo development server:Platform-Specific Features
iOS Specific
NativeWind automatically handles iOS-specific styling:- Safe Areas: Use the
tailwindcss-safe-areaplugin for notch/island support - Native Shadows: Box shadows are automatically converted to iOS shadow properties
Android Specific
For better shadow support on Android:elevation-* classes for Android-specific elevation.
Web Specific
When running on web, NativeWind uses CSS stylesheets for optimal performance:Troubleshooting
Styles not appearing
Styles not appearing
- Ensure
global.cssis imported in your app entry point - Clear Metro bundler cache:
expo start --clear - Verify
metro.config.jsincludeswithNativewindwrapper - Check that
postcss.config.mjsis properly configured
TypeScript errors with className
TypeScript errors with className
- Verify
nativewind-env.d.tsexists in your project root - Restart your TypeScript server in VS Code
- Check
tsconfig.jsonincludes the types directory - Ensure react-native-css types are installed
Dark mode not working
Dark mode not working
- Set
userInterfaceStyle: 'automatic'inapp.config.ts - Use
dark:prefix for dark mode classes - Test on a physical device or simulator with dark mode enabled
Web build errors
Web build errors
- Ensure
react-native-webis installed:npx expo install react-native-web - Verify PostCSS configuration is correct
- Clear
.expoandnode_modules/.cachedirectories
Advanced Configuration
Customizing Metro Options
Pass custom options towithNativewind:
metro.config.js
Expo Router Integration
For apps using Expo Router, import global CSS in your root layout:app/_layout.tsx
Next Steps
Core Concepts
Learn how styling works in NativeWind
Dark Mode
Implement dark mode in your app
Custom Styles
Add custom utilities and components
TypeScript
Configure TypeScript for NativeWind