Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to make tailwindcss custom color work in Laravel 9

I have installed tailwindcss in a Laravel 9 project and trying to add custom colors. Then added this in webpack.mix.js

const mix = require('laravel-mix');

mix.js('resources/js/app.js', 'public/js')
    .postCss('resources/css/app.css', 'public/css', [
        require("tailwindcss"),
    ]);

To add the custom colors, I have added the colors in my tailwind.config.js file like this

const colors = require('tailwindcss/colors');

module.exports = {
  content: [
    "./resources/**/*.blade.php",
    "./resources/**/*.js",
    "./resources/**/*.vue",
  ],
  theme: {
    color: {
      transparent: 'transparent',
      current: 'currentColor',
      'blue': '#71BBE2',
      'orange': '#E28333',
      'black': '#242121',
      'gray': '#242121CC',
      'lemon':  '#C3D14A',
      'green': '#88B667',
      'lime': '#F8FFF4',
      'purple':  '#9D2883',
      'white': '#FFFFFF'
    },
    extend: {},
  },
  plugins: [],
}

I have npm run watch running and I can see that laravel mix compiled successfully. Now when I use bg-orange in my view file like this

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<nav class="bg-orange">
    <div class="mx-32 py-2">
         //....
    </div>
</nav>

the color does not show in the browser and looking at the dev tools I cannot see the color appended to the bg prefix

<nav class="bg-">
    <div class="mx-32 py-2">
         //....
    </div>
</nav>

Any idea what the issue could be?

>Solution :

Change color to colors.

 theme: {
    // the line below
    color: { ...
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading