-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[Slider] - style rule names don't match other component's API and don't accept styles as expected #18010
Comments
Yeah I can see how this is unfortunate. @oliviertassinari Can we make this work without special syntax? |
@hoop71 The current CSS selector is: .Mui-disabled .MuiSlider-thumb {
/* foo */
} We apply the disabled pseudo-class once on the root of the slider. I would probably do: import styled from "styled-components";
const StyledSlider = styled(Slider)`
&.Mui-disabled {
.MuiSlider-thumb {
background-color: yellow;
}
}
`; https://codesandbox.io/s/create-react-app-rpv13 But maybe we should output the following to avoid leaks. .MuiSlider-root.Mui-disabled .MuiSlider-thumb {
/* foo */
} From what I understand, you would like to do: .Mui-disabled.MuiSlider-thumb {
/* foo */
} |
Ok, I have updated #18011 with an alternative proposal for the disabled state. It's closer to what we do in the rest of the codebase. I have left the vertical state unchanged. |
@oliviertassinari @eps1lon Yes this all makes sense. I do think it makes sense to be able to style like below without having to get the root involved.
I guess I am also unsure of what the
|
You need to think in terms of CSS selectors. $ reference another style rule |
You can resolve this selector manually:
|
Did you have a look at the changes I propose, does it match your problem? |
Yes! Looks good and should solve our needs. Thanks for your fast work as always! |
Current Behavior 😯
When trying to access the
disabled
rule of thethumb
rule the styles aren't applied as expectedexample
1
- Doesn't apply stylesinstead, you must apply them like with an unexpected
&
example
2
- Applies stylesExpected Behavior 🤔
You should be able to apply classes in the same was as other MUI components.
Steps to Reproduce 🕹
https://codesandbox.io/s/create-react-app-kkfhk
There are toggles to show the proposed solution.
Slider
must be disabled to see current issue and patch.Steps:
Slider
and usemakeStyles
hook to add custom stylesContext 🔦
Slider
styles to match the rest of the MUI APIYour Environment 🌎
The text was updated successfully, but these errors were encountered: