I am looking into ways of how I can integrate Tailwind CSS into ionic react application, I have tried this but fell into a dead end, I am aware of the the Next.JS and Tailwind CSS starter created by one of the ionic experts but also inspecting that even I fell into a dead end.
-
I set it up similar to this. https://codingthesmartway.com/using-tailwind-css-with-react/ – b_d_m_p Feb 13 '21 at 09:25
3 Answers
Ionic Framework React internally uses Create React App (CRA).
Thus following Tailwindcss CRA setup work as you would expect.
Just note that you do not need @tailwind base
since Ionic out of the box already import normalize.css
for us.

- 11
- 3
-
1How is this going to work with 'ionic serve' when that is not in the package.json scripts that are being replaced with craco? – Bryan Feb 27 '21 at 19:29
Yes we can add TailwindCSS to Ionic React by installing Tailwind CSS with Vite.
step 1: Run this command in terminal
npm install -D tailwindcss postcss autoprefixer
Step 2: Run this command in terminal
npx tailwindcss init -p
Step 3: Configure your template paths, Add the paths to all of your template files in your tailwind.config.js file.
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
step 4: Add the Tailwind directives to your CSS,
Add the @tailwind directives for each of Tailwind’s layers to your ./src/index.css file.
@tailwind base;
@tailwind components;
@tailwind utilities;
Step 5: Start your build process
Run your build process with :
ionic serve
finally Start using Tailwind in your project,
Start using Tailwind’s utility classes to style your content.
export default function App() {
return (
<h1 className="text-3xl font-bold underline">
Hello world!
</h1>
)
}
Reference link Install Tailwind CSS with Vite using React

- 21
- 5