Skip to main content
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.
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, or refer to MDN’s reference for the CSS light-dark() function for details and examples of implementing dark mode with CSS.

Dark mode switcher demo

Last modified on December 3, 2026