UI Components Easy
Hamburger Menu
An animated hamburger icon that morphs to an X and opens a fullscreen navigation overlay with staggered link reveals. No libraries.
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
- The three
.barspans use CSStransformto rotate into an X when.openis applied - The fullscreen nav slides in from the right with
translateX - Nav links animate in with staggered
transition-delayvalues - Escape key and clicking any nav link close the menu
Accessibility
aria-expandedon the button toggles between"true"/"false"aria-controlslinks the button to the nav panelrole="dialog"andaria-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