ContextMenu

App

Right-click context menu. Wraps any element as a trigger. Supports item groups, keyboard shortcuts, separators, danger items, and disabled items. Positions itself via viewport-aware boundary detection, auto-flips when near screen edges. Full keyboard navigation: ↑↓ arrows, Enter, Escape.

Text editor — clipboard + format actions

Preview
Right-click anywhere in this area
Code
<%- include('modules/app/ContextMenu', {
  children: '<div class="p-8 text-center text-sm text-text-secondary border-2 border-dashed border-border rounded-xl">Right-click anywhere in this area</div>',
  items: [
    { label: 'Cut',       icon: '<i class="fa-solid fa-scissors text-xs"></i>', shortcut: '⌘X' },
    { label: 'Copy',      icon: '<i class="fa-solid fa-copy    text-xs"></i>', shortcut: '⌘C' },
    { label: 'Paste',     icon: '<i class="fa-solid fa-paste   text-xs"></i>', shortcut: '⌘V' },
    { type: 'separator' },
    { label: 'Copy link', icon: '<i class="fa-solid fa-link    text-xs"></i>', shortcut: '⌘⇧C' },
    { type: 'separator' },
    { label: 'Rename',    icon: '<i class="fa-solid fa-pen     text-xs"></i>' },
    { label: 'Delete',    icon: '<i class="fa-solid fa-trash   text-xs"></i>', shortcut: '⌫', danger: true },
  ]
}) %>

File manager — groups + shortcut hint

Preview
Report Q1.pdf
Design System.fig
README.md
Code
<% files.forEach(function(file) { %>
  <%- include('modules/app/ContextMenu', {
    children: fileCardHtml(file),
    items: [
      { type: 'group', label: 'Actions' },
      { label: 'Open',     icon: '<i class="fa-solid fa-eye         text-xs"></i>' },
      { label: 'Download', icon: '<i class="fa-solid fa-download    text-xs"></i>', shortcut: '⌘D' },
      { label: 'Share',    icon: '<i class="fa-solid fa-share-nodes text-xs"></i>', shortcut: '⌘⇧S' },
      { type: 'separator' },
      { type: 'group', label: 'Organise' },
      { label: 'Move to…', icon: '<i class="fa-solid fa-arrow-right text-xs"></i>' },
      { label: 'Add tag',  icon: '<i class="fa-solid fa-tag         text-xs"></i>' },
      { type: 'separator' },
      { label: 'Delete',   icon: '<i class="fa-solid fa-trash       text-xs"></i>', danger: true },
    ]
  }) %>
<% }); %>

Code branch — some items disabled

Preview
feature/context-menu (right-click)
Code
<%- include('modules/app/ContextMenu', {
  children: branchRowHtml,
  items: [
    { label: 'View diff',        icon: '<i class="fa-solid fa-code-branch  text-xs"></i>' },
    { label: 'Copy branch name', icon: '<i class="fa-solid fa-copy         text-xs"></i>', shortcut: '⌘C' },
    { type: 'separator' },
    { label: 'Merge into main',  icon: '<i class="fa-solid fa-arrow-right  text-xs"></i>', disabled: true },
    { label: 'Cherry-pick',                                                                 disabled: true },
    { type: 'separator' },
    { label: 'Delete branch',    icon: '<i class="fa-solid fa-trash        text-xs"></i>', danger: true },
  ]
}) %>
Source modules/app/ContextMenu.ejs