Progress Rails Components
Progress bars show how far along a task is, like an upload, a quota, or a set of onboarding steps. They are built with Tailwind CSS only, so there is no JavaScript to install. For work with no known end, use a Loading Indicator instead.
Examples
Basic Progress
A track and an indicator whose width is the current value. The role="progressbar" and aria-valuenow attributes let screen readers announce the progress. Drag the slider to see the bar follow. The slider is only on this page; see Updating the Value for how to do it in your app.
<div role="progressbar" aria-label="Upload progress" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" class="h-2 w-full max-w-sm overflow-hidden rounded-full bg-neutral-900/10 dark:bg-white/15">
<div class="h-full bg-neutral-900 transition-[width] duration-500 ease-out motion-reduce:transition-none dark:bg-white" style="width: 60%"></div>
</div>
Progress with Label
A visible label linked with aria-labelledby and the value next to it. Use aria-valuetext when the value is not a percentage, like “7.2 GB of 10 GB”.
<div class="w-full max-w-sm space-y-6">
<div>
<div class="mb-2 flex items-center justify-between gap-4 text-sm">
<span id="upload-progress-label" class="font-medium text-neutral-900 dark:text-white">Uploading files</span>
<span class="tabular-nums text-neutral-500 dark:text-neutral-400" aria-hidden="true">66%</span>
</div>
<div id="upload-progress" role="progressbar" aria-labelledby="upload-progress-label" aria-valuenow="66" aria-valuemin="0" aria-valuemax="100" class="h-2 w-full overflow-hidden rounded-full bg-neutral-900/10 dark:bg-white/15">
<div class="h-full bg-neutral-900 transition-[width] duration-500 ease-out motion-reduce:transition-none dark:bg-white" style="width: 66%"></div>
</div>
</div>
<div>
<div class="mb-2 flex items-center justify-between gap-4 text-sm">
<span id="storage-progress-label" class="font-medium text-neutral-900 dark:text-white">Storage</span>
<span class="tabular-nums text-neutral-500 dark:text-neutral-400" aria-hidden="true">7.2 GB of 10 GB</span>
</div>
<div role="progressbar" aria-labelledby="storage-progress-label" aria-valuenow="7.2" aria-valuemin="0" aria-valuemax="10" aria-valuetext="7.2 GB of 10 GB" class="h-2 w-full overflow-hidden rounded-full bg-neutral-900/10 dark:bg-white/15">
<div class="h-full bg-neutral-900 transition-[width] duration-500 ease-out motion-reduce:transition-none dark:bg-white" style="width: 72%"></div>
</div>
</div>
</div>
Progress Variants
Small, default, and large heights, and success, warning, and danger colors for quotas and limits.
Sizes
Colors
<div class="grid w-full max-w-2xl gap-x-10 gap-y-8 sm:grid-cols-2">
<div class="space-y-4">
<p class="text-xs font-medium uppercase tracking-wide text-neutral-500 dark:text-neutral-400">Sizes</p>
<div>
<div class="mb-2 flex items-center justify-between gap-4 text-sm">
<span id="size-small-progress-label" class="font-medium text-neutral-900 dark:text-white">Small</span>
<span class="tabular-nums text-neutral-500 dark:text-neutral-400" aria-hidden="true">40%</span>
</div>
<div role="progressbar" aria-labelledby="size-small-progress-label" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" class="h-1 w-full overflow-hidden rounded-full bg-neutral-900/10 dark:bg-white/15">
<div class="h-full bg-neutral-900 transition-[width] duration-500 ease-out motion-reduce:transition-none dark:bg-white" style="width: 40%"></div>
</div>
</div>
<div>
<div class="mb-2 flex items-center justify-between gap-4 text-sm">
<span id="size-default-progress-label" class="font-medium text-neutral-900 dark:text-white">Default</span>
<span class="tabular-nums text-neutral-500 dark:text-neutral-400" aria-hidden="true">55%</span>
</div>
<div role="progressbar" aria-labelledby="size-default-progress-label" aria-valuenow="55" aria-valuemin="0" aria-valuemax="100" class="h-2 w-full overflow-hidden rounded-full bg-neutral-900/10 dark:bg-white/15">
<div class="h-full bg-neutral-900 transition-[width] duration-500 ease-out motion-reduce:transition-none dark:bg-white" style="width: 55%"></div>
</div>
</div>
<div>
<div class="mb-2 flex items-center justify-between gap-4 text-sm">
<span id="size-large-progress-label" class="font-medium text-neutral-900 dark:text-white">Large</span>
<span class="tabular-nums text-neutral-500 dark:text-neutral-400" aria-hidden="true">70%</span>
</div>
<div role="progressbar" aria-labelledby="size-large-progress-label" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" class="h-3 w-full overflow-hidden rounded-full bg-neutral-900/10 dark:bg-white/15">
<div class="h-full bg-neutral-900 transition-[width] duration-500 ease-out motion-reduce:transition-none dark:bg-white" style="width: 70%"></div>
</div>
</div>
</div>
<div class="space-y-4">
<p class="text-xs font-medium uppercase tracking-wide text-neutral-500 dark:text-neutral-400">Colors</p>
<div>
<div class="mb-2 flex items-center justify-between gap-4 text-sm">
<span id="tasks-progress-label" class="font-medium text-neutral-900 dark:text-white">Tasks completed</span>
<span class="tabular-nums text-neutral-500 dark:text-neutral-400" aria-hidden="true">90%</span>
</div>
<div role="progressbar" aria-labelledby="tasks-progress-label" aria-valuenow="90" aria-valuemin="0" aria-valuemax="100" class="h-2 w-full overflow-hidden rounded-full bg-green-500/15 dark:bg-green-400/20">
<div class="h-full bg-green-500 transition-[width] duration-500 ease-out motion-reduce:transition-none dark:bg-green-400" style="width: 90%"></div>
</div>
</div>
<div>
<div class="mb-2 flex items-center justify-between gap-4 text-sm">
<span id="quota-progress-label" class="font-medium text-neutral-900 dark:text-white">Monthly quota</span>
<span class="tabular-nums text-neutral-500 dark:text-neutral-400" aria-hidden="true">75%</span>
</div>
<div role="progressbar" aria-labelledby="quota-progress-label" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" class="h-2 w-full overflow-hidden rounded-full bg-amber-500/15 dark:bg-amber-400/20">
<div class="h-full bg-amber-500 transition-[width] duration-500 ease-out motion-reduce:transition-none dark:bg-amber-400" style="width: 75%"></div>
</div>
</div>
<div>
<div class="mb-2 flex items-center justify-between gap-4 text-sm">
<span id="disk-progress-label" class="font-medium text-neutral-900 dark:text-white">Disk space</span>
<span class="tabular-nums text-neutral-500 dark:text-neutral-400" aria-hidden="true">95%</span>
</div>
<div role="progressbar" aria-labelledby="disk-progress-label" aria-valuenow="95" aria-valuemin="0" aria-valuemax="100" class="h-2 w-full overflow-hidden rounded-full bg-red-500/15 dark:bg-red-400/20">
<div class="h-full bg-red-500 transition-[width] duration-500 ease-out motion-reduce:transition-none dark:bg-red-400" style="width: 95%"></div>
</div>
</div>
</div>
</div>
Updating the Value
The indicator animates its width, so you only have to update two things: the width of the indicator and aria-valuenow on the progress bar. Replace the bar with a Turbo Stream, or set them from your own JavaScript:
const bar = document.querySelector("#upload-progress")
bar.setAttribute("aria-valuenow", 80)
bar.firstElementChild.style.width = "80%"
Accessibility
- Use role="progressbar" with aria-valuenow, aria-valuemin, and aria-valuemax.
- Every progress bar needs an accessible name: aria-labelledby pointing to a visible label, or aria-label when there is none.
- Add aria-valuetext when the raw number is not meaningful on its own, like “Step 2 of 5” or “7.2 GB of 10 GB”.
- Hide the visible value with aria-hidden="true", since the progress bar already announces it.
- Don't rely on color alone to tell a warning from a normal state. Pair the color with a label or a value.