-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
Easier way to override not-selected tab color #9742
Comments
It seems like changing rootPrimary should be enough, but if we override the rootPrimary, the new class does not seem to have the same precedence, so it appears to override rootPrimarySelected and rootPrimaryDisabled, despite the deliberate ordering of the applied classes here: https://github.com/mui-org/material-ui/blob/1c212d61e877cda72399e065f050b110d29fa0a6/src/Tabs/Tab.js#L175-L185 @oliviertassinari is this expected specificity behavior with class overrides? Seems that way. |
@paour Bootstrap solves this issue by increasing the specificity of the disabled and selected state. It's the only solution I can think of. To give an idea of what that looks like in practice. Before rootAccent: {
color: theme.palette.text.secondary,
},
rootAccentSelected: {
color: theme.palette.secondary.A200,
},
rootAccentDisabled: {
color: theme.palette.text.disabled,
},
rootPrimary: {
color: theme.palette.text.secondary,
},
rootPrimarySelected: {
color: theme.palette.primary[500],
},
rootPrimaryDisabled: {
color: theme.palette.text.disabled,
}, After rootAccent: {
color: theme.palette.text.secondary,
'&$rootSelected': {
color: theme.palette.secondary.A200,
},
'&$rootDisabled': {
color: theme.palette.text.disabled,
},
},
rootPrimary: {
color: theme.palette.text.secondary,
'&$rootSelected': {
color: theme.palette.primary[500],
}
'&$rootDisabled': {
color: theme.palette.text.disabled,
},
},
rootSelected: {}
rootDisabled: {} This would be an important a profound change. |
@kgregory The order of the class names in the DOM doesn't matter. |
I'm in favor of such change. |
Sounds good |
For a specific tab bar, I wanted to tweak the color of not-currently-selected tabs to make it more different from the disabled state. Using the
classes
system, I had to overriderootPrimary
(expected), but since that style is applied to all three states of the tab, I had to also overriderootPrimaryDisabled
androotPrimarySelected
.Expected Behavior
It would be easier if there was an extra class
rootPrimaryUnselected
that I could use to set just the attributes specific to the unselected state, whilerootPrimary
would contain attributes common to all three states.Your Environment
The text was updated successfully, but these errors were encountered: