Components
Bar chart
A compact bar series with an accessible label.
Free
pnpm dlx shadcn@latest add @caliper/bar-chartWhen to use
Use it for
- Showing a handful of values at a glance.
- Inside cards and tables as a quick distribution.
Skip it when
- Exact reading or many series; use a full chart.
Installation
terminal
pnpm dlx shadcn@latest add @caliper/bar-chart
Adds its 2 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 { useState, type ReactNode } from "react" import { BarChart } from "@/components/ui/bar-chart" import { SegmentedControl } from "@/components/ui/segmented-control" import { cn } from "@/components/ui/lib/cn" function Panel({ title, context, action, className, children }: { title: string; context: string; action?: ReactNode; className?: string; children: ReactNode }) { return ( <section className={cn("grid w-full max-w-md min-w-0 gap-5 rounded-overlay border border-border bg-background p-6 shadow-resting", className)}> <div className="flex flex-wrap items-start justify-between gap-3"> <div className="grid min-w-0 gap-1"> <p className="font-medium">{title}</p> <p className="text-sm text-muted-foreground">{context}</p> </div> {action} </div> {children} </section> ); } const periods = [ { value: "week", label: "Week" }, { value: "month", label: "Month" }, { value: "year", label: "Year" }, ]; type Period = "week" | "month" | "year"; const volume: Record<Period, { values: number[]; labels: string[]; total: string }> = { week: { values: [42, 58, 51, 64, 47, 22, 18], labels: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], total: "302 tickets this week" }, month: { values: [212, 268, 244, 301], labels: ["Week 1", "Week 2", "Week 3", "Week 4"], total: "1,025 tickets this month, by week" }, year: { values: [780, 842, 910, 1025, 968, 1104, 1180, 1012, 1236, 1310, 1025, 1190], labels: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"], total: "12,582 tickets this year, by month" }, }; export function WeeklyVolume() { const [period, setPeriod] = useState<Period>("week"); return ( <Panel title="Support volume" context={volume[period].total} action={<SegmentedControl label="Period" value={period} onValueChange={(value) => setPeriod(value as Period)} options={periods} />} > <BarChart label={`Tickets opened by ${period}`} values={volume[period].values} labels={volume[period].labels} /> </Panel> ); }
API reference
BarChart
component
Also accepts the native props of its root element and a ref.
PropTypeDefaultDescription
values *readonly number[]—
label *string—
labelsreadonly string[]—One short label per bar, drawn under the baseline.
Accessibility
It exposes img semantics, with aria-label and aria-hidden kept in step with state.
No custom key handling; Tab and the native activation keys do the work.
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.