Skip to content

Snackbar

A brief message with an optional action and dismiss, queued through a host.

import { Snackbar, SnackbarHost, useSnackbarHostState } from '@windmorph/react';

Purpose

A snackbar shows a brief message about an app process at the bottom of the screen, with an optional single action and dismiss button. Use it for low-priority, transient feedback that does not interrupt the task. Reach for a Dialog when the user must act before continuing, and a Tooltip for a label on hover or focus.

Most apps show snackbars through a SnackbarHost: create a state with useSnackbarHostState(), place one host, and call showSnackbar. The host queues messages and shows one at a time. Render a Snackbar directly only for custom placement.

Snackbars appear above FABs, never in front of or behind them, and never over a navigation bar. Lift the host above what sits at the bottom of the screen: with a 56px FAB at bottom-4, place it at fixed inset-x-0 bottom-[72px] (the FAB's 16px margin and its height; the host's own 12px padding is the gap), and above a navigation bar add the bar's height. Move the host back down when the FAB hides.

Do and don't

Do: Show one snackbar at a time, with an Undo action when people may want to change their choice.
Don't: Don't stack snackbars on top of one another: queue them with a SnackbarHost.

When not to use

For a message that must be acknowledged use a Dialog; for persistent status use inline text.

See also

  • Snackbar on m3.material.io: Material's own guidelines, with anatomy and specs.
  • Dialog: A modal surface for a focused task or a decision, with a title, content and actions, or full screen on compact windows.
  • Progress indicators: Linear and circular indicators, determinate or indeterminate, flat or wavy.