Nexus UI

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.

  1. Draft saved

    Last edit 2 seconds ago.

  2. Invoice sent

    acme@studio.co will get it shortly.

Props

PropTypeDefaultWhat it does
toasts—Toasts in arrival order; the last sits at the front. Each has id, title, description?, type? (success | error | info) and action? ({ label }).
onDismiss—Called when a toast is swiped away, closed, 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.
className—Extra classes on the stack.

Add it to your project

  1. 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 (the registries key 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. 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. 3

    Check what was added

    With the standard aliases, these files land in your project:

    components/
    toast-stack/
    index.ts
    toast-stack.tsx
  4. 4

    Copying by hand? Install the packages

    Skip this if you used the command above.

    npm install framer-motion lucide-react
  5. 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>
      );
    }