StealThis .dev

Hamburger Menu

An animated hamburger icon that morphs to an X and opens a fullscreen navigation overlay with staggered link reveals. No libraries.

Open in Lab
vanilla-js css
Targets: JS HTML

Code

Hamburger Menu

A classic three-line hamburger button that animates into an X and reveals a fullscreen navigation overlay. Navigation links stagger in with a slide and fade effect. Closes on link click, backdrop click, or Escape key.

How it works

  1. The three .bar spans use CSS transform to rotate into an X when .open is applied
  2. The fullscreen nav slides in from the right with translateX
  3. Nav links animate in with staggered transition-delay values
  4. Escape key and clicking any nav link close the menu

Accessibility

  • aria-expanded on the button toggles between "true" / "false"
  • aria-controls links the button to the nav panel
  • role="dialog" and aria-modal="true" on the overlay

When to use it

  • Mobile-first sites that need a minimal header with a full-page nav
  • Marketing or portfolio sites with a small number of pages