Integrating Tailwind into Quasar



  • I am new to quasar and so far I really like it. With that said, I would like to integrate tailwindcss with it if possible so that I can use it’s utility classes when I want.

    Does anyone know how to do this – or can they point to any documentation that can explain how to integrate the two together?

    Thanks.



  • @moshemo Don’t know much about Tailwind. What kind of utility classes do you want to use?



  • Hey @moshemo ,

    I had the same questions and after digging a bit through the extensions I just finished a first version of a Quasar extension that includes TailwindCSS into your project.

    For details check https://github.com/matzeso/quasar-app-extension-tailwindcss

    To use it, simply run:
    quasar ext add tailwindcss



  • I’m new to Quasar too but just installed TailwindCSS as usual, added the tailwind classes to the app.css as described in the Tailwind docs and added it to the postcss config and it works out of the box as I would expect.

    I even (mind, I’m using Quasar with the Quasar CLI) was able to connect the color config of Tailwind with the brand color config of Quasar by extracting them into a separate Javascript file. In that brand config file I have a module.export with the brand object which I import into TailwindCSS config as the color object and also in the Quasar config as the framework config brand object.
    So I don’t use the config SASS file of Quasar for the brand colors but I put them right into the config javascript file. An example of that can be found when you export the colors via the Quasar Theme Builder in the docs.



  • It’s already in documentation
    https://tailwindcss.com/docs/installation/



  • @Tom-De-Smet that’s great, do you mind sharing your setup.



  • It’s very simple actually:

    Create a JS file somewhere (I created a brand.config.js file in my root where Tailwinds config also resides) with a color object which you will export (use the Quasar naming such as primary:

    const brand = {
        primary  : '#ffbb00',
        secondary: '#ffffff',
        accent   : '#242424',
        dark     : '#696969',
        positive : '#60e67f',
        negative : '#db394c',
        info     : '#e3e3e3',
        warning  : '#f2a838'
    };
    
    module.exports = brand;
    

    Than import this into Tailwind config and Quasar config files:

    const brand = require('./brand.config.js');

    Than use them in your Tailwind config

    theme: {
            extend: {
                colors: brand
        }
    }
    

    and Quasar config:

    framework: {
        config: {
            brand: brand
        }
    }
    

    You can also use the spread operator if you want to add additional colors:

    theme: {
            extend: {
                colors: {
                    ...brand,
                    'extra-color': '#555555'
            }
        }
    }
    

Log in to reply