Animated React toasts and banners

Toast stack

Notifications stacked in the middle of the container. Hover to fan them open, swipe one left or right to dismiss it, and add new ones from the pills below.

Feedback, drag, Motion

Install

npm i clsx motion tailwind-merge && curl -o components/toast-stack.tsx https://motion-brew.com/r/toast-stack.tsx

One self contained file for React and Tailwind CSS: toast-stack.tsx. Or ask your AI agent to add it through the MCP server.

Usage

import { useRef } from "react";
import { ToastStack, type ToastStackHandle } from "@/components/toast-stack";

export default function Workspace() {
  const toasts = useRef<ToastStackHandle>(null);
  const save = async () => {
    await saveSettings();
    toasts.current?.push({
      kind: "success",
      title: "Changes saved",
      description: "Your workspace settings are live.",
    });
  };
  return (
    <div className="grid place-items-center">
      <ToastStack ref={toasts} initial={[]} triggers={false} />
      <button onClick={save}>Save</button>
    </div>
  );
}

Props

PropTypeDefaultDescription
initialToastItem[]three samplesToasts shown at the start, oldest first; they stay
durationnumber6000Default time on screen in ms; 0 keeps toasts
visiblenumber3Toasts the folded stack shows
triggersbooleantrueRow of sample buttons under the stack
onDismiss(toast) => voidCalled when a toast leaves
classNamestringPlacement

More feedback

All animated react toasts and banners