ContextMenu
Provides contextual actions for a selected object.
See it and copy it
Framework example
Choose Astro, React, or Elements to compare native usage against the shared visual output. Each example assumes the framework-level setup is already complete.
View ContextMenu code
Framework usage
Switch targets to compare the adapter code. This live preview runs the Astro example. React and Elements use their own behavior APIs; complete the matching framework setup before copying an example.---
import { ContextMenu } from '@santi020k/lumen-astro'
---
<div
data-ui-context-menu-trigger="ex-context-menu"
style="border: 1px dashed hsl(var(--line)); border-radius: 0.5rem; padding: 2rem; text-align: center;"
tabindex="0"
>
Right-click (or press Shift+F10) inside this area
</div>
<ContextMenu aria-label="Project actions" id="ex-context-menu">
<button role="menuitem" type="button">Duplicate</button>
<button role="menuitem" type="button">Rename</button>
<button role="menuitem" type="button">Delete</button>
</ContextMenu>'use client'
import { Button, ContextMenu, useContextMenu } from '@santi020k/lumen-react'
export function Example() {
const menu = useContextMenu()
return (
<>
<Button {...menu.triggerProps} variant="outline">Right-click or press Shift+F10 for project actions</Button>
<ContextMenu {...menu.menuProps} aria-label="Project actions">
<Button role="menuitem" onClick={menu.close} variant="ghost">Duplicate preview</Button>
<Button role="menuitem" onClick={menu.close} variant="ghost">Close menu</Button>
</ContextMenu>
</>
)
}<script type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<div
data-ui-context-menu-trigger="ex-context-menu"
style="border: 1px dashed hsl(var(--line)); border-radius: 0.5rem; padding: 2rem; text-align: center;"
tabindex="0">
Right-click (or press Shift+F10) inside this area
</div>
<lumen-context-menu aria-label="Project actions" id="ex-context-menu">
<button role="menuitem" type="button">Duplicate</button>
<button role="menuitem" type="button">Rename</button>
<button role="menuitem" type="button">Delete</button>
</lumen-context-menu>Framework differences
React: Spread useContextMenu triggerProps and menuProps onto the trigger button and menu. Astro trigger attributes do not connect the React components.
Choose your target
Add this component
Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.
Glass
Add the glass prop to apply the shared blur, saturation, border, and highlight tokens. Glass reads best over vivid content, so place the surface above imagery or color.
View ContextMenu code
Framework usage
Switch targets to compare the adapter code. This live preview runs the Astro example. React and Elements use their own behavior APIs; complete the matching framework setup before copying an example.---
import { ContextMenu } from '@santi020k/lumen-astro'
---
<div class="docs-glass-demo" style="justify-items: center;">
<ContextMenu aria-label="Project actions" glass>
<button role="menuitem">Duplicate</button>
<button role="menuitem">Rename</button>
<button role="menuitem">Move to workspace</button>
<button role="menuitem">Delete</button>
</ContextMenu>
</div>'use client'
import { Button, ContextMenu, useContextMenu } from '@santi020k/lumen-react'
export function Example() {
const menu = useContextMenu()
return (
<>
<Button {...menu.triggerProps} variant="outline">Right-click or press Shift+F10 for project actions</Button>
<ContextMenu {...menu.menuProps} aria-label="Project actions">
<Button role="menuitem" onClick={menu.close} variant="ghost">Duplicate preview</Button>
<Button role="menuitem" onClick={menu.close} variant="ghost">Close menu</Button>
</ContextMenu>
</>
)
}<script type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<div class="docs-glass-demo" style="justify-items: center;">
<lumen-context-menu aria-label="Project actions" glass>
<button role="menuitem">Duplicate</button>
<button role="menuitem">Rename</button>
<button role="menuitem">Move to workspace</button>
<button role="menuitem">Delete</button>
</lumen-context-menu>
</div>API reference
Lumen-specific props and runtime attributes for the Astro primitive. Use the framework differences above and the copyable examples for React composition and Elements attributes; the public adapter types define their supported contracts.
| Attribute | Values | Default | Description |
|---|---|---|---|
| glass | boolean | "subtle" | "strong" | false | Applies the tokenized liquid-glass surface treatment with backdrop-filter fallbacks; "subtle" and "strong" adjust the fill intensity. |
| class, className | string | "" | Merges custom classes with the generated ui-* root classes. |
| ...native attributes | HTML attributes | - | Forwards standard attributes to the root element unless the component consumes them. |
Keyboard interactions
Keyboard behavior provided by the Astro UIPrimitives runtime for this component.
| Key | Action |
|---|---|
| ContextMenu, Shift+F10 on trigger | Open the linked menu near the trigger and focus the first focusable menu item. |
| Escape in menu | Close the menu and return focus to the trigger. |
| ArrowDown, ArrowUp in menu | Move focus through focusable menu items, wrapping at the ends. |
| Home, End in menu | Move focus to the first or last focusable menu item. |