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
| Prop | Type | Default | What it does |
|---|---|---|---|
| toasts | ToastItem[] | — | Toasts in arrival order; the last sits at the front. Each has id, title, description?, type? (success | error | info | warning) and action? ({ label }). |
| onDismiss | (id: string) => void | — | Called when a toast is swiped away, closed, times out, or dismissed with Escape. |
| onAction | (toast: ToastItem) => void | — | Called when a toast's action button is pressed. |
| position | "top" | "bottom" | "bottom" | Which edge the stack grows from. |
| expand | "hover" | "always" | "hover" | Fan out on hover/focus, or stay fanned out. |
| max | number | 3 | How many toasts are drawn at once. |
| width | number | 340 | Toast width in px; shrinks to fit narrow containers. |
| duration | number | 0 | Dismiss the front toast after this many ms, paused while the stack is open. 0 keeps toasts until closed. |
| autoplay | boolean | false | Fans the stack open and swipes the front toast away every few seconds until someone touches it. |
| className | string | — | Extra classes on the stack. |
| UndoToast.mails | UndoToastMail[] | four demo messages | The rows in the list: id, from, subject, time and an avatar colour (hue). |
| UndoToast.holdMs | number | 5000 | How long the toast waits for an Undo. Hovering or focusing the toast pauses the countdown. |
| UndoToast.onArchive | (mail: UndoToastMail) => void | undefined | Called when a row is archived. |
| UndoToast.onUndo | (mails: UndoToastMail[]) => void | undefined | Called with the archived rows when Undo is pressed. |
| UndoToast.autoplay | boolean | false | Archives 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 | string | "" | Extra classes for the card. |
| PromiseToast.onVisit | () => void | undefined | Called when Visit is pressed on the success toast. Nothing navigates by itself. |
| PromiseToast.onViewLogs | () => void | undefined | Called when View logs is pressed on the failure toast. |
| PromiseToast.autoplay | boolean | false | Runs 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 | string | "" | Extra classes for the wrapper. |
| TimedToastStack.duration | number | 5000 | How long a toast stays, in milliseconds. Paused while you point at the stack. |
| TimedToastStack.enableSound | boolean | true | Soft sounds: a pop as each arrives. They also follow the site-wide sound switch. |
| TimedToastStack.volume | number | 0.8 | Sound level, 0 to 1. |
| TimedToastStack.autoplay | boolean | false | Plays a short demo by itself until the visitor touches it. Never runs under reduced motion. |
| TimedToastStack.className | string | "" | Extra classes for the outer element. |
| enableSound | boolean | true | Plays 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
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 createscomponents.jsonand thecn()helper insrc/lib/utils.ts:npx shadcn@latest init -d
Starting from nothing? The Quick Start walks through the whole thing.
- 2
Connect the registry
Run this once per project. It writes the Nexus UI entry into
components.jsonfor 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.
- 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
- 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.tspromise-toast.tsxtimed-toast-stack.tsxtoast-stack.tsxundo-toast.tsx - 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:
- 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.