Motion Hamburger
A premium animated hamburger toggle that morphs into a close icon with SVG path-drawing, elastic rotation, and an optional ring.
Installation#
pnpm dlx shadcn@latest add @davinciui/motion-hamburgerUsage#
API Reference#
| Prop | Type | Default |
|---|---|---|
initialStateUncontrolled starting state of the toggle. | "closed" | "open" | "closed" |
openControlled open state. Omit for uncontrolled toggling. | boolean | — |
onToggle / onOpenChangeFired on every toggle with the next state. Connect overlays, drawers, or nav variants. | (isOpen: boolean) => void | — |
sizeIcon box size in pixels, clamped from 24 to 500. Geometry scales automatically. | number | 48 |
colorStroke color of the three lines. | string | "#FFFFFF" |
thicknessStroke width in SVG units, clamped from 1 to 8. | number | 2.5 |
showRingShow a subtle circular ring around the icon. | boolean | false |
ringColorRing stroke color. | string | "rgba(255, 255, 255, 0.35)" |
ringThickness / ringPaddingRing stroke width and gap around the icon in pixels. | number / number | 1 / 6 |
hoverGrowthHover scale for the whole assembly, clamped from 1 to 1.3. | number | 1.05 |
className / styleAdditional styling for the component root. | string / CSSProperties | — |
Accessibility#
The control is a real button with aria-expanded and a dynamic Open menu or Close menu label, so Enter and Space work natively. focus-visible shows a 2px outline; consumers can override the label or add their own.
Motion#
Top and bottom SVG paths redraw with 620ms stroke-dash transitions, the icon rotates with an overshoot easing, and the middle line collapses. prefers-reduced-motion reduces transition durations to near zero; no timing props are exposed beyond hoverGrowth.
About Motion Hamburger#
A hamburger toggle that morphs into a close icon with real SVG path-drawing — not three rotating divs.
The top and bottom strokes carry hidden curved geometry. On toggle, different portions of each path are revealed with stroke-dasharraywhile the whole icon rotates 45 degrees with an elastic overshoot and the middle line collapses. All four motions run together for the signature fluid feel.
Wire onToggle to a mobile nav, fullscreen overlay, sidebar, or drawer. Pass open to control the icon from outside.
Controls#
- Initial State sets whether the icon loads as a hamburger or an X.
- Icon controls size (24 to 500px, geometry scales automatically), stroke color, and line thickness.
- Ring adds a subtle circular ring that breathes with the toggle.
- Hover Growth scales the whole assembly on hover without disturbing the morph rotation.
- Keyboard toggles with Enter or Space and shows a visible focus ring. Reduced-motion preferences remove the overshoot while preserving both states.
Best For#
Site headers, mobile navigation triggers, fullscreen overlays, sidebars, drawers, and off-canvas menus that need a polished menu-to-close microinteraction.
View source
Keep in mind
Need a custom component?
I build bespoke UI components & websites tailored to your brand.

