-
-
Notifications
You must be signed in to change notification settings - Fork 298
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
[Request] Allow style overrides via material-ui theme #215
Comments
I'm wondering, are they an opportunity to use the Alert component inside notistack instead of a custom SnackbarItem? Alternatively, I would recommend something like this: -export default withStyles(styles, { index: 1 })(SnackbarItem);
+export default withStyles(styles, { name: 'NotistackItem })(SnackbarItem); ( |
Yeah, this would be great - they serve the same purpose. It'd be a significant change, though, impacting styling structure so it'd probably be a major version upgrade I think. We're fine with the CSS selector approach we're using for now but adding the
|
Thanks for the context. I can't find any reproduction in the linked issue. I would highly encourage to remove any custom index value. |
Can confirm, with notistack 0.9.7, when a snackbar is open, an extra We noticed this when switching to a dark theme with Material-UI; all the Papers on the page switch to a white background while the snackbar is open, as the second MuiPaper style is using a light theme. |
Commit for fixing #202 hasn't been published yet. So it is expected to still have this issue in
Although Alert component does look good, I think people are used to the current way notistack snackbars look like and can be customised. This would be a breaking change which requires much more thought to go into it and out of the scope of this issue.
Thanks for participating @oliviertassinari. Given that I could reproduce this issue at the time, as well as other people, what are the negative effects of applying a custom index? |
@iamhosseindhv Without a reproduction, I think that #202 should be considered invalid. I'm curious to hear more about how you have reproduced it. We have a couple of third-party libraries built on top of Material-UI, I'm not aware of anyone forcing an index value. The downside of this approach is that it forces the developers that want to customize the item to increase the index as well. Could it break people's customizations when released? |
Sorry, thought that commit had already been released. Do you have an estimate for when the next release can be expected? |
I was actually able to solve my issue; it was because my As per the README:
|
Appreciate this isn't the most convenient but it's also not an ugly solution / hack.
|
This doesn't seem to be working in the latest version of notistack and mui |
I just wrapped the provider to use the MUI theme palette colors which are already defined and easy to customize. const useStyles = makeStyles(({ palette }) => ({
// default variant
contentRoot: {
backgroundColor: 'aqua',
},
variantSuccess: {
backgroundColor: palette.success.main,
},
variantError: {
backgroundColor: palette.error.main,
},
variantInfo: {
backgroundColor: palette.info.main,
},
variantWarning: {
backgroundColor: palette.warning.main,
},
}));
export const NotistackProvider: FC = ({ children }) => {
const classes = useStyles();
return <SnackbarProvider classes={classes} children={children} />;
}; |
I can confirm this works in the latest version Please provide a reproduction if you think it's not working for you. |
Hello @iamhosseindhv, |
@chrisbag https://github.com/iamhosseindhv/notistack/blob/master/CHANGELOG.md#breaking-changes Overriding SnackbarContent styles through material ui theme is not supported after |
Ok, thanks a lot for the fast reply ! |
Hi, I'm trying to override the styles as above #215 (comment) However, I'm facing an issue where my new styles are not taking effect due to the
you can see an example here: Now i can force them with updating my styles with the |
I am having same issue as @SimonAmphora . Can we reopen this? |
There has been ongoing work to remove the dependency on Material-UI and adding this feature is stepping exactly in the opposite direction, so I don't think I/we will add support for customisation through MUI theme. v3 is on its way, downloadable by I'm committed to make sure you guys can apply your customisations somehow, regardless of whether you choose to upgrade to v3 to not. Also, as of |
@iamhosseindhv I'm running version 2.0.3 and I see the issue hasn't been solved yet. Are you going to fix it? |
@mbeltramin
If by issue you mean the ability to apply styles via MUI theme, I have previously mentioned it won't be supported. Did you mean some other issue? |
@iamhosseindhv I mean the order of the applyed styles, as @JonKrone mentioned. |
@mbeltramin Things have changes since Jan 2020 when this issue was opened. Please open a new one providing a reproduction example. |
Hello!
Context
We're building a themed component library which will be used to build many apps and want to customize the appearance of these
SnackbarItems
without other developers having to worry about it and maintain consistency with our company's theme.I understand that the oft-recommended styling strategy is to apply a
classes=
prop to theSnackbarProvider
, however, this isn't an ideal solution for us as it requires overhead for engineers to apply and maintain consistent theming with the rest of our apps. Usingtheme.overrides
allows us to change the appearance everywhere, with ease.It seems that there have been a few issues around this (#51 is the same question), and there are a lot of questions about how to customize styles here. Is it intentional that we can't override styles via the theme?
Expected Behavior
I would like to style the
SnackbarItem
via Material-UI themeoverrides
:Current Behavior
Can not apply global theme overrides.
From my initial digging into
withStyles
andmakeStyles
, it seems like the reason these overrides aren't possible is because theSnackbarItem
Component does not have adisplayName
property. Adding that fixes the style merging.The below also works and is what we're doing now, but slightly less ideal than adopting material-ui's theming pattern.
Steps to Reproduce
I think this is a known/intentional bug/feature but let me know if you'd like a real code sandbox demo.
Your Environment
The text was updated successfully, but these errors were encountered: