Use Recipe in globalStyle
for body
#601
-
Hello, is there a way to apply a recipe to the I have a globalStyle('body', {
margin: 0,
font({ size: 'medium' }) // doesn't work
}) |
Beta Was this translation helpful? Give feedback.
Answered by
AndrewLeedham
Apr 8, 2022
Replies: 1 comment
-
@bernhardw recipe runtime functions return a string of the generated class name. So there is no way to extract the style rules from it. You could do something like this: const fontStyles = {
base: {
lineHeight: '1.5em'
},
variants: {
size: {
medium: {
fontSize: '1rem'
}
}
}
}
export const font = recipe(fontStyles);
globalStyle('body', {
margin: 0,
...fontStyles.base,
...fontStyles.variants.size.medium
}); You would likely need to play around with the types to get better intellisense. But as far as I am aware there is no native way to do this. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
bernhardw
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@bernhardw recipe runtime functions return a string of the generated class name. So there is no way to extract the style rules from it. You could do something like this:
You would likely need to play around with the types to get better intellisense. But as far as I am aware there is no native way to do this.