notistack Documentation

Highly customizable notification snackbars (toasts) that can be stacked on top of each other

RAW Doc

Technical Documentation: iamhosseindhv/notistack

โ„น๏ธ Provenance: Multi-Tier Ingestion ยท CodeWiki Reference

Overview (`README.md`)

Table of Contents

Getting Started

Use your preferred package manager:

text
npm install notistack
yarn add notistack

Version guide

Version Notes
v3.x.x Latest stable release. Standalone (i.e. not dependent on material-ui)
<= v2.0.8 Requires Material-UI v5 as peer dependency. npm install [email protected]
<= 1.0.10 Requires Material-UI <= v4 as peer dependency. npm install notistack@latest-mui-v4

How to use

Instantiate a SnackbarProvider component and start showing snackbars: (see docs for a full list of available props)

jsx
import { SnackbarProvider, enqueueSnackbar } from 'notistack';

const App = () => {
  return (
    <div>
      <SnackbarProvider />
      <button onClick={() => enqueueSnackbar('That was easy!')}>Show snackbar</button>
    </div>
  );
};

Alternatively, You can use useSnackbar hook to display Snackbars. Just remember to wrap your app inside of a SnackbarProvider to have access to the hook context:

jsx
import { SnackbarProvider, useSnackbar } from 'notistack';

// wrap your app
<SnackbarProvider>
  <App />
  <MyButton />
</SnackbarProvider>

const MyButton = () => {
  const { enqueueSnackbar, closeSnackbar } = useSnackbar();
  return <Button onClick={() => enqueueSnackbar('I love hooks')}>Show snackbar</Button>;
};

Online demo

Visit the documentation website to see all the examples.
Or play with a minimal working example: codesandbox

Contribution

Open an issue and your problem will be solved.

Author - Contact

Hossein Dehnokhalaji




Overview (`examples/custom-snackbar-example-2/README.md`)

Notistack Custom Snackbar example


Overview (`examples/custom-snackbar-example/README.md`)

Notistack Custom Snackbar example


Overview (`examples/mobx-example/README.md`)

Notistack Mobx example


Overview (`examples/redux-example/README.md`)

Notistack Redux example


Overview (`examples/simple-example/README.md`)

Notistack simple example


--- METRICS ---