Skip to content
satin

Context menu

The actions for one thing, at the pointer, on right-click or a long press.

Installation

Terminal
npm i @uisatin/ui
Import
import { ContextMenu, ContextMenuItem, ContextMenuSeparator } from '@uisatin/ui/context-menu'

About 46.1 kB of JavaScript, minified and gzipped, with what it imports (React aside). The stylesheet is one file for every component.

First time with Satin? Set it up once, styles and fonts included, with the installation guide.

API Reference

The ContextMenu component opens on right-click or a long press of its trigger, at the pointer. ContextMenuItem, ContextMenuSub and ContextMenuSeparator build the list.

PropTypeDefault
trigger
ReactNode
—
children
ReactNode
—
onOpenChange
(open: boolean) => void
—
modal
boolean
true
ContextMenuItem.label
string
—
ContextMenuItem.icon
ReactNode
—
ContextMenuItem.shortcut
string
—
ContextMenuItem.destructive
boolean
—
ContextMenuSub.label
string
—
className
string
—
ref
Ref<HTMLElement>
—
...props
ComponentProps<typeof Context.Content>

Other attributes go to the Radix Context.Content part

—

Accessibility

A Radix context menu on the trigger, opened by the contextmenu event: right-click, a long press, or Shift+F10 and the menu key when the trigger has focus, so make the trigger focusable. The panel is a menu of menuitem rows; a submenu row has aria-haspopup="menu". Shortcuts are only shown. Keyboard and screen-reader users can’t always reach a context menu, so put the same actions somewhere else too.

KeyAction
Shift+F10On the focused trigger: opens the menu, where the browser fires contextmenu.
↑or↓Moves between items.
HomeorEndMoves to the first or last item.
A–ZMoves to the next item whose label starts with the typed letters.
EnterorSpaceRuns the focused item, or opens its submenu.
→Opens the submenu of the focused row.
←Closes the submenu and goes back to its row.
EscCloses the menu.