light-dark() — one rule, both themes
Six color pairs are declared once in this page, with
light-dark(light, dark). There is no
@media (prefers-color-scheme: dark) block anywhere in the file.
Watch the same declarations produce two different designs — then set
color-scheme yourself and find the bug that catches everyone.
Both cards below are styled by the identical five declarations. The only
difference is the color-scheme on their container. This pair is always
shown so you can see both outcomes no matter what your own device prefers.
color-scheme: lightYour team shipped 24 changes this week, up from 18.
color-scheme: darkYour team shipped 24 changes this week, up from 18.
Notice the text cursor and placeholder in each search box, and the scrollbars if you
shrink the window. color-scheme restyles the browser's own widgets too —
that's a second job the media-query approach never did for you.
color-scheme
This sets color-scheme on the preview below — exactly what
document.documentElement.style.colorScheme = … does in a real theme toggle.
color-scheme: light dark
Your team shipped 24 changes this week, up from 18.
Your device currently prefers ….
The struck-through value is the one the browser discarded for your current setting. Same source, different pick.
The values on the right are the colors that actually painted. Worth knowing:
reading a custom property back with getComputedStyle() hands you the
literal string light-dark(#ffffff, #1f2937), not a color — the function
resolves only when a real property uses the value. This panel reads invisible probe
elements inside the preview to get the resolved color.