-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
Removing a css property from the theme (override) without impacting another #36092
Comments
The only way to have that experience is to adopt CSS variables to components (so that the value can fallback to the initial one) but it depends on the use case if it is worth adding them. |
I'm currently using a custom CSS variables process (duplicating the theme to make it available in css modules stylesheets), but the initial value can't be erased. Do you have an example of what you are referring to? @siriwatknp |
I'm trying to achieve the exact same thing. Any idea why MuiCardContent has a different bottom padding when it's the last child? |
@RemyMachado @eloiqs Here is one example: Screen.Recording.2566-04-28.at.09.42.32.mov// the component
const Div = styled('div')`
--p: 1rem;
--p-last: 1.5rem;
padding: var(--p);
&:last-child {
padding-bottom: var(--pb-last, var(--p));
}
` By default, the last component's padding-bottom will be To ignore the <Div sx={{ '--pb-last': 'unset' }}> |
@siriwatknp I'm not sure I understand the relevance of your example, which doesn't use MUI. |
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example: codesandbox
Steps:
ThemeProvider
with the default themeMuiCardContent-root:last-child
style (padding-bottom
)MuiCardContent-root
style (padding
)Current behavior 😯
Currently, when I try to remove the
padding-bottom
fromMuiCardContent-root:last-child
it impacts thepadding
ofMuiCardContent-root
. I can't find out a way to remove this css property without overriding the defaultpadding
value.Expected behavior 🤔
We should be able to opt-out from a theme's css property, without impacting other css properties.
In this particular case I would expect the default
padding
to be kept intact:Context 🔦
I'm trying to remove the
padding-bottom: 24px
from theCardContext
component (&last-child
).The problem is that it impacts the default
padding: 16px
. When trying to unset thepadding-bottom
it removes the defaultpadding
.Your environment 🌎
Latest.
The text was updated successfully, but these errors were encountered: