Installation
pnpm dlx shadcn@latest add https://dithercn.dev/r/ridgelines.jsonUsage
import { Ridgelines } from "@/components/dithercn/ridgelines";
export function Section() {
return (
<section className="relative isolate min-h-[420px]">
<Ridgelines className="absolute inset-0 -z-10" />
</section>
);
}Each line is flat at the ends and peaked in the middle, and each one hides the lines behind it. The peaks shift slowly. A faint shade under the tallest peaks makes them read as solid ridges. Lines stay one cell wide and at least four cells apart, so a short box draws fewer of them.
Examples
In a card
Fewer lines, a narrower spread and small cells fit a pulsar plot in a card.
Mountain range
spread={1} raises peaks across the whole width. A lower amplitude keeps them low, and a three-colour palette shades the slopes.
Props
| Prop | Type | Default |
|---|---|---|
| lines How many lines, from 6 to 64. A short box draws fewer. | Type: number | Default 32 |
| amplitude Height of the peaks. 2 is twice as tall. | Type: number | Default 1 |
| spread Width of the peaked band, as a share of the box, from 0.1 to 1. | Type: number | Default 0.5 |
| shade Faint tone under the raised peaks, from 0 to 0.5. 0 keeps only the lines. | Type: number | Default 0.25 |
| palette Colours from paper to ink: palette names such as "blue", CSS variable names, or any CSS colour. | Type: [DitherColor, DitherColor, ...DitherColor[]] | Default ["--dither-paper", "--dither-ink"] |
| matrix The threshold pattern. See Dither engine. | Type: "bayer2" | "bayer4" | "bayer8" | "blue-noise" | Default "bayer4" |
| cell Size of one dither cell in CSS pixels. | Type: number | Default --dither-cell |
| speed How fast it moves. | Type: number | Default 1 |
| animate false draws one still frame. | Type: boolean | Default true |
| className Size and position. The background fills this box. | Type: string | Default – |
Notes
- It is decorative and hidden from assistive technology. Put real text on top of it, not inside it.
- With reduced motion turned on, it draws one still frame and stops.
- It pauses when scrolled out of view or when the tab is hidden, and releases its WebGL context when far offscreen. Without WebGL it shows thin CSS lines in the same colours.
- It costs one small draw per frame at 30 fps, at one pixel per dither cell. See Performance.