Skip to Content
Kokonut UI

BG-05Backgrounds

Topo Background

A living contour map that drifts, rises under the cursor and ripples on click, built with React and Canvas.

Install with
no extra packages

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-background

Usage

import TopoBackground from "@/components/kokonutui/topo-background";

export default function Example() {
  return <TopoBackground />;
}

Props

className
string

Extra classes for the root. The map draws on a transparent canvas, so className="bg-transparent" lays it over your own page background.

children
ReactNode

Content shown over the map. Pass null for a bare background.

interval
numberDefault 0.07

Height difference between two contour lines. Lower draws more lines.

speed
numberDefault 1

How fast the terrain drifts. 0 holds it still.

interactive
booleanDefault true

Raise a hill under the cursor and send a ripple on click.

seed
numberDefault 26

Seed for the terrain, so a page always opens on the same map.

labels
booleanDefault true

Print elevations on the index contours, as on a survey map.

Dependencies

NeedsVersionComes from
cn from lib/utils.tsshadcn init
React19Your app
Tailwind CSS4Your app

No provider, font or global CSS to set up: the file works as soon as it lands.