Ability to create global theme with media queries #1119
bassoGeorge
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
Okay, with a bit of digging, it turns out I can use globalStyle(':root', {
'@media': {
'(prefers-color-scheme: light)': {
vars: assignVars(ContextualColors, lightThemeColors)
},
'(prefers-color-scheme: dark)': {
vars: assignVars(ContextualColors, darkThemeColors)
},
},
}); From the documentation it wasn't immediately obvious that assignVars can also be used with a globalThemeContract. Makes sense, but getting to this point was a bit of maze. This is the best way to go about it right? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm enjoying VanillaExtract a lot, but have run into a bit of a roadblock.
Context
:root
element.createGlobalThemeContract
API. This allows me to have a nice typesafe object to refer to theme variables.createGlobalTheme
API, attaching them to their:root
selectors.Problem
I need to extend this with the ability to start with a sensible default based on the
@media (prefers-color-scheme: dark)
media query. ThecreateGlobalTheme
API only supports a string selector.Any way I can do this? The following is an example code snippet which illustrates the issue.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions