Semantic color scheme #17696
Answered
by
wongjn
martijnversluis
asked this question in
Help
Semantic color scheme
#17696
-
We use a palette of semantic colors, meaning we assign colors by their semantic name, and based on light or dark theme it maps to a color from the default palette. It used to be configured in I tested multiple ways, but no solution worked fully. Either no color would work (only black/white) or it would not switch. My current solution looks like this, no color works: @theme static {
--color-slate-50: #F7F7FB;
--color-black: #000000;
...
}
:root {
--color-*: initial;
--color-fill-ground: var(--color-slate-50);
...
@media (prefers-color-scheme: dark) {
--color-fill-ground: var(--color-black);
}
} Anybody know what the current setup should look like? |
Beta Was this translation helpful? Give feedback.
Answered by
wongjn
Apr 16, 2025
Replies: 1 comment 1 reply
-
You could do something like: @theme {
--color-slate-50: #F7F7FB;
--color-black: #000000;
--color-fill-ground: var(--color-slate-50);
}
@layer theme {
@media (prefers-color-scheme: dark) {
:root {
--color-fill-ground: var(--color-black);
}
}
}
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
martijnversluis
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could do something like:
@theme
.@layer theme
isn't strictly neccessary but follows convention of Tailwind core.@theme
compiles its CSS variables to:root
rule, so we can override it by selecting:root
too.--color-*: initial
, as that will mean the CSS variable references for the semantic color names wouldn't work.