-
Notifications
You must be signed in to change notification settings - Fork 496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mkdocs: add light/dark mode toggle #3637
Conversation
@@ -27,7 +27,7 @@ body, input { | |||
font-family: cash-market, "Helvetica Neue", helvetica, sans-serif; | |||
line-height: normal; | |||
font-weight: bold; | |||
color: #353535; | |||
color: var(--md-default-fg-color) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change means the header colour dynamically changes between light/dark mode
Before the colour of headers is hardcoded to be grey, even in dark mode:
After, using the var, the colour will dynamically change:
The full set of css vars that mkdocs provide are available here: https://github.com/squidfunk/mkdocs-material/blob/2569d4f0884b9fe3be934215ce0cfddf8efc94b8/src/assets/stylesheets/main/_colors.scss
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
Is it possible to use the media query to auto-switch to light/dark mode? Don't know, if other people would want this behavior too. |
The settings in this PR should evaluate the browser preferences to select the correct mode https://squidfunk.github.io/mkdocs-material/setup/changing-the-colors/#system-preference If you're asking about auto-switching based on time-of-day, the docs say that's not a publically available feature yet |
Yes, I mean this nice but private feature. But I am fine with the current publicly available feature. |
Adds a light/dark mode toggle to the docs
Live example: https://asemy.github.io/sqldelight/
Documentation here: https://squidfunk.github.io/mkdocs-material/setup/changing-the-colors/#color-palette-toggle
Example config here: https://github.com/squidfunk/mkdocs-material/blob/2569d4f0884b9fe3be934215ce0cfddf8efc94b8/mkdocs.yml#L60-L72