Topo Background - React Component | Kokonut UI
Topo Background
A living contour map that drifts, rises under the cursor and ripples on click, built with React and Canvas.
Installation
Topo Background is a free, open-source React component in the Kokonut UI Backgrounds collection. Add it with the shadcn CLI, which copies the source into components/kokonutui/topo-background.tsx, so the code is yours to change.
npx shadcn@latest add @kokonutui/topo-background
Usage
import TopoBackground from "@/components/kokonutui/topo-background";
export default function Example() {
return <TopoBackground />;
}
Props
classNamestring
Extra classes for the root. The map draws on a transparent canvas, soclassName="bg-transparent"lays it over your own page background.childrenReactNode
Content shown over the map. Passnullfor a bare background.intervalnumberDefault0.07
Height difference between two contour lines. Lower draws more lines.speednumberDefault1
How fast the terrain drifts. 0 holds it still.interactivebooleanDefaulttrue
Raise a hill under the cursor and send a ripple on click.seednumberDefault26
Seed for the terrain, so a page always opens on the same map.labelsbooleanDefaulttrue
Print elevations on the index contours, as on a survey map.
Dependencies
| Needs | Version | Comes from |
|---|---|---|
cn from lib/utils.ts |
shadcn init | |
| React | 19 |
Your app |
| Tailwind CSS | 4 |
Your app |
No provider, font or global CSS to set up: the file works as soon as it lands.
[Wind](/content/docs/backgrounds/flow-field/index.html)
Streamlines that part around the cursor, swirl in its wake and scatter on click, built with React and Canvas.
[Drape Background](/content/docs/backgrounds/drape-background/index.html)
A pleated curtain in a breeze that you can push and pull, built with React, WebGL and a cloth simulation.