Prepared Docs

Prepared Docs

⌘K

    Loading navigation…

User

  1. Components
  2. Snackbar
  3. API and Development

Snackbar

API and Development

View Source
Submit Issue

Snackbar displays temporary notification messages that appear on screen to inform users about actions, errors, or other system feedback. Snackbars automatically dismiss after a duration or can be manually closed. Snackbar provides a flexible notification system built on Sonner, supporting multiple types, positions, and configurations. Snackbars appear temporarily to communicate important information without interrupting the user's workflow. They support titles, descriptions, action links, and custom durations with full keyboard and screen reader accessibility.

Props

SnackbarManager

Name

Type

Default

Description

className

string

—

—

closeButton

boolean

true

Whether to show the close button

position

SnackbarPosition

SnackbarPosition.BottomCenter

Position of the snackbar on the screen

toastOptions

ToastOptions

{}

—

SnackbarProps (for show method)

NameDefaultDescription
titlerequiredThe main message text displayed in the snackbar.
descriptionOptional secondary text displayed below the title.
linkTextText for an optional action link button. Requires linkUrl.
linkUrlURL for the optional action link. Requires linkText.
onClickCustom click handler for the action link. If not provided, defaults to opening linkUrl.
onDismissCalled when the snackbar is dismissed manually (close button, swipe, or dismiss(id)). Not called for action-button clicks or auto-close.
onAutoCloseCalled when the snackbar auto-closes after duration. Sonner pauses this clock while hovered or while the document is hidden.
externalfalseWhether the link should open in a new tab/window.
duration5000Duration in milliseconds before the snackbar automatically dismisses.
typeSnackbarType.DefaultType of snackbar. Options: Default, Info, Success, Error, Warning.
idOptional unique identifier for the snackbar (useful for programmatic dismissal).

Storybook

Interactive examples and edge cases for this component are in Storybook.

Default
With Description
With Link
With Long Link Text
Info
Success
Error
Warning
With Long Title And Description
No Close Button
Positions
Snackbar Tests
Title And Action Snapshot
Clamped Title Snapshot

Setup

Include SnackbarManager in your application root to enable snackbar functionality. This docs app already mounts one manager in the shell, so live previews on this page omit <SnackbarManager /> to avoid duplicate Sonner toasters (which would repeat every toast).

Examples

Use useSnackbar and a button. The shell SnackbarManager displays the toast.

Default

With description

With link

With long link text

Info

Success

Error

Warning

Long title and description

Positioning

Positioning

Configure where snackbars appear with the position prop on your single SnackbarManager at the app root. Use one manager only; mounting several SnackbarManager / Sonner Toaster instances (for example in live previews) causes duplicate notifications.

On this docs site, the shell uses SnackbarPosition.BottomCenter, so interactive examples above show toasts there.

Bottom Center (Default)

Top Positions

TopLeft, TopCenter, or TopRight:

Bottom Positions

BottomLeft, BottomCenter, or BottomRight:

Without Close Button

Hide close buttons for snackbars that must be read.

Live previews on this page use the app shell’s manager (close button enabled by default).

Multiple Snackbars

Multiple snackbars stack automatically when shown in sequence.

Snackbar Types

Snackbar Types

Use different types to convey semantic meaning.

Info

Success

Error

Warning

Default

Custom Duration

Control how long snackbars remain visible.

Programmatic Dismissal

Dismiss snackbars programmatically using their IDs.

With Description

With Description

Add descriptive text below the title.

With Action Link

Include an action link button for additional options.

External Link

Open links in a new tab or window.

Custom Link Handler

Provide a custom click handler for the action link.

Previous

Snackbar / Usage

Next

Snackbar / Accessibility

On this page

Props
SnackbarManager
SnackbarProps (for show method)
Storybook
Setup
Examples
Default
With description
With link
With long link text
Info
Success
Error
Warning
Long title and description
Positioning
Positioning
Bottom Center (Default)
Top Positions
Bottom Positions
Without Close Button
Multiple Snackbars
Snackbar Types
Snackbar Types
Info
Success
Error
Warning
Default
Custom Duration
Programmatic Dismissal
With Description
With Description
With Action Link
External Link
Custom Link Handler