Skip to main content

Progress Bar

A solid fill progress bar with animated transitions. Supports horizontal and vertical orientations, alert zone bands, zone legends, and min/max labels.

Playground

info

onZoneChange callbacks work in your local project but not in this interactive playground due to how the editor re-renders components.

Props

PropTypeDefaultDescription
dataRelayDataPointRequired. { value, timestamp, isLoading?, error? }
minnumber0Minimum value
maxnumber100Maximum value
orientationstring"horizontal""horizontal" or "vertical"
showLabelbooleantrueShow value label on the fill bar
formatValuefunctionCustom value formatter: (value) => string
alertZonesAlertZone[]Color zones as background bands (15% opacity)
showAlertZonesbooleantrueShow zone bands behind the fill
showZoneLegendbooleanfalseShow zone legend below the bar
showZoneValuesbooleanfalseShow boundary values on zone edges
showMinMaxbooleanfalseShow min/max labels at bar ends
stylesobjectCustom styling — see Styles
showLastUpdatedbooleanfalseShow the timestamp from data.timestamp
formatTimestampfunctionCustom timestamp formatter: (ts) => string
showLoadingbooleantrueShow skeleton shimmer while loading
onZoneChangefunctionCalled when value enters a new zone — see onZoneChange
onErrorfunctionCalled on invalid data — see onError

Label Color

The label on the fill bar automatically switches color for readability:

  • White when the fill exceeds 50% of the bar width
  • Current text color when below 50%

Styles

styles={{
label_font_file: { fontSize: 14, fontWeight: 600, color: "#fff", fontFile: "/fonts/Custom.woff2" },
lastUpdated: { fontSize: 10, color: "#94a3b8" },
zoneValue: { fontSize: 10, color: "#6b7280" },
background: { color: "#f1f5f9" },
width: 400,
height: 28,
}}
FieldApplies toProperties
label_font_fileThe value label on the barfontFamily, fontSize, fontWeight, color, fontFile
lastUpdatedTimestamp textfontFamily, fontSize, fontWeight, color, fontFile
zoneValueZone boundary labelsfontFamily, fontSize, fontWeight, color, fontFile
backgroundComponent backgroundcolor
FieldTypeDefaultDescription
widthstring | numberFixed width override
heightstring | number24pxBar height

With Hooks

import { useRelayLatest, ProgressBar } from "@relay-x/ui";

function BatteryBar() {
const latest = useRelayLatest({
deviceIdent: "sensor_01",
metric: "battery",
timeRange: { start: Date.now() - 86400000, end: Date.now() },
});

return <ProgressBar data={latest} min={0} max={100} showLabel showMinMax />;
}