-
-
Notifications
You must be signed in to change notification settings - Fork 347
Dark Mode
Maxime Gross edited this page Jun 14, 2025
·
8 revisions
Flex provides a light (default) and dark theme. Optionally, Flex can automatically detect the color theme preference set by the user's browser/OS and can allow the user to switch the theme manually.
-
THEME_COLOR(either"light"(default) or"dark"): the default theme to use when the user/browser/OS does not override it. -
THEME_COLOR_AUTO_DETECT_BROWSER_PREFERENCE(bool): set toTrueif you want Flex to auto-detect the user's browser/OS color scheme preference and use the appropriate theme. -
THEME_COLOR_ENABLE_USER_OVERRIDE(bool): set toTrueif you want Flex to provide links in the footer of the page for the user to override the theme. -
PYGMENTS_STYLE_DARK(str, fallback toPYGMENTS_STYLEormonokai): select a Pygments style to use in dark mode.
This config will make Flex use the dark theme by default, but will respect the browser/OS color scheme preference, and allow the user to override the theme. It will also use the emacs Pygments theme in light mode, but the monokai theme in dark mode.
THEME_COLOR = 'dark'
THEME_COLOR_AUTO_DETECT_BROWSER_PREFERENCE = True
THEME_COLOR_ENABLE_USER_OVERRIDE = True
PYGMENTS_STYLE = 'emacs'
PYGMENTS_STYLE_DARK = 'monokai'- The
THEME_COLOR_AUTO_DETECT_BROWSER_PREFERENCEsetting relies on theprefers-color-schememedia query. The latest releases of all major browsers except for Internet Explorer this (Can I use). - JavaScript is not required for the
THEME_COLOR,THEME_COLOR_AUTO_DETECT_BROWSER_PREFERENCE, andPYGMENTS_STYLEsettings to work. (Only the media query is used.) - JavaScript is required for the
THEME_COLOR_ENABLE_USER_OVERRIDEto work.