Skip to content

Context Menu

Free

A menu that opens where people right-click or press and hold. It holds the actions for the thing under the pointer, with keys, toggles, and submenus.

  • Base UI
  • React 19
  • Tailwind CSS 4

Added Nov 8, 2026 · MIT + Commons Clause

Playground

Loading the preview

Props

ContextMenuTrigger is a plain div with no look of its own. Nothing shows that the menu is there, so make every action reachable another way.

file-row-menu.tsx

ContextMenu

PropTypeDefaultDescription
From Base UIContextMenu.RootBase UI docs
onOpenChange—Event handler called when the menu is opened or closed.
closeParentOnEscboolean—Deprecated: This prop has no effect on Context Menu.
childrenReactNode—

ContextMenuTrigger

<div>
PropTypeDefaultDescription
classNamestring—
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

ContextMenuPortal

<div>
PropTypeDefaultDescription
From Base UIMenu.PortalBase UI docs
keepMountedbooleanfalseWhether to keep the portal mounted in the DOM while the popup is hidden.
container—A parent element to render the portal element into.
className—CSS class applied to the element, or a function that returns a class based on the component's state.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

ContextMenuContent

<div>
PropTypeDefaultDescription
classNamestring—
arrowbooleanfalseShow an arrow that points at the trigger. The gap grows from 4px to 8px.
backdropbooleanfalsePut a clear layer under the popup (Base UI Menu.Backdrop), for example to dim it.
portalProps—Other Base UI props of the inner parts. A className here adds to the component classes.
positionerProps—
backdropPropsPopupPartProps<MenuBackdropProps>—
arrowPropsPopupPartProps<MenuArrowProps>—
From Base UIMenu.PopupBase UI docs
childrenReactNode—
idstring—
finalFocus—Determines the element to focus when the menu is closed. - false: Do not move focus. - true: Move focus based on the default behavior (trigger or previously focused element). - RefObject: Move focus to the ref element. - function: Called with the interaction type (mouse, touch, pen, or keyboard). Return an element to focus, true to use the default behavior, or false/undefined to do nothing.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.
  • Use it for quick actions on a row, a card, or a canvas.
  • Use it as a second way to reach actions that the page also shows.
  • Use the same item parts as the Menu: items, links, checks, radio items, and submenus.
  • For the only way to reach an action, use a Menu.
  • For a long list that needs a filter field, use a Menu.
Arrow DownorArrow UpMoves to the next or the previous item.
HomeorEndMoves to the first or the last item.
EnterorSpaceRuns the item, or changes a check or a radio choice.
Letter keysMoves to the item whose text starts with the typed letters.
Arrow RightOpens a submenu. In right to left, use Arrow Left.
Arrow LeftCloses a submenu. In right to left, use Arrow Right.
EscapeCloses the menu.

It is a Base UI Context Menu. The popup has the menu role, and the arrow keys move between items.

A right click opens it on a desktop, and a 500ms press and hold opens it on touch.

A keyboard has no sure way to open it, so give each action another path.

Open
popup · 150ms · ease-panel (0.2, 0.4, 0.2, 1) · fades in and scales from 95%
Close
popup-exit · 120ms · ease-out (0, 0, 0.2, 1)

Built with

Installs with Context Menu

Components
Menu
  1. AddedContext Menu, with Menu.
Open the release