material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[Snackbar] Add stacking support/display several

Open f0und3r opened this issue 9 years ago β€’ 19 comments

Summary πŸ’‘

Place multiple snack bars on the page.

Examples 🌈

Capture d’écran 2020-09-04 aΜ€ 15 41 59

Motivation πŸ”¦

Will the material design specification discourages to display multiple snackbar, and could stay the default, display multiple is a common use case:

Only one snackbar may be displayed at a time.

https://material.io/components/snackbars#usage

Benchmark

  • https://trello.com/c/tMdlZIb6/1989-snackbar-more-features
  • https://react-hot-toast.com/
  • https://mantine.dev/others/notifications/
  • https://blueprintjs.com/docs/#core/components/toast
  • https://seek-oss.github.io/braid-design-system/components/useToast
  • https://github.com/fkhadra/react-toastify
  • https://chakra-ui.com/toast
  • https://ant.design/components/message/
  • https://github.com/iamhosseindhv/notistack/
  • https://sancho-ui.com/components/toast/
  • https://evergreen.segment.com/components/toaster
  • https://twitter.com/railto/status/1232997843020996610
  • https://baseweb.design/components/toast/
  • https://toasted-notes.netlify.com/
  • https://github.com/kylecesmat/react-cheers
  • https://jossmac.github.io/react-toast-notifications/
  • https://github.com/mui-org/material-ui/issues/21053#issuecomment-630119128
  • https://twitter.com/listenMrUtkarsh/status/1283480376904568833

f0und3r avatar Oct 07 '15 07:10 f0und3r

Not to redirect the question... but is there a way to specify the placement of the snackbar? I noticed the example puts it in the bottom center of the page, but it always show up bottom left for me.

That might be what you're asking as well, @f0und3r ?

thataustin avatar Nov 12 '15 07:11 thataustin

Any news on this? Having several snackbar is indeed useful.

damianobarbati avatar Feb 08 '17 17:02 damianobarbati

@damianobarbati Do you mean several snackbar on the screen at the same time? I think that the material specification is discouraging for that use case. An alternative is to dismiss the currently displayed message for a new one.

oliviertassinari avatar Feb 08 '17 17:02 oliviertassinari

@oliviertassinari are you sure about this? :(

damianobarbati avatar Feb 09 '17 09:02 damianobarbati

@damianobarbati LMGTFY: https://material.io/guidelines/components/snackbars-toasts.html "Only one snackbar may be displayed at a time."

mbrookes avatar Feb 10 '17 02:02 mbrookes

Although guidelines recommend not to stack snackbars, we needed them for our internal use.

So I made this package called notistack. Hope it helps. You can position and customize it the same way you do for material-ui Snackbars, as all props get passed down to a material-ui Snackbar. πŸŽ‰πŸŽ‰πŸ™‚

iamhosseindhv avatar Aug 12 '18 20:08 iamhosseindhv

@iamhosseindhv Sweet 😍 ! Do you want to add a link in the documentation?

oliviertassinari avatar Aug 12 '18 20:08 oliviertassinari

That would be great. 😍 I'll keep working on it to make it more customisable then. πŸ‘πŸΌ

iamhosseindhv avatar Aug 12 '18 20:08 iamhosseindhv

@damianobarbati LMGTFY: https://material.io/guidelines/components/snackbars-toasts.html "Only one snackbar may be displayed at a time."

https://material.io/components/snackbars/#usage

dotmaike avatar Mar 20 '20 15:03 dotmaike

Having only one snackbar displayed at a time is stupid. Leave it to the dev and UX on how many make sense, but there are an infinite number of instances, where two or more notifications come up at the same time with different priorities and importance for a given user and we cannot afford to delay and show them one by one.

Just going for react-toastify ..

aakash-verma-aurea avatar Sep 21 '21 08:09 aakash-verma-aurea

Having only one snackbar displayed at a time is stupid. Leave it to the dev and UX on how many make sense, but there are an infinite number of instances, where two or more notifications come up at the same time with different priorities and importance for a given user and we cannot afford to delay and show them one by one.

Just going for react-toastify ..

@aakash-verma-aurea the intention of single display for snackbar is to adhere to the Material Design guidelines. This change would be a deviation to Material Design and specifically doing the exact example provided of what not to do. However, with that being said I am in favor of this deviation so long that it is opt-in only. For those cases it is best to adhere to the guidelines such as mobile devices with limited real estate this could potentially block interaction when they fill the screen.

zgover avatar Sep 22 '21 08:09 zgover

@zgover I totally understand and I'm blaming nothing but the guidelines. Opt-in totally works. One cannot have the same guidelines for all screen sizes as then devices at both ends of the spectrum(mobile vs laptops) suffer in one way or the other.

aakash-verma-aurea avatar Sep 22 '21 10:09 aakash-verma-aurea

It would be great if we have the possibility of showing more than one snackbar at a time folks. Let the dev decide what to do.

64J0 avatar Oct 05 '21 15:10 64J0

Hi, I ended up building a library for this use case with an imperative API. Check it out! https://github.com/ggcaponetto/mui-gotit

ggcaponetto avatar Oct 19 '21 13:10 ggcaponetto

PR opened for this at #31991 . We will be releasing it under MUI Lab initially.

Demo preview: https://deploy-preview-31991--material-ui.netlify.app/material-ui/react-snackbar/#experimental-api. We will be polishing the demos further.

ZeeshanTamboli avatar Apr 07 '22 09:04 ZeeshanTamboli

@ZeeshanTamboli, hi! πŸ‘‹ Great news. Are there any updates on this?

yurijmikhalevich avatar May 05 '22 13:05 yurijmikhalevich

Hi @yurijmikhalevich . You can follow #31991.

ZeeshanTamboli avatar May 05 '22 13:05 ZeeshanTamboli

Yes, please! You have my :+1: (bonus points if I can configure which "type" can be stacked and which not. Ie. I want errors stacked but infos/successes only replacing each other.

TheRealCuran avatar Aug 21 '22 00:08 TheRealCuran

Hello, thanks for this https://deploy-preview-31991--material-ui.netlify.app/material-ui/react-snackbar/#experimental-api in which version of mui/lab is it available? It does not seem to be available in 5.0.0-alpha.112 thanks

FaabLondon avatar Dec 15 '22 11:12 FaabLondon

It's pretty easy to do yourself without any external libraries: https://codesandbox.io/s/mui-snack-stack-jnrnwq?file=/src/App.tsx

g4ngzt4 avatar Feb 03 '23 16:02 g4ngzt4