Skip to main content

React animation example

React Animated Menu: Hamburger to Close Morph

A mobile menu has three moving parts that should feel like one gesture: the icon, the panel and the links. Here the hamburger's bars rotate into an X as a panel expands from the corner, then each link slides in 60 ms after the one above it. Hovering a link moves an indicator to it.

  • 4.4 KB file
  • 5 live inputs
  • React runtime
Live, try it

How this morphing hamburger menu works

  • Open progress is a single spring; the icon, panel radius and each link read from it with their own offsets.
  • Links are staggered by index, so adding a link to the input list keeps the rhythm.
  • Clicking a link fires "navigate" with the link label and closes the menu.

Add it to your React app

Install exodeui, download the file below, and paste this. The code updates as you customize. Other runtimes are in the other tabs.

import { ExodeUICanvas } from 'exodeui';

// react-animated-menu.bexode goes in /public (download it below)
export function ReactAnimatedMenu() {
  return (
    <ExodeUICanvas
      src="/react-animated-menu.bexode"
      fit="Layout"
      autoPlay
      interactive
      onTrigger={(name) => {
        // fires: 'navigate'
      }}
      style={{ width: '100%', height: 520 }}
    />
  );
}

Inputs

InputTypeDefaultRange
openBooleanfalse—
linksTextProduct,Pricing,Docs,Blog,Contact—
accentText#22c55ehex colour
inkText#f8fafchex colour
bgText#0b1110hex colour

Events: navigate

More React animations

The same idea in other frameworks: Flutter 3d drawer menu · Flutter morphing icons · SwiftUI context menu pop