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.
<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>import { Progress } from "@/components/vin/progress";
export function ProgressBasic() {
return (
<div style={{ display: "grid", gap: 20, width: "100%", maxWidth: 320 }}>
<Progress label="Uploading design.fig" value={64} showValue />
<Progress label="Backup complete" value={100} variant="success" showValue />
</div>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import Progress from "@/components/vin/progress.vue";
</script>
<template>
<div style="display: grid; gap: 20px; width: 100%; max-width: 320px">
<Progress label="Uploading design.fig" :value="64" show-value />
<Progress label="Backup complete" :value="100" variant="success" show-value />
</div>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import Progress from "$lib/components/vin/progress.svelte";
</script>
<div style="display: grid; gap: 20px; width: 100%; max-width: 320px">
<Progress label="Uploading design.fig" value={64} showValue />
<Progress label="Backup complete" value={100} variant="success" showValue />
</div>Sizes
Small (4px), medium (8px) and large (12px).
<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>import { Progress } from "@/components/vin/progress";
export function ProgressSizes() {
return (
<div style={{ display: "grid", gap: 20, width: "100%", maxWidth: 320 }}>
<Progress aria-label="Small" size="sm" value={25} />
<Progress aria-label="Medium" value={50} />
<Progress aria-label="Large" size="lg" value={75} />
</div>
);
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import Progress from "@/components/vin/progress.vue";
</script>
<template>
<div style="display: grid; gap: 20px; width: 100%; max-width: 320px">
<Progress aria-label="Small" size="sm" :value="25" />
<Progress aria-label="Medium" :value="50" />
<Progress aria-label="Large" size="lg" :value="75" />
</div>
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import Progress from "$lib/components/vin/progress.svelte";
</script>
<div style="display: grid; gap: 20px; width: 100%; max-width: 320px">
<Progress aria-label="Small" size="sm" value={25} />
<Progress aria-label="Medium" value={50} />
<Progress aria-label="Large" size="lg" value={75} />
</div>Unknown length
While you can't say how far along it is, leave out the value: the bar slides.
<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>import { Progress } from "@/components/vin/progress";
export function ProgressIndeterminate() {
return <Progress label="Preparing your export" style={{ width: "100%", maxWidth: 320 }} />;
}The Vue version renders the same markup as the HTML tab, so it looks and works the same.
<script setup lang="ts">
import Progress from "@/components/vin/progress.vue";
</script>
<template>
<Progress label="Preparing your export" style="width: 100%; max-width: 320px" />
</template>The Svelte version renders the same markup as the HTML tab, so it looks and works the same.
<script lang="ts">
import Progress from "$lib/components/vin/progress.svelte";
</script>
<Progress label="Preparing your export" style="width: 100%; max-width: 320px" />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:
npx @vinish/ui add progressimport { Progress } from "@/components/vin/progress";import Progress from "@/components/vin/progress.vue";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.
| Prop | Values | Default | In HTML |
|---|---|---|---|
value0–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 |
size | smmdlg | md | vin-progress--{value} |
variant | defaultsuccess | default | vin-progress--success |
labelShown above the bar and used as its name. | ReactNode | — | .vin-progress__head > .vin-label[id], aria-labelledby on the bar |
showValueShow the percentage next to the label. | boolean | false | .vin-progress__value |
Parts
| React, Vue, Svelte | HTML 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.
Customize
Saved in this browser. Style and accent are in the header.