Styling Remix using Tailwind and PostCSS
How to style a Remix app using Tailwind and PostCSS
December 4th, 2021
December 4th, 2021
TL;DR: Source and Demo
Here's a live demo
Link to the source code
Link to step by step commits
In my last blog post, I discussed how to style a Remix app using Vanilla CSS. This blog will show how to integrate Tailwind and PostCSS into our Remix app.
OR if you prefer yarn
package.json
Replace
npm run
withyarn
if you prefer to useyarn
I don't want to commit those generated CSS files to the repo, so I'll be adding them to .gitignore
Run npm run css:watch
in one terminal and remix dev
in another
DISCLAIMER: Don't expect it will work immediately. We still need to configure a few things with Tailwind and PostCSS.
If you are not a fan of multiple terminals, use concurrently
to run css:watch
and remix dev
in parallel
We need to explicitly declare the features we want to use in our CSS. Here's a reference of what you can use.
Some CSS defaults I prefer
Add a reference of the generated CSS files using links
in app/root.tsx
Use Tailwind, as usual; add Tailwind's class names added inside the className
prop.
If you're wondering where the above file came from, that is from my last blog post.
Here are some plugins that you can use to get a better experience using Tailwind and PostCSS in VSCode.
Integrating Tailwind and PostCSS in Remix is straightforward as we don't need to hack into the framework to make them work. We quickly achieved an extendable and customizable CSS generation boilerplate by adding a few configurations.