Skip to main content

Status Strip

A row of equal segments over time, such as one segment for each hour or day, each shaded by its share of the time in one state. A segment with no data is empty between two lines, so it does not read as 0.

Desktop viewport
Tablet viewport
Mobile viewport

When to use

  • Show when something was in one state over time, such as in stock or up, as a row of equal segments for each hour or day.
  • Prefer ProgressBar to show one value, such as how much of a task is complete.
  • Prefer BarChart when a reader must read exact values over time from axes and a tooltip.

Shares between 0 and 1

A segment can cover more than one reading, such as six hours of a 30-day range. Pass the share of those readings in the state as value. The fill starts at 35% strength above 0, so one hour in six still shows, and grows to full strength at 1.

Desktop viewport
Tablet viewport
Mobile viewport

No data

Pass value={null} for a segment with no reading. It is empty between two lines, at its top and bottom, and a segment at 0 fills with the track color. Never pass 0 for a segment with no data: a reader then sees a sold-out or down hour that nobody measured.

Desktop viewport
Tablet viewport
Mobile viewport

Beside text that says the same thing

When text beside the strip already gives its summary, pass aria-hidden in place of a name, so a screen reader does not read the same thing twice. Set the segment width with an auto-cols-* class, so each segment keeps its width when the number of segments changes.

Desktop viewport
Tablet viewport
Mobile viewport

Colors

The fill is --color-accent-600, and the track is --color-gray-300. Set --status-strip-fill or --status-strip-track on StatusStrip.Root to change them for every segment.

Desktop viewport
Tablet viewport
Mobile viewport

Threshold colors

To color one segment by a threshold, such as a weak day, set --status-strip-fill on that segment. A segment at 0 paints --status-strip-track, so set that variable to recolor a sold-out day. A bg-* class on a segment replaces the fill above 0, and a data-[share=none]: class replaces the paint at 0.

Desktop viewport
Tablet viewport
Mobile viewport

In a list

A strip has no state, effects, listeners, or layout reads, so it renders on the server, and hydration only renders it again. A list of strips needs no wrapper part. Give each row its own text, and pass aria-hidden when that text says what the strip shows.

Desktop viewport
Tablet viewport
Mobile viewport

Many segments

A strip fills its width by default, so it can hold a segment for each hour of a week. Keep the default 1px gap at that density, so the strip fits a 320px screen. At that width, neighboring hours in the same state can run together. When each hour must stay separate on a narrow screen, show a segment for each day.

Desktop viewport
Tablet viewport
Mobile viewport

Composition

StatusStrip.Root
└── StatusStrip.Segment

Polymorphism

StatusStrip.Root and StatusStrip.Segment take asChild. Use it on StatusStrip.Root to render the strip as a <div> in flow content, and on StatusStrip.Segment to render your own element.

Keep each segment non-interactive. A screen reader reads role="img" as one image, so it cannot reach a link or a button inside the strip. Under aria-hidden, such a control still takes keyboard focus, with no name. Put a link to a day's detail outside the strip.

Accessibility

  • StatusStrip.Root is role="img", so a screen reader reads its name as one summary and skips the segments. The type requires aria-label or aria-labelledby, or aria-hidden. An empty or blank name throws. Under asChild, the root's role and name replace the child's own.
  • With aria-hidden, the root has no role, and the strip is hidden from assistive technology. Use it only when nearby text says the same thing.
  • A segment's title shows on hover. It is a hint for a pointer, so put what a reader must know in the root's name. When the times matter, such as when stock ran out, list them in text near the strip.
  • The states differ in strength and in shape (a fill or two lines), not only in hue.

API Reference

StatusStrip.Root

The strip: a full-width <span> grid of equal columns, 1.5rem tall, with a 1px gap. Set the height with h-*, the gap with gap-*, and a fixed segment width with auto-cols-*. It accepts every span prop except role.

PropTypeDefaultDescription
aria-labelstringnoneThe summary a screen reader reads. Required unless aria-labelledby or aria-hidden is set.
aria-labelledbystringnoneThe id of visible text that summarizes the strip.
aria-hiddentruenoneHides the strip from assistive technology. Set it only when nearby text says what the strip shows.
asChildbooleanfalseRender your own element in place of the <span>, and merge the props onto it.
CSS VariableDefaultDescription
--status-strip-fillvar(--color-accent-600)The color of a segment with a share above 0. Read by StatusStrip.Segment.
--status-strip-trackvar(--color-gray-300)The fill of a segment at 0, and the lines of a segment with no data. Read by StatusStrip.Segment.
Data AttributeValueDescription
data-slot"status-strip"The root element.

StatusStrip.Segment

One segment, such as one hour or one day. It accepts every span prop except children.

PropTypeDefaultDescription
valuenumber | nullnoneThe share of the segment's time in the state, from 0 to 1, or null for no data. Required; any other value throws.
titlestringnoneA hint that shows on hover, such as the time span and its share.
asChildbooleanfalseRender your own non-interactive element in place of the <span>, and merge the props onto it.
CSS VariableDefaultDescription
--status-strip-fillvar(--color-accent-600)The fill above 0. Set it on StatusStrip.Root, or on one segment for its own color, such as a threshold color.
--status-strip-trackvar(--color-gray-300)The fill at 0, and the lines with no data. Set it on StatusStrip.Root, or on one segment.
Data AttributeValueDescription
data-slot"status-strip-segment"The segment element.
data-share"no-data", "none", "some", "all"null, 0, between 0 and 1, and 1. Style a state with data-[share=none]:.