Create a new app with expo file routing.
npx create-expo-app your_app_name --template blank
create all the pages or screens in the folder (app).
Install nativewind and tailwind CSS with version 3.2.2.
npm install nativewind npm install --save-dev tailwindcss@3.3.2
Set up tailwind CSS.
Run npx tailwindcss init to create tailwind.config.js file.
// tailwind.config.js
module.exports = {
- content: [],
+ content: ["./App.{js,jsx,ts,tsx}", "./app/**/*.{js,jsx,ts,tsx}"],
theme: {
extend: {},
},
plugins: [],
}
Add the Babel plugin.
// babel.config.js
module.exports = function (api) {
api.cache(true);
return {
presets: ["babel-preset-expo"],
+ plugins: ["nativewind/babel"],
};
};
New step: make postcss.config.js look like this.
// postcss.config.js
module.exports = {
plugins: [require("tailwindcss"), [require("nativewind/postcss")]],
};
Don't forget to remove the cache.
npm start -- --reset-cache
Congratulations, you have setup the nativewind with expo file routing.