Xzero UI
Pro library

Icon morph

Icons that morph between states: menu to close, play to pause, copy to check, and more.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui/icon-morph
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui/icon-morph

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { useState } from "react";
import { IconMorph } from "@/components/xzero/icon-morph/icon-morph";

export function MenuToggle() {
  const [open, setOpen] = useState(false);
  return (
    <button type="button" aria-label="Menu" aria-expanded={open} onClick={() => setOpen(value => !value)}>
      <IconMorph name="menu" state={open} size={20} />
    </button>
  );
}

API reference

IconMorph

One entry point for eight two-state icons that morph instead of swapping. Pick one by name and drive it with state.

PropTypeDefaultDescription
name (required)"menu" | "play" | "plus" | "copy" | "theme" | "chevron" | "bell" | "heart"–Which icon to render.
statebooleanfalseThe second state: menu to close, play to pause, plus or copy to check, sun to moon, chevron turned, bell on, heart liked.
sizenumber24Rendered size in px.
strokeWidthnumber1.75Stroke width in the 24 unit grid.
...propsOmit<SVGProps<SVGSVGElement>, "ref" | "children">–Forwarded to the svg.

MenuIcon

Menu to close: outer lines rotate into an X and the middle line folds away. Takes the same props as IconMorph without name.

No props.

PlayPauseIcon

Play to pause: the triangle splits into two halves that straighten into bars.

No props.

PlusCheckIcon

Plus to check: each bar swings its ends into one leg of the check.

No props.

CopyCheckIcon

Copy to check: the sheets tuck away and a check draws in.

No props.

SunMoonIcon

Sun to moon: the disc grows while a shadow carves the crescent and the rays fold in.

No props.

ChevronIcon

A chevron that turns on a spring, for disclosure and sort controls.

PropTypeDefaultDescription
turnnumber180Degrees the chevron turns when state is true. 180 flips down to up; 90 turns right to down.
pointing"down" | "right""down"Where the chevron points at rest.

BellIcon

Notifications: turning on rings the bell with a lagging clapper; turning off strikes it through.

No props.

HeartIcon

Like: the heart fills with a pop and a ring and sparks burst once. Liked color is --icon-morph-like, default --danger.

No props.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in buttons

Guidance for AI tools

Icon morph: Icons that morph between states: menu to close, play to pause, copy to check, and more. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components