Skip to content

Switching between 'system' and user toggled Color Modes #2264

Answered by hasparus
fbolcic asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, this would be the perfect behaviour. This is a very good question.

So the problem is, because of useColorSchemeMediaQuery is set to system, Theme UI disregards the color scheme value in localStorage, right?

Unfortunately, I don't have a built-in convenient solution for you. Unifying color mode state and the color scheme media query options into one value is a very neat idea for future versions.

I've hacked a workaround really quickly — https://codesandbox.io/s/loving-clarke-iofv4t?file=/src/App.tsx
This is by no means elegant, but maybe it can help you just a bit.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@fbolcic
Comment options

@hasparus
Comment options

@fbolcic
Comment options

@fbolcic
Comment options

@hasparus
Comment options

Answer selected by fbolcic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants