Gravity Letters

A playful gravity field where letters, numbers, emoji, or any components you pass fall and pile up like real objects.

Interaction Type

Click or tap anywhere to drop a glyph, or press and hold to pour a steady stream. 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. Honors prefers-reduced-motion.

Props

Options you can pass to customize this component.

Prop
Type
Description
type
lettersnumbersboth

Which pool to draw from: letters, digits, or both. Ignored when items is set.

items
React.ReactNode[]

Your own drop pool: emoji, icons, or any components. Each drop picks a random entry. Overrides type.

gravity
number

Downward acceleration in px/s². Lower is floatier, higher is heavier.

size
number

Base glyph size in pixels. Each drop varies slightly around it.

color
#1A73F2#5856D6#AF52DE#FF2D92#FF3B30#F75001#FFB800#34C759

Glyph color. Defaults to currentColor so it follows your theme.

maxGlyphs
number

Max glyphs kept in the field; past the cap the oldest fade out. Unlimited by default.

deviceTilt
boolean

Tilting a phone spills the pile toward the low side. iOS asks for motion permission on the first tap.

className
string

Extra classes for the root element. Use it to size the field.

Installation

npx shadcn add swamimalode07/rare-ui/gravity-letters

How to use

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 stays clickable-through */}
<p className="absolute inset-0 grid place-items-center text-sm text-muted-foreground">
Click anywhere
</p>
</GravityLetters>
)
}
// Digits instead:
// <GravityLetters type="numbers" />
// Or drop your own content: emoji, icons, any component:
// <GravityLetters items={["šŸŽ", "šŸŠ", "šŸ‡", <Sparkles key="s" className="size-7" />]} />

Source Code

Click the code icon in the top-right corner to view the source code.

Keep in mind

Most components here are recreations of great work from around the web. I don't claim to be the original creator - this is my attempt to reverse-engineer, replicate, and often add a few extra features. I've tried to credit everyone; if I missed someone, let me know.

Contact

Found a bug or issue? Feel free to drop a DM.

License & Usage

  • •Free to use and modify in both personal and commercial projects.
  • •Attribution to Rare UI is appreciated when using a component.
  • •Please don't resell the components as your own kit.
Gravity Letters
Click anywhere in the box