Docusaurus: (v2) Can't enable light mode by default

Created on 3 Jun 2020  路  9Comments  路  Source: facebook/docusaurus

馃悰 Bug Report

I cannot enable light mode by default, even though I have both
disableDarkMode: false, defaultDarkMode: false
I have tried playing around with both options. No luck.

bug

All 9 comments

Can you provide more details? Demo or repo? Steps to reproduce?

Hi @EthanSK

Can you also verify that your computer/browser does not indicate a color scheme preference?

This per-user preference overrides the Docusaurus default.

You can know if you prefer the dark mode by running: window.matchMedia('(prefers-color-scheme: dark)').matches

Please reopen after providing the repo steps. The issue templates were created to help us help you, please do not ignore it.

window.matchMedia('(prefers-color-scheme: dark)').matches

Ah! Didn't even know this existed. My system theme was dark, so it was going dark despite defaultDarkMode: false or disableDarkMode: true in the docusaurus config.

Maybe it might be confusing/unwanted behaviour to have this, because there is currently no way to enforce either a default colour , or a colour full stop.

For example, if my Mac's system settings are on dark mode, I cannot with the current system have docusaurus light by default, or light only (without the option to switch) I really think there should be more options in the docusaurus config to overwrite prefers-color-scheme, or just change the behaviour

@EthanSK I agree there's something not totally ok with current settings and some things might be impossible

What do you want exactly? You want to setup a default theme to light or dark (which one?), even if user has a default preference?

@slorber For me specifically, I would like to set up a default theme to light, even if the user has a default dark system preference.

But I can imagine some other people might want it the other way round - default to dark even if user has a default light system preference.

I think the way it should be done is both defaultDarkMode and disableDarkMode should completely ignore the system preferences, and the developer has to explicitly enable somethnig like prioritizeSystemTheme to be able to use that.

@EthanSK what do you think of this PR?

https://github.com/facebook/docusaurus/pull/2939

@EthanSK what do you think of this PR?

2939

lgtm, thanks!

Hey all, this is feature is now released!
If you like it, don't forget to retweet 馃槃
https://twitter.com/docusaurus/status/1286715187983048704

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yangshun picture yangshun  路  27Comments

knowbody picture knowbody  路  23Comments

XavierNV picture XavierNV  路  24Comments

yangshun picture yangshun  路  70Comments

cameronelliott picture cameronelliott  路  28Comments