A radar scope with range rings and a turning beam, where contacts flare as the beam passes over them, then fade.
Topographic lines that slowly shift like terrain, with a vignette for your content.
Customize
Usage
import { ContourLines } from "@/components/motionkit/contour-lines";
<ContourLines className="h-96 rounded-3xl">
<h1>Your hero</h1>
</ContourLines>Motion
The exact curves this component runs, plotted with Motion's own maths.
Terrain shift
Runs on its own
Outdoor, travel, maps and data brands, or any hero that wants texture without imagery.
Each contour is an SVG path generated from layered sine waves. Motion morphs each path's d attribute between frames that share the same number of points, so the terrain shifts smoothly. A vignette keeps the middle clear for your content.
Works in the App Router as is. Requires Tailwind CSS v4.
One command adds the file and installs its dependencies. Needs a components.json (run npx shadcn@latest init once if you don't have one).
npx shadcn@latest add https://www.motionkitui.com/r/contour-lines.jsonnpm install motionSave as components/motionkit/contour-lines.tsx.
"use client";
import type { ReactNode } from "react";
import { motion, useReducedMotion } from "motion/react";
type ContourLinesProps = {
children?: ReactNode;
/** Number of contour lines. */
lines?: number;
/** How tall the hills are, 0–1. */
amplitude?: number;
/** Seconds for one full shift of the terrain. */
duration?: number;
color?: string;
className?: string;
};
const W = 400;
const H = 240;
const POINTS = 48;
/** One contour as an SVG path; the same point count at every phase so Motion can morph between them. */
function contour(index: number, total: number, amplitude: number, phase: number) {
const baseline = ((index + 1) / (total + 1)) * H;
const height = amplitude * 38;
let d = "";
for (let i = 0; i <= POINTS; i++) {
const x = (i / POINTS) * W;
const t = x / W;
const y =
baseline +
Math.sin(t * Math.PI * 2 + phase + index * 0.55) * height * 0.6 +
Math.sin(t * Math.PI * 5 - phase * 1.3 + index * 0.9) * height * 0.25;
d += `${i ? "L" : "M"}${x.toFixed(1)} ${y.toFixed(1)}`;
}
return d;
}
export function ContourLines({
children,
lines = 14,
amplitude = 0.6,
duration = 16,
color = "#7D9E9D",
className = "",
}: ContourLinesProps) {
const reduceMotion = useReducedMotion();
return (
<div className={`relative isolate overflow-hidden bg-[#0C1010] ${className}`}>
<svg aria-hidden viewBox={`0 0 ${W} ${H}`} preserveAspectRatio="none" className="absolute inset-0 -z-10 h-full w-full">
{Array.from({ length: lines }, (_, index) => {
const frames = [0, Math.PI * 0.66, Math.PI * 1.33, Math.PI * 2].map((phase) => contour(index, lines, amplitude, phase));
return (
<motion.path
key={index}
d={frames[0]}
fill="none"
stroke={color}
strokeOpacity={0.12 + (index % 4 === 0 ? 0.16 : 0)}
strokeWidth={index % 4 === 0 ? 1.4 : 1}
vectorEffect="non-scaling-stroke"
animate={reduceMotion ? undefined : { d: frames }}
transition={{ duration, repeat: Infinity, ease: "linear" }}
/>
);
})}
</svg>
{/* vignette keeps text readable in the middle */}
<div aria-hidden className="absolute inset-0 -z-10 bg-[radial-gradient(ellipse_at_center,#0C1010cc,transparent_75%)]" />
{children}
</div>
);
}
| Prop | Type | Default | Description |
|---|---|---|---|
| lines | number | 14 | Number of contour lines. |
| amplitude | number | 0.6 | How tall the hills are, 0 to 1. |
| duration | number | 16 | Seconds for one full shift. |
| color | string | "#7D9E9D" | Line colour. |
How we audit: the WCAG 2.2 animation checklist and respecting reduced motion in React.
Yes. The file starts with "use client", so you can import it straight into a Server Component page or layout. It works in Vite as is, and in Astro as a React island.
Only the motion package, beside React and Tailwind CSS v4. There is no MotionKit package and no Tailwind config to add.
Yes. Run npx shadcn@latest add https://www.motionkitui.com/r/contour-lines.json in any project with a components.json. It saves the file to components/motionkit and installs its dependencies.
The lines hold still for reduced-motion users. It loops forever otherwise, so if it sits beside other content for more than 5 seconds, WCAG 2.2.2 asks you to add a pause control.
A radar scope with range rings and a turning beam, where contacts flare as the beam passes over them, then fade.
A circuit board around a clear centre: traces fan out from every side, and pulses of light race along them at scattered times.
Translucent waves layered along the bottom of a hero, each rolling at its own pace so they slide over one another like a calm sea.
Find your bearings