Skip to main content

BarIndicator

Every example on this page is live, drawn by the library's Storybook, where you can also change its props and see the result.

A horizontal bar chart that displays a ratio as a filled percentage. Useful for showing progress, utilization, or any value relative to a maximum. The bar fills its box, rounded and outlined, and keeps its rounding and outline at the same size however wide or tall the box is.

Import​

import { BarIndicator } from "~lib/charts/bar-indicator";

Props​

NameTypeRequiredDefaultDescription
numeratornumberYesN/AThe current value
denominatornumberYesN/AThe maximum value
widthnumber | stringNo"100%"The width of the bar
heightnumber | stringNo"0.75rem"The height of the bar

Examples​

Simple​

A basic bar showing 50 out of 100 (50% filled):

Open Simple in Storybook

Exceed Maximum​

When numerator exceeds denominator, the bar is clamped to 100%:

Open Exceed Maximum in Storybook

Negative​

Negative values are clamped to 0%:

Open Negative in Storybook

See Also​

  • DonutGauge - Circular gauge for displaying ratios
  • LineChart - Line chart for time series data