StealThis .dev

Menubar App

Desktop-style application menubar (File, Edit, View…) with nested submenus, keyboard shortcuts display, and full keyboard navigation.

Open in Lab
css vanilla-js
Targets: JS HTML

Code

A desktop-application-style menubar (File · Edit · View · Help) with dropdown menus, nested submenus, keyboard shortcut hints, dividers, and full keyboard navigation.

Features

  • Top-level menu items open on click (or hover after first open)
  • Nested submenus with arrow indicator and right-side expand
  • Keyboard shortcut labels aligned to the right (⌘S, Ctrl+Z, etc.)
  • Divider rows between groups
  • Keyboard: ←→ between top items, ↑↓ inside open menu, Escape closes
  • Click outside or focus-out closes open menus

How it works

  1. Menu state is tracked with a currentOpenMenu variable; toggling adds .open class
  2. Submenus are positioned left: 100% relative to their parent item
  3. mouseenter on other top-level items auto-switches when one is already open
  4. role="menubar", role="menu", role="menuitem" ARIA pattern