Responsive styles on global theme #143
Answered
by
mattcompiles
elliotschultz
asked this question in
Q&A
-
Hi there, really loving this library. I'm trying to create a responsive theme and the example provided to demonstrate (For quick reference, this is it:) import { createThemeContract, style, assignVars } from '@vanilla-extract/css';
export const vars = createThemeContract({
space: {
small: null,
medium: null,
large: null
}
});
export const responsiveSpaceTheme = style({
vars: assignVars(vars.space, {
small: '4px',
medium: '8px',
large: '16px'
}),
'@media': {
'screen and (min-width: 1024px)': {
vars: assignVars(vars.space, {
small: '8px',
medium: '16px',
large: '32px'
})
}
}
}); My question is: is it possible to have the same behaviour but target the Essentially the goal is to have a globally scoped, responsive theme. I've been playing around a little with |
Beta Was this translation helpful? Give feedback.
Answered by
mattcompiles
May 17, 2021
Replies: 1 comment 1 reply
-
The following should work. globalStyle(':root', {
vars: assignVars(vars.space, {
small: '4px',
medium: '8px',
large: '16px'
}),
'@media': {
'screen and (min-width: 1024px)': {
vars: assignVars(vars.space, {
small: '8px',
medium: '16px',
large: '32px'
})
}
}
}); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
elliotschultz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following should work.