Toast Stack, animated React component
Notifications that rest in a tidy stack, fan out into a list on hover or focus, and can be swiped away, with optional action buttons.
- Free
- Cards
- Hover
- Spring
Play with it
Move the controls and watch it change. Copy code gives you a snippet with only the props you changed.
Payment declined
Try another card.
Draft saved
Last edit 2 seconds ago.
Invoice sent
acme@studio.co will get it shortly.
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) and action? ({ label }). |
| onDismiss | (id: string) => void | — | Called when a toast is swiped away, closed, 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. |
| className | string | — | Extra classes on the stack. |
Add it to your project
- 1
Prepare your project
You need Tailwind CSS and the
@/import alias. If shadcn isn't set up yet, initialise it once:npx shadcn@latest init
Then add the Nexus registry to your
components.json(theregistrieskey is the part that matters):{ "$schema": "https://ui.shadcn.com/schema.json", "style": "default", "rsc": true, "tsx": true, "tailwind": { "css": "src/app/globals.css", "baseColor": "neutral", "cssVariables": true, "prefix": "" }, "aliases": { "components": "@/components", "utils": "@/lib/utils", "ui": "@/components/ui", "lib": "@/lib", "hooks": "@/hooks" }, "registries": { "@nexus-labs": "https://www.nexus-ui.com/api/registry/{name}" } } - 2
Add the component
Run this from your project root. It adds the component, the utilities it uses and its packages.
npx shadcn@latest add @nexus-labs/toast-stack
- 3
Check what was added
With the standard aliases, these files land in your project:
components/toast-stack/index.tstoast-stack.tsx - 4
Copying by hand? Install the packages
Skip this if you used the command above.
npm install framer-motion lucide-react
- 5
Use it in a page
Import it and render it. The Code tab above has the full example.
// app/page.tsx import { ToastStack, useToastStack } from "@/components/toast-stack"; export default function Page() { return ( <main> <ToastStack /> </main> ); }