Skip to content

Segmented Progress Bar

Dark Bootstrap 5 stacked progress bar split into colored segments, with tooltips, percentages and a legend that highlights each part.

Also known as: multi segment progress bar, stacked progress bar, progress bar with legend, segmented bar chart, storage usage bar

Segmented Progress Bar live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

A dark Bootstrap 5 segmented progress bar that splits one bar into colored parts for several values, with an interactive legend. Typical uses are storage usage meters, sprint or task status overviews, budget breakdowns and quota displays in dashboards.

How it works

Each .sp-card contains a Bootstrap .progress-stacked bar (.sp-bar) and a legend (.sp-legend). Every segment is a .progress element with role="progressbar", an aria-label, a data-sp-key and a data-sp-value. The card's data-sp-total sets what 100% means and data-sp-unit the unit shown in texts.

On DOMContentLoaded the script reads each value, calculates its percentage of the total and sets aria-valuenow, aria-valuemax and a readable aria-valuetext. It fills the matching legend .sp-pct with the percentage, writes the summed value into .sp-used and the remaining share into .sp-pct--rest. Then it adds .sp-ready and grows every segment from 0 to its width with a CSS transition. A Bootstrap tooltip on each segment shows the label, value and percentage on hover.

Legend entries are buttons. Hovering or focusing one adds .sp-card--focus to the card, which fades every segment except the matching .is-active one. Clicking a legend button pins that highlight and sets aria-pressed="true"; clicking it again releases it. The second card uses .sp-bar--gapped, which adds gaps, padding and rounded segments for a block-style look.

Customization

  • data-sp-total and data-sp-unit on .sp-card: set the maximum and the unit, for example 100 and %.
  • data-sp-value on each .progress: change a segment's size; percentages and ARIA values are recalculated.
  • --sp-c1 to --sp-c5 on .sp-section: change the segment colors used by the .sp-c1 to .sp-c5 classes.
  • --sp-height on .sp-section or .sp-bar--gapped: makes the bar thinner or taller.
  • Add or remove .sp-bar--gapped on .sp-bar: switch between a continuous bar and separated blocks.
  • progress-bar-striped on a .progress-bar: marks a segment as in progress with diagonal stripes.
  • --sp-card and --sp-track on .sp-section: recolor the cards and the unused part of the bar.

Use cases

  • Storage dashboards: one bar splits usage into colored segments for files, photos and other data
  • Budget and analytics pages: tooltips and percentages explain each part of a total
  • Admin panels: a legend highlights the matching segment on hover
  • Reports: stacked segments show how a whole breaks down in a small space

Accessibility

Each segment is a separate role="progressbar" with its own label and an aria-valuetext such as "Photos: 92 GB (35.9%)". Legend buttons are keyboard focusable, show a visible outline and report their pinned state with aria-pressed. Color is never the only cue because each legend entry repeats the name, value and percentage in text. The width transition and stripe animation are disabled for prefers-reduced-motion.

Usage notes

Requires Bootstrap 5.3 (for .progress-stacked, added automatically) and Bootstrap Icons. Without JavaScript the segments share the bar equally, so keep the script enabled. Several cards work independently on one page.

Segmented Progress Bar at a glance

Framework
Bootstrap 5
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Bootstrap 5, Bootstrap Icons
Layout
Responsive, works on mobile, dark design
Category
Progress Bars
License
Free for personal and commercial use

Questions about this template

Can I use the Segmented Progress Bar code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Bootstrap 5 and Bootstrap Icons from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
  • <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
Segmented Progress Bar – free Bootstrap 5 progress bar template
Segmented Progress Bar · free Bootstrap 5 progress bar template

More Progress Bars

Upload Progress List – free Tailwind CSS progress bar template

Upload Progress List

Dark Tailwind CSS upload list with per-file progress bars, speed and time left, pause, resume, retry and remove actions, a queue and total progress.

Circular Progress Indicator – free Pure CSS progress bar template

Circular Progress Indicator

SVG ring progress indicators with an animated fill, count-up percentage, glow colors and a slider-driven demo ring with color thresholds.

Animated Progress Bars – free Bootstrap 5 progress bar template

Animated Progress Bars

Bootstrap 5 dark dashboard with labelled bars that fill on scroll, a striped animated build progress bar and a stacked storage bar.

Skill Progress Bars – free Tailwind CSS progress bar template

Skill Progress Bars

Animated Tailwind CSS skill bars for resumes and portfolios that fill and count up when scrolled into view, with grouped skills and a profile panel.