Gravity Letters React component for Tailwind CSS v4
v1.0.1Updated in 1.2.1
A React physics text effect: a gravity field where letters, numbers, emoji or any components you pass fall and pile up like real objects.
The field opens by pouring its initial text, letter by letter, onto the floor. Click or tap anywhere to drop a glyph, or press and hold to pour a steady stream that follows your pointer. Glyphs tumble as they fall, bounce softly when they land, and pile up into rounded hills. On phones, tilt the device to spill the pile toward the low side. With reduced motion on, glyphs appear straight on the pile.
Gravity Letters is a free React component in the React effect components category, written in TypeScript for React 19 and Tailwind CSS v4. It installs as source with npx wingo-ui@latest add gravity-letters, together with UIProvider.
Add to a project
Requirements: React 19 and Tailwind CSS v4, in Next.js (App Router or Pages), Vite or React Router. Installation guide ยท Next.js setup ยท Vite setup
npx wingo-ui@latest add gravity-lettersUsage
Import GravityLetters from @/components/ui/gravity-letters.
import GravityLetters from "@/components/ui/gravity-letters"
export function Demo() {
return (
<GravityLetters type="letters" className="h-96 w-full rounded-3xl border">
{/* anything you render inside sits under the falling glyphs */}
<p className="absolute inset-0 grid place-items-center text-sm text-muted-foreground">
Click anywhere
</p>
</GravityLetters>
)
}
// A blank field, or your own opening word:
// <GravityLetters initialText="" />
// <GravityLetters initialText="404" type="numbers" />
// Digits instead:
// <GravityLetters type="numbers" />
// Or drop your own content: emoji, icons, any component:
// <GravityLetters items={["๐", "๐", "๐", <Sparkles key="s" className="size-7" />]} />Props
typedefault"letters""letters" | "numbers" | "both"Which pool to draw from: letters, digits, or both. Ignored when items is set.
initialTextdefault"HELLO"stringLetters poured across the middle of the field on mount, one after another, so it never starts empty. Spaces leave gaps; pass an empty string for a blank field.
itemsReact.ReactNode[]Your own drop pool: emoji, icons, or any components. Each drop picks a random entry. Overrides type.
gravitydefault800numberDownward acceleration in px/sยฒ. Lower is floatier, higher is heavier. Changes apply mid-fall.
sizedefault28numberBase glyph size in pixels. Each drop varies by up to 20% around it. Applies to new drops.
colordefault"currentColor"stringGlyph color, any CSS color. Defaults to currentColor so it follows your theme.
weightdefault"semibold""normal" | "medium" | "semibold" | "bold"Font weight of the falling glyphs.
sizeVariancedefault0.2numberHow much a dropped glyph's size varies around size: 0.2 means 80% to 120%. initialText letters always use size exactly.
bouncedefault0.22numberHow much of its speed a glyph keeps on its first touch down, 0 (a thud) to 0.95.
holdDelaydefault300numberHow long a press has to last, in milliseconds, before glyphs start pouring.
pourIntervaldefault120numberTime between glyphs while pouring, in milliseconds.
maxGlyphsdefault0numberMax glyphs kept in the field; past the cap the oldest fade out and the pile settles into the gap. 0 keeps every glyph, which is the default.
deviceTiltdefaulttruebooleanTilting a phone spills the pile toward the low side. iOS asks for motion permission on the first tap.
childrenReact.ReactNodeRendered under the glyph layer, e.g. a hint or an empty state. Clicks on it still drop glyphs unless a handler calls preventDefault.
classNamestringExtra classes for the root element. Use it to size the field; glyphs pile on its bottom edge and are clipped to it. Pointer handlers you pass run before the drop.
Examples
Celebrating empty state
items swaps the letters for emoji; the message sits behind the pile and maxGlyphs keeps it light.
Numbers in a brand color
type numbers pours 2026 on load in bold orange; every click adds a random digit.
Your own components
Any element can fall, here tag pills with no size variance and a bouncier landing.
Dependencies
Files
- components/ui/gravity-letters.tsx
FAQ
Is the React Gravity Letters component free?
Yes. The source is free and needs no account: copy it from the Code tab or install it with the CLI.
How do I install Gravity Letters?
Run npx wingo-ui@latest add gravity-letters. It also adds the Wingo UI item it builds on (UIProvider). With shadcn, run npx shadcn@latest add https://wingo-ui.com/r/gravity-letters.json.
How does Gravity Letters behave on phones?
On phones, tilt the device to spill the pile toward the low side.
See also
More React effect components
Articles using this component
- Magic UI Alternatives: 5 Animated React Libraries Compared
Comparisons and alternatives11 min read