Get Started

    Components

      Overview

      The Snackbar component provides a way to display brief messages at the bottom of the screen to provide feedback or information to the user. It can be used to show notifications, alerts, or confirmations in a non-intrusive way.

      Variants

      The snackbar component supports several variants to suit different use cases:

      • Basic Snackbar: Displays a simple message to the user.
      • Snackbar with Action Button: Includes an action button for immediate user interaction.
      • Snackbar with Close Button: Allows users to manually close the snackbar.

      Configuration

      ThemeProvider Integration

      The snackbar system is integrated into the ThemeProvider, so you don't need any additional providers. Just make sure you have root={true} set on your ThemeProvider at the application root:

      Configuring Snackbar System

      You can configure the snackbar system with additional props on the ThemeProvider:

      useSnackbar Hook

      The useSnackbar hook provides access to the snackbar system from anywhere in your application:

      Manual Snackbar Component

      While the context-based approach is recommended, you can still use the Snackbar component directly for advanced use cases where you need full control:

      API Reference

      Snackbar

      A notification component that appears temporarily to provide feedback or information.

      Props

      NameTypeDefaultDescription
      messagestringRequiredThe message to display in the snackbar
      openbooleanfalseWhether the snackbar is visible
      autoHideDurationnumber4000Time in milliseconds before auto-hiding. Set to 0 to disable auto-hide
      actionNamestringundefinedText for the action button
      onActionClick() => voidundefinedCallback fired when the action button is clicked
      onClose() => voidundefinedCallback fired when the snackbar is closed
      closeablebooleanfalseWhether to show a close button

      Inherited Props

      The Snackbar component accepts all standard HTML div element props.

      useSnackbar Hook

      Hook for accessing the snackbar system from within components.

      Returns

      NameTypeDescription
      showSnackbar(options: SnackbarOptions) => voidFunction to show a new snackbar
      hideSnackbar(id: string) => voidFunction to hide a specific snackbar by ID
      hideAllSnackbars() => voidFunction to hide all snackbars

      SnackbarOptions

      NameTypeDefaultDescription
      messagestringRequiredThe message to display
      actionNamestringundefinedText for the action button
      onActionClick() => voidundefinedAction button click handler
      closeablebooleanfalseWhether to show close button
      autoHideDurationnumber4000Auto-hide duration in milliseconds