Capacitor app with dark mode #5055
Unanswered
DuncanTLaw
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am coding using Angular Ionic with Capacitor. I would like to make a toggle for dark mode:
Light | Dark | Auto
where light or dark is the appearance of the PWA and 'Auto' follows system dark/light mode.
I have tried removing the CSS rule
@media (prefers-color-scheme: dark)
then dynamically addingclass = "dark"
which does work, however when the system OS toggles back to light mode the app goes back to light mode. How can I make sure that the theme is retained? I have addedwindow.addEvenetListener('change', (ev) => { this.dark = ev }
to listen to the change event.Beta Was this translation helpful? Give feedback.
All reactions