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

Adding new component variants does not work as documented for all components #29455

Open
2 tasks done
olivierbeaulieu opened this issue Nov 1, 2021 · 1 comment
Open
2 tasks done
Labels
new feature New feature or request

Comments

@olivierbeaulieu
Copy link

olivierbeaulieu commented Nov 1, 2021

The v5 documentation details how to create new variants for components. The example there with Button works great with TS because @mui/material/Button exports ButtonPropsVariantOverrides.

However, it seems that not all components follow this pattern - namely @mui/material/Menu and @mui/material/Select. There are probably more, but these two do not export something along the lines of SelectPropsVariantOverrides - their variants are merely a string union. It would be great to achieve consistency in how new variants are added and typed across components

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

There is no clear way to add new typed variants in TS for Select and Menu

Expected Behavior 🤔

It should work as well as it does with the Button component - I should be able to create new variants for MuiSelect in my theme file.

Steps to Reproduce 🕹

https://codesandbox.io/s/old-lake-ut7e1?file=/src/Demo.tsx

Context 🔦

I'm trying to create new variants for MuiSelect in my theme file.

Your Environment 🌎

`npx @mui/envinfo`
Browser: Chrome

  System:
    OS: macOS 11.6
  Binaries:
    Node: 14.17.6 - /usr/local/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 6.14.15 - /usr/local/bin/npm
  Browsers:
    Chrome: 95.0.4638.69
    Edge: Not Found
    Firefox: 93.0
    Safari: 15.0
  npmPackages:
    @emotion/react: latest => 11.5.0
    @emotion/styled: latest => 11.3.0
    @mui/core:  5.0.0-alpha.53
    @mui/icons-material: ^5.0.5 => 5.0.5
    @mui/lab: ^5.0.0-alpha.53 => 5.0.0-alpha.53
    @mui/material: latest => 5.0.6
    @mui/private-theming:  5.0.1
    @mui/styled-engine:  5.0.2
    @mui/system:  5.0.6
    @mui/types:  7.0.0
    @mui/utils:  5.0.1
    @types/react: latest => 17.0.33
    react: latest => 17.0.2
    react-dom: latest => 17.0.2
    typescript: latest => 4.4.4
@olivierbeaulieu olivierbeaulieu added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Nov 1, 2021
@siriwatknp siriwatknp added new feature New feature or request and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 2, 2021
@siriwatknp
Copy link
Member

Some component is not possible to extend the variant because the variant is bound to the component's logic. The Button variant can be extended because its variants are used in styling only.

We will definitely try to improve this experience in the second design system and see how we can make it works with @mui/material.

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
Projects
None yet
Development

No branches or pull requests

2 participants