Skip to content
English
Segmented meter comes with Pro. Its preview shows once you unlock it.

How it works

Ticks are a flex row with 3px gaps; each tick takes the colour of the part under its midpoint, and its delay is computed so it lights exactly when the counting hero number passes it. Bars are flex items sized by flex-grow, each fill sliding in from the left inside a rounded clip so the ends stay round. Nothing is measured in JavaScript, so the server render is already right. Hover, touch or the arrow keys pick a part: it stays lit, the rest dim, and an ink tooltip sits over it.

Use it for

  • A score or level against a fixed scale: credit score, fitness level, battery.
  • A total split into a few parts where the split matters: time by activity, visits by type, storage by kind.
  • Compact cards where a full chart would be too much.

Look elsewhere when

  • Comparing parts precisely or more than five parts: use ranked bars.
  • Values over time: use a bar or line chart.
  • A plain task progress with no parts: a progress bar is simpler.

Usage

import { SegmentedMeter } from './SegmentedMeter.jsx'

const hm = (m) => `${Math.floor(m / 60)}h ${String(Math.round(m % 60)).padStart(2, '0')}m`

export function WorkTime() {
  return (
    <SegmentedMeter
      title="Work time"
      qualifier="This week"
      tone={6}
      formatValue={hm}
      legend="beside"
      breakdown
      segments={[
        { name: 'Focus', value: 1466 },
        { name: 'Meetings', value: 629 },
        { name: 'Admin', value: 233 },
      ]}
    />
  )
}

export function CreditScore() {
  return <SegmentedMeter title="Credit health" caption="Your credit score" unit="/ 850" tone={6} segments={[{ name: 'Score', value: 712 }]} total={850} ticks={30} height={44} />
}

Props

PropTypeDefaultWhat it does
title / qualifierstring—Card title (15px semibold) and grey words after it.
iconReactNode—An 18px icon in a 32px square tinted with the card colour.
onAction / actionIcon / actionLabel / action() => void / 'open' | 'more' / string / ReactNode- / 'open'A round chevron or three-dot button at the right of the title row, its accessible name, or your own element instead.
captionstring—Grey line above the hero number.
valuenumber—Hero number; defaults to the sum of the parts. It counts up with the ticks.
unitstring—Grey unit beside the hero number, such as “/ 850”.
delta / deltaLabel / formatDelta / trendGoodWhennumber / string / (n) => string / 'up' | 'down'- / - / `${n}%` / 'up'A change beside the hero with a diagonal arrow: green when it moves the good way, red otherwise, with the direction also read out.
noteReactNode—A grey sentence under the hero.
segments{ name: string, value: number, color?: string }[]—The parts, in order. Colours follow --ds-chart-N from tone unless given. Zero is not drawn, negatives count as 0, beyond 8 the rest merge into “Other”.
totalnumber—The whole. When larger than the parts, the rest stays unlit; one part with a total is a score meter.
variant'ticks' | 'bar''ticks'A row of ticks, or rounded bars with gaps sized by value.
ticksnumber40Number of ticks (8-120); they share the width with 3px gaps.
heightnumber28 (bar: 10)Tick or bar height in px.
legend'below' | 'beside' | 'none''below'Where the legend goes: under the meter with counted values, or compact at the right of the hero. Shown with two or more parts.
breakdownbooleanfalseA column per part under the meter with its counted value and share, marked in its colour.
tone1-81Card colour for the icon tint and the first part.
formatValue / formatPercent(n) => stringtoLocaleString('en-US') / `${Math.round(p)}%`Number and share formats; formatValue also receives in-between values while counting.
textobject—Replaces built-in words (other, rest, open, more, up, down, meter, part); shallow-merged over the English defaults.
labelstring—Accessible name of the meter; defaults to the title.
replayKeyany—Change it to light the meter again from zero.
...restHTMLAttributes<HTMLDivElement>—Other attributes go to the card.

Accessibility

  • The meter is a focusable group whose name reads every part with its value and share; Left and Right step through parts, Home and End jump, Escape clears, and each step is announced.
  • The delta reads its direction in words, and the legend and breakdown repeat values as text, so colour is never the only cue.
  • Nothing is shown only on hover: keyboard focus shows the same tooltip.
  • With reduced motion every tick is lit at once and the numbers show their final values.

Motion

When 30% of the card is on screen the ticks light up left to right over 900ms, each fading in and springing to full height in 320ms at the moment the hero number passes it; bars slide in one after another over 560ms. Legend and breakdown count on the same curve. Hover dims the other parts in 160ms and the tooltip follows in 220ms.

Add it to your project

Pro members copy a prompt and their coding agent installs the source, the same way as the free components.

SegmentedMeter.jsxsegmented-meter.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Charts
Trilateration comes with Pro. Its preview shows once you unlock it.