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 use the useHvSnackbar
hook in any component.
This hook provides the enqueueSnackbar
function to show a snackbar and closeSnackbar
to dismiss it programmatically.
Content
The HvSnackbarProvider
uses HvSnackbarContent
internally to render snackbars.
You can customize the content using the snackbarContentProps
prop.
For more details, see the HvSnackbar
documentation.
Label
The snackbar label
accepts a React.ReactNode
, allowing you to pass any component—including HvOverflowTooltip
for long messages.
However, avoid displaying lengthy content in a snackbar, as it’s meant for brief, ephemeral messages that auto-dismiss after a short time.