Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
---
2
layout: docs
3
title: Spinners
4
description: Indicate the loading state of a component or page with Bootstrap spinners, built entirely with HTML, CSS, and no JavaScript.
5
group: components
6
toc: true
7
---
8
 
9
## About
10
 
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
 
13
For accessibility purposes, each loader here includes `role="status"` and a nested `<span class="sr-only">Loading...</span>`.
14
 
15
{{< callout info >}}
16
{{< partial "callout-info-prefersreducedmotion.md" >}}
17
{{< /callout >}}
18
 
19
## Border spinner
20
 
21
Use the border spinners for a lightweight loading indicator.
22
 
23
{{< example >}}
24
<div class="spinner-border" role="status">
25
  <span class="sr-only">Loading...</span>
26
</div>
27
{{< /example >}}
28
 
29
### Colors
30
 
31
The border spinner uses `currentColor` for its `border-color`, meaning you can customize the color with [text color utilities][color]. You can use any of our text color utilities on the standard spinner.
32
 
33
{{< example >}}
34
{{< spinner.inline >}}
35
{{- range (index $.Site.Data "theme-colors") }}
36
<div class="spinner-border text-{{ .name }}" role="status">
37
  <span class="sr-only">Loading...</span>
38
</div>
39
{{- end -}}
40
{{< /spinner.inline >}}
41
{{< /example >}}
42
 
43
{{< callout info >}}
44
**Why not use `border-color` utilities?** Each border spinner specifies a `transparent` border for at least one side, so `.border-{color}` utilities would override that.
45
{{< /callout >}}
46
 
47
## Growing spinner
48
 
49
If you don't fancy a border spinner, switch to the grow spinner. While it doesn't technically spin, it does repeatedly grow!
50
 
51
{{< example >}}
52
<div class="spinner-grow" role="status">
53
  <span class="sr-only">Loading...</span>
54
</div>
55
{{< /example >}}
56
 
57
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.
58
 
59
{{< example >}}
60
{{< spinner.inline >}}
61
{{- range (index $.Site.Data "theme-colors") }}
62
<div class="spinner-grow text-{{ .name }}" role="status">
63
  <span class="sr-only">Loading...</span>
64
</div>
65
{{- end -}}
66
{{< /spinner.inline >}}
67
{{< /example >}}
68
 
69
## Alignment
70
 
71
Spinners in Bootstrap are built with `rem`s, `currentColor`, and `display: inline-flex`. This means they can easily be resized, recolored, and quickly aligned.
72
 
73
### Margin
74
 
75
Use [margin utilities][margin] like `.m-5` for easy spacing.
76
 
77
{{< example >}}
78
<div class="spinner-border m-5" role="status">
79
  <span class="sr-only">Loading...</span>
80
</div>
81
{{< /example >}}
82
 
83
### Placement
84
 
85
Use [flexbox utilities][flex], [float utilities][float], or [text alignment][text] utilities to place spinners exactly where you need them in any situation.
86
 
87
#### Flex
88
 
89
{{< example >}}
90
<div class="d-flex justify-content-center">
91
  <div class="spinner-border" role="status">
92
    <span class="sr-only">Loading...</span>
93
  </div>
94
</div>
95
{{< /example >}}
96
 
97
{{< example >}}
98
<div class="d-flex align-items-center">
99
  <strong>Loading...</strong>
100
  <div class="spinner-border ml-auto" role="status" aria-hidden="true"></div>
101
</div>
102
{{< /example >}}
103
 
104
#### Floats
105
 
106
{{< example >}}
107
<div class="clearfix">
108
  <div class="spinner-border float-right" role="status">
109
    <span class="sr-only">Loading...</span>
110
  </div>
111
</div>
112
{{< /example >}}
113
 
114
#### Text align
115
 
116
{{< example >}}
117
<div class="text-center">
118
  <div class="spinner-border" role="status">
119
    <span class="sr-only">Loading...</span>
120
  </div>
121
</div>
122
{{< /example >}}
123
 
124
## Size
125
 
126
Add `.spinner-border-sm` and `.spinner-grow-sm` to make a smaller spinner that can quickly be used within other components.
127
 
128
{{< example >}}
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>
135
{{< /example >}}
136
 
137
Or, use custom CSS or inline styles to change the dimensions as needed.
138
 
139
{{< example >}}
140
<div class="spinner-border" style="width: 3rem; height: 3rem;" role="status">
141
  <span class="sr-only">Loading...</span>
142
</div>
143
<div class="spinner-grow" style="width: 3rem; height: 3rem;" role="status">
144
  <span class="sr-only">Loading...</span>
145
</div>
146
{{< /example >}}
147
 
148
## Buttons
149
 
150
Use spinners within buttons to indicate an action is currently processing or taking place. You may also swap the text out of the spinner element and utilize button text as needed.
151
 
152
{{< example >}}
153
<button class="btn btn-primary" type="button" disabled>
154
  <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
155
  <span class="sr-only">Loading...</span>
156
</button>
157
<button class="btn btn-primary" type="button" disabled>
158
  <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
159
  Loading...
160
</button>
161
{{< /example >}}
162
 
163
{{< example >}}
164
<button class="btn btn-primary" type="button" disabled>
165
  <span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
166
  <span class="sr-only">Loading...</span>
167
</button>
168
<button class="btn btn-primary" type="button" disabled>
169
  <span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
170
  Loading...
171
</button>
172
{{< /example >}}
173
 
174
 
175
[color]:   {{< docsref "/utilities/colors" >}}
176
[display]: {{< docsref "/utilities/display" >}}
177
[flex]:    {{< docsref "/utilities/flex" >}}
178
[float]:   {{< docsref "/utilities/float" >}}
179
[margin]:  {{< docsref "/utilities/spacing" >}}
180
[sizing]:  {{< docsref "/utilities/sizing" >}}
181
[text]:    {{< docsref "/content/typography" >}}