Race bar chart
Animated ranking over time where bars overtake each other on springs, values count continuously, and a timeline plays, pauses, or scrubs.
import { RaceBarChart } from '@uthereal/ui/race-bar-chart'Race bar chart playground
- Furniture
- Lighting
- Textiles
| Item | Jan 2026 | Feb 2026 | Mar 2026 | Apr 2026 | May 2026 | Jun 2026 |
|---|---|---|---|---|---|---|
| Oak lounge chair | $42,000 | $64,000 | $92,000 | $118,000 | $141,000 | $176,000 |
| Arc floor lamp | $68,000 | $74,000 | $86,000 | $98,000 | $115,000 | $134,000 |
| Handwoven wool rug | $54,000 | $61,000 | $79,000 | $109,000 | $148,000 | $164,000 |
| Walnut writing desk | $39,000 | $52,000 | $71,000 | $96,000 | $129,000 | $169,000 |
| Brass wall sconce | $31,000 | $43,000 | $58,000 | $72,000 | $88,000 | $102,000 |
| Washed linen throw | $27,000 | $36,000 | $45,000 | $54,000 | $68,000 | $84,000 |
| Fluted glass pendant | $19,000 | $28,000 | $41,000 | $62,000 | $83,000 | $111,000 |
| Cedar entryway bench | $14,000 | $18,000 | $26,000 | $48,000 | $74,000 | $95,000 |
Overview
A race bar chart animates how a ranking changes across ordered periods. As time advances, values interpolate smoothly between frames, bar lengths track the current leader, rows swap rank on springs, and items falling below the visible cut slide out of view. The period label rolls in large display type beside the live running total, and a scrubbable timeline lets readers play, pause, replay, or jump to any period. Pointing at or focusing a bar highlights it, dims peers, and tracks a tooltip with exact rank, share of total, and period-over-period change. A native data table lists every item across every period.
Use a race bar chart when rank changes and overtakes across many periods are the story, such as monthly product revenue, city populations, or package downloads. For exact time-series trends without rank swaps, use a line chart. For a single period comparison, use a bar chart. For before-and-after rank shifts across two points in time, use a slope chart.
Usage
import { RaceBarChart } from '@uthereal/ui/race-bar-chart'
const items = [
{ id: 'chair', label: 'Oak lounge chair', group: 'furniture' },
{ id: 'lamp', label: 'Arc floor lamp', group: 'lighting' },
{ id: 'rug', label: 'Handwoven wool rug', group: 'textiles' },
{ id: 'desk', label: 'Walnut writing desk', group: 'furniture' },
]
const groups = [
{ id: 'furniture', label: 'Furniture' },
{ id: 'lighting', label: 'Lighting' },
{ id: 'textiles', label: 'Textiles' },
]
const frames = [
{
period: 'January',
values: { chair: 14000, lamp: 66000, rug: 42000, desk: 29000 },
},
{
period: 'February',
values: { chair: 52000, lamp: 78000, rug: 69000, desk: 48000 },
},
{
period: 'March',
values: { chair: 112000, lamp: 94000, rug: 98000, desk: 84000 },
},
]
export function ProductRace() {
return (
<RaceBarChart
label="Revenue by product"
items={items}
groups={groups}
frames={frames}
highlight="chair"
valueFormat={{
style: 'currency',
currency: 'USD',
maximumFractionDigits: 0,
}}
/>
)
}Give each item a stable id so bars retain identity during overtakes. Pass cumulative values for races that grow monotonically, or raw period values for rankings that rise and fall. Pass frame and onFrameChange to synchronize the period with external controls, or playing and onPlayingChange to manage playback from the host.
Examples
Use <SchemaPlayground /> above to inspect grouped categories, highlight, and bar capping (bars).
Looping playback with speed control and unit suffix
Enable speedControl to add a playback speed toggle (0.5x, 1x, 1.5x, 2x) beside the play button, pair loop with frameDuration for continuous recaps, and append a unit suffix with tableToggle for direct tabular inspection.
| Item | Jul 2026 | Aug 2026 | Sep 2026 | Oct 2026 |
|---|---|---|---|---|
| @uthereal/ui | 18.4K downloads | 24.6K downloads | 33.9K downloads | 46.2K downloads |
| @uthereal/charts | 9.2K downloads | 15.8K downloads | 26.4K downloads | 38.9K downloads |
| @uthereal/editor | 6.1K downloads | 11.4K downloads | 19.2K downloads | 29.8K downloads |
| @uthereal/icons | 14.8K downloads | 16.2K downloads | 18.5K downloads | 21.4K downloads |
| @uthereal/cli | 4.9K downloads | 7.3K downloads | 11.2K downloads | 15.6K downloads |
Behavior
Bars render with a 40% tinted body and a solid 3 px end cap so category hues stay distinct while text remains readable. When groups is provided, the first four groups take the chromatic series hues (--ui-series-1 through --ui-series-4), groups five through eight take neutral ink steps (--ui-series-5 through --ui-series-8), and further groups fall back to --ui-series-other. Without groups, every bar uses --ui-series-1.
Playback pauses automatically whenever the chart scrolls out of view or the browser tab becomes hidden. When autoPlay is enabled, playback starts once as the chart enters the viewport. Below 400 px plot width, item labels move inside the bars so bars retain length, and values shift past the label when a bar is shorter than its name. Below 480 px container width, the period display type steps down from 30 px to 24 px. A single requestAnimationFrame loop updates transforms, widths, axis ticks, and live counts directly in the DOM and sleeps whenever playback is paused and springs settle.
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
label | stringDefault: "Race bar chart" | Names the chart for assistive technology and captions the data table. Used as the figure heading when title is omitted. |
title | string— | Optional visible figure title above the period readout. |
description | string— | One or two sentences on what the chart shows, below the title; omit it when the title says enough. |
items | RaceBarItem[]Default: [{"id":"oak-chair","label":"Oak lounge chair","group":"furniture"},{"id":"arc-lamp","label":"Arc floor lamp","group":"lighting"},{"id":"wool-rug","label":"Handwoven wool rug","group":"textiles"},{"id":"walnut-desk","label":"Walnut writing desk","group":"furniture"},{"id":"brass-sconce","label":"Brass wall sconce","group":"lighting"},{"id":"linen-throw","label":"Washed linen throw","group":"textiles"},{"id":"birch-stool","label":"Birch counter stool","group":"furniture"},{"id":"glass-pendant","label":"Fluted glass pendant","group":"lighting"},{"id":"cotton-drape","label":"Heavy cotton drape","group":"textiles"},{"id":"cedar-bench","label":"Cedar entryway bench","group":"furniture"}] | Ranked entities (1–60), each with a stable unique id, a label, and an optional group id matching an entry in groups. |
frames | RaceBarFrame[]Default: [{"period":"Jan 2026","values":{"oak-chair":42000,"arc-lamp":68000,"wool-rug":54000,"walnut-desk":39000,"brass-sconce":31000,"linen-throw":27000,"birch-stool":24000,"glass-pendant":19000,"cotton-drape":16000,"cedar-bench":14000}},{"period":"Feb 2026","values":{"oak-chair":64000,"arc-lamp":74000,"wool-rug":61000,"walnut-desk":52000,"brass-sconce":43000,"linen-throw":36000,"birch-stool":29000,"glass-pendant":28000,"cotton-drape":21000,"cedar-bench":18000}},{"period":"Mar 2026","values":{"oak-chair":92000,"arc-lamp":86000,"wool-rug":79000,"walnut-desk":71000,"brass-sconce":58000,"linen-throw":45000,"birch-stool":34000,"glass-pendant":41000,"cotton-drape":29000,"cedar-bench":26000}},{"period":"Apr 2026","values":{"oak-chair":118000,"arc-lamp":98000,"wool-rug":109000,"walnut-desk":96000,"brass-sconce":72000,"linen-throw":54000,"birch-stool":43000,"glass-pendant":62000,"cotton-drape":39000,"cedar-bench":48000}},{"period":"May 2026","values":{"oak-chair":141000,"arc-lamp":115000,"wool-rug":148000,"walnut-desk":129000,"brass-sconce":88000,"linen-throw":68000,"birch-stool":55000,"glass-pendant":83000,"cotton-drape":49000,"cedar-bench":74000}},{"period":"Jun 2026","values":{"oak-chair":176000,"arc-lamp":134000,"wool-rug":164000,"walnut-desk":169000,"brass-sconce":102000,"linen-throw":84000,"birch-stool":66000,"glass-pendant":111000,"cotton-drape":61000,"cedar-bench":95000}}] | Ordered period frames (1–120), each with a period label and a map of nonnegative numeric values by item id. Missing ids count as zero. |
groups | RaceBarGroup[]— | Optional ordered group definitions (1–8). The first four groups take chromatic series hues (series1–series4), groups five through eight take neutral ink steps (series5–series8), and a legend appears when two or more groups are provided. |
bars | integerDefault: 8 | Top N bars visible at once (3–20). Lower-ranked items slide below the cut and fade out while remaining in the data table. |
defaultFrame | integerDefault: 0 | Initial period index when uncontrolled (0-based). Later argument edits do not reset a mounted instance. |
defaultPlaying | booleanDefault: false | Initial playback state when uncontrolled. Later argument edits do not reset a mounted instance. |
autoPlay | booleanDefault: true | Start playing the first time the chart scrolls into view. Ignored under reduced motion or motion="none". |
frameDuration | integerDefault: 1400 | Milliseconds spent on each period during playback (200–10000). |
loop | booleanDefault: false | Rewind to the first period after holding on the last period and keep playing. |
speedControl | booleanDefault: false | Show a playback speed button beside Play/Pause that cycles 0.5x, 1x, 1.5x, and 2x. |
highlight | string— | Optional item id whose label and value receive primary emphasis, such as a featured product or team. |
unit | string— | Optional unit suffix appended after formatted values, such as "pts" or "MW". |
valueFormat | NumberFormat— | How values appear in the tooltip, table and axis: decimal, percent or currency, with fraction digits. Axis ticks are compacted (12.9K). |
emptyLabel | stringDefault: "No data yet" | Shown inside the plot when there are no frames or items. |
tableToggle | booleanDefault: false | Show a button that reveals the data table. The table is always available to assistive technology. |
tableLabel | stringDefault: "Data table" | Name of the data table button. |
locale | string— | BCP 47 locale for numbers and dates. Omit it to inherit the application locale (en-US by default). |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes use the same interaction behavior. |
theme | RaceBarChartTheme— | Color mode, accent, and semantic tokens including the chart palette and display font family. See Theming. |
motion | none | subtle | expressiveDefault: "subtle" | Animation preset. System reduced-motion preferences take precedence. |
motionOptions | RaceBarChartMotionOptions— | draw and morph transitions; morph spring parameters govern rank-swap physics. |
dir | ltr | rtl— | Reading direction for labels, bars, tooltip, and timeline scrubber. Omit to inherit the page direction. |
React integration
| Prop | Purpose |
|---|---|
frame | Controlled period index; updating it glides the race to that period |
onFrameChange | Fires with the rounded period index when the shown period changes |
playing | Controlled playback state |
onPlayingChange | Fires with the next boolean playback state when play, pause, or end occurs |
formatValue | Custom formatter (value: number) => string for bars, tooltip, and table |
formatTick | Custom formatter (value: number) => string for value-axis tick labels |
preset | Application defaults, overridden by explicit instance props |
tokens | CSS variables applied after the typed theme |
ref | Ref forwarded to the root <figure> |
className, style | Applied to the root <figure> |
| Native attributes | id, data-*, and remaining <figure> attributes forwarded to the root |
Keyboard & accessibility
| Key | Interaction |
|---|---|
Tab | Move focus between the plot, Play/Pause button, speed button, and timeline |
Space, Enter | Play or pause playback; replay from the first period when at the end |
ArrowLeft, ArrowRight | Step one period backward or forward (mirrored in dir="rtl") |
ArrowUp, ArrowDown | Move active reading through visible bars by rank and show the tooltip |
Home, End | Jump to the first or last period |
PageUp, PageDown | Step three periods forward or backward while focused on the timeline slider |
Escape | Clear the active bar reading and hide the tooltip |
The chart renders a <figure> named by title (or visually hidden label when title is omitted) and linked via aria-details to a native data table containing every item's formatted value for every period. The plot is a focusable group (aria-roledescription="bar chart race"), and the timeline track implements role="slider" with aria-valuemin, aria-valuemax, aria-valuenow, and aria-valuetext set to the current period label.
Stepping between periods announces the period name and current leader through a polite role="status" live region; moving through bars announces the item name, rank, and formatted value. All geometry uses logical CSS properties and mirrors cleanly in dir="rtl". Under forced-colors: active, system colors (Canvas, CanvasText, Highlight, HighlightText) replace tinted fills and shadows.
Motion and theming
Values interpolate continuously between periods while each row's vertical rank position rides a critically damped spring (visualDuration: 0.5s, zero bounce by default, customizable via motionOptions.morph). The drawn clock follows requested frame jumps on a 0.42s zero-bounce spring so manual steps glide and replays sweep back through every period. Axis ticks glide with the leader's scale, tooltips follow on a snappy spring, and the period heading rises out of a soft blur.
Under prefers-reduced-motion: reduce, autoPlay is skipped, playback steps discretely period by period without continuous value interpolation, bars snap immediately to rank positions, and the period heading and play icon crossfade briefly. Under motion="none", all transitions and animations resolve immediately (0 ms).
theme accepts a mode, an accent, and semantic tokens across the core, control, and chart groups plus borderStrong, borderSubtle, track, shadowRaised, and fontFamilyDisplay. An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, RaceBarChart is a leaf with no actions. The active period index is host state stored at /components/instance-<id>/frame, initialized from defaultFrame. onPlayingChange is a transient UI control bound to playing. The host updates items and frames through composition updates. See Building with agents.
{
"type": "RaceBarChart",
"props": {
"label": "Revenue by product",
"items": [
{ "id": "chair", "label": "Oak lounge chair", "group": "furniture" },
{ "id": "lamp", "label": "Arc floor lamp", "group": "lighting" }
],
"groups": [
{ "id": "furniture", "label": "Furniture" },
{ "id": "lighting", "label": "Lighting" }
],
"frames": [
{ "period": "Jan 2026", "values": { "chair": 14000, "lamp": 66000 } },
{ "period": "Feb 2026", "values": { "chair": 52000, "lamp": 78000 } }
]
},
"children": []
}