progress.md 5.08 KB
Newer Older
Mark Otto's avatar
Mark Otto committed
1
---
Mark Otto's avatar
Mark Otto committed
2
layout: docs
Mark Otto's avatar
Mark Otto committed
3
title: Progress
4
group: components
Mark Otto's avatar
Mark Otto committed
5
6
---

Chris Rebert's avatar
Chris Rebert committed
7
Stylize [the HTML5 `<progress>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/progress) with a few extra classes and some crafty browser-specific CSS. Be sure to read up on the browser support.
Mark Otto's avatar
Mark Otto committed
8

Mark Otto's avatar
Mark Otto committed
9
10
11
12
13
## Contents

* Will be replaced with the ToC, excluding the "Contents" header
{:toc}

Mark Otto's avatar
Mark Otto committed
14
15
16
### Example

{% example html %}
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

<div class="text-xs-center" id="example-caption-1">Reticulating splines&hellip; 0%</div>
<progress class="progress" value="0" max="100" aria-describedby="example-caption-1"></progress>

<div class="text-xs-center" id="example-caption-2">Reticulating splines&hellip; 25%</div>
<progress class="progress" value="25" max="100" aria-describedby="example-caption-2"></progress>

<div class="text-xs-center" id="example-caption-3">Reticulating splines&hellip; 50%</div>
<progress class="progress" value="50" max="100" aria-describedby="example-caption-3"></progress>

<div class="text-xs-center" id="example-caption-4">Reticulating splines&hellip; 75%</div>
<progress class="progress" value="75" max="100" aria-describedby="example-caption-4"></progress>

<div class="text-xs-center" id="example-caption-5">Reticulating splines&hellip; 100%</div>
<progress class="progress" value="100" max="100" aria-describedby="example-caption-5"></progress>
Mark Otto's avatar
Mark Otto committed
32
33
34
35
36
37
38
{% endexample %}

### IE9 support

Internet Explorer 9 doesn't support the HTML5 `<progress>` element, but we can work around that.

{% example html %}
39
40
<div class="text-xs-center" id="example-caption-6">Reticulating splines&hellip; 25%</div>
<progress class="progress" value="25" max="100" aria-describedby="example-caption-6">
Mark Otto's avatar
Mark Otto committed
41
  <div class="progress">
42
    <span class="progress-bar" style="width: 25%;"></span>
Mark Otto's avatar
Mark Otto committed
43
44
45
46
47
48
49
50
51
  </div>
</progress>
{% endexample %}

### Contextual alternatives

Progress bars use some of the same button and alert classes for consistent styles.

{% example html %}
52
53
54
55
56
57
58
59
60
61
62
<div class="text-xs-center" id="example-caption-7">Reticulating successful splines&hellip; 25%</div>
<progress class="progress progress-success" value="25" max="100" aria-describedby="example-caption-7"></progress>

<div class="text-xs-center" id="example-caption-8">Reticulating informative splines&hellip; 50%</div>
<progress class="progress progress-info" value="50" max="100" aria-describedby="example-caption-8"></progress>

<div class="text-xs-center" id="example-caption-9">Reticulating warning splines&hellip; 75%</div>
<progress class="progress progress-warning" value="75" max="100" aria-describedby="example-caption-9"></progress>

<div class="text-xs-center" id="example-caption-10">Reticulating dangerous splines&hellip; 100%</div>
<progress class="progress progress-danger" value="100" max="100" aria-describedby="example-caption-10"></progress>
Mark Otto's avatar
Mark Otto committed
63
64
65
66
67
68
69
{% endexample %}

### Striped

Uses a gradient to create a striped effect.

{% example html %}
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<div class="text-xs-center" id="example-caption-11">Reticulating plain splines&hellip; 10%</div>
<progress class="progress progress-striped" value="10" max="100" aria-describedby="example-caption-11">10%</progress>

<div class="text-xs-center" id="example-caption-12">Reticulating successful splines&hellip; 25%</div>
<progress class="progress progress-striped progress-success" value="25" max="100" aria-describedby="example-caption-12">25%</progress>

<div class="text-xs-center" id="example-caption-13">Reticulating informative splines&hellip; 50%</div>
<progress class="progress progress-striped progress-info" value="50" max="100" aria-describedby="example-caption-13">50%</progress>

<div class="text-xs-center" id="example-caption-14">Reticulating warning splines&hellip; 75%</div>
<progress class="progress progress-striped progress-warning" value="75" max="100" aria-describedby="example-caption-14">75%</progress>

<div class="text-xs-center" id="example-caption-15">Reticulating dangerous splines&hellip; 100%</div>
<progress class="progress progress-striped progress-danger" value="100" max="100" aria-describedby="example-caption-15">100%</progress>
Mark Otto's avatar
Mark Otto committed
84
85
{% endexample %}

Mark Otto's avatar
Mark Otto committed
86
87
88
### Animated stripes

The striped gradient can also be animated. Add `.progress-animated` to `.progress` to animate the stripes right to left via CSS3 animations.
Mark Otto's avatar
Mark Otto committed
89

90
**Animated progress bars do not work in IE9 and Opera 12** – as they don't support CSS3 animations – **nor in IE10+ and Microsoft Edge** – as they currently don't support CSS3 animations on the [`::-ms-fill` pseudo-element](https://msdn.microsoft.com/en-us/library/windows/apps/hh465757.aspx).
Mark Otto's avatar
Mark Otto committed
91

92
<div class="bd-example">
93
94
  <div class="text-xs-center" id="example-caption-16">Reticulating splines&hellip; 25%</div>
  <progress class="progress progress-striped" value="25" max="100" aria-describedby="example-caption-16">25%</progress>
95
  <button type="button" class="btn btn-secondary bd-activate-animated-progressbar" data-toggle="button" aria-pressed="false" autocomplete="off">
Mark Otto's avatar
Mark Otto committed
96
97
98
99
100
    Toggle animation
  </button>
</div>

{% highlight html %}
101
102
<div class="text-xs-center" id="example-caption-16">Reticulating splines&hellip; 25%</div>
<progress class="progress progress-striped progress-animated" value="25" max="100" aria-describedby="example-caption-16">25%</progress>
Mark Otto's avatar
Mark Otto committed
103
{% endhighlight %}