motion-swap

Splits text into individual characters and swaps them vertically on hover or scroll reveal. Each character has an original and duplicate that trade places with a spring animation.

Preview

Hover me

Import

Usage

Properties

Attribute Property Type Default Description
trigger trigger "hover" | "reveal" "hover" Animation trigger — hover swaps in/out on mouseenter/mouseleave; reveal plays once on viewport entry
reverse reverse boolean true When true, letters swap bottom-to-top. When false, top-to-bottom.
stagger-duration staggerDuration number 0.03 Delay in seconds between each character's animation start
transition transition object { type: "spring", duration: 0.7 } Motion animation options for each character pair
once once boolean true Animate only on first intersection (reveal mode)
delay delay number 0 Delay in seconds before animation starts

Accessibility

Respects prefers-reduced-motion: when enabled, the swap effect is skipped and the text appears at its default state.