BG-05Backgrounds
Topo Background
A living contour map that drifts, rises under the cursor and ripples on click, built with React and Canvas.
PRODither Reveal Hero and more like it are in Kokonut UI Pro
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-backgroundUsage
import TopoBackground from "@/components/kokonutui/topo-background";
export default function Example() {
return <TopoBackground />;
}Props
classNamestringExtra classes for the root. The map draws on a transparent canvas, so className="bg-transparent" lays it over your own page background.
childrenReactNodeContent shown over the map. Pass null for a bare background.
intervalnumberDefault 0.07Height difference between two contour lines. Lower draws more lines.
speednumberDefault 1How fast the terrain drifts. 0 holds it still.
interactivebooleanDefault trueRaise a hill under the cursor and send a ripple on click.
seednumberDefault 26Seed for the terrain, so a page always opens on the same map.
labelsbooleanDefault truePrint 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.