> ## Documentation Index
> Fetch the complete documentation index at: https://docs.median.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Dark mode

> Set dark mode for native UI elements.

You may add support for dark and light modes within your web content by making use of the `prefers-color-scheme` CSS media query. Your app sets this parameter to `light` and `dark` based on the current device mode, and will change it dynamically when the device mode changes.

You may add a control toggle within your web content to force light or dark mode in addition to following the device setting (Auto mode). Median will set a property on your webpage called `data-color-scheme-option` with the current app setting of `light`, `dark`, or `auto`. You can use the value of this property to set the state of said toggle.

> [!TIP]
>
> **Test  with our demo page**
>
> We host a ready-made demo page at
>
> that calls the  features through the Median JavaScript Bridge.
> Load it inside your Median app during development, either by setting it
> as your app's website URL in App Studio or by navigating to it from your
> own site, and use it to confirm  works on a real device before
> you add it to your own pages.
>
> The demo page only works inside a Median app with  enabled.
> Opened in a regular mobile or desktop browser, the native features
> won't respond. Remember to switch your app back to your own URL before
> release.

Median JavaScript Bridge

```javascript JavaScript theme={null}
// Force Light Mode
// Always use Light styling irrespective of device mode
if (navigator.userAgent.indexOf("median") > -1) {
  median.screen.setColorScheme("light");
}

// Force Dark Mode
// Always use Dark styling irrespective of device mode
if (navigator.userAgent.indexOf("median") > -1) {
  median.screen.setColorScheme("dark");
}

// Auto Mode
// Set to Auto mode to follow the device mode (Light or Dark)
if (navigator.userAgent.indexOf("median") > -1) {
  median.screen.setColorScheme("auto");
}

// Revert to Default
// Revert to the default configuration set in the app (Light/Dark/Auto)
if (navigator.userAgent.indexOf("median") > -1) {
  median.screen.resetColorScheme();
}
```

We recommend using CSS variables to define the desired colors in light mode versus dark mode.

For a live example that you can adapt for your own website, check out Median's [dark mode switcher CodePen example](https://codepen.io/gonative/pen/dyzLKQQ), or refer to [MDN's reference for the CSS light-dark() function](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/color_value/light-dark/) for details and examples of implementing dark mode with CSS.

[Dark mode switcher](https://codepen.io/gonative/embed/dyzLKQQ?default-tab=css%2Cresult\&editable=false\&theme-id=dark)

Dark mode switcher demo


## Related topics

- [Status bar](https://docs.median.co/docs/status-bar.md)
- [Splash screen](https://docs.median.co/docs/splash-screen.md)
- [System navigation bar (Android)](https://docs.median.co/docs/system-nav-bar.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.