20

I was trying to use colors such as amber and lime, which are mentioned in the documentation. These colors didn't work. Only colors with names such as the primary color name (eg. red, pink) worked.

Colors which are not working: amber, emerald, lime, rose, fuchsia, slate, zinc, and even orange.

I'm using version 2.26, but I used the Tailwind playground to check the versions between 1.9 and 2.25, and still these colors didn't work. Even in the playground, these color names are not suggested.

Why can't I use these colors?

Roddy of the Frozen Peas
  • 14,380
  • 9
  • 49
  • 99
Poornima T
  • 263
  • 1
  • 2
  • 8

3 Answers3

33

This is documentation for Tailwind version 3, it has expanded color palette.

You either need to update to version 3 or use version 2 documentation and expand palette manually, like that:

// tailwind.config.js
const colors = require('tailwindcss/colors')

module.exports = {
  theme: {
    extend: {
      colors: {
        // you can either spread `colors` to apply all the colors
        ...colors,
        // or add them one by one and name whatever you want
        amber: colors.amber,
        emerald: colors.emerald,
      }
    }
  }
}

More info about v2 color customization

Color palette reference v2

So, just read this v2 docs if you want to configure your palette.

Danila
  • 15,606
  • 2
  • 35
  • 67
  • Thanks! I'll try this one. I had actually tried using the color names on version3 at tailwind playground but i had not overridden the config file and tried so I could not get those colors. ref-( https://play.tailwindcss.com/gbngSXMwJt?file=config) . – Poornima T Jan 15 '22 at 14:19
  • Again, what you have linked is a v2 playground, not v3. There is selector in the top right corner to chose version. Here is v3 playground with colors working out of the box https://play.tailwindcss.com/AD4gMp7Nxm – Danila Jan 15 '22 at 14:27
5

Try this:

const colors = require('tailwindcss/colors')

module.exports = {
    theme: {
        extend: {
            colors: {
                   //just add this below and your all other tailwind colors willwork
                ...colors
            }
        }
    }
}
Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
1

If you're using the PostCSS 7 Compatibility Build (https://www.npmjs.com/package/@tailwindcss/postcss7-compat) then you'll need to add the colours to tailwind.config.js like so:

const colors = require('tailwindcss/colors')

module.exports = {
    theme: {
        extend: {
            colors: {
                stone: colors.warmGray,
                sky: colors.lightBlue,
                neutral: colors.trueGray,
                gray: colors.coolGray,
                slate: colors.blueGray,
            }
        }
    }
}

Explanation: I was having the same issue (with the Compatibility Build) so I did some digging and found the following in colors.d.ts, which means you can add the above to the tailwind.config.js file in your project to use those same colours with their v3 utility class names (e.g. "bg-neutral-800").

/**
 * @deprecated renamed to 'sky' in v2.2
 */
lightBlue: TailwindColorGroup;
/**
 * @deprecated renamed to 'stone' in v3.0
 */
warmGray: TailwindColorGroup;
/**
 * @deprecated renamed to 'neutral' in v3.0
 */
trueGray: TailwindColorGroup;
/**
 * @deprecated renamed to 'gray' in v3.0
 */
coolGray: TailwindColorGroup;
/**
 * @deprecated renamed to 'slate' in v3.0
 */
blueGray: TailwindColorGroup;
Toby Scott
  • 79
  • 7