Overview
NativeWind requires configuration in three key areas: Metro bundler, Babel transpiler, and Tailwind CSS. This guide walks you through setting up each component for optimal performance.NativeWind v5 uses
react-native-css under the hood and processes styles at build time for better performance.Metro Configuration
Metro is React Native’s JavaScript bundler. NativeWind provides a wrapper function that configures Metro for CSS processing.Install dependencies
First, ensure you have the required peer dependencies:
NativeWind requires
tailwindcss >4.1.11 and react-native-css ^3.0.1Configure Metro
Wrap your Metro config with
withNativewind:metro.config.js
For React Native CLI projects
For React Native CLI projects
metro.config.js
Configure with options
The
withNativewind function accepts options to customize behavior:metro.config.js
Set to
true to disable automatic generation of nativewind-env.d.tsCustom path for the TypeScript environment declaration file
Enables the
className prop on all React Native componentsBabel Configuration
Babel transforms your JavaScript code. NativeWind’s Babel plugin is re-exported fromreact-native-css.
Update babel.config.js
For Expo projects, use
babel-preset-expo:babel.config.js
The NativeWind Babel plugin is automatically included through the Metro configuration. You don’t need to add it manually.
Tailwind CSS Configuration
NativeWind v5 uses Tailwind CSS v4’s new CSS-based configuration system.Create global CSS file
Create a
global.css file in your project root (or src/ directory):global.css
What does each import do?
What does each import do?
tailwindcss/theme.css- Defines theme tokens (colors, spacing, etc.)tailwindcss/preflight.css- Base styles and resetstailwindcss/utilities.css- Utility classes (text-red-500, flex, etc.)nativewind/theme- React Native-specific utilities and platform modifiers
Platform-Specific Configuration
NativeWind includes platform-specific utilities and modifiers.Platform Modifiers
Use platform modifiers to apply styles conditionally:Custom Theme Configuration
Extend the default theme using CSS custom properties:global.css
Advanced Configuration
Monorepo Setup
For monorepo setups, configure Metro to resolve node_modules correctly:metro.config.js
Disabling TypeScript Generation
If you manage types throughcompilerOptions.types, disable auto-generation:
metro.config.js
Verification
Verify your configuration is working:Check generated types
After running your dev server, verify
nativewind-env.d.ts was created:nativewind-env.d.ts
Next Steps
TypeScript Setup
Configure TypeScript for type safety with NativeWind
Custom Styles
Learn to create custom utilities and components
Troubleshooting
Common issues and solutions
Tailwind Plugin
API reference for the Tailwind plugin