Morph Icon
An animated SVG icon that morphs between two states by animating path and shape geometry directly, with no path-morph library.
Installation
npx smoothui-cli add morph-iconFeatures
- Eight ready-made variants:
sidebar,list,grid,compact,menu,search,play,check - Morphs by animating SVG geometry attributes (
x1/y1/x2/y2,d,r,pathLength) directly — no path-morph library - Toggle-driven via a single
activeboolean prop - Customizable size, stroke width, color, and duration
- Purely decorative by default, or an accessible labeled image when
labelis passed - Respects reduced motion preferences
Accessibility
ARIA Attributes
| Attribute | Element | Purpose |
|---|---|---|
aria-hidden="true" | <svg> | Applied when no label is passed, hiding a purely decorative icon from assistive technology |
role="img" | <svg> | Applied when label is passed, exposing the icon as a single accessible image |
<title> | <svg> child | Provides the accessible name for the icon when label is passed |
Keyboard Interactions
This component renders a static graphic with no interactive elements of its own; it has no keyboard interactions. Wrap it in a <button> or other interactive element to make it actionable, and drive the active prop from that element's state.
Screen Reader
- Without a
label, the icon isaria-hiddenand is skipped entirely by screen readers — pair it with visible or accessible text on its container. - With a
label, the icon is announced as an image with that label as its accessible name.
Reduced Motion
This component respects the prefers-reduced-motion media query via useReducedMotion from Motion. When reduced motion is preferred, all geometry transitions snap instantly between states with duration: 0.
Props
Created by
Powered by
© 2026 SmoothUI. Built by Eduardo Calvo.