Create a project directory
1
2
| mkdir my-simple-app
cd my-simple-app
|
Install
1
2
| npx create-expo-app@latest .
npm run reset-project
|
https://www.nativewind.dev/docs/getting-started/installation
1
2
| npm install nativewind tailwindcss react-native-reanimated react-native-safe-area-context
npx tailwindcss init
|
1
2
3
4
5
6
7
8
9
| /** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./app/**/*.{js,jsx,ts,tsx}", "./components/**/*.{js,jsx,ts,tsx}"],
presets: [require("nativewind/preset")],
theme: {
extend: {},
},
plugins: [],
}
|
Add globals.css in app folder.
1
2
3
| @tailwind base;
@tailwind components;
@tailwind utilities;
|
Add babel.config.js in the project folder.
1
2
3
4
5
6
7
8
9
| module.exports = function (api) {
api.cache(true);
return {
presets: [
["babel-preset-expo", { jsxImportSource: "nativewind" }],
"nativewind/babel",
],
};
};
|
Add metro.config.js. Make sure the input points to the globals.css location.
1
| npx expo customize metro.config.js
|
1
2
3
4
5
6
| const { getDefaultConfig } = require("expo/metro-config");
const { withNativeWind } = require('nativewind/metro');
const config = getDefaultConfig(__dirname)
module.exports = withNativeWind(config, { input: './app/globals.css' })
|
Download the Expo app
Run
Comments powered by Disqus.