Overview
ThewithUniwindConfig
function configures Uniwind in your Metro bundler. This is required to enable CSS processing, type generation, and theme support in your React Native application.
All Metro configuration changes require a Metro bundler restart to take effect. Clear the cache with
npx expo start --clear
if you encounter issues.Basic Usage
Import and wrap your Metro config withwithUniwindConfig
:
metro.config.js
Configuration Options
cssEntryFile
The relative path to your CSS entry file from the project root. This file should contain your Tailwind imports and custom CSS.
metro.config.js
global.css
Keep your CSS entry file in the root,
app
, or src
directory for easier path management.extraThemes
An array of custom theme names beyond the default
light
and dark
themes. Each theme must be defined in your CSS using the @variant
directive.metro.config.js
global.css
After adding new themes, restart your Metro bundler for changes to take effect.
Custom Themes
Learn more about creating and managing custom themes
dtsFile
The path where Uniwind will auto-generate TypeScript type definitions for your CSS classes and themes. Defaults to
./uniwind-types.d.ts
in your project root.metro.config.js
Place the
.d.ts
file in your src
or app
directory for automatic TypeScript inclusion. For custom paths outside these directories, add the file to your tsconfig.json
.tsconfig.json
polyfills
Configuration for CSS unit polyfills and adjustments to ensure cross-platform consistency.
polyfills.rem
The base font size (in pixels) used for rem unit calculations. Defaults to
16
, which is the standard browser default.metro.config.js
- Your design system uses a different base font size
- You need to scale your entire UI proportionally
- You’re migrating from a web app with a custom rem base
- You’re migrating from NativeWind
Complete Configuration Example
Here’s a full example with all options configured:metro.config.js
Bare React Native
For bare React Native projects (non-Expo), use the@react-native/metro-config
package:
metro.config.js