DEV Community

Cover image for Add Tailwind CSS to your Quasar project in 5 minutes or less.
Elvis Ibarra 🐃
Elvis Ibarra 🐃

Posted on

23 3

Add Tailwind CSS to your Quasar project in 5 minutes or less.

Why do this?

I've been building a passion project of mine, Jiujitsio, in Quasar for the past few months and wanted to implement Tailwind styling when prototyping new or creating custom components.

Step 1 - Install Tailwind

Install Tailwind via NPM or Yarn.

Install via npm or yarn screenshot

Step 2 - Add Tailwind to your CSS.

Import Tailwind Directives. Add the following in between the style tags of any Quasar component you wish to style with Tailwind.

Tailwind directives screenshot

Step 3 - Process your CSS with Tailwind

Since Vue styles are piped through PostCSS we are going to need to modify our .postcssrc.js file to require Tailwind.

Alt Text

Step 4 - Profit & Next Steps

That's it! Any Quasar components in your project where you add the Tailwind directives will now respond to Tailwind class styling. You can also optionally also add a Tailwind config file (may be a follow up post) for further customization.

Video Demo:

Relevant Docs:

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (6)

Collapse
 
ciokan profile image
Romeo Mihalcea

Pictures as code - the coolest thing to post in programming articles.

Collapse
 
ifierygod profile image
Goran Kortjie

This is funny 😄 but imagine building an entire website and all you have to do is send it pictures of code.

Collapse
 
linnaek profile image
LinnaeK

Thank you for these clear directions. I have been trying to attach Tailwind to Quasar components (ex q-input) that already have their own CSS. So far the Quasar CSS has been overwriting most of the Tailwind CSS. Do you have suggestions on how to reverse this? (my Tailwind classes are prefixed with tw-)

Collapse
 
eltoritoelvis profile image
Elvis Ibarra 🐃

Hi LinnaeK 👋,



Thanks for your question. I’m currently sticking to using Quasar’s CSS in my own project rather than trying to fight with the framework as I don’t think there currently is a way to fix the conflicts you described.

I mainly wrote that for fun and would wait until/if this is fixed before trying to use Tailwind & Quasar together on a production app without running into these issues.



There’s an open issue about this on Quasar’s Github page. 



I hope they are able to “fix” this as I would love to be able to use either or both options.

Collapse
 
thekhairul profile image
thekhairul

Thanks for the concise article. Adding tailwind modules (utilities, components, base) in my component increased compile time considerably. I then moved those in the entry css file (app.scss). Working great :)

Collapse
 
psanchezp31 profile image
Paula Sánchez P

Hi guys, I just wanted to let you know, that this worked for me but only installing this versions:
npm i -D tailwindcss@npm:@tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9.
Thank you..

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Instrument, monitor, fix: a hands-on debugging session

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️