Responsive variants take precedence over inline sx styles
See original GitHub issueIssue
Works as intended. DripText gets the styles fonts-size: 2px:
const theme = {
text: {
primary: {
fontSize: 40,
},
},
}
...
<DripText variant="primary" sx={{ fontSize: 2 }}>
joi
</DripText>
Doesn’t work as intended. DripText maintains the responsive styles e.i 40px, 50px, 60px:
const theme = {
text: {
primary: {
fontSize: [40, 50, 60],
},
},
}
...
<DripText variant="primary" sx={{ fontSize: 2 }}>
joi
</DripText>
Other notes
- When inline sx
fontSizeis changed to a string value e.i"2px"I get the same behavior. - Reproduced on example app and in my own applications
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
The Ultimate Guide to the MUI 'sx' Prop - Smart Devpreneur
Both of the new APIs offer the following advantages over makeStyles : ... Easy responsive styling – properties in sx can accept an...
Read more >Responsive values is variant styles override sx styles #720
Pretty sure I'm having the same issue: My cards.primary defines p: [2, 3] . To set padding to 0, I have to do...
Read more >The `sx` Prop - Theme UI
The sx prop lets you style elements inline, using values from your theme. To use the sx prop, add the custom /** @jsxImportSource...
Read more >Style library interoperability - Material UI - MUI
Note: Most CSS-in-JS solutions inject their styles at the bottom of the HTML <head> , which gives MUI precedence over your custom styles....
Read more >Component Style - Chakra UI
Variant : A component can have different visual styles (e.g. outline, solid, ghost); Color scheme: For a given variant, a component can have...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

In terms of order, precedence should take place based on each item in the array. So a responsive value from
superStyleshould override any style for the same style key before it. It looks like this is just checking if a non-responsive value already exists for a given key, and if it does, use that. I believe this would mean that we wouldn’t be able to override theme values with any responsive style props.I’ll think this one over as well.
The main question: how do we get styles to cascade in order from top to bottom of
styleArray, where each style overwrites the previous one, and where we only sometimes have a responsive array?Closing since there hasn’t been activity here in a while