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

Ability to create custom classes in overrides #15454

Closed
2 tasks done
kaywyeex opened this issue Apr 23, 2019 · 5 comments
Closed
2 tasks done

Ability to create custom classes in overrides #15454

kaywyeex opened this issue Apr 23, 2019 · 5 comments
Labels
new feature New feature or request package: material-ui Specific to @mui/material
Milestone

Comments

@kaywyeex
Copy link

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

Expected Behavior 🤔

Addition of an unknown class in overrides(or elsewhere), should make it possible to use to the given className matching prop on a component.

Current Behavior 😯

It currently throws a warning, saying that the class you're trying to override doesn't exist. Which makes sense!

Examples 🌈

Theme

    MuiTypography: {
      colorSuccess: {
        color: green[500]
      }
    }

Component

<Typography color="success" />

Context 🔦

I find myself wanting to use additional colors (eg. green for success) on components like Typography on occasion, and noticed it figures out the color by matching capitalized props against the classes.

This presented me with the idea of adding my own prop (colorSuccess), in the hopes that I would be able to use it globally, on a Mui imported component.

This however, doesn't seem possible today. Unless I've missed something?
I could see an argument against this, (transparency?), however in a large project with several people, this would be a pretty dope feature, since it prevents you from having to repeat class implementations (or create yet another file in /components/).

Thanks in advance!

@eps1lon
Copy link
Member

eps1lon commented Apr 23, 2019

This is technically possible currently: https://codesandbox.io/s/zyjwxqj04. However it relies on implementation details.

We're working on a better color prop API (see #13875) that should cover this use case. For more advanced overrides I would recommend using your own wrapper component. We can't cover every single use case via props only.

@eps1lon eps1lon added new feature New feature or request package: material-ui Specific to @mui/material labels Apr 23, 2019
@oliviertassinari
Copy link
Member

oliviertassinari commented Apr 23, 2019

Could it be a duplicate of #13875?

The success, danger, warning and info are values I think that we should support by default.

@kaywyeex
Copy link
Author

@eps1lon
Agreed, however it logs a warning in the console, which is why I figured one should probably shy away from doing so. 🤔

@oliviertassinari
I agree with the default values you mentioned, given those are the ones we usually find using the most. Would probably also be less painful to implement than custom colors.(?) 💯

@roflc0pter
Copy link

Is this in progress? Otherwise I would like to contribute.

@oliviertassinari
Copy link
Member

I'm closing for #13875. We have solved most of the infrastructure issues. Now, it's about making sure it works end-to-end with each use cases

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

No branches or pull requests

4 participants