A clean character-by-character word swap that flips the next word smoothly into place on hover, focus, or tap.
pnpm dlx shadcn@latest add @componentry/flipping-word-swapDependencies: gsap clsx tailwind-merge
import { FlippingWordSwap } from "@/components/ui/flipping-word-swap"
<div className="flex min-h-[400px] items-center justify-center">
<FlippingWordSwap
word1="Componentry"
word2="Consistency"
duration={400}
stagger={44}
className="text-zinc-950 dark:text-zinc-100"
toClassName="text-zinc-950 dark:text-zinc-100"
style={{
fontSize: 48,
fontWeight: 700,
lineHeight: 1,
letterSpacing: "-0.025em",
}}
/>
</div>| Prop | Type | Default |
|---|---|---|
word1 | stringThe word displayed at rest. | — |
word2 | stringThe word revealed during interaction. | — |
duration | numberDuration of each character flip in milliseconds. | 400 |
stagger | numberDelay between neighboring character flips in milliseconds. | 44 |
className | stringAdditional classes for layout and inherited typography. | — |
toClassName | stringAdditional classes applied only to the revealed word. | — |
style | CSSPropertiesInline styles applied to the container for dynamic typography and color controls. | — |
toStyle | CSSPropertiesInline styles applied only to the revealed word. | — |
Keep in mind
Need a custom component?
I build bespoke UI components & websites tailored to your brand.