Component reference
ContextMenu
Contextual commands for a project row.
Preview
Live previewOptional six-digit hex. Clear to restore the preset. Check contrast with your brand color.
Changes apply to this preview only.
Width adapts to the available space
"use client";
import { useState } from "react";
import {
Button,
Card,
CardHeader,
CardTitle,
CardContent,
ContextMenu,
ContextMenuTrigger,
ContextMenuContent,
ContextMenuItem
} from "@pimolu/react";
export function DemoExample() {
const [action, setAction] = useState("No command selected.");
return (
<Card>
<CardHeader>
<CardTitle>Project Atlas</CardTitle>
</CardHeader>
<CardContent>
<div
className="grid gap-5 min-w-0"
>
<p id="project-menu-help">
Right-click the project or focus it and press Shift F10. The
visible actions below provide an alternative.
</p>
<ContextMenu>
<ContextMenuTrigger>
<Button
appearance="outline"
aria-describedby="project-menu-help"
>
Project Atlas · production
</Button>
</ContextMenuTrigger>
<ContextMenuContent>
<ContextMenuItem
onSelect={() => setAction("Project details opened locally.")}
>
Open details
</ContextMenuItem>
<ContextMenuItem
onSelect={() => setAction("Project removed from this demo's recent list.")}
>
Remove from recents
</ContextMenuItem>
</ContextMenuContent>
</ContextMenu>
<div className="flex flex-wrap items-center gap-3 min-w-0">
<Button
size="sm"
appearance="ghost"
onClick={() => setAction("Project details opened locally.")}
>
Open details
</Button>
<Button
size="sm"
appearance="ghost"
onClick={() => setAction("Project removed from this demo's recent list.")}
>
Remove from recents
</Button>
</div>
<p
role="status"
>{
action
}</p>
</div>
</CardContent>
</Card>
);
}More examples
Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.
Document commands
Right-click or press Shift+F10 on the focusable document; selection is reported.
Right-click area
Right-click anywhere inside the surface. The native menu is suppressed.
Examples
A row or card can own its context menu without changing the surrounding layout.
Usage
Offer the same actions through a visible alternative because right click is not universally discoverable.
API reference
Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.
PimoluContextMenuProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
childrenRequired | ReactNode | — | Public Pimolu prop; see the source declaration for details. |
open | boolean | undefined | — | Controlled open state. Omit to let the component own it. |
defaultOpen | boolean | undefined | false | Initial open state when uncontrolled. Defaults to false. |
onOpenChange | ((open: boolean) => void) | undefined | — | Called whenever the component asks to open or close. |
childrenRequiredReactNodeNo default extracted.
Public Pimolu prop; see the source declaration for details.
openboolean | undefinedNo default extracted.
Controlled open state. Omit to let the component own it.
defaultOpenboolean | undefinedDefault: false
Initial open state when uncontrolled. Defaults to false.
onOpenChange((open: boolean) => void) | undefinedNo default extracted.
Called whenever the component asks to open or close.
PimoluContextMenuTriggerProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
childrenRequired | ReactElement<unknown, string | JSXElementConstructor<any>> | — | The single element that opens the menu. It gets the contextmenu handler and the ref, and the handlers it already had keep working. |
childrenRequiredReactElement<unknown, string | JSXElementConstructor<any>>No default extracted.
The single element that opens the menu. It gets the contextmenu handler and the ref, and the handlers it already had keep working.
PimoluContextMenuContentProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
childrenRequired | ReactNode | — | Public Pimolu prop; see the source declaration for details. |
collisionPadding | number | undefined | 8 | Minimum distance kept from the viewport edges, in pixels. Defaults to 8. |
className | string | undefined | — | Class applied to the menu panel. |
childrenRequiredReactNodeNo default extracted.
Public Pimolu prop; see the source declaration for details.
collisionPaddingnumber | undefinedDefault: 8
Minimum distance kept from the viewport edges, in pixels. Defaults to 8.
classNamestring | undefinedNo default extracted.
Class applied to the menu panel.
PimoluContextMenuItemProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
childrenRequired | ReactNode | — | Public Pimolu prop; see the source declaration for details. |
onSelect | (() => void) | undefined | — | Called before the menu closes and focus returns to the trigger. |
disabled | boolean | undefined | false | Public Pimolu prop; see the source declaration for details. |
childrenRequiredReactNodeNo default extracted.
Public Pimolu prop; see the source declaration for details.
onSelect(() => void) | undefinedNo default extracted.
Called before the menu closes and focus returns to the trigger.
disabledboolean | undefinedDefault: false
Public Pimolu prop; see the source declaration for details.
PimoluContextMenuSeparatorProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
className | string | undefined | — | Public Pimolu prop; see the source declaration for details. |
classNamestring | undefinedNo default extracted.
Public Pimolu prop; see the source declaration for details.
PimoluContextMenuLabelProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
childrenRequired | ReactNode | — | Public Pimolu prop; see the source declaration for details. |
className | string | undefined | — | Public Pimolu prop; see the source declaration for details. |
childrenRequiredReactNodeNo default extracted.
Public Pimolu prop; see the source declaration for details.
classNamestring | undefinedNo default extracted.
Public Pimolu prop; see the source declaration for details.
Accessibility
- Verify the keyboard context-menu path, menu navigation, dismissal and focus return.