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

Don't store dark/light toggle if it matches the OS setting #73

Open
odrotbohm opened this issue Jan 6, 2023 · 3 comments
Open

Don't store dark/light toggle if it matches the OS setting #73

odrotbohm opened this issue Jan 6, 2023 · 3 comments

Comments

@odrotbohm
Copy link
Contributor

It would be nice if the CSS could automatically detect whether to use dark or light mode based on the user theme (via media queries).

@philwebb
Copy link
Contributor

philwebb commented Jan 6, 2023

We should already do this. See

"(prefers-color-scheme: dark)"
and
return theme ? theme === "dark" : prefersDarkColorScheme.matches;
.

The problem might be that the theme has been toggled in the past and saved to local storage.

@odrotbohm What does an incognito window do?

@odrotbohm
Copy link
Contributor Author

You're right. An incognito window brings up the dark theme on a dark OS. I guess I've clicked on the button just to test the switch at some point. A localStorage.removeItem("theme") did the trick. Wonder if that could be made a bit more convient to reset? Additional icon next to the switch in case a value is set and a click on it removing the value?

@philwebb
Copy link
Contributor

philwebb commented Jan 7, 2023

Perhaps we just shouldn't save a local value if it matches the detected one.

@philwebb philwebb added this to the 0.0.x milestone Jan 7, 2023
@philwebb philwebb changed the title Automatically detect dark/light mode based on OS settings Don't store dark/light taggle if it matches the OS setting Jan 7, 2023
@wilkinsona wilkinsona changed the title Don't store dark/light taggle if it matches the OS setting Don't store dark/light toggle if it matches the OS setting Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants