MrDogeBro / sphinx_rtd_dark_mode

Adds a toggleable dark mode to the Read the Docs theme for Sphinx.
sphinx-rtd-dark-mode.vercel.app
MIT License
49 stars 15 forks source link

Request user preference with a media query instead of defaulting to a hardcoded light/dark theme #44

Open whitequark opened 4 months ago

whitequark commented 4 months ago

You can find out the user's color scheme preference by running window.matchMedia('(prefers-color-scheme:dark)').matches. This is broadly supported by browsers.