Skip to main content
NetScriptdocs Search docs ⌘K v0.0.9
Browse documentation

ContextMenu

Pointer and keyboard context region with native shared menu content.

All components · Theme builder · Implementation source

Live preview

Open live context-menu preview

Install

Shell
netscript ui:add context-menu

Usage and examples

The preview runs this JSX with the installed components. Import any composed primitives from your UI directory.

TypeScript
import { useState } from 'preact/hooks';
import { Button } from '@app/components/ui/button.tsx';
import { ContextMenu } from '@app/components/ui/context-menu.tsx';

export function Example() {
  const [value, setValue] = useState('standard');
  const [open, setOpen] = useState(false);
  const [notice, report] = useState('');
  return (<><div><ContextMenu label="Order actions" items={[{id:"save",label:"Save order",onSelect:()=>report("Saved")}]}><Button variant="outline">Order actions</Button></ContextMenu></div><p role="status">{notice}</p></>);
}

Props

Generated from native deno doc --json --private over the shipped implementation. Compound component props retain their owning interface; native attributes pass through where declared.

OwnerPropTypeOptionalDescription
ContextMenuPropslabelstringNo
ContextMenuPropsitems[object Object]No
ContextMenuPropschildrenComponentChildrenNo
ContextMenuPropsopenbooleanYes
ContextMenuPropsdefaultOpenbooleanYes
ContextMenuPropsonOpenChange(open: boolean) => voidYes
ContextMenuPropsdisabledbooleanYes
ContextMenuPropsclassstringYes
TypeScript
ContextMenuProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "class">

Keyboard

KeyAction
ArrowUp/ArrowDownNavigate items
Enter/SpaceActivate focused item
EscapeDismiss menu
Shift+F10/ContextMenuOpen at the focused context region.
Home/End/printable characterTraverse current menu using shared ActionMenu behavior.
Tab/Shift+TabClose and leave through the native focusable region.

Tokens

Semantic contract roles: surface/card, text/fg.

CSS custom properties referenced directly: --ns-border, --ns-border-width, --ns-floating-fallback-inset, --ns-muted-fg, --ns-ring, --ns-space-16, --ns-space-4, --ns-text-small.

Contract and compatibility

Accessibility pattern: WAI-ARIA guidance

  • Focusable native group region supports pointer contextmenu and Shift+F10/ContextMenu invocation; rich content can retain its own native semantics.
  • Shared ActionMenu content owns menu keys and choices/submenus; native top layer plus fixed client coordinates provide pointer placement and viewport clamping.
  • Explicit Escape/action restores context-region focus; outside dismissal keeps its destination. Browser-forced native dismissal remains platform-owned.

Design contract values marked planned are not implementation props. The props above describe what ships today.

Search all documentation

Type a term to search the documentation.