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.
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
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
-
Add the pieces it builds on: Alert Sheet, Dropdown Menu,
use-mobile. -
Copy and paste the following code into your project.
- Update the import paths to match your project setup.
Usage
Composition
Use the following composition to build a ActionMenu:
Examples
With icons
Places an icon before every action. Set variant="destructive" on an item, here Delete, to style it as a destructive action.
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.
Accessibility
- On desktop the popup has the
menurole and each item has themenuitemrole. ArrowDownfrom the trigger opens the menu and focuses the first item; arrow keys move between items andEnterruns the focused one.Escapecloses the menu and returns focus to the trigger.
API Reference
ActionMenu
The root that renders a DropdownMenu on desktop and an AlertSheet on mobile.
| Prop | Type | Default |
|---|---|---|
open | boolean | - |
defaultOpen | boolean | - |
onOpenChange | (open: boolean) => void | - |
dismissible | boolean | true |
children | React.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.
| Prop | Type | Default |
|---|---|---|
render | React.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".
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
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.
| Prop | Type | Default |
|---|---|---|
cancelLabel | string | "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.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "destructive" | - |
disabled | boolean | - |
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.