Nested / complex conditions #322
Unanswered
bradbarrow
asked this question in
Q&A
Replies: 2 comments 2 replies
-
I think I'm having the same question. I would also like to combine conditions in sprinkles for the same properties (in my case colors). In my use case it would be combining const styles = atoms({
background: {
lightMode: 'white',
darkMode: 'black',
hover: {
lightMode: 'red',
darkMode: 'blue',
}
}
}); To achieve the same that I would do in TailwindCSS with: <button class="bg-white dark:bg-black hover:br-red dark:hover:bg-blue">Button</button> Is that possible at the moment – if yes, how do I set that up? |
Beta Was this translation helpful? Give feedback.
1 reply
-
I recently learned that that you can't nest the conditions but one can have multiple queries: const colorProperties = defineProperties({
conditions: {
lightMode: {},
darkMode: { '@media': '(prefers-color-scheme: dark)' },
lightModeHover: {
'@media': '(prefers-color-scheme: light)',
selector: '&:hover'
},
darkModeHover: {
'@media': '(prefers-color-scheme: dark)',
selector: '&:hover'
}
},
defaultCondition: 'lightMode',
properties: {
color: vars.colors,
background: vars.colors
}
}); So you can do: const styles = sprinkles({
background: {
lightMode: 'white',
darkMode: 'black',
lightModeHover: 'red',
darkModeHover: 'blue'
}
}); |
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
Say I want a different color on desktop and mobile but furthermore (for each of those) a different color for light/dark mode (4 colors total).
How might I achieve that?
Is this possible with just the above APIs or might I have to get cleve with composition?
Additional question
Also, even without wanting to target them all together, if I have
color
as a property ofresponsiveStyles
andlightDarkStyles
, can this ever work? Or must they always be exclusive?Beta Was this translation helpful? Give feedback.
All reactions