1 |
efrain |
1 |
---
|
|
|
2 |
layout: docs
|
|
|
3 |
title: Progress
|
|
|
4 |
description: Documentation and examples for using Bootstrap custom progress bars featuring support for stacked bars, animated backgrounds, and text labels.
|
|
|
5 |
group: components
|
|
|
6 |
toc: true
|
|
|
7 |
---
|
|
|
8 |
|
|
|
9 |
## How it works
|
|
|
10 |
|
|
|
11 |
Progress components are built with two HTML elements, some CSS to set the width, and a few attributes. We don't use [the HTML5 `<progress>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/progress), ensuring you can stack progress bars, animate them, and place text labels over them.
|
|
|
12 |
|
|
|
13 |
- We use the `.progress` as a wrapper to indicate the max value of the progress bar.
|
|
|
14 |
- We use the inner `.progress-bar` to indicate the progress so far.
|
|
|
15 |
- The `.progress-bar` requires an inline style, utility class, or custom CSS to set their width.
|
|
|
16 |
- The `.progress-bar` also requires some `role` and `aria` attributes to make it accessible.
|
|
|
17 |
|
|
|
18 |
Put that all together, and you have the following examples.
|
|
|
19 |
|
|
|
20 |
{{< example >}}
|
|
|
21 |
<div class="progress">
|
|
|
22 |
<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
23 |
</div>
|
|
|
24 |
<div class="progress">
|
|
|
25 |
<div class="progress-bar" role="progressbar" style="width: 25%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
26 |
</div>
|
|
|
27 |
<div class="progress">
|
|
|
28 |
<div class="progress-bar" role="progressbar" style="width: 50%" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
29 |
</div>
|
|
|
30 |
<div class="progress">
|
|
|
31 |
<div class="progress-bar" role="progressbar" style="width: 75%" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
32 |
</div>
|
|
|
33 |
<div class="progress">
|
|
|
34 |
<div class="progress-bar" role="progressbar" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
35 |
</div>
|
|
|
36 |
{{< /example >}}
|
|
|
37 |
|
|
|
38 |
Bootstrap provides a handful of [utilities for setting width]({{< docsref "/utilities/sizing" >}}). Depending on your needs, these may help with quickly configuring progress.
|
|
|
39 |
|
|
|
40 |
{{< example >}}
|
|
|
41 |
<div class="progress">
|
|
|
42 |
<div class="progress-bar w-75" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
43 |
</div>
|
|
|
44 |
{{< /example >}}
|
|
|
45 |
|
|
|
46 |
## Labels
|
|
|
47 |
|
|
|
48 |
Add labels to your progress bars by placing text within the `.progress-bar`.
|
|
|
49 |
|
|
|
50 |
{{< example >}}
|
|
|
51 |
<div class="progress">
|
|
|
52 |
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">25%</div>
|
|
|
53 |
</div>
|
|
|
54 |
{{< /example >}}
|
|
|
55 |
|
|
|
56 |
## Height
|
|
|
57 |
|
|
|
58 |
We only set a `height` value on the `.progress`, so if you change that value the inner `.progress-bar` will automatically resize accordingly.
|
|
|
59 |
|
|
|
60 |
{{< example >}}
|
|
|
61 |
<div class="progress" style="height: 1px;">
|
|
|
62 |
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
63 |
</div>
|
|
|
64 |
<div class="progress" style="height: 20px;">
|
|
|
65 |
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
66 |
</div>
|
|
|
67 |
{{< /example >}}
|
|
|
68 |
|
|
|
69 |
## Backgrounds
|
|
|
70 |
|
|
|
71 |
Use background utility classes to change the appearance of individual progress bars.
|
|
|
72 |
|
|
|
73 |
{{< example >}}
|
|
|
74 |
<div class="progress">
|
|
|
75 |
<div class="progress-bar bg-success" role="progressbar" style="width: 25%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
76 |
</div>
|
|
|
77 |
<div class="progress">
|
|
|
78 |
<div class="progress-bar bg-info" role="progressbar" style="width: 50%" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
79 |
</div>
|
|
|
80 |
<div class="progress">
|
|
|
81 |
<div class="progress-bar bg-warning" role="progressbar" style="width: 75%" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
82 |
</div>
|
|
|
83 |
<div class="progress">
|
|
|
84 |
<div class="progress-bar bg-danger" role="progressbar" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
85 |
</div>
|
|
|
86 |
{{< /example >}}
|
|
|
87 |
|
|
|
88 |
## Multiple bars
|
|
|
89 |
|
|
|
90 |
Include multiple progress bars in a progress component if you need.
|
|
|
91 |
|
|
|
92 |
{{< example >}}
|
|
|
93 |
<div class="progress">
|
|
|
94 |
<div class="progress-bar" role="progressbar" style="width: 15%" aria-valuenow="15" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
95 |
<div class="progress-bar bg-success" role="progressbar" style="width: 30%" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
96 |
<div class="progress-bar bg-info" role="progressbar" style="width: 20%" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
97 |
</div>
|
|
|
98 |
{{< /example >}}
|
|
|
99 |
|
|
|
100 |
## Striped
|
|
|
101 |
|
|
|
102 |
Add `.progress-bar-striped` to any `.progress-bar` to apply a stripe via CSS gradient over the progress bar's background color.
|
|
|
103 |
|
|
|
104 |
{{< example >}}
|
|
|
105 |
<div class="progress">
|
|
|
106 |
<div class="progress-bar progress-bar-striped" role="progressbar" style="width: 10%" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
107 |
</div>
|
|
|
108 |
<div class="progress">
|
|
|
109 |
<div class="progress-bar progress-bar-striped bg-success" role="progressbar" style="width: 25%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
110 |
</div>
|
|
|
111 |
<div class="progress">
|
|
|
112 |
<div class="progress-bar progress-bar-striped bg-info" role="progressbar" style="width: 50%" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
113 |
</div>
|
|
|
114 |
<div class="progress">
|
|
|
115 |
<div class="progress-bar progress-bar-striped bg-warning" role="progressbar" style="width: 75%" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
116 |
</div>
|
|
|
117 |
<div class="progress">
|
|
|
118 |
<div class="progress-bar progress-bar-striped bg-danger" role="progressbar" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
|
|
|
119 |
</div>
|
|
|
120 |
{{< /example >}}
|
|
|
121 |
|
|
|
122 |
## Animated stripes
|
|
|
123 |
|
|
|
124 |
The striped gradient can also be animated. Add `.progress-bar-animated` to `.progress-bar` to animate the stripes right to left via CSS3 animations.
|
|
|
125 |
|
|
|
126 |
<div class="bd-example">
|
|
|
127 |
<div class="progress">
|
|
|
128 |
<div class="progress-bar progress-bar-striped" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 75%"></div>
|
|
|
129 |
</div>
|
|
|
130 |
<button type="button" class="btn btn-secondary bd-toggle-animated-progress" data-toggle="button" aria-pressed="false">
|
|
|
131 |
Toggle animation
|
|
|
132 |
</button>
|
|
|
133 |
</div>
|
|
|
134 |
|
|
|
135 |
```html
|
|
|
136 |
<div class="progress">
|
|
|
137 |
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 75%"></div>
|
|
|
138 |
</div>
|
|
|
139 |
```
|