Icon Morph
Spring morph between icons when control state changes, such as copy to copied.
Copy
Change iconKey when the state changes; the old icon scales and blurs out as the new one comes in. Revert after a short delay.
Toggle
For controls that flip between two states, such as mute and play. iconKey accepts a boolean, string or number.
Best practices
When to use
- Use when an icon button's glyph should acknowledge a state change: copy to copied, mute to unmuted, play to pause.
- Use a plain icon swap for changes people do not trigger themselves, and Toast when the result needs words.
Behavior
- Change iconKey on every state change; it accepts a boolean, string or number. The morph uses a zero-bounce spring (scale, opacity, blur) and swaps instantly under reduced motion.
- Revert temporary states such as copied after about two seconds, and clear the timer on unmount.
- Keep the morph inside a fixed-size icon-only Button so the layout does not shift.
Accessibility
- Update the trigger's aria-label when the action completes ("Copied agent ID"). For toggles, keep the label stable and set aria-pressed.