Skip to content

Semantic color scheme #17696

Answered by wongjn
martijnversluis asked this question in Help
Apr 16, 2025 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

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); 
    }
  }
}
  • Have the light color mode in @theme.
  • The @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.
  • You don't want to do --color-*: initial, as that will mean the CSS variable references for the semantic color names wouldn't work.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@martijnversluis
Comment options

Answer selected by martijnversluis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants