Progress Shared Partial

1. Copy shared partial files

Download all 1 shared partial files as a ZIP file.

Download all files (ZIP)

After downloading, unzip and copy the progress/ folder to your app/views/shared/components/ directory.

Copy these files to your app/views/shared/components/progress/ directory:

2. Usage example

<%# Basic Progress %>
<%= render "shared/components/progress/progress", value: 60, aria_label: "Upload progress", classes: "max-w-sm" %>

<%# Progress with Label %>
<div class="w-full max-w-sm space-y-6">
  <%= render "shared/components/progress/progress", value: 66, label: "Uploading files", id: "upload-progress" %>
  <%= render "shared/components/progress/progress", value: 7.2, max: 10, label: "Storage", value_text: "7.2 GB of 10 GB" %>
</div>

<%# Progress Variants %>
<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>
    <%= render "shared/components/progress/progress", value: 40, label: "Small", size: :sm %>
    <%= render "shared/components/progress/progress", value: 55, label: "Default" %>
    <%= render "shared/components/progress/progress", value: 70, label: "Large", size: :lg %>
  </div>

  <div class="space-y-4">
    <p class="text-xs font-medium uppercase tracking-wide text-neutral-500 dark:text-neutral-400">Colors</p>
    <%= render "shared/components/progress/progress", value: 90, label: "Tasks completed", variant: :success %>
    <%= render "shared/components/progress/progress", value: 75, label: "Monthly quota", variant: :warning %>
    <%= render "shared/components/progress/progress", value: 95, label: "Disk space", variant: :danger %>
  </div>
</div>

Rendered usage example

Uploading files
Storage

Sizes

Small
Default
Large

Colors

Tasks completed
Monthly quota
Disk space

Progress ViewComponent

1. Ensure the gem is installed

gem "view_component", "~> 4.2"

2. Copy component files

Download all 2 component files as a ZIP file.

Download all files (ZIP)

After downloading, unzip and copy the progress/ folder to your app/components/ directory.

Copy these files to your app/components/progress/ directory:

3. Usage example

<%# Basic Progress %>
<%= render Progress::Component.new(value: 60, aria_label: "Upload progress", classes: "max-w-sm") %>

<%# Progress with Label %>
<div class="w-full max-w-sm space-y-6">
  <%= render Progress::Component.new(value: 66, label: "Uploading files", id: "upload-progress") %>
  <%= render Progress::Component.new(value: 7.2, max: 10, label: "Storage", value_text: "7.2 GB of 10 GB") %>
</div>

<%# Progress Variants %>
<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>
    <%= render Progress::Component.new(value: 40, label: "Small", size: :sm) %>
    <%= render Progress::Component.new(value: 55, label: "Default") %>
    <%= render Progress::Component.new(value: 70, label: "Large", size: :lg) %>
  </div>

  <div class="space-y-4">
    <p class="text-xs font-medium uppercase tracking-wide text-neutral-500 dark:text-neutral-400">Colors</p>
    <%= render Progress::Component.new(value: 90, label: "Tasks completed", variant: :success) %>
    <%= render Progress::Component.new(value: 75, label: "Monthly quota", variant: :warning) %>
    <%= render Progress::Component.new(value: 95, label: "Disk space", variant: :danger) %>
  </div>
</div>

Rendered usage example

Uploading files
Storage

Sizes

Small
Default
Large

Colors

Tasks completed
Monthly quota
Disk space

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.

60%
<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”.

Uploading files
Storage
<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

Small
Default
Large

Colors

Tasks completed
Monthly quota
Disk space
<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.

Table of contents

Powered by

Get notified when new components come out