Living contour lines with a hill under the pointer.
Installation
Install the packages
npm install @prequelui/react motion@prequelui/react reuses the primitive library your components already depend on.
Add the component
npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/topography.jsonnpx shadcn@latest add https://animate.prequelui.terravidhal.me/r/topography.json
Turn on the motion
npx @prequelui/cli@latest animate topographyThe CLI finds the component through components.json, swaps the import and removes the CSS animation classes that Motion replaces.
Usage
Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.
import { TopographyBackground } from "@/components/prequelui/backgrounds/topography";
export default function Demo() {
return (
<div className="relative h-96 overflow-hidden rounded-xl">
<TopographyBackground />
</div>
);
}import { Topography } from "@/components/prequelui/topography";
export function Variant() {
return (
<Topography tempo={1.2}>
…
</Topography>
);
}Animation
A contour map is computed from a sum of travelling waves. Marching squares turns the field into two paths, minor lines at 30% and every fifth level at 68%; the pointer raises a hill under the cursor and a click sends a ripple through the terrain.
- Field: four sine terms plus a Gaussian hill and decaying ripples.
- Grid: 14 px cells, 14 levels by default, redrawn at 30 fps.
- Pointer and hill are smoothed with exponential easing, not per-move state.
- Reduced motion renders a static map and ignores pointer input.
API Reference
Each part accepts the usual HTML props in addition to the motion props below. No accessibility prop is hidden behind the animation layer.
TopographyBackground
| Prop | Type | Default |
|---|---|---|
| interactive | boolean | true |
| levels | number | 14 |
| scale | number | 1 |
| peak | number | 1 |
| lineColor | string | undefined | foreground |
| speed | number | 1 |
| paused | boolean | false |
| className | string | — |