An accessible progress bar identifies the task, exposes its measured progress, and distinguishes an unknown total from zero completed work. Use the native HTML progress element when possible. Give it a visible label, remove its value attribute when the total is unknown, and show a clear outcome when work ends.
For a student project, file importer, or public dashboard, a moving strip alone leaves important questions unanswered: what is running, how much is finished, and did it succeed? This guide builds a small progress-state demonstration and tests its markup before launch. It does not require an upload service or pretend that a timer measures real work.
Build an accessible progress bar with native HTML
Start with a label connected by ID and a separate visible description of the current value:
<label for="import-progress">Import project files</label>
<progress id="import-progress" max="10" value="3"
aria-describedby="import-detail"></progress>
<p id="import-detail">3 of 10 files processed.</p>
The HTML progress element reference documents its label association and numeric attributes. Text between the opening and closing progress tags does not supply its accessible label. Keep the task name visible and stable; update the count separately. If several imports can run together, name each one with enough context to distinguish it.
For native progress, zero is the minimum. Set a positive max and a value between zero and that maximum. Do not add a min attribute or duplicate the native semantics with role="progressbar" and parallel ARIA values.
Decide what the units mean before wiring the component. Ten processed files out of twenty measures file count, not elapsed time. If one file takes much longer, explain the current stage rather than implying a reliable time estimate. For an upload followed by server processing, do not show the whole task as complete when only the transfer has finished.
The HTML Standard's progress definition distinguishes task completion from a measurement in a known range. Use meter for a measurement such as storage usage; use progress for work moving toward completion. A multi-page form may instead need a visible step list that identifies the current page and available navigation.
Represent unknown progress without inventing a percentage
An indeterminate progress bar has no value attribute:
<label for="discover-progress">Find project files</label>
<progress id="discover-progress" max="10"></progress>
<p>Finding files. The total is not available yet.</p>
Setting value="0" means a known amount of work has made no progress. An empty string is not a useful substitute for removing the attribute. When moving from measured to unknown work, use removeAttribute('value') and replace any stale count nearby.
Keep a readable explanation alongside the indicator. If discovery stalls or the request fails, show the failure and a recovery action appropriate to the application. Do not leave an indefinite animation as the only result. If you add custom movement, review the reduced motion implementation guide, including how users can still recognize pending work when animation is removed.
Keep value changes and terminal states consistent
Use one state update to change the bar and its explanatory text together. The following standalone demo starts in an unknown state. Its buttons simulate events so you can inspect every state without waiting for a backend. They are demonstration controls, not controls to include in a real import interface.
<label for="demo-progress">Import project files</label>
<progress id="demo-progress" max="10"
aria-describedby="demo-detail"></progress>
<p id="demo-detail">Finding files. Total unknown.</p>
<p id="demo-status" role="status"></p>
<div id="demo-controls">
<button type="button" data-state="known">Receive file count</button>
<button type="button" data-state="unknown">Total unavailable</button>
<button type="button" data-state="complete">Finish import</button>
<button type="button" data-state="failed">Fail import</button>
</div>
Put this script after the HTML. In an application, call the same rendering function from validated job events instead of the demo buttons.
const bar = document.querySelector('#demo-progress');
const detail = document.querySelector('#demo-detail');
const status = document.querySelector('#demo-status');
function renderProgress(state) {
const terminal = state.kind === 'complete' || state.kind === 'failed';
bar.hidden = terminal;
if (state.kind === 'known') {
if (!Number.isFinite(state.total) || state.total <= 0 ||
!Number.isFinite(state.done) || state.done < 0 ||
state.done > state.total) {
throw new Error('Invalid progress range');
}
bar.max = state.total;
bar.value = state.done;
detail.textContent = `${state.done} of ${state.total} files processed.`;
} else {
bar.removeAttribute('value');
detail.textContent = state.kind === 'complete'
? 'All 10 files imported.'
: state.kind === 'failed'
? 'Import stopped. Check the file format before retrying.'
: 'Finding files. Total unknown.';
}
status.textContent = terminal ? detail.textContent : '';
}
const demoStates = {
known: { kind: 'known', done: 3, total: 10 },
unknown: { kind: 'unknown' },
complete: { kind: 'complete' },
failed: { kind: 'failed' },
};
for (const button of document.querySelectorAll('#demo-controls button')) {
button.addEventListener('click', () => {
renderProgress(demoStates[button.dataset.state]);
});
}
The fixed completion count belongs to this ten-file fixture. Real code must derive it from the confirmed job result. Validate event kinds as well as numeric values at your API boundary, ignore stale events from superseded jobs, and keep failed or cancelled work separate from successful completion. Never convert a network failure into 100 percent just to stop an animation.
The bar is informational: do not make it a Tab stop or move focus to it on each update. Put any actual cancel or retry button alongside it. Test that cancellation affects the job and that retry does not submit duplicate work; the website form testing checklist covers those request and recovery paths.
A progress value changing is not a guarantee of a spoken announcement. WCAG's Status Messages explanation covers feedback that assistive technology can present without receiving focus. The demo uses an existing status region for terminal messages. For a longer task, choose useful milestones rather than announcing every increment; follow the aria-live announcement guide for timing, repeated messages, and manual speech verification.
Fix a custom ARIA progressbar carefully
If a custom component is necessary, keep its visible label outside the progressbar and reference that label explicitly:
<p id="export-label">Export project files</p>
<div role="progressbar" aria-labelledby="export-label"
aria-valuemin="0" aria-valuemax="10" aria-valuenow="3"
aria-valuetext="3 of 10 files exported"></div>
WAI-ARIA's progressbar role specification requires a name and defines its range properties. Keep aria-valuenow inside the declared range; omit it for indeterminate progress. Remove stale aria-valuetext at the same transition. When using value text, update it with the numeric state so the two cannot contradict each other.
The empty element above demonstrates semantics; it does not draw a bar. Connect any visual fill to the same state and keep readable progress text outside it. MDN's progressbar role reference explains that descendants are presentational in accessibility APIs. Do not put a heading or cancel button inside the bar and expect its semantics to survive.
If an audit reports aria-progressbar-name, inspect the rendered label reference rather than adding a percentage as the name. Deque's rule guidance describes accepted naming patterns. A missing label target, empty string, or duplicated ID can break the intended relationship. Use the accessible name guide to trace the actual computed name.
Test accessible progress bar states in Playwright
Serve the demo HTML and script at your preview route, then adapt this test's URL. The Playwright assertion reference documents retrying checks for names, attributes, visibility, and text.
import { expect, test } from '@playwright/test';
test('progress exposes unknown, measured, and completed states', async ({ page }) => {
await page.goto('https://preview.example.com/progress-demo');
const bar = page.getByRole('progressbar', { name: 'Import project files' });
const detail = page.locator('#demo-detail');
await expect(bar).toBeVisible();
await expect(bar).not.toHaveAttribute('value');
await expect(detail).toHaveText('Finding files. Total unknown.');
await page.getByRole('button', { name: 'Receive file count' }).click();
await expect(bar).toHaveAttribute('max', '10');
await expect(bar).toHaveAttribute('value', '3');
await expect(detail).toHaveText('3 of 10 files processed.');
await page.getByRole('button', { name: 'Total unavailable' }).click();
await expect(bar).not.toHaveAttribute('value');
await expect(detail).toHaveText('Finding files. Total unknown.');
await page.getByRole('button', { name: 'Finish import' }).click();
await expect(page.locator('#demo-progress')).toBeHidden();
await expect(page.getByRole('status')).toHaveText('All 10 files imported.');
});
test('failure does not leave an active progress indicator', async ({ page }) => {
await page.goto('https://preview.example.com/progress-demo');
const fail = page.getByRole('button', { name: 'Fail import' });
await fail.focus();
await fail.press('Enter');
await expect(fail).toBeFocused();
await expect(page.locator('#demo-progress')).toBeHidden();
await expect(page.getByRole('status')).toContainText('Import stopped.');
});
These tests protect the demonstration's state contract. Add application tests that exercise real job responses, cancellation, retry, and stale events. Keep them with your website regression tests. Run a manual screen-reader pass to check the task name, current value, and terminal message; DOM assertions cannot verify speech. Also inspect narrow layouts, zoom, and contrast themes so progress remains readable without relying solely on color or motion.
Check the surrounding public page with Slop Audit
After fixing the component, run Slop Audit on the public page to collect the implemented axe findings, sampled keyboard-focus evidence, and mobile/desktop screenshots when Browser Run completes. Use the reported rule IDs and selectors to repair observed markup, then rescan the deployed route.
Slop Audit does not drive this demo, verify a job's numeric accuracy, run a screen reader, or guarantee that it observes a short-lived progress state. Keep the targeted tests and manual evidence alongside the audit report. The useful launch record is the public URL, tested build, observed states, remaining barriers, and a confirmed recovery path.