Snackbar
A Snackbar provides brief messages about app processes. It is dismissed automatically after a given interval. Snackbar can be built with two different components. One is the HvSnackbar, which wraps all the positioning, transition, auto hide, etc. The other is the HvSnackbarContent, which allows a finer control and customization of the content of the Snackbar.
Custom Icon
You can pass a custom icon to the snackbar by using the customIcon
prop.
Actions
Use the action
prop to add an action to the snackbar. The onAction
prop is a callback function that is called when the action is clicked.
Long content
Although not desirable, sometimes you may need to display a long message in the snackbar. You can combine the snackbar with the HvOverflowTooltip
component to display the full message.
Customization
You can customize the snackbar and change it’s position, transition direction and autohide duration,.
You can specify the position of the snackbar by using the anchorOrigin
prop. To set the transition direction of the snackbar use the transitionDirection
prop.
The setAutoHideDuration
prop is used to specify the duration in milliseconds after which the snackbar will automatically close. This will
trigger the onClose
callback of the snackbar component with the reason set to timeout
.