light-dark()
noun
say it: “LYTE DARK” /laɪt dɑːrk/
A CSS function that holds two colors in one value, the first for the light theme and the second for the dark theme. The page's color-scheme decides which one shows.
What does light-dark() do?
light-dark() holds two colors in one value: the first for the light theme and the second for the dark theme. The browser picks one from the page's color-scheme, so it only works once color-scheme is set.
:root { color-scheme: light dark; }
body {
color: light-dark(#222222, #eeeeee);
background: light-dark(#ffffff, #121212);
}
In a sentence
- “With light-dark(), the card background is white in light mode and charcoal in dark mode, from a single line.”
Level: Journeyman · More CSS terms at this level
Updated