This is a change request.
In My opinion, it would be helpful if the color prop of Typography is set to inherit by default.
It would also match expectation that when I set a color on a parent component then all children inherit the color (unless overridden).
Additionally, it would be awesome if this could be done for Icons as well.
When I am working on a customised design, I am finding myself writing color="inherit" on Many of the Typography elements across components.
Typography elements.Now even though the color is explicitly defined in parent component, still typography needs to have a prop.
Having to specify color prop many times.
| Tech | Version |
|--------------|---------|
| Material-UI | |
| React | |
| browser | |
| etc | |
Additionally, it would be awesome if this could be done for Icons as well.
@sambhav-gore I believe it's already the case.
it would be helpful if the color prop of Typography is set to inherit by default.
I have audited my code base. I have found the following occurrence for the usage of the Typography component:
color="inherit": 23color="primary": 0color="secondary": 0color="error": 0color="textSecondary": 0So I'm against this change.
@sambhav-gore
When I am working on a customised design, I am finding myself writing color="inherit" on Many of the Typography elements across components.
You could create a very simple wrapper for that: const InheritColorTypography = (props) => <Typography color="inherit" {...props} />
@leMaik this is a good suggestion, I didn't even think about it.
@sambhav-gore We are personally wrapping ~30 components from Material-UI on my project in order to apply some tweaks. It's IMHO the best approach to follow. I don't think that the component overhead has much impact in from the JavaScript VM perspective.
The main issue with the wrapping pattern is really about educating the team to use the "right" version of the components. I don't have a good answer to this problem. Having a storybook with the wrapped components can help. Using naming convention can help. Writing an eslint plugin forbidding direct import can help.
Thank you for consideration and the alternate solution is fine with me.
Most helpful comment
@sambhav-gore
You could create a very simple wrapper for that:
const InheritColorTypography = (props) => <Typography color="inherit" {...props} />