Skip to content

Progress

A bar that shows how far a task has got. Same markup and props in every style: switch the style in the header to see it change.

With a label

A label and the percentage above the bar. Turn it green when the task is done.

Uploading design.fig 64%
Backup complete 100%
progress-basic.html
<div style="display: grid; gap: 20px; width: 100%; max-width: 320px">
  <div class="vin-field">
    <div class="vin-progress__head">
      <span class="vin-label" id="upload-label">Uploading design.fig</span>
      <span class="vin-progress__value">64%</span>
    </div>
    <div class="vin-progress" role="progressbar" aria-labelledby="upload-label" aria-valuemin="0" aria-valuemax="100" aria-valuenow="64" style="--vin-value: 64%"></div>
  </div>
  <div class="vin-field">
    <div class="vin-progress__head">
      <span class="vin-label" id="backup-label">Backup complete</span>
      <span class="vin-progress__value">100%</span>
    </div>
    <div class="vin-progress vin-progress--success" role="progressbar" aria-labelledby="backup-label" aria-valuemin="0" aria-valuemax="100" aria-valuenow="100" style="--vin-value: 100%"></div>
  </div>
</div>

Sizes

Small (4px), medium (8px) and large (12px).

progress-sizes.html
<div style="display: grid; gap: 20px; width: 100%; max-width: 320px">
  <div class="vin-progress vin-progress--sm" role="progressbar" aria-label="Small" aria-valuemin="0" aria-valuemax="100" aria-valuenow="25" style="--vin-value: 25%"></div>
  <div class="vin-progress" role="progressbar" aria-label="Medium" aria-valuemin="0" aria-valuemax="100" aria-valuenow="50" style="--vin-value: 50%"></div>
  <div class="vin-progress vin-progress--lg" role="progressbar" aria-label="Large" aria-valuemin="0" aria-valuemax="100" aria-valuenow="75" style="--vin-value: 75%"></div>
</div>

Unknown length

While you can't say how far along it is, leave out the value: the bar slides.

Preparing your export
progress-indeterminate.html
<div class="vin-field" style="width: 100%; max-width: 320px">
  <div class="vin-progress__head">
    <span class="vin-label" id="export-label">Preparing your export</span>
  </div>
  <div class="vin-progress vin-progress--indeterminate" role="progressbar" aria-labelledby="export-label" aria-valuemin="0" aria-valuemax="100"></div>
</div>

Installation

React, Vue and Svelte: add the component to your project with the CLI. It reads your framework from vin.json and also copies any component this one needs. Then import it:

Terminal
npx @vinish/ui add progress
React
import { Progress } from "@/components/vin/progress";
Vue
import Progress from "@/components/vin/progress.vue";
Svelte
import Progress from "$lib/components/vin/progress.svelte";

The import paths assume the default folders: @/components/vin (React and Vue, with the usual @ → src alias) and $lib/components/vin (SvelteKit). Use your own if you chose another folder in init. How the Vue and Svelte versions pass values and content is in Frameworks.

Plain HTML: the classes come with the style's stylesheet. It needs no JavaScript.

API

From spec/progress.json, which every framework version is tested against.

PropValuesDefaultIn HTML
value
0–100. Leave it out while the amount is unknown: the bar slides (indeterminate).
number—aria-valuenow="64" style="--vin-value: 64%", or .vin-progress--indeterminate
sizesmmdlgmdvin-progress--{value}
variantdefaultsuccessdefaultvin-progress--success
label
Shown above the bar and used as its name.
ReactNode—.vin-progress__head > .vin-label[id], aria-labelledby on the bar
showValue
Show the percentage next to the label.
booleanfalse.vin-progress__value

Parts

React, Vue, SvelteHTML classes
<Progress>.vin-progress.vin-progress--sm.vin-progress--lg.vin-progress--success.vin-progress--indeterminate.vin-progress__head.vin-progress__value

Accessibility

  • role="progressbar" with aria-valuenow, -min and -max: screen readers say the percentage.
  • Every bar has a name: the visible label (aria-labelledby) or an aria-label.
  • An indeterminate bar has no aria-valuenow, which tells screen readers the amount is unknown.
  • The sliding bar stops when motion is off.