Skip to content

Dumbbell and Slope Chart for React

A React dumbbell or slope chart shows before and after for each item, with every change printed in words and arrows. Pass data as readonly DumbbellItem[]: takes one item per row: { label, from, to }.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/dumbbell-chart.json

Median salary

Use the up and down arrow keys to read each item.

  • DumbbellChart
  • DumbbellTable
  • dumbbellColors
  • dumbbellLegend
  • defaultDumbbellChartLabels
  • +3 more

Dumbbell

Median salary by department, 2024 to 2025. On first view each “after” dot travels out from its “before” dot. Sort by the change and the rows slide into their new order.

Median salary

By department, in thousands of US dollars

  • 2024
  • 2025

Slope chart

variant="slope": the two ends in columns, a line per channel. Labels spread apart so none collide, and highlight keeps the two channels the story is about in color.

NPS by support channel

Q1 against Q2

  • Q1
  • Q2

Files to copy

15 folders · 30 files · 4 packages
From theme/src/
  • components/charts/{dumbbell-chart.tsx, histogram.tsx, chart-export-menu.tsx, chart-export.ts, chart-figure.tsx, chart-fit.tsx, chart-icons.tsx, chart-parts.tsx, chart-patterns.tsx, chart-pointer.tsx, chart-tip.tsx, chart-utils.ts, heatmap.tsx}
  • components/charts/chart-parts/
  • components/charts/dumbbell-chart/
  • components/charts/heatmap/
  • components/charts/histogram/
  • components/charts/kits/
  • components/drawer/parts/sheet.tsx
  • components/kbd/
  • components/menu/
  • components/skeleton/
  • components/status-icons/
  • hooks/{use-controllable.ts, use-direction.ts, use-intersection.ts, use-latest.ts, use-media-query.ts, use-preferences.ts}
  • motion/tokens.ts
  • lib/{cn.ts, csv.ts, form.ts, glide-highlight.tsx, heading.ts, math.ts, popup-a11y.ts, popup-motion.ts, warn-once.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/dumbbell-chart.jsonRegistry item: dumbbell-chart. The styles need the Tailwind v4 glass UI setup.
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Next.js: samples here pass functions (formatters, seriesLegend, a dashboard's load), so put them in a file that starts with "use client".

Props

PropTypeDefaultDescription
data (required)readonly DumbbellItem[]NoneTakes one item per row: { label, from, to }.
variant"slope" | "dumbbell""dumbbell""dumbbell": a row per item, a dot at each end. "slope": two columns joined by a line per item.
fromLabelstringNoneSets the name of the "before" end, e.g. "2024".
toLabelstringNoneSets the name of the "after" end, e.g. "2025".
sort"none" | "from" | "to" | "change""none"Order of the items. "change" puts the biggest rise first.
higherIsBetterbooleantrueIs a rise good (revenue) or bad (costs, churn)? Picks the status colour of the change.
change"none" | "percent" | "absolute""absolute"Show each item's change: "absolute" (+12), "percent" (+8%), or "none".
highlightstring | string[]NoneEmphasise these items (by label); the rest step back to grey.
colorChartColor1Palette slot (1–8): the "after" dot in full, the "before" dot a lighter shade of it.
includeZerobooleanfalseKeep 0 on the value axis.
heightnumber340Height of a slope chart. Dumbbell rows grow with the items.
valueLabelstringNoneNames the value axis.
format((n: number) => string)formatCompact in localeFormats a value for the labels, tooltips and data table: takes the number, returns the text shown.
formatPercent((ratio: number) => string)percentages in localeFormats percent changes (0.08 → "8%").
localestring"en"Locale of the default number formats.
emptyStateReactNodeNoneShown when there is nothing to plot.
labelsPartial<DumbbellChartLabels>defaultDumbbellChartLabelsEvery other string, for translation: labels={{ roleDescription: "…" }}; omitted keys keep the English of defaultDumbbellChartLabels. All 10 keys of DumbbellChartLabels are listed in the key table under the props table.
aria-label (required)stringNoneNames the chart for assistive tech (required).
classNamestringNoneAdds extra classes to the outer element.
DumbbellChartLabels keys and English defaults (10)
Pass any key in labels; the rest keep the defaults of defaultDumbbellChartLabels.
KeyEnglish default
roleDescription(slope) => (slope ? "slope chart" : "dumbbell chart")
instructionsUse the up and down arrow keys to read each item.
hintTap a row to read it
fromBefore
toAfter
changeChange
percentChange% change
noChangeNo change
itemItem
noDataNo data

DumbbellTable props

PropTypeDefaultDescription
data (required)readonly DumbbellItem[]NoneTakes one item per row: { label, from, to }.
format((n: number) => string)formatCompact in localeFormats a value for the labels, tooltips and data table: takes the number, returns the text shown.
sort"none" | "from" | "to" | "change""none"Order of the items. "change" puts the biggest rise first.
labelsPartial<DumbbellChartLabels>defaultDumbbellChartLabelsEvery other string, for translation: labels={{ roleDescription: "…" }}; omitted keys keep the English of defaultDumbbellChartLabels. All 10 keys of DumbbellChartLabels are listed in the key table under the props table.
localestring"en"Locale of the default number formats.
formatPercent((ratio: number) => string)percentages in localeFormats percent changes (0.08 → "8%").
fromLabelstringNoneSets the name of the "before" end, e.g. "2024".
toLabelstringNoneSets the name of the "after" end, e.g. "2025".
captionstringNoneHidden caption that names the table for screen readers.
classNamestringNoneAdds extra classes to the outer element.

Keyboard

KeysAction
TabFocus the chart. It is one tab stop; the arrow keys then read it.
↑/↓Move between items.
Home/EndJump to the first / last item.
EscapeClear the reading.

Accessibility

  • Keyboard and screen-reader users get a single focusable figure labelled by the chart title, with a short reading hint as its description; inside a ChartCard with a table view, aria-details links it to the table. Every value read is announced politely, once. Every change is printed with an up or down arrow and a success or danger tone (set by higherIsBetter), so color never carries it alone.
  • For a non-visual reading, give ChartCard's table prop a DumbbellTable; the Chart / Table tabs then expose each value as plain table cells.
  • Under reduced motion nothing morphs: the dots and the connecting bars render at their final values and new data replaces the old at once.

All exports on this page

  • DumbbellChart — Before → after for each item.
  • DumbbellTable — Every item's two values, its change and its percent change.
  • defaultDumbbellChartLabels — The built-in English strings of DumbbellChart; spread it into your own labels and change what you need.
  • dumbbellColors — The two shades of a dumbbell: the "before" end is a paler step of the "after" hue.
  • dumbbellLegend — Legend items for a dumbbell or slope chart: the two ends.

When to use the dumbbell and slope chart

  • Use it as a before and after chart for year-over-year comparisons across named items, such as revenue per product in 2024 against 2025, where the size and direction of each change is the story.
  • Use the slope variant for ranking shifts between two points in time, with the two ends in columns, lines joining them and labels spread so none collide.
  • Sort by change to put the biggest rise first, and set higherIsBetter to false for costs or churn so the status color of each change is not misleading.
  • Skip it when you have more than two time points per item, where a Line chart shows the whole path, or when you compare totals rather than change, where a Bar chart is enough.
  • Pair it with ChartCard and DumbbellTable for a text view, plus a SegmentedControl to switch between the dumbbell and slope variants or between absolute and percent change.

Frequently asked questions

48 charts pages in all: browse them on Charts.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .