SnackbarProvider
A snackbar provider to control the stacking of multiple snackbars in the app.
This component uses of the Notistack library. Please refer to its API Reference for more complex usage scenarios.
The provider is not meant to be 100% feature complete, but instead, ease the majority of use-cases we have been encountering. If you need any customization or extension to the behavior, please feel free to copy and customize it.
import {
HvSnackbarProvider,
useHvSnackbar,
} from "@hitachivantara/uikit-react-core";
After adding the provider at the root of your app, you can call the useHvSnackbar
at any component inside your app. This hook will allow you to request the rendering of a snackbar through the use of the enqueueSnackbar
function or close one with closeSnackbar
.
Content
Internally, the HvSnackbarProvider
uses the HvSnackbarContent
to render the snackbar. You can use the snackbarContentProps
to customize the content of the snackbar.
Check the HvSnackbar
documentation for more information.
Label
The snackbar label acceps a React.ReactNode
which means you can pass any component as the label.
This allows you to use the HvOverflowTooltip
component to display a long message with ellipsis and a tooltip.
Note, though, that you shouldn’t have long messages displayed in a snackbar as it is meant to be a ephemerous message that will
be dismissed automically after a some time.