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.
Inside, the dotted X is where the lines end: the top and bottom lines slide to the middle and turn to cross, and the middle one fades. Press the button, or Show me.
Swaps at once: the icon and menu simply change; Becomes an X: the same three lines move into an X and the items arrive one by one. Press the button, or 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.
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.
Your settings
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 GitHubWhat it is
The full explanation is in README.md.