← All Tools

CSS light-dark() Playground

The CSS light-dark(LIGHT, DARK) function returns the first value under a light color-scheme and the second under a dark one — letting you define one set of custom properties that adapts automatically, with no @media (prefers-color-scheme) blocks. Define your token pairs below, preview the rendered theme, and copy the generated CSS.

Goes on :root. light dark means the browser picks based on prefers-color-scheme. light-dark() needs an explicit color-scheme to resolve.
CSS variable Light Dark
Each pair becomes --name: light-dark(LIGHT, DARK);. Hex shortcuts give you a color picker; type any valid CSS value (e.g. oklch(0.6 0.18 250)) directly.
Switches a wrapper inside the preview iframe; your real OS setting isn't changed.
Live previewlight
The preview renders inside an iframe so color-scheme works in isolation from this page.
Generated CSS

    

Support: light-dark() is in Chrome 123+, Edge 123+, Safari 17.5+, and Firefox 120+ (all 2024). Older browsers ignore the declaration — provide a fallback by repeating the property with a static value first.

Tips