# Simplifying Dark Mode with light-dark()

> A game-changer for theming with a single CSS function

Published: 2024-11-24  
Tags: css  
Source: https://www.rege-dev.xyz/writing/light-dark

The `light-dark()` function enables defining two colors for a property in a single declaration, automatically adapting to the system theme. [Read more on MDN →](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/light-dark)

```css
:root {
  color-scheme: light dark;
}

.element {
  background-color: light-dark(#f4f4f5, #27272a);
  color: light-dark(#18181b, #fafafa);
}
```

_Interactive demo: https://www.rege-dev.xyz/writing/light-dark_
