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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to set component props other than style to new component variants #27836

Open
1 task done
yblok13 opened this issue Aug 18, 2021 · 1 comment
Open
1 task done
Labels
new feature New feature or request package: styled-engine Specific to @mui/styled-engine

Comments

@yblok13
Copy link

yblok13 commented Aug 18, 2021

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

Summary 馃挕

Just like you can set style on a custom variant, we should be able to set all the other props for each variant.

Examples 馃寛

const theme = createTheme({
  components: {
    MuiChip: {
      variants: [{
        props: { variant: '0' },
        label: 'DRAFT',
        sx: { bgcolor: 'orange', color: 'black' }
      }]
});

function StatusBar(statusNumber = 0) {

  return (
    <ThemeProvider theme={theme}>
      <Chip variant={statusNumber} />
    </ThemeProvider>
  )
}

Motivation 馃敠

Instead of creating a bunch of custom components, it's super easy to just declare the variant on the component instead of all the other props as well. I also rather use sx prop than the style prop.

@yblok13 yblok13 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 18, 2021
@eps1lon eps1lon added new feature New feature or request package: styled-engine Specific to @mui/styled-engine and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 23, 2021
@eps1lon
Copy link
Member

eps1lon commented Aug 23, 2021

Thanks for the feedback.

Note that the best approach still is to create custom components. The theming based approach always has the downside of improving bundle size globally and makes discoverability of the implementation harder.

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: styled-engine Specific to @mui/styled-engine
Projects
None yet
Development

No branches or pull requests

2 participants