Select dark mode by default #571
-
Hi @Mister-Hope, Thanks for putting together this amazing theme! We're looking into using the dark theme only. Is there a way we can specify dark mode to be on by default? Best, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Currently, no. Here is a possible workaround:
export default {
mounted(){
document.body.classList.add('theme-dark');
}
}
|
Beta Was this translation helpful? Give feedback.
-
I cannot catch up with an idea. It has to work on SSR. And here is the document: I can only handle the render result of If I try to add classes or attributes on this div to control the css vars, that will make the global UI appearance fail in darkmode. If I want to modify If you have any idea on how to implement this feature, welcome to comment. If you don't know either, you can try the workaround I described above. |
Beta Was this translation helpful? Give feedback.
-
Was thinking of adding another config option to darkmode called enabled.
And adding some code in mounted for that component to call
this.setDarkmode(true) if configDarkmode === “enabled”. That should go
through the same code path as if the user would click on the darkmode
button in the UI.
Let me know if that would work. Was looking into making a PR and wasn’t
sure how to build the theme to test or make a release.
|
Beta Was this translation helpful? Give feedback.
Currently, no.
Here is a possible workaround:
themeConfig.darkmode: 'disable'
mounted
lifetime to addtheme-dark
class on body.I may support this in the next version, but I will take a careful look on letting the SSR render the dark-theme by default after setting an optin while remaining the rest feature working.