Interactive wrapper that smoothly swaps between two icons on hover or click with fluid spring micro-interactions.
This component works with any icon library (Lucide, Hugeicons, Radix, etc.). For interactive stroke/path micro-animations, it connects directly with icons from @animate-ui/react (or components/animate-ui/icons).
npm i @animate-ui/react| Prop | Type | Default | Description |
|---|---|---|---|
iconA | ReactNode | ComponentType | undefined | First icon component or node rendered in the default state. |
iconB | ReactNode | ComponentType | undefined | Second icon component or node rendered in the active state. |
trigger | "click" | "hover" | "controlled" | "click" | Interaction mode that triggers swapping between the two icons. |
active | boolean | undefined | Controlled boolean state for programmatic icon switching. |
onToggle | (active: boolean) => void | undefined | Callback fired whenever the active icon state changes. |
size | number | 16 | Icon width and height bounding box in pixels. |
animateOnHover | boolean | true | Whether the default icon plays its micro-animation when hovered. |
transitionDuration | number | 0.18 | Duration of the icon swap spring transition in seconds. |
as | "span" | "div" | "button" | "span" | Underlying HTML element tag to render as. |
iconClassName | string | "" | Additional CSS classes applied to the default icon container. |
activeIconClassName | string | "" | Additional CSS classes applied to the active icon container. |
className | string | "" | Additional CSS classes applied to the wrapper element. |