What's the new and improved way to override the gray color, to lets say, slate or stone? #16400
-
As stated in the title, what is the best way to override colors in v4? In the past, you would have the following in your config file: module.exports = {
theme: {
extend: {
colors: {
gray: require("tailwindcss/colors").slate, // Change 'gray' to 'slate'
},
},
},
}; Is this still the best way, or does it even work anymore? Thanks for the help! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
I'm pretty sure in v4 the best way is to override the default colours altogether rather than "extending" it. const colors = require('tailwindcss/colors')
module.exports = {
theme: {
colors: { gray: colors.slate },
},
} |
Beta Was this translation helpful? Give feedback.
-
We explored coming up with some clever syntax for this but ultimately decided the right thing to recommend is just defining the colors in the most basic way possible. Here's an example of taking all of the zinc shades but calling them gray instead: @import "tailwindcss";
@theme {
--color-gray-50: oklch(0.985 0 0);
--color-gray-100: oklch(0.967 0.001 286.375);
--color-gray-200: oklch(0.92 0.004 286.32);
--color-gray-300: oklch(0.871 0.006 286.286);
--color-gray-400: oklch(0.705 0.015 286.067);
--color-gray-500: oklch(0.552 0.016 285.938);
--color-gray-600: oklch(0.442 0.017 285.786);
--color-gray-700: oklch(0.37 0.013 285.805);
--color-gray-800: oklch(0.274 0.006 286.033);
--color-gray-900: oklch(0.21 0.006 285.885);
--color-gray-950: oklch(0.141 0.005 285.823);
} Basically just copy the color you want and change the name. You only have to do it once, and then when you go to look at your source files the values are right there in plain sight instead of some cryptic abstract DSL for aliasing things. Can find all of the default colors here for copy and pasting reference: https://tailwindcss.com/docs/colors#default-color-palette-reference |
Beta Was this translation helpful? Give feedback.
-
I have this css file but color ovverride is not woking can anyone help me?@import "tailwindcss"; @theme { --color-light-20: "#E3E5E5"; --color-violet-20: "#EEE5FF"; --color-red-20: "#FDD5D7"; --color-green-20: "#CFFAEA"; --color-yellow-20: "#FCEED4"; --color-blue-20: "#BDDCFF"; |
Beta Was this translation helpful? Give feedback.
We explored coming up with some clever syntax for this but ultimately decided the right thing to recommend is just defining the colors in the most basic way possible.
Here's an example of taking all of the zinc shades but calling them gray instead: