Icon Swap

Animate icon swaps with scale, blur, and fade transitions.

motion-sv

Installation

pnpm dlx shadcn-svelte@latest add http://sveltekit-prerender/r/icon-swap.json

Features

  • Animate icon swaps with scale, blur, and fade transitions
  • Compound component structure with IconSwap and IconSwapItem
  • Swap triggers automatically when the item's key changes

Props

IconSwap

AnimatePresence wrapper for swapping icon content.

NameTypeDefaultDescription
childrenSnippetrequiredKeyed IconSwapItem content to animate between.
modeAnimatePresenceProps['mode']'popLayout'Controls how entering and exiting items are sequenced.
initialbooleanfalseWhether content should animate on its initial render.

IconSwapItem

Motion element that defines the icon enter and exit transition.

NameTypeDefaultDescription
childrenSnippetrequiredIcon content rendered inside the motion element.
astypeof motion.div | typeof motion.spanmotion.divMotion element used as the item wrapper.