ContextMenu
A menu surface that opens at a right-click's pointer position, composing Menu's popover styling and role="menu" wiring directly so its rows read and behave exactly like a standard menu's.
Right-click a row, or focus it and press the Context Menu key.
2.4 MB · edited by Ana Souza · yesterday
View code
<div mix={[vstack({ gap: 2, align: "stretch" }), is("100%"), maxIs("28rem")]}>
<p mix={[text("sm"), fg("neutral")]}>Right-click a row, or focus it and press the Context Menu key.</p>
<ContextMenu.Trigger
tabIndex={0}
aria-label="q3-board-review.pdf, press the Context Menu key for actions"
mix={[
rounded("lg"),
border({ color: "neutral", width: 1 }),
p(1),
contextMenu("preview-row-menu"),
]}
>
<Item>
<Item.Media>
<FileTextIcon size={18} aria-hidden="true" />
</Item.Media>
<Item.Content>
<Item.Title>q3-board-review.pdf</Item.Title>
<Item.Description>2.4 MB · edited by Ana Souza · yesterday</Item.Description>
</Item.Content>
</Item>
</ContextMenu.Trigger>
<ContextMenu id="preview-row-menu" aria-label="File actions" mix={[menuKeys()]}>
<ContextMenu.Group aria-labelledby="preview-row-menu-file">
<ContextMenu.Label id="preview-row-menu-file">File</ContextMenu.Label>
<ContextMenu.Item mix={[hstack({ gap: 2, align: "center" })]}>
<PencilIcon size={16} aria-hidden="true" />
Rename
<ContextMenu.Shortcut>F2</ContextMenu.Shortcut>
</ContextMenu.Item>
<ContextMenu.Item mix={[hstack({ gap: 2, align: "center" })]}>
<CopyIcon size={16} aria-hidden="true" />
Duplicate
<ContextMenu.Shortcut>⌘D</ContextMenu.Shortcut>
</ContextMenu.Item>
<ContextMenu.Item href="#download" mix={[hstack({ gap: 2, align: "center" })]}>
<DownloadIcon size={16} aria-hidden="true" />
Download
</ContextMenu.Item>
</ContextMenu.Group>
<ContextMenu.Group aria-labelledby="preview-row-menu-share">
<ContextMenu.Label id="preview-row-menu-share">Share</ContextMenu.Label>
<ContextMenu.SubTrigger commandfor="preview-row-menu-share-surface" command="toggle-popover">
Send a copy
<ChevronRightIcon data-slot="icon" size={16} aria-hidden="true" />
</ContextMenu.SubTrigger>
<ContextMenu.CheckboxItem aria-selected="true">Anyone with the link</ContextMenu.CheckboxItem>
</ContextMenu.Group>
<ContextMenu.Separator />
<ContextMenu.Item danger mix={[hstack({ gap: 2, align: "center" })]}>
<TrashIcon size={16} aria-hidden="true" />
<span mix={[weight("medium")]}>Move to trash</span>
<ContextMenu.Shortcut>⌫</ContextMenu.Shortcut>
</ContextMenu.Item>
</ContextMenu>
<ContextMenu.SubContent
id="preview-row-menu-share-surface"
aria-label="Send a copy"
mix={[menuKeys()]}
>
<ContextMenu.Item>Email</ContextMenu.Item>
<ContextMenu.Item>Slack</ContextMenu.Item>
<ContextMenu.Item>Copy link</ContextMenu.Item>
</ContextMenu.SubContent>
</div>Demo apps
Whole pages built only from @sdxc/ui, each for an invented product with its own palette and type. They open in a new tab.
- Food deliveryBocadoBocado, an invented food delivery app: restaurants by cuisine and delivery time, search with filters, menus with options, a cart, checkout and live order tracking on a drawn map./showcase/bocado/demo
- Issue trackerCairnCairn, an invented issue tracker: grouped issue lists with filters in the address, a drag-and-drop board, projects on a roadmap, cycles with burn-up charts and an inbox./showcase/cairn/demo
- Social networkChorusChorus, an invented social network: a live timeline with pictures, link cards, polls and threads, profiles, grouped notifications, search and messages./showcase/chorus/demo
- Code hostDeltaDelta, a code host whose one repository is its own source: a file tree beside the code, line links, blame and the commits list, every file and commit read from git when the site is built./showcase/delta/demo
- Online storeHangwellHangwell, an invented poster shop: collections with facet filters, product pages with format, size and frame pickers and a room preview, a bag, a checkout that adapts to print files, order tracking, downloads and returns./showcase/hangwell/demo
- CMSInkwellInkwell, a demo CMS built from @sdxc/ui/app: posts with count tabs and quick edit, an editor with a quiet save status and a loud Publish, media and settings./showcase/inkwell/demo
- Music streamingMurmurMurmur, an invented music service: home shelves, search by genre, a library, albums, playlists and artists, with a player that keeps playing while you browse./showcase/murmur/demo
- Team chatParleyParley, an invented team chat: channels and direct messages with unread and mention badges, threads, reactions, edits, pins, search, a quick switcher and teammates who type and post live./showcase/parley/demo
- Photo and video networkPinholePinhole, an invented social network for photographs and short videos: a feed under a story tray, full-screen stories, a vertical reels feed, profiles with highlights, Explore and posts with comments./showcase/pinhole/demo
- Ops dashboardPulsePulse, an invented ops dashboard: Northwind's services with live filters, a peek sheet and a bulk bar, metrics that switch one chart, incidents, deploys and settings./showcase/pulse/demo
- Support inboxRelayRelay, an invented support inbox: mailboxes, conversations and the open conversation on one screen, with contacts, reports and settings./showcase/relay/demo
- CalendarSundialSundial, an invented calendar: day, week and month views, an agenda, events you drag, resize and create on the grid, a second time zone, and a find-a-time view across a team in five zones./showcase/sundial/demo
- Chat assistantTernTern, an invented chat assistant: conversations with streamed replies, code and tables, projects, a canvas, sharing and settings./showcase/tern/demo
- Banking & budgetsTuppenceTuppence, an invented personal bank: multi-currency accounts, a statement by day with search and splits, spending and budgets, savings pots, bills ahead, cards that freeze and a transfer flow, all with fake money./showcase/tuppence/demo
- Streaming serviceVesperVesper, an invented streaming service: profiles, a home of sideways shelves under a billboard, series with seasons and episodes, search, My List and a theater player./showcase/vesper/demo
- Travel bookingWayfernWayfern, an invented travel app: stays, flights, cars and packages from one search, results on a real map, seat maps and boarding passes, and one itinerary of trips that exports to calendars./showcase/wayfern/demo
Every demo, landings and docs sites alike, is listed in the showcase.
Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Usage
import { ContextMenu } from "@sdxc/ui/app";Renders Menu unchanged; positioning against the pointer is handled
entirely by the contextMenu() mixin a consuming island applies to
ContextMenu.Trigger, while every nested row stays a real, tab-reachable <a> or <button>.
Composition
The parts the component publishes, each a static property of the host.
ContextMenuContextMenu.TriggerRenders ContextMenu.TriggerProps.children inside a plain<div>, the area a pointer gesture opens the paired ContextMenu against.ContextMenu.GroupRenders ContextMenu.GroupProps.children as one labeled run of rows: Section restyled with a divider above every group but the first.ContextMenu.LabelRenders ContextMenu.LabelProps.children as a ContextMenu.Group's small, muted heading, sized and spaced to sit directly above the group's first row for a dense row of actions.ContextMenu.SubTriggerRenders a row that opens a nested ContextMenu.SubContent surface: Menu.Item restyled with inline-end padding for a trailing chevron icon; pointcommandforat the nested surface'sidwithcommand="toggle-popover".ContextMenu.SubContentRenders a nested surface opened by a ContextMenu.SubTrigger row: ContextMenu itself, defaultingplacementto DEFAULT_SUB_PLACEMENT since a nested row conventionally opens beside itself.ContextMenu.ShortcutRenders ContextMenu.ShortcutProps.children as a row's trailing keyboard-shortcut hint: pushed to the row's inline end, muted, and set in tabular digits so the hints of a column of rows line up.
Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
Also accepts everything in Menu.Props.
ContextMenu.Trigger
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
children | RemixNode | — | Yes | The content the pointer gesture opens ContextMenu against. |
Also accepts everything in TagProps<"div">.
ContextMenu.Group
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
children | RemixNode | — | Yes | The group's rows, typically a ContextMenu.Label followed by a run of ContextMenu.Items. |
Also accepts everything in Section.Props.
ContextMenu.Label
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
children | RemixNode | — | Yes | The group's visible label text. |
Also accepts everything in TagProps<"header">.
ContextMenu.SubTrigger
ContextMenu.SubContent
Also accepts everything in Props.
ContextMenu.Shortcut
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
children | RemixNode | — | Yes | The shortcut hint text, typically a key combination like "⌘⇧D". |
Also accepts everything in TagProps<"span">.