Modus UI

Gravity Text Swap

Web (React)

Text that detaches and falls away with simulated gravity when swapped.

A physics-based typography component. The old characters physically drop out of the layout with staggered gravity logic, allowing the new characters to spring into place from above.

Let's
Design
faster.

Installation

CLI

npx @modus-ui/cli add gravity-text-swap

Manual

  1. Copy the code from the component tab.
  2. Create a file at components/ui/gravity-text-swap.tsx.
  3. Paste the code.

Usage

tsx
import { GravityTextSwap } from "@/components/ui/gravity-text-swap";

export default function Example() {
  return <GravityTextSwap texts={["Hello", "World", "Build"]} duration={0.6} />;
}

Props

PropTypeDefaultDescription
textsstring[]-The strings to cycle through.
durationnumber0.5Seconds each swap animation takes.
pauseDurationnumber2Seconds each string stays visible.

Comments

  • No comments yet.