| name | expo-tailwind-setup |
| description | Set up Tailwind CSS v4 in Expo with react-native-css and NativeWind v5 for universal styling |
| category | Document Processing |
| source | antigravity |
| tags | ["javascript","typescript","react","api","ai","document","image","security","tailwind","cro"] |
| url | https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/expo-tailwind-setup |
Tailwind CSS Setup for Expo with react-native-css
When to Use
Use this skill when you need set up Tailwind CSS v4 in Expo with react-native-css and NativeWind v5 for universal styling.
This guide covers setting up Tailwind CSS v4 in Expo using react-native-css and NativeWind v5 for universal styling across iOS, Android, and Web.
Overview
This setup uses:
- Tailwind CSS v4 - Modern CSS-first configuration
- react-native-css - CSS runtime for React Native
- NativeWind v5 - Metro transformer for Tailwind in React Native
- @tailwindcss/postcss - PostCSS plugin for Tailwind v4
Installation
npx expo install tailwindcss@^4 nativewind@5.0.0-preview.2 react-native-css@0.0.0-nightly.5ce6396 @tailwindcss/postcss tailwind-merge clsx
Add resolutions for lightningcss compatibility:
{
"resolutions": {
"lightningcss": "1.30.1"
}
}
- autoprefixer is not needed in Expo because of lightningcss
- postcss is included in expo by default
Configuration Files
Metro Config
Create or update metro.config.js:
const { getDefaultConfig } = require("expo/metro-config");
const { withNativewind } = require("nativewind/metro");
const config = getDefaultConfig(__dirname);
module.exports = withNativewind(config, {
inlineVariables: false,
globalClassNamePolyfill: false,
});
PostCSS Config
Create postcss.config.mjs:
export default {
plugins: {
"@tailwindcss/postcss": {},
},
};
Global CSS
Create src/global.css:
@import "tailwindcss/theme.css" layer(theme);
@import "tailwindcss/preflight.css" layer(base);
@import "tailwindcss/utilities.css";
@media android {
:root {
--font-mono: monospace;
--font-rounded: normal;
--font-serif: serif;
--font-sans: normal;
}
}
@media ios {
:root {
--font-mono: ui-monospace;
--font-serif: ui-serif;
--font-sans: system-ui;
--font-rounded: ui-rounded;
}
}
IMPORTANT: No Babel Config Needed
With Tailwind v4 and NativeWind v5, you do NOT need a babel.config.js for Tailwind. Remove any NativeWind babel presets if present:
CSS Component Wrappers
Since react-native-css requires explicit CSS element wrapping, create reusable components:
Main Components (src/tw/index.tsx)
import {
useCssElement,
useNativeVariable as useFunctionalVariable,
} from "react-native-css";
import { Link as RouterLink } from "expo-router";
import Animated from "react-native-reanimated";
import React from "react";
import {
View as RNView,
Text as RNText,
Pressable as RNPressable,
ScrollView as RNScrollView,
TouchableHighlight as RNTouchableHighlight,
TextInput as RNTextInput,
StyleSheet,
} from "react-native";
export const Link = (
props: React.ComponentProps<typeof RouterLink> & { className?: string }
) => {
return (, props, { : });
};
. = .;
. = .;
. = .;
. = .;
useCSSVariable =
process.. !==
? useFunctionalVariable
: ;
= .< > & {
?: ;
};
= () => {
(, props, { : });
};
. = ;
= () => {
(, props, { : });
};
. = ;
= () => {
(, props, {
: ,
: ,
});
};
. = ;
= () => {
(, props, { : });
};
. = ;
= () => {
u