Todae

Todae

Progress and Meter

Progress.Root is a native <progress> and Meter.Root a native <meter>. The browser exposes their roles and values to assistive technology. Todae replaces the browser's bar with a track and a fill from the progress and meter contract tokens. Server Components can import them from @tounsoo/todae/progress and @tounsoo/todae/meter.

On this page

Progress

Progress.Root shows how far a task has come. Leave out value when the end is unknown: a band sweeps the track, and stops when the user asks for reduced motion. A new value glides the fill to its new length over progress.motion.fill.duration and progress.motion.fill.easing, in Chrome and Safari; it jumps in Firefox and under reduced motion.

import { Field, Label, Progress, Stack } from '@tounsoo/todae';
import { useId } from 'react';

export default function ProgressStates() {
  const done = useId();
  const loading = useId();
  return (
    <Stack.Root>
      <Field.Group>
        <Label.Root htmlFor={done}>Uploading report.pdf</Label.Root>
        <Progress.Root id={done} value={64} max={100}>
          64%
        </Progress.Root>
      </Field.Group>
      <Field.Group>
        <Label.Root htmlFor={loading}>Loading results</Label.Root>
        <Progress.Root id={loading} />
      </Field.Group>
    </Stack.Root>
  );
}
64%

Meter

Meter.Root shows a measurement within a known range, such as storage or battery. Set low, high and optimum, and the browser decides whether the value is good, fair or poor. Todae colors those three states from meter.fill.optimum, meter.fill.suboptimum and meter.fill.critical.

import { Field, Label, Meter, Stack } from '@tounsoo/todae';
import { useId } from 'react';

export default function MeterLevels() {
  const storage = useId();
  const battery = useId();
  return (
    <Stack.Root>
      <Field.Group>
        <Label.Root htmlFor={storage}>Storage used</Label.Root>
        <Meter.Root id={storage} min={0} max={100} low={70} high={90} optimum={0} value={92}>
          92%
        </Meter.Root>
      </Field.Group>
      <Field.Group>
        <Label.Root htmlFor={battery}>Battery</Label.Root>
        <Meter.Root id={battery} min={0} max={100} low={20} high={60} optimum={100} value={80}>
          80%
        </Meter.Root>
      </Field.Group>
    </Stack.Root>
  );
}
92%
80%

Name each one with a Label or aria-label, and put the value as text inside the element for browsers that do not draw it. Restyle the track, height and radius through progress.track, progress.height and progress.radius. Meter reads the same three tokens, and the same fill motion, so a change to them reaches both.

Accessible composition

Todae handles: Style only. The browser gives <progress> the progressbar role, gives <meter> its own role, and exposes their values; Todae keeps all of that. The indeterminate band holds still and a new value jumps the fill under reduced motion, and the track and fill keep distinct system colors in forced colors mode.

You supply: A name for each one: a Label, aria-label or aria-labelledby. The value as text inside the element. Todae announces nothing when a value changes, so when the task ends or fails, say so in text, and announce it with useAnnouncer if the user may not be looking.

Watch for: A wrapper that draws its own bar from divs, which loses the role and the value. A wrapper that takes a label prop but never connects it to the element. A meter whose level is told only by the fill color; say "Almost full" in text when it matters. A progress bar removed the moment it finishes, with nothing left to say the task is done.

When to use

When: Progress → a task that moves toward done. Meter → a level within a range that does not change because of the user's task.

When not: A value the user sets → Slider. A short wait, or content whose layout you know → Loader and Skeleton.

Props

Progress.Root props
NameTypeDescription
valuenumber | string

How far the task has come, from 0 to max. Leave it out when the end is unknown: a band sweeps the track.

maxnumber | string

The value at which the task is done.

Default: 1

aria-labelstring

Names the bar when no label element points at it. Every progress bar needs a name.

childrenReact.ReactNode

The value as text, for browsers that do not draw the bar.

Meter.Root props
NameTypeDescription
valuenumber | string

The measurement, between min and max.

minnumber | string

The low end of the range.

Default: 0

maxnumber | string

The high end of the range.

Default: 1

lownumber

Where the low part of the range ends.

highnumber

Where the high part of the range starts.

optimumnumber

The best value. With low and high it decides whether the fill is meter.fill.optimum, meter.fill.suboptimum or meter.fill.critical.

aria-labelstring

Names the meter when no label element points at it.

childrenReact.ReactNode

The value as text, for browsers that do not draw the meter.