Range Bar Chart
Range bar chart for a span per category — minimum to maximum, planned against actual, as dumbbells or as gradient bars.
Playground
Installation
Range Bar Chart comes with WunderUI Core and Pro, in the package from your plan. See the plans.
The charts live in their own entry point: import the chart, its card and its hooks from @wunderui/react/charts, not from @wunderui/react.
Then import what you need:
import {
RangeBarChart,
RangeBarChartProps,
RangeBarChartVariant,
} from "@wunderui/react/charts"Then use it:
import { RangeBarChart } from "@wunderui/react/charts"
const data = [
{ month: "Jan", min: 0, max: 7 },
{ month: "Feb", min: 1, max: 9 },
{ month: "Mar", min: 4, max: 13 },
]
export function TemperatureRange() {
return <RangeBarChart data={data} index="month" label="Temperature range per month" />
}Expected result: You should see one floating bar per month, from its lowest to its highest value, on an axis that does not start at 0.
When to use
Use Range Bar Chart for
- A minimum and a maximum per category (temperatures, price ranges)
- Planned against actual spans (schedules, ranges of weeks)
- A dumbbell or a gradient span for a range between two measures
Use something else for
- Bar Chart for one value per category
- Timeline Chart for tasks and milestones on a time axis
- Distribution Chart for the spread of raw observations
- Waterfall Chart for changes that add up to a total
States
Loading, empty and error keep the chart's size, so the card never jumps. Add a retry handler and the error state offers a Try again button.
Keyboard interactions
The plot is focusable: Arrow keys walk the categories, and the tooltip and live region give both ends of every range.
- TaborShiftTab
- Moves focus to the plot and away from it. The plot is one tab stop; so is every legend badge.
- ArrowRightorArrowLeft
- Moves to the next or previous category. The tooltip follows, and a live region announces the one you are on. The first press starts at the first one (Left: the last one).
- HomeorEnd
- Jumps to the first or last category.
- Escape
- Clears the active point.
- EnterorSpace
- On a legend badge of a ChartCard: switches its series off or on. The last visible series stays on.
Behavior and motion
What the chart does on its own and what the page decides.
- Ranges
- Ranges is a list of low, high, label and colour field names (default min to max). Several ranges per category show planned against actual.
- Domain
- The value axis is fitted to the lows and highs and does not include zero by default, so a short span in a high range stays readable. Horizontal range bars put the category on the left.
- No change chip
- The tooltip shows each range as low to high with its colour and no change chip, since a span has no previous value.
- Loading, empty and error
- The chart keeps its size while loading, empty or failed, so the card never changes height. Add a retry handler to show a Try again button on error.
- Legend
- In a ChartCard, each series badge is a button that switches its series off, but the last visible series stays on. A legend of roles can be made static.
- Size
- The chart fills the width of its container and you set the plot height. Text never scales, so labels keep their size at every width.
Motion
The enter sequence and the hover follow the motion tokens of the library.
- Enter
- The marks play an enter sequence when the chart first comes into view, after loading and when new data arrives. The animation can be turned off.
- Reduced motion
- With reduced motion on, the chart appears at once without the enter sequence. The tooltip and every state still work.
Anatomy
RangeBarChart draws a span from a low to a high value per category: bars, dumbbells with two dots on a stem, or a gradient. The value axis fits the data instead of starting at zero.
Temperature
| month | Low | High |
|---|---|---|
| Jan | 0 °C | 7 °C |
| Feb | 1 °C | 9 °C |
| Mar | 4 °C | 13 °C |
| Apr | 8 °C | 18 °C |
| May | 12 °C | 23 °C |
| Jun | 15 °C | 27 °C |
Pass data with the field for the category name and a list of ranges, each with low and high fields, a label and a colour. Several ranges per category show planned against actual.
- data-slot="chart-plot"
The focusable region. Arrow keys walk the categories, and the tooltip and live region give both ends of every range, such as Jan: Range 4 °C to 12 °C.
- data-slot="chart-grid"
The domain is fitted to the lows and highs, so a short span in a high range stays readable. Horizontal range bars put the category on the left.
- data-slot="chart-marks"
One rounded bar from low to high per range, a dumbbell (two dots joined by a stem) on the dots variant, or a fill that fades from low to high on the gradient variant.
- data-slot="chart-tooltip"
Each range as low to high with its colour, and no change chip, since a span has no previous value.
- data-slot="chart-message"
Muted columns on the vertical variants and muted rows on the horizontal one, under the shimmer.
A screen-reader table with a Low and a High column per range, plus the live region for the active category. The description names the overall low and high.
Best practices
- Do
Say what the ends mean in the label, such as Min to max or Planned, because a bare span has no scale to explain itself.
- Do
Use the dots variant when the exact ends matter more than the span, and a plain bar when the length is the point.
- Do
Limit the horizontal variant to two ranges per row, in two colours. Three overlapping spans on one row are hard to read.
- Don’t
Don't mix the cropped axis with zero-based charts on the same dashboard without saying so. A range axis that starts at 40 next to a bar chart from 0 looks like the same scale.
- Don’t
Don't use it when only a midpoint exists. A single value belongs in LineChart or BarChart.
API reference
One table for RangeBarChart, listing every prop. A ChartCard around it takes its own props, and the chart works without one.
Pass data with the field for the category name and a list of ranges, each with low and high fields, a label and a colour. Several ranges per category show planned against actual.
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("range-bar-chart")The full library index for assistants is at /llms.txt.