Metamorph

Icon Morph

Icons that flow into each other: menu and close, play and pause.

Preview

Installation

Terminal
npx @usefluid/cli add icon-morph

Usage

IconMorph.tsx
import { IconMorph, icons } from "./IconMorph";

<IconMorph on={open} off={icons.menu} onIcon={icons.close} label="Menu" onClick={() => setOpen(!open)} />

API reference

PropTypeDefaultDescription
onboolean—Which icon is showing.
offstring—Path shown when on is false. Ready ones: icons.menu, play, plus.
onIconstring—Path shown when on is true. Ready ones: icons.close, pause, check.
labelstring—Accessible name of the button.
...button props—Anything a <button> takes, like onClick.

Keyboard and screen readers

A real button with aria-pressed. Draw your own icons in a 120 x 120 box, filled, not stroked.

Notes

For a menu that also opens, use MenuMorph.

Every colour comes from the --fluid-* variables, and the piece is yours to change.

How it is made

The same engine as the logo, in a 56 px button. The three menu bars become the X: one bar flows into the new shape and the other two shrink into a point. The button reports its state with aria-pressed.

For your agent

For your agent

Add Icon Morph to my project with the Fluid library. Replace the open and close, play and pause icons in my project with IconMorph. Read my project first. Use my logo, my colours and my font through the --fluid-* variables. Keep 44px touch targets, visible focus and reduced motion. If I have no SVG logo, ask before making one up.