by Springtime · 3y ago · 0 comments
Then in CSS setting both the prefers-color-scheme media queries but also configuring how the colors should react when the checkbox state is changed. So if a user has prefers-color-scheme:light then when the theme switcher is clicked it styles the page the opposite (example selector: .theme-switch:checked ~ .pagebody). Can also add such styling as a default outside of media queries, too, for browsers that don't recognize prefers-color-scheme.
Saving the state across pages however requires some JS but just wanted to comment that CSS-only toggles are possible.
No comments yet.