Drag & physics

Physics playground

Every child becomes a body: they fall, collide, push each other and can be grabbed and thrown.

Paste it into ChatGPT, Claude, Cursor or v0.
gravity2000
bounciness0.55
bodies18

Usage

import { PhysicsWorld } from '@vizzele/react';

<PhysicsWorld gravity={{ x: 0, y: 2000 }} restitution={0.55} style={{ height: 480 }}>
  {tags.map((t) => <span key={t} className="ball">{t}</span>)}
</PhysicsWorld>

Props

PropTypeDefaultDescription
gravity{ x: number; y: number }{ x: 0, y: 2000 }px/s².
restitutionnumber0.5Bounciness 0–1.
dragnumber0.08Air drag per second.
frictionnumber0.3Rolling friction on walls.
interactivebooleantrueGrab and throw bodies.
worldRefRef<PhysicsWorld>—impulse(x, y), setGravity(), wake()…

Accessibility

  • Decorative toy: keep important content out of it, or mirror it elsewhere.
  • Reduced motion: the world settles instantly into a still pile.
  • Sleeps (zero CPU) once everything is at rest.