-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
textStyles defined inside extendTheme aren’t applied correctly #3884
Comments
Hi! |
Bump
…On 2 Jun 2021, 19:03 +0200, stale[bot] , wrote:
Hi!
This issue hasn't seen any activity recently. We close inactive issues after 35 days to manage the volume of issues we receive.
If we missed this issue or you want to keep it open, please reply here. That will reset the timer and allow more time for this issue to be addressed before it is closed.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Tested it with the latest version 1.6.3, still the same problem. Sadly, at the moment |
Any updates on this?
|
Bump – I really would love to see a solution for this. |
Same, can't manage to have Here's a narrowed down example in CodeSandbox
const customTheme = extendTheme({
textStyles: {
h1: {
fontSize: "32px",
color: "blue",
},
h2: {
fontSize: "24px",
color: "red",
},
h3: {
fontSize: "16px",
color: "orange",
}
}
}); And used this way: <VStack spacing="8px">
<Heading as="h1" textStyle="h1">
Heading 1
</Heading>
<Heading as="h2" textStyle="h2">
Heading 2
</Heading>
<Heading as="h3" textStyle="h3">
Heading 3
</Heading>
</VStack> |
After some further investigation it looks like we should be using theme |
Sadly this doesn’t tackle the base problem – just have a look for example at my initial sandbox where I applied To cite the documentation:
So as described I just want to be able to apply my pre-definied |
Yes, this is definitely a bug as it should work as stated in the documentation. Should have made it clear in my prior comment. The suggestion is a workaround that might not work for everywhere but as it appears to be a complex issue on chakra's side that's all we can do for now. I hope they can fix it in an upcoming release as it's not a satisfying solution. |
This issue occurs with both text and layer styles. It's possible it occurs with I'm not sure why priority was given to the theme. It would seem that what is specified in the JSX would have a higher precedence. If you were to specify the attributes separately in JSX, I can remove the style lookup, but I'm not sure what the thinking was at the time. There are no comments in the code nor is there anything in the documentation about theme styles having precedence over text and layer styles. ** Update ** |
Any word on this? It looks like there's an umerged PR aiming to fix this. |
Guys, and if you adopt managing those text styles with global settings instead textStyles? Instead of using:
and
Try it:
Share with me if it works. Thank you! |
@stridesdigital That defeats the purpose of Text and Layer Styles. You don't get the same advantage using global styles. One can define a style with |
@primos63 Preserving font style properties through your project makes it easier to maintain and make it more consistent. But, if you really need to change a specific text style, instead of facing a Chakra UI bug (topic related) by using textStyle, you can customize your extended theme. Instead of using this:
You can try this:
Your HeadingStyles will look like that:
And finally, you can use for global style:
And this for another customized value:
What did you think? Does this provide any help? |
The issue was with the precedence order for which I believe I fixed and submitted a PR which has yet to be reviewed. I have no control over that. Workarounds should be temporary. |
🐛 Bug report
Styles defined via
textStyles
are not applied correctly although they’re set withinextendTheme
.💥 Steps to reproduce
textStyles which should be applied
body styles
✅
font-size
fromtextStyles
is used.💥
font-family
andline-height
aren’t applied bytextStyles
.Heading styles
💥 Neither
font-family
norfont-size
andline-height
are applied bytextStyles
.Button styles
✅
font-family
fromtextStyles
is used.💥
font-size
andline-height
aren’t applied bytextStyles
.Text styles
✅ All styles set by
textStyles
are used.💻 Link to reproduction
CodeSandbox reproduction: https://codesandbox.io/s/textstyle-problems-ibu9h?file=/src/App.tsx:176-186
🧐 Expected behavior
Styles like
font-family
,font-size
andline-height
defined intextStyles
should be applied when passed throughextendTheme
according to this comment. This behaviour should be consistent and reliable when used on all elements (even<body />
).🧭 Possible Solution
–
🌍 System information
📝 Additional information
–
The text was updated successfully, but these errors were encountered: