Skip to content

docs(progress-bar): documentation updates #5553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/easy-jobs-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@spectrum-web-components/progress-bar': patch
---

**Added**: Deprecation warning for the over-background attribute.
55 changes: 41 additions & 14 deletions packages/progress-bar/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,45 @@
## Description
<sp-alert-banner open variant="info">
<div class="spectrum-InLineAlert-header">
<span>Deprecated</span>
</div>
<div class="spectrum-InLineAlert-content">
The <code>over-background</code> attribute has been deprecated and will be removed in a future release. Use <code>static-color="white"</code> instead.
</div>
</sp-alert-banner>

An `<sp-progress-bar>` shows the progression of a system operation such as downloading, uploading, processing, etc. in a visual way. It can represent determinate or indeterminate progress.
## Overview

An `<sp-progress-bar>` is used to visually show the progression of a system operation such as downloading, uploading, processing, etc. By default, progress bars have a blue fill that shows the progress.

### Usage

[![See it on NPM!](https://img.shields.io/npm/v/@spectrum-web-components/progress-bar?style=for-the-badge)](https://www.npmjs.com/package/@spectrum-web-components/progress-bar)
[![How big is this package in your project?](https://img.shields.io/bundlephobia/minzip/@spectrum-web-components/progress-bar?style=for-the-badge)](https://bundlephobia.com/result?p=@spectrum-web-components/progress-bar)
[![Try it on Stackblitz](https://img.shields.io/badge/Try%20it%20on-Stackblitz-blue?style=for-the-badge)](https://stackblitz.com/edit/vitejs-vite-evntgrmn)

```
```zsh
yarn add @spectrum-web-components/progress-bar
```

Import the side effectful registration of `<sp-progress-bar>` via:

```
```ts
import '@spectrum-web-components/progress-bar/sp-progress-bar.js';
```

When looking to leverage the `ProgressBar` base class as a type and/or for extension purposes, do so via:

```
```ts
import { ProgressBar } from '@spectrum-web-components/progress-bar';
```

### Anatomy

- **Label:** Progress bars should have a label that gives context about the operation being performed. Use an ellipsis at the end of the label text to communicate that the process is in progress.
- **Value label:** Progress bars can have a value label that gives detailed information about the progress. This value label works alongside the label and should not be displayed if the label itself is not displayed. The value label is always placed above the track.

Labels are set using the `label` slot and values are set using the `progress` slot.

## Sizes

<sp-tabs selected="m" auto label="Size Attribute Options">
Expand Down Expand Up @@ -93,25 +109,31 @@ import { ProgressBar } from '@spectrum-web-components/progress-bar';
</sp-tab-panel>
</sp-tabs>

## Variants
### Options

### Over background
#### Variants

When a progress bar needs to be placed on top of a colored background, use the over background progres bar as signified by `[over-background]`. This progress bar uses a white opaque color no matter the background. Make sure the background offers enough contrast for the loader to be legible.
<sp-tabs selected="static-white" auto label="Variants">
<sp-tab value="static-white">Static white</sp-tab>
<sp-tab-panel value="static-white">

When a progress bar needs to be placed on top of a colored background, use the static white progress bar as signified by `[static-color="white"]`. This progress bar uses a white opaque color no matter the background. Make sure the background offers enough contrast for the loader to be legible.

```html
<div
style="width: 240px; height: 160px; display: flex; flex-direction: column; align-items: center; justify-content: space-around; background-color: var(--spectrum-transparent-black-400);"
style="width: 240px; height: 160px; display: flex; flex-direction: column; align-items: center; justify-content: space-around; background-color: var(--spectrum-seafoam-900);"
>
<sp-progress-bar
label="Loaded a large amount"
progress="77"
over-background
static-color="white"
></sp-progress-bar>
</div>
```

### Indeterminate
</sp-tab-panel>
<sp-tab value="indeterminate">Indeterminate</sp-tab>
<sp-tab-panel value="indeterminate">

A progress bar can be either determinate or indeterminate as signified by `[indeterminate]`. By default, loaders are determinate. Use a determinate loader when progress can be calculated against a specific goal (e.g., downloading a file of a known size). Use an indeterminate loader when progress is happening but the time or effort to completion can’t be determined (e.g., attempting to reconnect to a server).

Expand All @@ -128,7 +150,9 @@ A progress bar can be either determinate or indeterminate as signified by `[inde

The above `sp-progress-bar` also leverages the `aria-label` attribute in place of the `label` attribute in ensure that the element is labelled correctly without that label appearing visibly in the UI.

### Side Label
</sp-tab-panel>
<sp-tab value="side-label">Side label</sp-tab>
<sp-tab-panel value="side-label">

A progress bar can be delivered with its labeling displayed above its visual indicator or to either side. Use the boolean `[side-label]` attribute to define where this content should appear.

Expand All @@ -138,12 +162,15 @@ A progress bar can be delivered with its labeling displayed above its visual ind
>
<sp-progress-bar
side-label
indeterminate
label="Label Beside"
progress="23"
></sp-progress-bar>
</div>
```

## Accessibility
</sp-tab-panel>
</sp-tabs>

### Accessibility

An `sp-progress-bar` element will register itself as a `role="progressbar"` element in the accessibility tree. Any value applied to the `label` attribute will be used both to visibly label the element and to set the `aria-label` attribute on the host. In cases where a visible label is not desired, be sure to include an `aria-label` attribute manually to ensure that the `sp-progress-bar` correctly fulfills its responsibilities to visitors of you site of all abilities.
11 changes: 10 additions & 1 deletion packages/progress-bar/src/ProgressBar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020 Adobe. All rights reserved.
Copyright 2025 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Expand Down Expand Up @@ -146,6 +146,15 @@ export class ProgressBar extends SizedMixin(
}

if (window.__swc.DEBUG) {
if (changes.has('over-background')) {
window.__swc.warn(
this,
`The "over-background" attribute on <${this.localName}> has been deprecated and will be removed in a future release. Use "static-color='white'" instead.`,
'https://opensource.adobe.com/spectrum-web-components/components/progress-bar/#variants',
{ level: 'deprecation' }
);
}

if (
!this.label &&
!this.getAttribute('aria-label') &&
Expand Down
Loading