Data

Spring Bars

A bar chart whose bars rise like liquid, with a value bubble that flows to the bar you point at.

Preview

Installation

Terminal
npx @usefluid/cli add spring-bars

Usage

SpringBars.tsx
import { SpringBars } from "./SpringBars";

<SpringBars label="Orders this week" max={100} data={[{ label: "Mon", value: 32 }, { label: "Tue", value: 48 }]} />

API reference

PropTypeDefaultDescription
labelstring—Accessible name of the chart.
data{ label, value }[]—One bar per item. Labels must be unique. Change the values and the bars flow to them.
maxnumberthe largest valueThe value of a full bar. Keep it fixed when the data changes, so bars compare across changes.
formatIntl.NumberFormatOptions—How values are written, as in Intl.NumberFormat.
localestringthe browser'sLocale for the values.

Keyboard and screen readers

Each bar is a button named with its label and value. Tab reaches the chart once; the arrow keys, Home and End move between bars, and the bubble follows. With reduced motion bars change at once.

Notes

Bars further right use slightly slower springs, so a change ripples across the chart. Every colour comes from the --fluid-* variables, and the piece is yours to change.

How it is made

Each bar has a spring of its own, a little slower from left to right, so a change ripples across the chart instead of jumping. The bubble is on two springs, sideways and up, and follows the pointer or the arrow keys. Every bar is a button read with its label and value.

For your agent

For your agent

Add Spring Bars to my project with the Fluid library. Replace the bar charts of my dashboard with SpringBars, with a fixed max so bars compare across changes. Read my project first. Use my logo, my colours and my font through the --fluid-* variables. Keep 44px touch targets, visible focus and reduced motion. If I have no SVG logo, ask before making one up.