Skip to content
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

Ability to customize the default snackbar #180

Closed
Brettm12345 opened this issue Oct 10, 2019 · 4 comments
Closed

Ability to customize the default snackbar #180

Brettm12345 opened this issue Oct 10, 2019 · 4 comments

Comments

@Brettm12345
Copy link

I would love to be able to use the children parameter from enqueueSnackbar on SnackbarProvider in order to customize the default snackbar

@iamhosseindhv
Copy link
Owner

Thanks for reporting @Brettm12345 .
Functionality has been implemented and will be published in the next major release. children paramter of enqueueSnackbar has been renamed to content. And you can customize the default snackbar globally using content prop of SnackbarProvider.

@dalborgo
Copy link

dalborgo commented Mar 3, 2020

Hi iamhosseindhv. Great job!

From documentation (content section): "You can entirely customize your snackbars by passing a custom children in SnackbarProvider props or options parameter of enqueueSnackbar."

I'm expecting to be possible to pass to the Provider something like that to set a default property:

content = {{ variant: 'error' }}

Is there a way to set the variant: 'error' as default.

Thanks

@iamhosseindhv
Copy link
Owner

@dalborgo Once v0.9.9 is released you can do the following to set default variant to error:

<SnackbarProvider variant="error">
     // ...
</SnackbarProvider>

@Abolfazl2647
Copy link

Abolfazl2647 commented Dec 29, 2021

@iamhosseindhv i think if you do this

  if (typeof content === 'function') {
    content = content(key, {...snack});
  } //

instead of this:

  if (typeof content === 'function') {
  content = content(key, snack.message);
} //

you solve many problems.

if you path {...snack} like this at line 572 in notistack.esm.js insted of snack.message we can use options to customize snack bars in content props. version 2.0.3

i thinks it is rare for developers to use variant props on snackbar.provider.
Great library BTW

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants