Comments (4)
For others looking back at this, there's another approach in your theme.overrides
:
overrides: {
MuiSnackbarContent: {
root: {
'&[class*="variantInfo"]': {
backgroundColor: <Your color here>
},
// .. and etc for the other variants
}
},
}
from notistack.
I did something like this. I'd like to know if you found a better solution!
const snackbarClasses = Object.keys(classes).filter(key => key.match(/^MuiSnackbarContent_/)).reduce(
(result, key, index) => {
result[key.replace(/^MuiSnackbarContent_/, '')] = classes[key];
return result;
},
{}
);
<SnackbarProvider
classes={snackbarClasses}
/>
const themeStyles = (theme) => {
const {
overrides = {}
} = theme,
{
MuiSnackbarContent = {}
} = overrides;
return Object.keys(MuiSnackbarContent).reduce(
(result, key, index) => {
result["MuiSnackbarContent_"+key] = MuiSnackbarContent[key];
return result;
},
{}
);
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(withStyles(themeStyles)(App));
from notistack.
@yTakkar
Did you ever end up finding a solution? I am currently looking to them my snackbars as well. Would love to hear what you have found out!
Thanks.
from notistack.
<ThemeProvider theme={theme}>
<SnackbarProvider classes={theme.overrides.MuiSnackbarContent} maxSnack={3}>
{children}
</SnackbarProvider>
</ThemeProvider>
from notistack.
Related Issues (20)
- NextJs server component support - enqueueSnackbar is not a function (missing "use client" directive) HOT 1
- Feature Request
- Can we use the existing snackbar to use the notistack
- Styles not applied when rendering in custom element with shadow dom HOT 2
- domRoot is ineffective HOT 2
- [help] How can I make new snackbar always appears at the start position instead of at the rear? HOT 2
- Document has multiple elements referenced with ARIA with the same id attribute: notistack-snackbar
- autoHideDuration values not respected in Chrome 116.0.5845.179 HOT 3
- Feature request: option to bypass `maxSnack` HOT 2
- Question is it possible to identify if there is snack on the screen
- JS Example for Custom Notistack HOT 1
- Feature request: compiled react / pure JS documentation
- How to trigger "close Snack bar" from custom snack bar component. HOT 3
- Update clsx version
- snackbar id value appears on the screen
- Impossible to tell if user intentionally closed a notification
- Type issue when extending SnackbarProvider Components with custom component HOT 6
- The global settings on the provider doesn't work HOT 4
- [Documentation] Update custom snackbar component example HOT 2
- Incorrectly generated styles only in production build
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from notistack.