In my tailwind config, i would like to be able to add some custom colors BUT also use all of tailwinds as well, e.g. i add a green but then can also use green-500.
Here is my config:
/** @type {import('tailwindcss').Config} */
module.exports = {
darkMode: 'class',
content: ['./src/**/*.{js,jsx,ts,tsx}'],
variants: {
extend: {
display: ['group-hover'],
},
},
theme: {
extend: {
animation: {
pulse: 'pulse 2s infinite',
},
keyframes: {
pulse: {
'0%, 100%': { opacity: 1 },
'50%': { opacity: 0.5 },
},
},
borderWidth: {
1: '1px',
},
spacing: {
18: '4.5rem',
},
colors: {
dark: '#242424',
paperdark: '#343434',
bright: '#f1f0eb',
cyan: '#5ccabe',
green: '#71b468',
red: '#ee6022',
white: '#ffffff',
},
},
},
// eslint-disable-next-line @typescript-eslint/no-var-requires
plugins: [require('tailwind-scrollbar')({ nocompatible: true })],
};
But whenever I try to use like text-blue-500
or bg-blue-500
i dont see the color.
2
Answers
You could try adding the color to
green-*
instead of replacing the originalgreen
property.When extending colors in
extend
, the original colors will be inherited directly. You only need to add your colors to the corresponding color property object:Usage:
Demo on Tailwind Play.
You could as replace as add your custom naming