Progress

Struct Progress 

Source
pub struct Progress;
Expand description

The <progress> element - represents the completion progress of a task.

§Purpose

The <progress> element displays the progress of a task, such as a file upload, download, or form completion. Shows a progress bar indicating how much of the task has been completed. Can represent both determinate (known total) and indeterminate (unknown total) progress.

§Content Categories

  • Flow Content
  • Phrasing Content
  • Palpable Content

§Permitted Content Model

  • Phrasing content (fallback for browsers without progress support, but no <progress> descendants)

§Common Use Cases

  • File upload progress indicators
  • Download progress displays
  • Form completion tracking
  • Multi-step process progress
  • Loading indicators with known duration

§Key Attributes

  • value: Current progress value
  • max: Maximum value (total amount of work, default: 1.0)

§Example

<!-- Basic progress bar -->
<label for="file-progress">Uploading file:</label>
<progress id="file-progress" value="70" max="100">70%</progress>

<!-- Progress with percentage label -->
<p>
  Installation progress:
  <progress value="0.6" max="1.0">60%</progress>
  60%
</p>

<!-- Indeterminate progress (no value attribute) -->
<p>
  Loading...
  <progress max="100">Loading...</progress>
</p>

<!-- Progress updated via JavaScript -->
<progress id="dynamic-progress" value="0" max="100"></progress>
<script>
  let progress = 0;
  setInterval(() => {
    progress = Math.min(progress + 10, 100);
    document.getElementById('dynamic-progress').value = progress;
  }, 500);
</script>

<!-- Download progress -->
<p>
  Downloading: <span id="filename">document.pdf</span>
  <progress id="download" value="2.5" max="10">2.5 MB of 10 MB</progress>
  <span id="progress-text">2.5 MB of 10 MB</span>
</p>

<!-- Form completion indicator -->
<form>
  <p>Form completion: <progress value="3" max="5">Step 3 of 5</progress></p>
  <!-- Form fields here -->
</form>

<!-- Styled progress bar -->
<progress value="75" max="100" style="width: 300px; height: 30px;">
  75% complete
</progress>

§Accessibility

  • Provide text content as fallback for older browsers
  • Use aria-label or nearby text to describe what’s progressing
  • Update aria-valuenow, aria-valuemin, aria-valuemax for complex cases
  • Announce progress updates to screen readers with aria-live regions
  • Ensure progress bar has sufficient color contrast

§WHATWG Specification

Trait Implementations§

Source§

impl HtmlElement for Progress

Source§

const TAG: &'static str = "progress"

The HTML tag name (e.g., “div”, “span”, “img”).
Source§

const VOID: bool = false

Whether this is a void element (self-closing, no children allowed).
Source§

impl<T: PhrasingContent> CanContain<T> for Progress

Source§

impl FlowContent for Progress

Source§

impl PalpableContent for Progress

Source§

impl PhrasingContent for Progress

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.