Skip to content

Progress ​

Shows how far a task has got, on the native progress element, with an optional label and value.

Installation ​

bash
npx bootcn add progress
bash
pnpm dlx bootcn add progress
bash
yarn dlx bootcn add progress
bash
bunx --bun bootcn add progress

The CLI also installs the design tokens and these components: none. It prints the <link> and <script> tags to add to your layout.

Usage ​

It is the native <progress> element: set value (and max, default 1) from your script. Leave value out for work of unknown length; the bar then slides. Name each bar with a <label for> or aria-label.

Accessibility ​

  • Native <progress>: screen readers announce the percentage, or "busy" when indeterminate.
  • The visible percentage next to the label is hidden from screen readers, so it is not read twice.

Dependencies ​

  • Bootstrap 5.3+ CSS.
  • themes/tokens/tokens.css.

Source ​

The exact files the CLI installs (progress@1.0.0). View on GitHub · Report an issue

html
<div class="bootcn-progress-label">
  <label for="bootcn-progress-upload">Uploading report.pdf</label>
  <span aria-hidden="true">60%</span>
</div>
<progress class="bootcn-progress" id="bootcn-progress-upload" max="100" value="60">60%</progress>

<progress class="bootcn-progress mt-4" aria-label="Profile completeness" max="100" value="25">
  25%
</progress>

<div class="bootcn-progress-label mt-4">
  <label for="bootcn-progress-sync">Syncing contacts</label>
</div>
<progress
  class="bootcn-progress"
  id="bootcn-progress-sync"
  aria-describedby="bootcn-progress-sync-help"
></progress>
<p class="bootcn-progress-help" id="bootcn-progress-sync-help">This can take a minute.</p>
css
.bootcn-progress {
  --bootcn-progress-height: 0.5rem;

  display: block;
  width: 100%;
  max-width: 28rem;
  height: var(--bootcn-progress-height);
  overflow: hidden;
  border: 0;
  border-radius: 9999px;
  background-color: var(--bootcn-muted);
  color: var(--bootcn-primary);
  appearance: none;
}

.bootcn-progress::-webkit-progress-bar {
  border-radius: 9999px;
  background-color: var(--bootcn-muted);
}

.bootcn-progress::-webkit-progress-value {
  border-radius: 9999px;
  background-color: var(--bootcn-primary);
  transition: width var(--bootcn-transition);
}

.bootcn-progress::-moz-progress-bar {
  border-radius: 9999px;
  background-color: var(--bootcn-primary);
}

/* No value: indeterminate. A sliding bar, still under reduced motion. */
.bootcn-progress:indeterminate {
  background-image: linear-gradient(
    to right,
    var(--bootcn-muted) 0%,
    var(--bootcn-primary) 50%,
    var(--bootcn-muted) 100%
  );
  background-size: 50% 100%;
  background-repeat: no-repeat;
  animation: bootcn-progress-slide 1.4s ease-in-out infinite;
}

.bootcn-progress:indeterminate::-webkit-progress-bar {
  background-color: transparent;
}

.bootcn-progress:indeterminate::-moz-progress-bar {
  background-color: transparent;
}

@keyframes bootcn-progress-slide {
  from {
    background-position: -100% 0;
  }

  to {
    background-position: 200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bootcn-progress:indeterminate {
    background-position: 50% 0;
    animation: none;
  }
}

.bootcn-progress-label {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  max-width: 28rem;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.bootcn-progress-label label {
  margin: 0;
}

.bootcn-progress-help {
  margin: 0.5rem 0 0;
  color: var(--bootcn-muted-foreground);
  font-size: 0.875rem;
}

Released under the MIT License. Not affiliated with Bootstrap or shadcn/ui.