Ridgeline

Overlapping distributions, one ridge per group: hover to lift a ridge and read its quartiles, switch datasets and every curve morphs.

pnpm dlx shadcn@latest add @uiarc/ridgeline
Live · keyboard ready

Daily highs

Zurich, 2025

Daily high temperatures in Zurich, 2025
SeriesMedianFirst quartileThird quartileLowestHighestCount
Jan2°-0.2°6.1°-5.7°9.1°31
Feb4.3°1.5°7.5°-0.9°13.7°28
Mar10.1°7.5°11.8°-0.6°19.9°31
Apr15.3°12.8°17.6°6.2°24.2°30
May19°15.4°21.7°11.5°25.6°31
Jun23.4°20.7°24.7°16°27.6°30
Jul24.6°22.3°26.2°16.8°30.1°31
Aug24°22.5°25.5°18.6°29.3°31
Sep19.3°17.1°21.6°12.3°25.6°30
Oct14.4°12.3°16.5°6.1°19.5°31
Nov8.1°6.2°10°0.4°14.7°30
Dec4°1.5°6.2°-6.2°9°31
  • Seasonal or categorical distributions such as temperatures by month or response times by region.
  • Showing where two groups differ in shape, such as bimodal winters.
  • Use beeswarm when each individual observation matters.
  • Use bar-chart when only one summary number per group matters.

Installation

Add Ridgeline with the shadcn CLI, or copy the source by hand.

pnpm dlx shadcn@latest add @uiarc/ridgeline

Adds the component and its local dependencies, and installs motion. First time? Add the @uiarc registry to components.json, or use the full URL:

example.tsx
import { Ridgeline } from "@/registry/components/ridgeline/ridgeline"; export function Latency({ regions }: { regions: { id: string; label: string; values: number[] }[] }) {  return <Ridgeline series={regions} label="API latency by region" unit=" ms" />;}

Ridgeline

A ridgeline (joy) plot: one smoothed distribution per row, overlapping like mountain ridges, tinted by median. Hover lifts a ridge above its neighbours to read its quartiles; switching datasets morphs every curve.

PropTypeDefaultDescription
seriesRequired{ id: string; label: string; values: number[] }[]–One ridge per series, drawn top to bottom. Values are raw observations; the ridge is their kernel density.
labelRequiredstring–What is measured. Names the chart for assistive technology.
unitstring–Unit after each value, such as "°" or " ms".
formatValue(value: number) => string–Formats values. Overrides unit.
domain[number, number]–Value range of the axis. Fix it to keep the axis still across datasets. Defaults to the data with room on each side.
overlapnumber2.4How far the tallest ridge rises into the rows above, in row heights.
rowHeightnumber30Height of one row in pixels.
bandwidthnumber–Smoothing in value units. Defaults to Silverman's rule per series.
tintbooleantrueShades each ridge by its median, from a light tint to the full first series color, with a stepped scale under the axis.
activestring | null–Controlled id of the lifted ridge.
defaultActivestring | nullnullInitial lifted ridge when uncontrolled.
onActiveChange(id: string | null) => void–Called when the lifted ridge changes.
emptyLabelstring"No data yet"Shown when there are no values.
classNamestring–Extra class on the root figure.
ArrowUporArrowDown
Lifts the previous or next ridge.
ArrowLeftorArrowRight
Moves the reading cursor along the values by one axis step.
HomeorEnd
Lifts the first or last ridge.
Escape
Lowers the ridge and clears the reading.
  • The plot is a focusable group; the lifted ridge's median, middle half, range, and count are announced through a polite live region.
  • A visually hidden table lists median, quartiles, extremes, and count for every series.
  • Every row is labelled in text; the median tint is backed by the table and tooltip.
  • Curves are sampled on a shared grid, so a new dataset or domain interpolates every point: ridges swell, slide, and split in one spring.
  • The first reveal rolls the ridges in from the top row down.
  • The lifted ridge is a copy drawn above the others that rises 6px on a spring, with its middle half shaded and its median marked.
  • The tooltip glides after the pointer and stays inside the chart. Reduced motion draws final shapes immediately.
  • Label gutter and tick count adapt to width; the plot redraws at the measured size so strokes stay crisp.
  • Touch taps lift a ridge and read at the tapped value.
  • Densities are computed once per dataset (96 samples per ridge); animation interpolates arrays and writes path strings directly.
  • Suitable for up to a few thousand observations per series.

Notes for AI

Give your coding assistant the Markdown reference instead of screenshots.

  • Choose it to compare the shape of many distributions: spread, skew, and bimodality, not just averages.
  • Pass raw observations, at least 20 per series, and fix domain when switching datasets so shapes move on a still axis.
  • Keep rows to about 20; beyond that, use small multiples or a box plot.
  • Colors come from the shared --series-1 to --series-4 tokens in foundation.css: series 1 is the accent itself and series 2 to 4 rotate its hue, validated all-pairs for color vision deficiency across every accent in light and dark. Override the tokens on any ancestor to rebrand.
/components/ridgeline/markdown

The full library index for assistants is at /llms.txt.