Command Palette
Search for a command to run

Letter Swap

A text component that swaps the letters vertically on hover.

motion-sv
Hover me chief! Awesome! Good day! More text? oh, seriously?!

There are two types of animations available for this component:

  1. Forward animation — plays the animation timeline once forward, when you hover over the text.
  2. Ping Pong animation — plays the animation timeline in a ping pong fashion. It plays once forward when you hover over the text, and once in the opposite direction when you hover away from the text.

Installation

Forward Animation

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

Ping Pong Animation

pnpm dlx shadcn-svelte@latest add http://sveltekit-prerender/f/letter-swap-ping-pong.json
Visit Original Docs

For more deeper understaing visit fancy components documentation.

Examples

Stagger From

First Center Last

Line Swap

By setting the staggerDelay prop to zero, you can create a line swap effect.

oh, wow! nice!

Ping Pong

First Center Last

Props

Shared Props

These props apply to both the forward and ping-pong Letter Swap variants shown on this page.

NameTypeDefaultDescription
label
string required Text string split into characters and animated on hover.
reverse
boolean true Reverses the vertical swap direction for the entering characters.
transition
AnimationOptions { type: "spring", duration: 0.7 } Motion options used for the character swap animation.
staggerDuration
number 0.03 Delay in seconds between adjacent character swaps.
staggerFrom
"first" | "last" | "center" | number "first" Starting point used when calculating stagger delays.
class
string undefined Classes merged onto the interactive text wrapper.