I'm customizing the colors of my project using Chakra UI, but I came across a situation that I couldn't find in the project's documentation.
Well, I used extendTheme to change the green colors.
const theme = extendTheme({
colors: {
green: {
50: "#ecfdf5",
100: "#d1fae5",
200: "#a7f3d0",
300: "#6ee7b7",
400: "#34d399",
500: "#10b981",
600: "#059669",
700: "#047857",
800: "#065f46",
900: "#064e3b",
},
},
});
This in itself is working. When I use it in a component, for example:
<Box bg="green.400" />
The problem arises when I try to use just the name green. It uses the default green from CSS and not one of the 50-900 shades of green that I defined. I don't know how I can define a color to be the default.
The key word that helped me find the solution was
semanticTokens
.With this configuration, I managed to define a token for the
green
color.More information can be found at:
https://chakra-ui.com/docs/styled-system/semantic-tokens
In the documentation, they use terms like
success
,danger
,error
, etc. But color names can also be applied.