Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

Toast Stack, animated React component

Notifications that rest in a tidy stack: a new toast drops onto the pile squashed and springs into shape, and hover or focus fans the stack into a list. Fling a toast sideways and it tilts and skids off; with a duration set, the front toast counts down along its bottom edge and waits while the stack is open. Also includes Undo Toast, where an archived row shrinks into the toast, a ring counts down around Undo, and undo drops the row back in place. Also includes Promise Toast, a pill that follows a deploy step by step with progress filling behind the words and lands on a live link or an error with a way to the logs. Also includes Timed Toast Stack, toasts that stack like cards with each one's time left running round its edge, swipe-away with momentum, an upload that turns into done in place and a delete with Undo.

  • Free
  • Cards
  • Hover
  • Spring

Swishes when you swipe a toast away or close it, and taps its action button; Undo Toast pings on archive and drops on Undo; Promise Toast pings on Deploy, then chimes on success or bumps on error. A toast you push with { sound: true } pings, chimes or bumps by type. Sound is off on this site until you switch it on.

Toast Stack

Undo Toast

Promise Toast

Timed Toast Stack

Like Toast Stack? 301 more are in Pro.

Pro unlocks all 301 Pro components, every template and block, and everything we release next. Toast Stack stays free.

Props

PropTypeDefaultWhat it does
toasts—Toasts in arrival order; the last sits at the front. Each has id, title, description?, type? (success | error | info | warning) and action? ({ label }).
onDismiss—Called when a toast is swiped away, closed, times out, or dismissed with Escape.
onAction—Called when a toast's action button is pressed.
position"bottom"Which edge the stack grows from.
expand"hover"Fan out on hover/focus, or stay fanned out.
max3How many toasts are drawn at once.
width340Toast width in px; shrinks to fit narrow containers.
duration0Dismiss the front toast after this many ms, paused while the stack is open. 0 keeps toasts until closed.
autoplayfalseFans the stack open and swipes the front toast away every few seconds until someone touches it.
className—Extra classes on the stack.
UndoToast.mailsfour demo messagesThe rows in the list: id, from, subject, time and an avatar colour (hue).
UndoToast.holdMs5000How long the toast waits for an Undo. Hovering or focusing the toast pauses the countdown.
UndoToast.onArchiveundefinedCalled when a row is archived.
UndoToast.onUndoundefinedCalled with the archived rows when Undo is pressed.
UndoToast.autoplayfalseArchives a row and undoes it on a loop until someone touches the component. Never runs under reduced motion and pauses when off screen.
UndoToast.className""Extra classes for the card.
PromiseToast.onVisitundefinedCalled when Visit is pressed on the success toast. Nothing navigates by itself.
PromiseToast.onViewLogsundefinedCalled when View logs is pressed on the failure toast.
PromiseToast.autoplayfalseRuns a good deploy and then a failing one on a loop until someone touches the component. Never runs under reduced motion and pauses when off screen.
PromiseToast.className""Extra classes for the wrapper.
TimedToastStack.duration5000How long a toast stays, in milliseconds. Paused while you point at the stack.
TimedToastStack.enableSoundtrueSoft sounds: a pop as each arrives. They also follow the site-wide sound switch.
TimedToastStack.volume0.8Sound level, 0 to 1.
TimedToastStack.autoplayfalsePlays a short demo by itself until the visitor touches it. Never runs under reduced motion.
TimedToastStack.className""Extra classes for the outer element.
enableSoundtruePlays interface sounds on interaction. They follow the sound switch (setSoundsEnabled, on by default) and stay silent on hover. Autoplay makes the same sounds once the visitor has used the page. Pass false to silence this component.

Add it to your project

  1. 1

    Set up your project once

    You need a Next.js project with Tailwind CSS and the @/ import alias. In its root folder, run this once. It creates components.json and the cn() helper in src/lib/utils.ts:

    npx shadcn@latest init -d

    Starting from nothing? The Quick Start walks through the whole thing.

  2. 2

    Connect the registry

    Run this once per project. It writes the Nexus UI entry into components.json for you:

    npx shadcn@latest registry add "@nexus-labs=https://www.nexus-ui.com/api/registry/{name}"

    Type it exactly as shown. {name} is filled in by the CLI with the component you ask for, so you never replace it.

  1. 3

    Add the component

    Run this from your project root. It adds the component, the helpers it imports and its npm packages.

    npx shadcn@latest add @nexus-labs/toast-stack
  2. 4

    Check what was added

    With a project made as in the Quick Start (a src/ folder), these files land in it:

    components/
    toast-stack/
    index.ts
    promise-toast.tsx
    timed-toast-stack.tsx
    toast-stack.tsx
    undo-toast.tsx
  3. 5

    Copying by hand? Skip the registry

    Instead of steps 2 and 3 you can copy the files yourself, with no registry and no API key. Step 1 still applies, so that cn() exists. Install the packages:

    npm install framer-motion

    Then show the source and create each file at the path it gives:

  4. 6

    Use it in a page

    Installing only adds the files. Import the component in a page and render it. The Usage tab on the preview shows a fuller example with props:

    // src/app/page.tsx
    import { ToastStack, useToastStack } from "@/components/toast-stack";
    
    export default function Page() {
      return (
        <main>
          <ToastStack />
        </main>
      );
    }

Like Toast Stack? 301 more are in Pro.

Pro unlocks all 301 Pro components, every template and block, and everything we release next. Toast Stack stays free.

Toast Stack questions

Does it make sound, and how do I turn it off?

Swishes when you swipe a toast away or close it, and taps its action button; Undo Toast pings on archive and drops on Undo; Promise Toast pings on Deploy, then chimes on success or bumps on error. A toast you push with { sound: true } pings, chimes or bumps by type. Sounds are synthesised with the Web Audio API, so there are no audio files, and they only play after a click or key press. Pass `enableSound={false}` to silence this component, or call `setSoundsEnabled(false)` from `@/lib/ui-sounds` to switch every sound off at once. The CLI installs `@/lib/ui-sounds` with the component.

Guides