-
Notifications
You must be signed in to change notification settings - Fork 113
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
Dark theme from CSS media query #447
Comments
If there is an easier or more flexible way to work with a custom theme I'm in for it. What I like about the current solution is that you can programmatically control what theme is used by adding/remove a class name. So you can toggle not only dark theme, but any custom theme. Is there a way to allow for both? I.e. be able to load the dark theme CSS and have control over whether to use it or not both via JS (toggling a classs) and via CSS (like using |
So given the scenario that the user has their device set to dark theme, but visits a website that embeds jsoneditor and toggle it to light theme - then we would need a second CSS class
The app I currently work on does this, we just let the OS / browser guide us to which theme to render, but we provide our users a way to render the app in a specific theme from their preference page. If you wanted, this feature could be provided in a separate CSS file that developers opt-in to e.g.
... But given the widespread adoption of light / dark themes in at the OS level and browser level... I'm not sure you'd want to go against the grain. |
I'm totally for using I was reading up on the following two articles that describe how to achieve this:
They both come up with about the same solution to allow toggling system/light/dark, see this example "Overriding OS Settings". However the solution involves repeating all theme variables twice. I'm not sure yet how we could prevent that and provide a `jse-theme-dark.css that supports both being loaded based on either the system preference or a choice. Any ideas? |
Any idea on how to go about this? Maybe we should deliver two different files, one for each purpose, and have an internal built tool that can generate one from the other. |
@josdejong What are your thoughts on providing the dark theme via
@media (prefers-color-scheme: dark)
instead of having to add thejse-theme-dark
class?The text was updated successfully, but these errors were encountered: