caliper uidocs

Ridgeline

Free

Stacked distributions that overlap for easy comparison.

Installs components/ui/ridgeline.tsxDepends on d3-shapeMotion none in component source
pnpm dlx shadcn@latest add https://caliperui.site/r/ridgeline.json
Activity by weekday

Activity by weekday
PointMonTueWed
0:00111010
2:00131110
4:00191311
6:00311913
8:00443119
10:00504431
12:00445044
14:00314450
16:00193144
18:00131931
20:00111319
22:00101113

When to use #

Use it for

  • Comparing how several groups are distributed over the same axis.
  • Daily patterns across weekdays.

Skip it when

  • A single distribution; use a histogram.

Installation #

terminal
pnpm dlx shadcn@latest add https://caliperui.site/r/ridgeline.json

Adds its 3 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.

Usage #

This is the code behind the preview above.

example.tsx
import { Ridgeline } from "@/components/ui/ridgeline"

export function WeekdayRidges() {
  const hours = Array.from({ length: 12 }, (_, index) => `${index * 2}:00`);
  const wave = (shift: number) => hours.map((_, index) => Math.round(10 + 40 * Math.exp(-Math.pow(index - shift, 2) / 6)));
  return (
    <div className="w-full max-w-xl">
      <Ridgeline label="Activity by weekday" xLabels={hours} rows={[{ id: "mon", label: "Mon", values: wave(5) }, { id: "tue", label: "Tue", values: wave(6) }, { id: "wed", label: "Wed", values: wave(7) }]} />
    </div>
  );
}

API reference #

Ridgeline

component
PropTypeDefaultDescription
label *string—
rows *readonly RidgeRow[]—
xLabels *readonly string[]—One label per sample, shared by every row.
unitstring""
formatValue((value: number) => string)numberText
loadingboolean—
errorstring—
classNamestring—

Accessibility #

It exposes group and status semantics, with aria-label, aria-busy, aria-pressed and aria-hidden kept in step with state. Changes that matter are announced through a live region.

KeyBehaviour
↑Moves to the previous item or value.
↓Moves to the next item or value.
→Moves to the next item or value.
←Moves to the previous item or value.
PageUpMoves by a larger step, or to the previous page.
PageDownMoves by a larger step, or to the next page.
HomeJumps to the first item or the minimum.
EndJumps to the last item or the maximum.
EnterActivates the focused control.
SpaceActivates the focused control.
EscapeCloses or cancels, then returns focus to where it came from.

Motion #

It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.