Skip to main content

Variants

Six variants. The fill uses the 700 shade (400 in dark mode) on a light track, so it keeps 3:1 against the track as non-text content. Pick the variant for the meaning: success for done, warning when a limit is near, danger when it is over.

Dominant 20%
Primary 35%
Success 50%
Info 65%
Warning 80%
Danger 95%

Sizes

Four heights. Medium (h-2) is the default and the size used on the dashboard. Use the large sizes when the bar is the main content of a view, such as an upload.

Small (h-1.5) 64%
Medium (h-2) 64%
Large (h-3) 64%
Extra large (h-4) 64%

Label and value

Without text, the percentage shows beside the label. Every bar needs a name: point aria-labelledby at the visible label, or use aria-label. With aria-labelledby the label can be any element outside the bar, as in the last example. The value can sit beside the label, show real units (add aria-valuetext so a screen reader says “$612 of $700”), or sit inside a taller bar. Inside text uses the 700 shade (white text) in light mode and 400 with dark text in dark mode to keep 4.5:1.

Uploading products.csv 64%
Groceries $612 / $700
Profile completion
75%

Disk usage on the backup server

40%

Indeterminate

When the total is not known, leave out aria-valuenow: the element is then an indeterminate progress bar and a screen reader says it is busy, not a percentage. The fill slides along the track; with prefers-reduced-motion it stays still (motion-reduce:animate-none). Replace it with a determinate bar as soon as you know the value.

Importing products…

Segmented

Several parts in one bar. It is not a single value, so it is an img with an aria-label that lists every part; the legend repeats the numbers as text and never relies on colour alone. A small gap separates the parts.

Storage 44 of 50 GB used
  • Documents 24 GB
  • Photos 12 GB
  • Apps 8 GB

Options reference

No JavaScript is needed: the bar is two elements and a few attributes. To change the value, set aria-valuenow and the width of the fill.

Part Value Description
role="progressbar" on the track Required. The track is the element that clips the fill (overflow-hidden rounded-full).
aria-valuemin, aria-valuemax 0, 100 The range. Use your own maximum when the unit is not a percent.
aria-valuenow number The current value. Leave it out for an indeterminate bar.
aria-valuetext text Optional. A readable value with units, for example $612 of $700 budget.
aria-labelledby or aria-label text Required: the name of the bar.
style="width: 64%" on the fill The width of the fill. Update it together with aria-valuenow.
Variant bg-{variant}-700 dark:bg-{variant}-400 On the fill. Variants: dominant, primary, success, info, warning, danger. The track is bg-dominant-200 dark:bg-dominant-800.
Size h-1.5, h-2, h-3, h-4 The height of the track.
animate-indeterminate class Defined in the @theme of this page: the keyframes slide the fill along the track. Copy both if you use it.