Progress bar
Progress of a task, known or indeterminate.
Example
<div class="stack"> <focsd-progress label="Uploading report.pdf" value="40"></focsd-progress> <focsd-progress label="Preparing export" indeterminate></focsd-progress></div>Ring
Progress as a ring, with the percentage in the center, for a compact space such as a card or a toolbar.
<focsd-progress variant="ring" label="Uploading report.pdf" value="40" show-value></focsd-progress><focsd-progress variant="ring" label="Syncing" indeterminate></focsd-progress><focsd-progress variant="ring" label="Saving" value="70" style="--focsd-progress-ring-size: 1.5rem"></focsd-progress>Usage
Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.
<script type="module"> import '@focsd-dev/components/focsd-progress.js';</script>
<focsd-progress label="Uploading report.pdf" value="40"></focsd-progress>import { Progress } from '@focsd-dev/react';
export function Example() { return <Progress label="Uploading report.pdf" value="40"></Progress>;}<script setup>import '@focsd-dev/components/focsd-progress.js';</script>
<template> <focsd-progress label="Uploading report.pdf" value="40"></focsd-progress></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/components/focsd-progress.js';
// template<focsd-progress label="Uploading report.pdf" value="40"></focsd-progress><script> import '@focsd-dev/components/focsd-progress.js';</script>
<focsd-progress label="Uploading report.pdf" value="40"></focsd-progress>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
value | value | number | 0 |
max | max | number | 100 |
label | label | string | — |
indeterminate | indeterminate | boolean | false |
variant | variant | 'bar' | 'ring' | bar |
show-value | showValue | boolean | false |
CSS parts
Style the inside of the component with ::part(), for example focsd-progress::part(indicator).
| Part | Description |
|---|---|
indicator | The bar's indicator element. |
track | The bar's track element. |
ring | The ring variant's box, holding the circle and the value. |
ring-track | The ring's full circle behind the arc (a band between two thin outlines, as the bar's track). |
ring-indicator | The ring's arc, as long as the value. |
value | The ring's value as a percentage, shown with `show-value` (hidden from assistive technology, which reads aria-valuenow). |
Accessibility
role="progressbar"witharia-valuenow/min/maxand a requiredlabel; indeterminate omitsaria-valuenow.
Ring
- The ring is the same
role="progressbar"as the bar, named bylabel, witharia-valuenow,aria-valueminandaria-valuemax; the drawing is hidden from assistive technology. - With
show-valuethe percentage appears in the center. It is hidden from screen readers, which already read the value fromaria-valuenow. - While
indeterminate, there is noaria-valuenowand the ring turns. When reduced motion is preferred it stops turning and shows a still arc. - Like the bar, the track is a sunk band with a thin edge-colored outline on each side. The arc against the band measures 6.33:1 (light), 10.02:1 (dark) and 16.39:1 (contrast), and the outline against the page 3.63:1, 3.63:1 and 21:1, so both the value and the ring’s extent meet the 3:1 non-text minimum.
- In forced colors the arc uses
Highlight, the bandCanvasand its outlinesCanvasText. - Set
--focsd-progress-ring-sizeto change its size (3rem by default).
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.