04.23 · Micro-Interactions

Hamburger Menu Toggle

Three lines turn into an X as the menu opens. Best for mobile menus.

Click it

Press the button to open the menu and again to close it, or press Show me.

Try it

Change a setting, then try it again or press Show me.

Speed

How long the lines take to turn into an X.

Feel

Springy lets the X overshoot a little, then settle.

More optionsFewer options

Line thickness

Thicker lines read better at small sizes.

Copy the prompt

Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.

Add a menu button whose three lines turn into an X to [the menu button in your header]. When it is pressed, the top and bottom lines move to the middle and turn to cross each other while the middle line fades away, and pressing it again reverses the change. Use the same three lines for both states, moving and turning them rather than swapping icons, and move each outer line exactly to the middle so the X meets at its center. Make it a real button that tells screen readers whether the menu is open. If the visitor has reduced motion turned on, switch between the two icons without movement. Match the settings listed below.

Replace the words in brackets with your own element. Your settings are added at the end.

Free and open source. If this helped, a star on GitHub helps other people find it.

Star on GitHub

What it is

The full explanation is in README.md.

Good for

  • Mobile menus
  • Compact headers
  • Side panels

Avoid on

  • Wide desktop menus