Promote Dark Mode OS Setting

CONSIDER: Add a new function in the tw-themes API that promotes the Dark Mode OS setting.

This would be used by the client as one factor in setting the initTwThemes() initialInvertShade parameter.


+ osSettingPrefersDarkMode(): boolean ... true: dark-mode, false light-mode


The implementation would utilize the prefers-color-scheme media query (which is supported in all browsers except IE).

function osSettingPrefersDarkMode() {
  const prefersDarkMode = window.matchMedia('(prefers-color-scheme: dark)');
  return prefersDarkMode.matches;



To contribute to this topic, please refer to this discussion.

results matching ""

    No results matching ""