Skip to content
IndexRequest a UIAboutContact

Snackbar

A single bottom message with one action, typically Undo, that replaces the previous one.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Build a list of three email rows with a delete icon on each. Deleting a row removes it from the list with a 180ms height collapse and shows a snackbar at the bottom of the demo area reading "Conversation archived" with an "Undo" button and a close icon. The snackbar slides up over 240ms with cubic-bezier(0.2,0.8,0.2,1), stays 6 seconds, pauses while hovered or focused, and then disappears; the deletion stands. Pressing Undo (also reachable by keyboard) restores the row at its original position. If another row is deleted while a snackbar is visible, finalise the previous deletion and replace the bar. Use role="status" on the bar. Under prefers-reduced-motion use opacity only.

About this pattern

Definition

A narrow bar that slides up from the bottom to report an action and offer one response, most often Undo. Only one is shown at a time; a new one replaces the current one.

Purpose & UX principles

  • Makes destructive actions reversible without a confirmation dialog, which is faster and less annoying.
  • The action must stay available long enough to be read and used: at least 5 seconds, longer for longer text.
  • Pause the timer while the user hovers or focuses it.

Interaction states

  • Hidden, entering, visible, action pressed, dismissed.
  • Pressing Undo restores the item and closes the bar; ignoring it lets the deletion stand.
  • Announced politely through role="status".

Motion specification

  • Enter: translateY(24px) to 0 with opacity, 240ms cubic-bezier(0.2, 0.8, 0.2, 1).
  • Exit: 180ms ease-in.
  • Replacement: the old bar leaves before the new one enters.
  • Reduced motion: fade only.

Responsive behaviour

  • Phones: spans the width with 12px margins above any bottom navigation.
  • Desktop: centred, maximum width 480px.

Code

HTML
<div class="box"><ul id="list">
  <li data-id="1"><span>Welcome to the team</span><button class="del" aria-label="Archive Welcome to the team">🗑</button></li>
  <li data-id="2"><span>Your invoice is ready</span><button class="del" aria-label="Archive Your invoice is ready">🗑</button></li>
  <li data-id="3"><span>Weekly digest</span><button class="del" aria-label="Archive Weekly digest">🗑</button></li>
</ul>
<div class="snack" id="snack" role="status" hidden><span>Conversation archived</span><button id="undo">Undo</button><button id="cls" aria-label="Dismiss">×</button></div></div>

Related patterns

Toast

↗
ToastFeedback & Notifications

Modal Dialog

↗
Modal DialogOverlays & Dialogs

Validation States

↗
Validation StatesInputs & Forms