suiss/ui
  • Docs
  • Components
  • Patterns
  • Interactions
  • Charts
  • Blocks
  • AI
GitHubCreate
DocsComponentsPatternsInteractionsChartsBlocksAICreate
Patterns19
  • Overview
  • Action Bar
  • Action Menu
  • App Shell
  • Command Palette
  • Confirm
  • Context Actions
  • Date Picker
  • Flyout
  • Modal
  • Navbar
  • Paged List
  • Panel
  • Picker
  • Preview
  • Search Picker
  • Segment Picker
  • Split View
  • Table List
  • Trail

suiss/ui · Pattern

Action Menu

A list of actions that opens as a dropdown menu on desktop and an action sheet on mobile.

Action Menu is an open-source pattern from suiss/ui for React. The @esuiss/ui CLI copies its source into your project, so you own the code.

import {
  ActionMenu,
  ActionMenuContent,
  ActionMenuItem,
  ActionMenuLabel,
  ActionMenuSeparator,
  ActionMenuTrigger,
} from "@/components/patterns/action-menu"
import { Button } from "@/components/ui/button"

export default function ActionMenuDemo() {
  return (
    <div className="flex min-h-svh items-center justify-center">
      <ActionMenu>
        <ActionMenuTrigger render={<Button variant="outline" />}>
          Order actions

ActionMenu renders a DropdownMenu on desktop and an AlertSheet below the 48rem breakpoint (useIsMobile). Each part switches to its matching component: items become DropdownMenuItems or AlertSheetActions, and the label becomes a menu label or the sheet title.

Use it for a short set of actions on a single object, such as editing, sharing or deleting a record, where an action sheet suits touch screens.

Installation

$ pnpm dlx shadcn@latest add @esuiss/action-menu

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add patterns action-menu
  1. Add the pieces it builds on: Alert Sheet, Dropdown Menu, use-mobile.

  2. Copy and paste the following code into your project.

components/patterns/action-menu.tsx
"use client"

import * as React from "react"

import {
  AlertSheet,
  AlertSheetAction,
  AlertSheetCancel,
  AlertSheetContent,
  AlertSheetGroup,
  AlertSheetHeader,
  AlertSheetTitle,
  AlertSheetTrigger,
} from "@/components/ui/alert-sheet"
import {
  DropdownMenu,
  1. Update the import paths to match your project setup.

Usage

import {
  ActionMenu,
  ActionMenuContent,
  ActionMenuItem,
  ActionMenuLabel,
  ActionMenuSeparator,
  ActionMenuTrigger,
} from "@/components/patterns/action-menu"
import { Button } from "@/components/ui/button"
<div className="flex min-h-svh items-center justify-center">
  <ActionMenu>
    <ActionMenuTrigger render={<Button variant="outline" />}>
      Order actions
    </ActionMenuTrigger>
    <ActionMenuContent>
      <ActionMenuLabel>Order #1042</ActionMenuLabel>
      <ActionMenuItem>Edit</ActionMenuItem>
      <ActionMenuItem>Duplicate</ActionMenuItem>
      <ActionMenuItem>Share</ActionMenuItem>
      <ActionMenuSeparator />
      <ActionMenuItem variant="destructive">Delete</ActionMenuItem>
    </ActionMenuContent>
  </ActionMenu>
</div>
<div className="flex min-h-svh items-center justify-center">
  <ActionMenu>
    <ActionMenuTrigger asChild>
      <Button variant="outline">Order actions</Button>
    </ActionMenuTrigger>
    <ActionMenuContent>
      <ActionMenuLabel>Order #1042</ActionMenuLabel>
      <ActionMenuItem>Edit</ActionMenuItem>
      <ActionMenuItem>Duplicate</ActionMenuItem>
      <ActionMenuItem>Share</ActionMenuItem>
      <ActionMenuSeparator />
      <ActionMenuItem variant="destructive">Delete</ActionMenuItem>
    </ActionMenuContent>
  </ActionMenu>
</div>
<div className="flex min-h-svh items-center justify-center">
  <ActionMenu>
    <Button variant="outline">Order actions</Button>
    <ActionMenuContent>
      <ActionMenuLabel>Order #1042</ActionMenuLabel>
      <ActionMenuItem>Edit</ActionMenuItem>
      <ActionMenuItem>Duplicate</ActionMenuItem>
      <ActionMenuItem>Share</ActionMenuItem>
      <ActionMenuSeparator />
      <ActionMenuItem variant="destructive">Delete</ActionMenuItem>
    </ActionMenuContent>
  </ActionMenu>
</div>

Composition

Use the following composition to build a ActionMenu:

ActionMenu
├── ActionMenuTrigger
└── ActionMenuContent
    ├── ActionMenuLabel
    ├── ActionMenuItem
    └── ActionMenuSeparator

Examples

With icons

Places an icon before every action. Set variant="destructive" on an item, here Delete, to style it as a destructive action.

import {
  CopyIcon,
  PencilSimpleIcon,
  ShareIcon,
  TrashIcon,
} from "@phosphor-icons/react"
import {
  ActionMenu,
  ActionMenuContent,
  ActionMenuItem,
  ActionMenuSeparator,
  ActionMenuTrigger,
} from "@/components/patterns/action-menu"
import { Button } from "@/components/ui/button"

export default function ActionMenuWithIcons() {

Not dismissible

Set dismissible to false so the mobile sheet uses an alert dialog that closes only through an action or Cancel, not on an outside press.

import {
  ActionMenu,
  ActionMenuContent,
  ActionMenuItem,
  ActionMenuLabel,
  ActionMenuSeparator,
  ActionMenuTrigger,
} from "@/components/patterns/action-menu"
import { Button } from "@/components/ui/button"

export default function ActionMenuNotDismissible() {
  return (
    <div className="flex min-h-svh items-center justify-center">
      <ActionMenu dismissible={false}>
        <ActionMenuTrigger render={<Button variant="outline" />}>
          Order actions

Accessibility

  • On desktop the popup has the menu role and each item has the menuitem role.
  • ArrowDown from the trigger opens the menu and focuses the first item; arrow keys move between items and Enter runs the focused one.
  • Escape closes the menu and returns focus to the trigger.

API Reference

ActionMenu

The root that renders a DropdownMenu on desktop and an AlertSheet on mobile.

PropTypeDefault
openboolean-
defaultOpenboolean-
onOpenChange(open: boolean) => void-
dismissiblebooleantrue
childrenReact.ReactNode-

open, defaultOpen and onOpenChange work on both layouts, so the menu can be controlled or uncontrolled.

ActionMenuTrigger

The button that opens the menu or sheet.

PropTypeDefault
renderReact.ReactElement-

Also accepts the props of DropdownMenuTrigger.

Use render to replace the default button with your own element, for example a Button with variant="outline".

PropTypeDefault
asChildbooleanfalse

Also accepts the props of DropdownMenuTrigger.

Set asChild to render your own button in place of the default one, for example a Button with variant="outline".

Also accepts the props of DropdownMenuTrigger.

You can also leave it out and place your own Button directly inside ActionMenu to open it.

ActionMenuContent

The popup holding the actions; on mobile it adds a Cancel button below them.

PropTypeDefault
cancelLabelstring"Cancel"

Also accepts align, alignOffset, side and sideOffset from DropdownMenuContent, which position the desktop popup, and the props of React.HTMLAttributes<HTMLElement>.

Also accepts placement, offset and crossOffset from DropdownMenuContent, which position the desktop popup, and className, children, id and aria-label.

The positioning props are ignored on mobile, where the content wraps the items in a grouped card and appends a Cancel button labelled by cancelLabel.

ActionMenuLabel

A non-interactive heading; a menu label on desktop and the sheet title on mobile.

Also accepts the props of React.HTMLAttributes<HTMLElement>.

Also accepts className, children and id.

ActionMenuItem

An actionable entry that closes the menu when chosen.

PropTypeDefault
variant"default" | "destructive"-
disabledboolean-

Also accepts the props of React.HTMLAttributes<HTMLElement>.

Respond to the item with onAction. Also accepts className, children, id and aria-label.

ActionMenuSeparator

A divider between groups of items, rendered on desktop only.

Also accepts the props of React.HTMLAttributes<HTMLElement>.

Also accepts className.

ActionMenuSeparator renders nothing on mobile; the sheet groups items in a single card instead. Each part sets a data-slot, such as action-menu-content or action-menu-item, for styling.

NextApp ShellPreviousAction Bar

On this page

  1. 01Installation
  2. 02Usage
  3. 03Composition
  4. 04Examples
    • With icons
    • Not dismissible
  5. 05Accessibility
  6. 06API Reference
    • ActionMenu
    • ActionMenuTrigger
    • ActionMenuContent
    • ActionMenuLabel
    • ActionMenuItem
    • ActionMenuSeparator