1

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

<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?

2
  • 1
    It should be colors not color section of tailwind.config.js Commented Mar 23, 2022 at 8:15
  • @IharAliakseyenka thanks for pointing the typo out. it fixed the issue Commented Mar 23, 2022 at 8:20

1 Answer 1

2

Change color to colors.

 theme: {
    // the line below
    color: { ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.