@@ -10,14 +10,16 @@ toc: true
10
10
11
11
Bootstrap "spinners" can be used to show the loading state in your projects. They're built only with HTML and CSS, meaning you don't need any JavaScript to create them. You will, however, need some custom JavaScript to toggle their visibility. Their appearance, alignment, and sizing can be easily customized with our amazing utility classes.
12
12
13
- For accessibility purposes, each loader here includes ` role="status" ` and ` Loading... ` text within. We account for this in our CSS, using a text hiding technique to prevent it from rendering on screen .
13
+ For accessibility purposes, each loader here includes ` role="status" ` and a nested ` <span class="sr-only"> Loading...</span> ` .
14
14
15
15
## Border spinner
16
16
17
17
Use the border spinners for a lightweight loading indicator.
18
18
19
19
{% capture example %}
20
- <div class =" spinner-border " role =" status " >Loading...</div >
20
+ <div class =" spinner-border " role =" status " >
21
+ <span class =" sr-only " >Loading...</span >
22
+ </div >
21
23
{% endcapture %}
22
24
{% include example.html content=example %}
23
25
@@ -27,7 +29,9 @@ The border spinner uses `currentColor` for its `border-color`, meaning you can c
27
29
28
30
{% capture example %}
29
31
{% for color in site.data.theme-colors %}
30
- <div class =" spinner-border text-{{ color.name }} " role =" status " >Loading...</div >{% endfor %}
32
+ <div class =" spinner-border text-{{ color.name }} " role =" status " >
33
+ <span class =" sr-only " >Loading...</span >
34
+ </div >{% endfor %}
31
35
{% endcapture %}
32
36
{% include example.html content=example %}
33
37
@@ -41,15 +45,19 @@ The border spinner uses `currentColor` for its `border-color`, meaning you can c
41
45
If you don't fancy a border spinner, switch to the grow spinner. While it doesn't technically spin, it does repeatedly grow!
42
46
43
47
{% capture example %}
44
- <div class =" spinner-grow " role =" status " >Loading...</div >
48
+ <div class =" spinner-grow " role =" status " >
49
+ <span class =" sr-only " >Loading...</span >
50
+ </div >
45
51
{% endcapture %}
46
52
{% include example.html content=example %}
47
53
48
54
Once again, this spinner is built with ` currentColor ` , so you can easily change its appearance with [ text color utilities] [ color ] . Here it is in blue, along with the supported variants.
49
55
50
56
{% capture example %}
51
57
{% for color in site.data.theme-colors %}
52
- <div class =" spinner-grow text-{{ color.name }} " role =" status " >Loading...</div >{% endfor %}
58
+ <div class =" spinner-grow text-{{ color.name }} " role =" status " >
59
+ <span class =" sr-only " >Loading...</span >
60
+ </div >{% endfor %}
53
61
{% endcapture %}
54
62
{% include example.html content=example %}
55
63
@@ -62,7 +70,9 @@ Spinners in Bootstrap are built with `rem`s, `currentColor`, and `display: inlin
62
70
Use [ margin utilities] [ margin ] like ` .m-5 ` for easy spacing.
63
71
64
72
{% capture example %}
65
- <div class =" spinner-border m-5 " role =" status " >Loading...</div >
73
+ <div class =" spinner-border m-5 " role =" status " >
74
+ <span class =" sr-only " >Loading...</span >
75
+ </div >
66
76
{% endcapture %}
67
77
{% include example.html content=example %}
68
78
@@ -74,15 +84,17 @@ Use [flexbox utilities][flex], [float utilities][float], or [text alignment][tex
74
84
75
85
{% capture example %}
76
86
<div class =" d-flex justify-content-center " >
77
- <div class =" spinner-border " role =" status " >Loading...</div >
87
+ <div class =" spinner-border " role =" status " >
88
+ <span class="sr-only">Loading...</span>
89
+ </div >
78
90
</div >
79
91
{% endcapture %}
80
92
{% include example.html content=example %}
81
93
82
94
{% capture example %}
83
95
<div class =" d-flex align-items-center " >
84
96
<strong >Loading...</strong >
85
- <div class =" spinner-border ml-auto " role =" status " ></div >
97
+ <div class =" spinner-border ml-auto " role =" status " aria-hidden = " true " ></div >
86
98
</div >
87
99
{% endcapture %}
88
100
{% include example.html content=example %}
@@ -91,7 +103,9 @@ Use [flexbox utilities][flex], [float utilities][float], or [text alignment][tex
91
103
92
104
{% capture example %}
93
105
<div class =" clearfix " >
94
- <div class =" spinner-border float-right " role =" status " >Loading...</div >
106
+ <div class =" spinner-border float-right " role =" status " >
107
+ <span class="sr-only">Loading...</span>
108
+ </div >
95
109
</div >
96
110
{% endcapture %}
97
111
{% include example.html content=example %}
@@ -100,7 +114,9 @@ Use [flexbox utilities][flex], [float utilities][float], or [text alignment][tex
100
114
101
115
{% capture example %}
102
116
<div class =" text-center " >
103
- <div class =" spinner-border " role =" status " >Loading...</div >
117
+ <div class =" spinner-border " role =" status " >
118
+ <span class="sr-only">Loading...</span>
119
+ </div >
104
120
</div >
105
121
{% endcapture %}
106
122
{% include example.html content=example %}
@@ -110,16 +126,24 @@ Use [flexbox utilities][flex], [float utilities][float], or [text alignment][tex
110
126
Add ` .spinner-border-sm ` and ` .spinner-grow-sm ` to make a smaller spinner that can quickly be used within other components.
111
127
112
128
{% capture example %}
113
- <div class =" spinner-border spinner-border-sm " role =" status " >Loading...</div >
114
- <div class =" spinner-grow spinner-grow-sm " role =" status " >Loading...</div >
129
+ <div class =" spinner-border spinner-border-sm " role =" status " >
130
+ <span class =" sr-only " >Loading...</span >
131
+ </div >
132
+ <div class =" spinner-grow spinner-grow-sm " role =" status " >
133
+ <span class =" sr-only " >Loading...</span >
134
+ </div >
115
135
{% endcapture %}
116
136
{% include example.html content=example %}
117
137
118
138
Or, use custom CSS or inline styles to change the dimensions as needed.
119
139
120
140
{% capture example %}
121
- <div class =" spinner-border " style =" width : 3rem ; height : 3rem ;" role =" status " >Loading...</div >
122
- <div class =" spinner-grow " style =" width : 3rem ; height : 3rem ;" role =" status " >Loading...</div >
141
+ <div class =" spinner-border " style =" width : 3rem ; height : 3rem ;" role =" status " >
142
+ <span class =" sr-only " >Loading...</span >
143
+ </div >
144
+ <div class =" spinner-grow " style =" width : 3rem ; height : 3rem ;" role =" status " >
145
+ <span class =" sr-only " >Loading...</span >
146
+ </div >
123
147
{% endcapture %}
124
148
{% include example.html content=example %}
125
149
@@ -129,21 +153,23 @@ Use spinners within buttons to indicate an action is currently processing or tak
129
153
130
154
{% capture example %}
131
155
<button class =" btn btn-primary " type =" button " disabled >
132
- <span class =" spinner-border spinner-border-sm " role =" status " >Loading...</span >
156
+ <span class =" spinner-border spinner-border-sm " role =" status " aria-hidden =" true " ></span >
157
+ <span class =" sr-only " >Loading...</span >
133
158
</button >
134
159
<button class =" btn btn-primary " type =" button " disabled >
135
- <span class =" spinner-border spinner-border-sm " role =" status " ></span >
160
+ <span class =" spinner-border spinner-border-sm " role =" status " aria-hidden = " true " ></span >
136
161
Loading...
137
162
</button >
138
163
{% endcapture %}
139
164
{% include example.html content=example %}
140
165
141
166
{% capture example %}
142
167
<button class =" btn btn-primary " type =" button " disabled >
143
- <span class =" spinner-grow spinner-grow-sm " role =" status " >Loading...</span >
168
+ <span class =" spinner-grow spinner-grow-sm " role =" status " aria-hidden =" true " ></span >
169
+ <span class =" sr-only " >Loading...</span >
144
170
</button >
145
171
<button class =" btn btn-primary " type =" button " disabled >
146
- <span class =" spinner-grow spinner-grow-sm " role =" status " ></span >
172
+ <span class =" spinner-grow spinner-grow-sm " role =" status " aria-hidden = " true " ></span >
147
173
Loading...
148
174
</button >
149
175
{% endcapture %}
0 commit comments