Make an animated hamburger menu
Type your links. Get a menu button that turns into an X and opens a slide-out menu, as HTML, CSS and JS or React.
- Free, no sign-up
- Runs in your browser
- HTML + CSS + JS, React
One per line, or separated by commas. A colour like #1e293b sets the header colour.
Nothing in mind? Try one:
How it works
- Type your links. One per line or separated by commas: "Home, Shop, About, Contact". Bullets and numbers are taken off, and a colour like #1e293b sets the header colour.
- Try it. The preview is a real menu in a phone-sized frame: press the button, or "Open / close", to watch the icon change and the menu open with its links coming in one after another. Every change you make plays again.
- Check it. The page checks the timing against the animation rules for navigation menus (a 300 ms hamburger morph, opening in 200 to 250 ms with ease-out, closing in 150 to 200 ms with ease-in, links 20 to 40 ms apart), the button's touch size and the contrast of the icon and the text.
- Copy it. As HTML, CSS and JS, CSS only, HTML only, the JavaScript function that opens and closes the menu, or a React component, or download a standalone .html page.
Questions
- How fast should a hamburger menu animate?
- The navigation-menus skill changes the hamburger icon in 300 ms, opens a menu in 200 to 250 ms with ease-out and closes it in 150 to 200 ms with ease-in, quicker than it opened. Links come in one after another, 20 to 40 ms apart.
- How does the icon turn into an X?
- The three lines first slide together to the middle, then the top and bottom lines turn 45 degrees while the middle one fades. Closing plays it backwards: the lines turn back, then spread. Each step takes half the icon time, using the CSS translate, rotate and scale properties.
- Is the menu accessible?
- The button is a real button with aria-expanded and aria-controls, and its label switches between Open menu and Close menu. Opening moves focus to the first link, Tab stays inside the open menu, and Escape, a link, the backdrop or a click outside closes it. A closed menu is hidden from the keyboard and from screen readers.
- Is anything uploaded?
- No. The menu, the check and the code are made in your browser. The optional AI advice sends the settings, the links and your description, only when you press its button. If you sign in, the menus you copy or download are also kept in your SkillSafe account.
- Which browsers does it work in?
- Every current browser. The icon uses the separate CSS translate, rotate and scale properties, which work in Chrome and Edge 104 and later, Safari 14.1 and later, and Firefox 72 and later.