Getting StartedComponentsDesign TokensThemingTheme SynthesizerFrameworksAccessibilityUtilitiesServer RenderingBrowser SupportContributingChangelogApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip
ARC UIARC Radiant Components
v4.9DocsComponentsTokensSynthesizer
Getting StartedFrameworksServer RenderingDesign TokensThemingTheme SynthesizerTypographyUtilitiesAll ComponentsAccessibilityBrowser SupportChangelogContributingStatsApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip

Context Menu

Right-click context menu with keyboard shortcuts.

ComponentsContext Menu
feedbackinteractive
<arc-context-menu>

Overview

ContextMenu replaces the browser's native right-click menu with a styled menu that matches your application's design system. It attaches a `contextmenu` event listener to its parent element, so any right-click within that parent opens the custom menu at the cursor position. The menu supports icons, labels, keyboard shortcut hints, disabled items, and visual dividers via `<arc-menu-item>` and `<arc-menu-divider>` children. The menu appears with a scale-in animation and flips away from viewport edges so it never renders off-screen. When an item is clicked or activated via keyboard, the component dispatches an `arc-select` event with the item's label, shortcut, and icon metadata, then closes itself. Clicking the transparent backdrop or pressing Escape also dismisses the menu. Keyboard navigation follows the standard menu pattern: ArrowDown and ArrowUp move focus through selectable items (skipping dividers and disabled entries), Home and End jump to the first and last items, Enter or Space activate the focused item, and Escape closes the menu. The `prefers-reduced-motion` media query disables the entrance animation for users who request it.

Guidelines

When to use

  • Place ContextMenu as a direct child of the element that should trigger the right-click menu
  • Group related items with <arc-menu-divider> to improve scannability (e.g. clipboard actions, then navigation actions)
  • Include keyboard shortcut hints on items that have global keybindings for consistency
  • Disable items that are contextually unavailable rather than removing them, so users learn the full action set
  • Keep the menu under 10 items; use submenus or a CommandPalette for larger action sets

When not to use

  • Do not attach a ContextMenu to the entire document body. Scope it to a specific interactive region
  • Do not put complex UI (forms, multi-select lists) inside context menu items
  • Do not forget to handle the arc-select event; without it, selecting an item has no effect
  • Do not mix ContextMenu with DropdownMenu on the same element; they serve different interaction models
  • Do not remove the default Escape-to-close behavior, as keyboard users depend on it

Features

  • Automatically intercepts contextmenu events on the parent element
  • Viewport-aware positioning that flips to avoid off-screen rendering
  • Scale-in entrance animation with `prefers-reduced-motion` support
  • Keyboard navigation: ArrowUp/Down, Home/End, Enter/Space to select, Escape to close
  • Support for icons, labels, shortcut hints, and disabled state on each menu item
  • Visual dividers via `<arc-menu-divider>` to group related actions
  • `arc-select` event with item metadata (label, shortcut, icon) on activation
  • Transparent backdrop click-to-close

Preview

Right-click anywhere in this box Cut Copy Paste Select All Delete

Usage

This component requires JavaScript. No pure HTML/CSS version is available. Use the Web Component directly or a framework wrapper.

<arc-context-menu>
  <div slot="trigger">Right-click me</div>
  <arc-menu-item shortcut="⌘C">Copy</arc-menu-item>
  <arc-menu-item shortcut="⌘V">Paste</arc-menu-item>
</arc-context-menu>

API

openbooleanfalse
Controls the visibility of the context menu. Set to true when the contextmenu event fires; set to false when the user selects an item, clicks the backdrop, or presses Escape.

Events

arc-open
Fired when the context menu opens
arc-close
Fired when the context menu closes
arc-select
Fired when a menu item is selected

MenuItem

<arc-menu-item>

A single action entry inside the context menu.

displayLabel
The text to draw. label was documented as a prop and implemented as a getter over textContent with no setter and no attribute, so <arc-menu-item label="Cut"></arc-menu-item> rendered a blank item, silently, and the six generated wrappers exposed a writable label that did nothing (finding #32). It is a real property now; the text-content form stays the fallback, so every existing consumer is unaffected.
selectionValue
What arc-select reports. Falls back to the label so an item that never sets value behaves as it always did.
labelstring''
Display text for the menu item. Settable, and falls back to the element's text content when unset: <arc-menu-item label="Cut"> and <arc-menu-item>Cut</arc-menu-item> are equivalent.
shortcutstring''
Keyboard shortcut hint displayed on the right side.
iconstring''
Name of the icon to display before the label.
valuestring''
Stable identifier carried on the arc-select detail. Defaults to the label, which is fine until two items share one. Give anything a handler must act on its own value rather than matching against display text.
disabledbooleanfalse
Disables the item, preventing interaction.

MenuDivider

<arc-menu-divider>

A visual separator between groups of menu items.

MenuLabel

<arc-menu-label>

A heading over a group of menu items. The items after it, up to the next label, form one named group.

displayLabel
labelstring''
The heading text. Falls back to the element's text content when unset, as on arc-menu-item.

See Also