[system] Support sx on all primitive elements
See original GitHub issueSummary 💡
It would be great if we can support the sx
props on the primitives with jsx pragma. That would basically help us to replace
<Box
component="img"
sx={{
display: "block",
mr: { sm: 3 },
mx: { xs: "auto", sm: 0 },
mb: { xs: 1, sm: 0 },
width: { xs: "4rem", sm: "6rem" },
height: { xs: "4rem", sm: "6rem" },
borderRadius: "50%"
}}
src="https://material-ui.com/static/logo_raw.svg"
/>
with
<img
sx={{
display: "block",
mr: { sm: 3 },
mx: { xs: "auto", sm: 0 },
mb: { xs: 1, sm: 0 },
width: { xs: "4rem", sm: "6rem" },
height: { xs: "4rem", sm: "6rem" },
borderRadius: "50%"
}}
src="https://material-ui.com/static/logo_raw.svg"
/>
For instance https://xstyled.dev/docs/emotion/#use-css-prop or https://theme-ui.com/sx-prop. It seems that we could only support it with emotion, which is OK-ish as it’s the default engine 🙃.
Motivation 🔦
This would help us to move away from templates that would use the Box
component everywhere. On the other hand, we plan to support the sx
prop on all core components, so it may not be that bad, but still, I think this is something that will bring us in the right direction.
Raised in #23053
Issue Analytics
- State:
- Created 3 years ago
- Reactions:43
- Comments:6 (4 by maintainers)
Top Results From Across the Web
[system] Support sx on all primitive elements #23220 - GitHub
// just an example of importing primitives import { mui } from '@material-ui/core/primitives'; // remain the same const styles = (theme: Theme) ...
Read more >MUI on Twitter: "v5.0.0-alpha.14 is out ! Extend the system with ...
Extend the system with a new `sx` prop Upgrade Popper.js from v1 to v2 ... [system] Support sx on all primitive elements ·...
Read more >MUI System - Overview
MUI System is a set of CSS utilities to help you build custom designs more efficiently when working with MUI component libraries like...
Read more >COUNTING PRIMITIVE ELEMENTS IN FREE GROUPS - UPC
Note that this notion does not depend on the set of generators because for every other finite generating system Y ,. 6. Page...
Read more >XML Schema Part 2: Datatypes Second Edition - W3C
The type system defined in this specification provides a ... All ·minimally conforming· processors ·must· support year values with a minimum ...
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 FreeTop 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
Top GitHub Comments
There were also discussions about changing the prefered API from:
to
inspired by https://xstyled.dev/. This is superior when you have long children. The closing tag is more helpful in the latter option (
</x.footer>
is more helpful than</Box>
).See https://github.com/mui-org/material-ui/pull/27207#issuecomment-880731270 for why it could be valuable for developers.
There’s no need for a pragma, you can release a Babel macro in a similar fashion to Styled Components’.