Skip to content
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

[system] Propagate custom style props to component SxProps. #27673

Open
1 task done
R-Bower opened this issue Aug 10, 2021 · 0 comments
Open
1 task done

[system] Propagate custom style props to component SxProps. #27673

R-Bower opened this issue Aug 10, 2021 · 0 comments
Labels
new feature New feature or request package: system Specific to @mui/system

Comments

@R-Bower
Copy link
Contributor

R-Bower commented Aug 10, 2021

  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 💡

  • Custom props created using style aren't propagated to the SxProps which enhances each MUI component. While the SxProps prop technically works with any valid CSS, the theme-aware transformers aren't applied.

Examples 🌈

import {Box} from "@material-ui/core"
import styled from "@emotion/styled"
import {style} from "@material-ui/system"

const bgStyle = style({
  cssProperty: "backgroundColor"
  prop: "bg",
  themeKey: "palette",
})

const CustomBox = styled(Box)`
  ${bgStyle};
`

// doesn't work
<CustomBox sx={{bg: "background.primary"}} />

One way to get it working today would be to create a custom Sx function and then override the default Sx prop on each component.

What if we provided additional transformers at the ThemeProvider level? Perhaps we could expose a method to override getThemeValue globally?

Updated example*

@R-Bower R-Bower added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 10, 2021
@eps1lon eps1lon added new feature New feature or request package: system Specific to @mui/system and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request package: system Specific to @mui/system
Projects
None yet
Development

No branches or pull requests

2 participants