Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

Stagger Menu, animated React component

A share menu that unfolds from its button with the items arriving one after another, a highlight that glides between rows, arrow-key navigation, and a button label that rolls to confirm what you picked.

  • Free
  • Inputs & Controls
  • Hover
  • Spring

Pops when the menu opens, ticks when you press an item, then chimes as the button shows its confirmation. Sound is off on this site until you switch it on.

Like Stagger Menu? 301 more are in Pro.

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

Props

PropTypeDefaultWhat it does
items—Each item has id, label, icon, and optional danger (red, after a divider) and done (the confirmation shown in the button).
onSelect—Called with the id of the picked item.
label"Share"Button label.
autoplayfalseOpens and browses the menu by itself until someone interacts.
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/stagger-menu
  2. 4

    Check what was added

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

    components/
    stagger-menu/
    index.ts
    stagger-menu.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 { StaggerMenu } from "@/components/stagger-menu";
    
    export default function Page() {
      return (
        <main>
          <StaggerMenu />
        </main>
      );
    }

Like Stagger Menu? 301 more are in Pro.

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

Stagger Menu questions

How do I install Stagger Menu?

Run `npx shadcn@latest add @nexus-labs/stagger-menu`. It is a free component and installs framer-motion.

How do I define the menu items?

Pass `items` as `{ id, label, icon, danger?, done? }`. `icon` is any React node, `danger` makes the row red and places it after a divider, and `done` is the text the button shows after the pick (it falls back to `label`).

How do I run an action when something is picked?

Pass `onSelect`; it receives the item `id` and the menu closes. The component copies or downloads nothing itself, so do that in your handler. Because it is a function prop, the page that passes it must be a client component.

What keyboard support does it have?

The button has `aria-haspopup="menu"` and `aria-expanded`, and items are `menuitem` buttons. With focus inside the open menu, the up and down arrows move through items and wrap around. Escape closes it, as does clicking outside.

Can I change the button label or demo it automatically?

`label` sets the button text (default "Share"). `autoplay` is off by default; when on, the menu opens and browses itself until someone interacts. Items arrive staggered, and a highlight glides between rows.

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

Pops when the menu opens, ticks when you press an item, then chimes as the button shows its confirmation. 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