121
GitHub
OverlaysGlass surface

ContextMenu

Provides contextual actions for a selected object.

FrameworksAstro · React · Elements

Registry commandlumen add ContextMenu

InteractionEnhanced runtime

01

See it in context

Preview

Right-click (or press Shift+F10) inside this area
02

Copy a working example

Usage

Astro examples assume UIPrimitives is mounted once in your root layout. Do not add the runtime next to each component instance.

astro
---
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>
---
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>
03

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.

bash@santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
bashAstro wrapper
lumen add ContextMenu
lumen add ContextMenu

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.

astro
---
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>
---
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>

API reference

Lumen-specific props and runtime attributes for the Astro primitive. React props follow the same names; Elements use equivalent kebab-case attributes where custom elements expose them.

AttributeValuesDefaultDescription
glassboolean | "subtle" | "strong"falseApplies the tokenized liquid-glass surface treatment with backdrop-filter fallbacks; "subtle" and "strong" adjust the fill intensity.
surface"default" | "glass""default"Deprecated alias for glass; surface="glass" maps to glass={true}.
class, classNamestring""Merges custom classes with the generated ui-* root classes.
...native attributesHTML 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.

KeyAction
ContextMenu, Shift+F10 on triggerOpen the linked menu near the trigger and focus the first focusable menu item.
Escape in menuClose the menu and return focus to the trigger.
ArrowDown, ArrowUp in menuMove focus through focusable menu items, wrapping at the ends.
Home, End in menuMove focus to the first or last focusable menu item.