2

I want to use color variable (default, or extended) to my extended theme like:

module.exports = {
    content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
    theme: {
        extend: {
            colors: {
                lime: {
                    '100': 'green'
                }
            },
            backgroundColor: {
                skin: {
                    base: 'bg-red-500',
                    secondary: 'lime-100',
                },
            },
        },
    },
    plugins: [],
};

but this isn't working. How can I have a class bg-skin-base equivalent to bg-red-500 and another class bg-skin-secondary that is equivalent to bg-[green]?

1 Answer 1

5

There isn't a backgroundColor. Any colors added under extend > colors are available for text-, bg-, border- etc.

Just add skin under colors and you should be good.

tailwind docs reference

const colors = require("tailwindcss/colors")

extend: {
   colors: {
      lime: {
        '100': 'green'
      },
      skin: {
        base: '#yourhex",
        secondary: '#yourhex",
        third: colors.violet["500"]
      }
   },
}

You can't use bg-red-500 like you have in your example for base. If you are looking to alias a tailwind color you can either use the hex or use tailwind colors by const colors = require("tailwindcss/colors") and then you can do colors.red[500] or whatever color you want.

Sign up to request clarification or add additional context in comments.

5 Comments

What do you mean by Just add skin under colors and you should be good.? Can you provide a code example?
@abc added to the answer
I don't want to use my own hex colors though, I want to use the shade of red in say bg-red-500. base: 'var(--red-500)' is what I want to do, but it doesn't work.
You have to require tailwind colors and then you can reference any tailwind color you want (skin.third) is the example above.
You can extend backgroundColor as an option as well. Docs reference

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.