-
-
Notifications
You must be signed in to change notification settings - Fork 32.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
[docs] Component Variants #34517
Comments
@mnajdova but just for my understanding, is the behavior that the variants (at least) work like I described something I can rely on? Or is this more a coincidence that I shouldn't consider a reliable? |
I wouldn't rely on it, as we haven't tested this behavior. For example, there may e issues like |
Duplicates
Latest version
Steps to reproduce 🕹
Steps:
Current behavior 😯
The docs explicitly say "You can use the variants key in the theme's components section to create new variants to Material UI components."
I created a new button variant like described in the docs. Also added the
ButtonPropsVariantOverrides
module augmentation.Worked great and as expected.
But I interpreted the sentence above from the docs that this is basically doable for all components. So I created in the same way for a
CardHeader
a new variant. But realized that there are not types likeCardHeaderPropsVariantOverrides
. Read a bit through the issues here and understood that this is basically not possible for ALL components. Just for some which already have variants.But the weird thing is: it works somehow. Though I'm not seeing a class for my "small" variant on the
Cardheader
likeMuiCardHeader-small
, but the styles I defined in the theme variant are applied.This is how the DOM element looks like (I realized that the variant property being interpreted as a html attribute)
And
css-wha30x-MuiCardHeader-root
is applying my variant styles.Maybe its just me being confused about this. But I just wanted to leave it here in case someone else is also confused :)
Expected behavior 🤔
A bit clearer documentation if variants can be used on all components or on only some, like button etc.
Context 🔦
No response
Your environment 🌎
npx @mui/envinfo
The text was updated successfully, but these errors were encountered: