Skip to content
caliper ui pro docs

Date range compare

The period every figure on a page answers to: presets for the usual ranges, a two-month calendar for any other, and a switch that compares with the period just before. The KPI row counts to its new figures and, while comparing, gives each change with its direction in words and the previous figure.

Pro

Period

3 Nov – 30 Nov · 28 days against the 28 before

  • Visitors57,1626.2%up, good vs 6 Oct – 2 Novfrom 53,804
  • Page views131,1546.2%up, good vs 6 Oct – 2 Novfrom 123,507
  • Signups1,7072.6%up, good vs 6 Oct – 2 Novfrom 1,664
  • Bounce rate43.2%0.2%down, good vs 6 Oct – 2 Novfrom 43.3%

When to use

  • The top of an analytics, finance or product metrics page.
  • Any report where a number means little without the period before it.

When not to use

  • Picking a single date; use the date input.
  • Comparing with the same period last year; this compares with the period just before.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/date-range-compare

Adds its 15 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.

API reference

DateRangeCompare

9 props
PropTypeDefaultDescription
range *{ start: string; end: string; }—
onRangeChange *(range: { start: string; end: string; }) => void—
presetsreadonly DateRangePreset[][]
compare *boolean—
onCompareChange *(compare: boolean) => void—
kpis *readonly CompareKpi[]—Figures for `range`, with `previous` filled from `previousRange(range)` by the host.
loadingboolean—
errorstring—
classNamestring—

previousRange

2 props
PropTypeDefault
start *string—
end *string—

rangeDays

2 props
PropTypeDefault
start *string—
end *string—

percentChange

0 props

No props of its own; it accepts the native props of its root element.

formatRange

2 props
PropTypeDefault
start *string—
end *string—

Keyboard

  • Keyboard and focus come from Radix popover: arrow keys move through items, Enter and Space select, and Escape closes and returns focus.

Accessibility

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

Notes for AI

Give your coding assistant this page as Markdown instead of screenshots: the props, keyboard and examples in one file.

/docs/components/date-range-compare.md

The index of every part is at /llms.txt.

More in Metrics