Skip to content
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

Adapt to the dark theme of modern browsers corresponding to the scroll bar under the dark theme #5566

Closed
4 tasks done
SuperManito opened this issue May 27, 2023 · 14 comments
Closed
4 tasks done
Labels
change request Issue requests a new feature or improvement resolved Issue is resolved, yet unreleased if open

Comments

@SuperManito
Copy link

Context

add head meta

<meta name="color-scheme" content="<light or dark>">

Description

The scroll bar can use the dark mode. If the scroll bar still displays the default light mode after switching to the dark mode it will be uncomfortable

Related links

Use Cases

Docusaurus2 Vuepress

image
image

Visuals

No response

Before submitting

@squidfunk
Copy link
Owner

squidfunk commented May 27, 2023

Thanks for suggesting! Fixed in fe0c966. We opted for the CSS color-scheme property, as it can be directly defined in the color schemes that we offer. Additionally, it's easier for authors to set those in their own custom color schemes.

As an addendum, here's a good read on color-scheme.

@squidfunk squidfunk added change request Issue requests a new feature or improvement resolved Issue is resolved, yet unreleased if open labels May 27, 2023
@SuperManito
Copy link
Author

Thanks for suggesting! Fixed in fe0c966. We opted for the CSS color-scheme property, as it can be directly defined in the color schemes that we offer. Additionally, it's easier for authors to set those in their own custom color schemes.

As an addendum, here's a good read on color-scheme.

Your document website looks the same as it did before the fix commit

@SuperManito
Copy link
Author

Thanks for suggesting! Fixed in fe0c966. We opted for the CSS color-scheme property, as it can be directly defined in the color schemes that we offer. Additionally, it's easier for authors to set those in their own custom color schemes.

As an addendum, here's a good read on color-scheme.

I have some other suggestions. I think the background color in dark mode should be more towards black. Preferably controlled by the user via css variables.

The problem now is that when the background color or theme color is changed, the background color of some button hover does not change accordingly. This often requires providing multiple tones of different depths at the same time.

So my suggestion has two solutions: one is that the user only defines one main color, and the auxiliary colors of other depths are automatically provided by dependencies, such as tinycolor of npm; the other is to define a whole set of variables in css instead. Docusaurus provides an online solution styling-your-site-with-infima

@squidfunk
Copy link
Owner

Your document website looks the same as it did before the fix commit

The changes haven't been merged in Insiders yet, and our site is built with Insiders. We'll do that before the next release.

The problem now is that when the background color or theme color is changed, the background color of some button hover does not change accordingly. This often requires providing multiple tones of different depths at the same time.

So my suggestion has two solutions: one is that the user only defines one main color, and the auxiliary colors of other depths are automatically provided by dependencies, such as tinycolor of npm; the other is to define a whole set of variables in css instead. Docusaurus provides an online solution styling-your-site-with-infima

Please create a discussion for your suggestion with some screenshots or a screencast, so we can better understand what you want to see ☺️ It's beyond the scope of this issue, and we shouldn't mix feature requests in issues. Please also note that Material for MkDocs does not have an author-facing build step that compiles the CSS – 99% of users do not have a Node.js environment in their build pipeline available. For this reason, we decided that CSS variables are the best solution for overrides. If you want to deduce tints, you can always fork the theme, or set up a Node.js environment yourself and compute CSS variables, adding that as extra CSS. It's actually not that hard. For the majority of users, the current solution is simpler.

@squidfunk
Copy link
Owner

Released as part of 9.1.15!

@SuperManito
Copy link
Author

Released as part of 9.1.15!

Are you sure it works? I think this should be provided by default rather than user-defined.

@squidfunk
Copy link
Owner

Yes, color-scheme is definitely being defined as of 9.1.15. We provide it for the included color schemes (default and slate). For custom color schemes, you must just set it accordingly:

// Slate theme, i.e. dark mode
[data-md-color-scheme="slate"] {
// Indicate that the page is rendered with a dark color scheme
color-scheme: dark;

@SuperManito
Copy link
Author

color-scheme: dark;

no effect

@squidfunk
Copy link
Owner

squidfunk commented Jun 6, 2023

Works perfectly for me. If I visit our documentation site, and add an unstyled input field to the content, it will adapt to the OS color scheme:

Bildschirm­foto 2023-06-06 um 10 25 13

If I uncheck color-scheme: dark, it doesn't adapt. Thus, it behaves as advertised:

Bildschirm­foto 2023-06-06 um 10 25 41

@SuperManito
Copy link
Author

SuperManito commented Jun 6, 2023

Works perfectly for me. If I visit our documentation site, and add an unstyled input field to the content, it will adapt to the OS color scheme:

Bildschirm­foto 2023-06-06 um 10 25 13 If I uncheck `color-scheme: dark`, it doesn't adapt. Thus, it behaves as advertised: Bildschirm­foto 2023-06-06 um 10 25 41

Your screenshot doesn't show scrollbars. I raise this question mainly to solve the display problem of the browser's default scrollbar under the dark theme.

After my tests, this may need to be defined on the head tag. Because I have tried to do this with css before raising this issue

@squidfunk
Copy link
Owner

squidfunk commented Jun 6, 2023

Okay, so we might need to set the color-scheme meta tag for that. We can't set it in the template, we must set it via JavaScript, as pressing the toggle to change the scheme will also change the value of the meta tag. Re-opening.

@squidfunk squidfunk reopened this Jun 6, 2023
@squidfunk
Copy link
Owner

squidfunk commented Jun 6, 2023

Fixed in d2f4034. The color-scheme meta tag is now synchronized with the palette. Please check if this fixes you reported. Thank you.

@SuperManito
Copy link
Author

Fixed in d2f4034. The color-scheme meta tag is now synchronized with the palette. Please check if this fixes you reported. Thank you.

image
image

It's worked

@squidfunk
Copy link
Owner

Released as part of 9.1.16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change request Issue requests a new feature or improvement resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

2 participants