11---
22layout : docs
33title : Loading Buttons
4- description : Buttons with built-in loading indicators. Indicate the loading state of the button bridging the gap between action and feedback .
4+ description : Bootstrap loading buttons are interactive elements that provide visual feedback to users, indicating that an action is being processed. These buttons typically display a loading spinner or animation .
55aliases :
66 - " /4.0/components/loading-buttons/"
77toc : true
@@ -12,35 +12,64 @@ other_frameworks: loading-button
1212
1313## Basic example
1414
15+ Create basic Bootstrap Loading Buttons with different styles: primary, outline, and ghost. These buttons show a loading state when clicked.
16+
1517{{< example >}}
16- <button type =" button " class =" btn btn-primary btn-loading " data-coreui-timeout =" 2000 " data-coreui-toggle =" loading-button " >Submit</button >
17- <button type =" button " class =" btn btn-outline-primary btn-loading " data-coreui-toggle =" loading-button " >Submit</button >
18- <button type =" button " class =" btn btn-ghost-primary btn-loading " data-coreui-toggle =" loading-button " >Submit</button >
18+ <button type =" button " class =" btn btn-primary " data-coreui-timeout =" 2000 " data-coreui-toggle =" loading-button " >Submit</button >
19+ <button type =" button " class =" btn btn-outline-primary " data-coreui-toggle =" loading-button " >Submit</button >
20+ <button type =" button " class =" btn btn-ghost-primary " data-coreui-toggle =" loading-button " >Submit</button >
1921{{< /example >}}
2022
2123## Spinners
2224
2325### Border
2426
27+ The default option. Use loading buttons with a border spinner to indicate loading status.
28+
2529{{< example >}}
26- <button type =" button " class =" btn btn-info btn-loading " data-coreui-toggle =" loading-button " >Submit</button >
27- <button type =" button " class =" btn btn-outline-success btn-loading " data-coreui-toggle =" loading-button " >Submit</button >
28- <button type =" button " class =" btn btn-ghost-warning btn-loading " data-coreui-toggle =" loading-button " >Submit</button >
30+ <button type =" button " class =" btn btn-info " data-coreui-toggle =" loading-button " >Submit</button >
31+ <button type =" button " class =" btn btn-outline-success " data-coreui-toggle =" loading-button " >Submit</button >
32+ <button type =" button " class =" btn btn-ghost-warning " data-coreui-toggle =" loading-button " >Submit</button >
2933{{< /example >}}
3034
3135### Grow
3236
37+ Switch to a grow spinner for Bootstrap loading buttons by adding ` data-coreui-spinner-type="grow" ` .
38+
3339{{< example >}}
34- <button type =" button " class =" btn btn-info btn-loading " data-coreui-spinner-type =" grow " data-coreui-toggle =" loading-button " >Submit</button >
35- <button type =" button " class =" btn btn-outline-success btn-loading " data-coreui-spinner-type =" grow " data-coreui-toggle =" loading-button " >Submit</button >
36- <button type =" button " class =" btn btn-ghost-warning btn-loading " data-coreui-spinner-type =" grow " data-coreui-toggle =" loading-button " >Submit</button >
40+ <button type =" button " class =" btn btn-info " data-coreui-spinner-type =" grow " data-coreui-toggle =" loading-button " >Submit</button >
41+ <button type =" button " class =" btn btn-outline-success " data-coreui-spinner-type =" grow " data-coreui-toggle =" loading-button " >Submit</button >
42+ <button type =" button " class =" btn btn-ghost-warning " data-coreui-spinner-type =" grow " data-coreui-toggle =" loading-button " >Submit</button >
3743{{< /example >}}
3844
3945
4046## Usage
4147
4248{{< bootstrap-compatibility >}}
4349
50+ ### Via data attributes
51+
52+ Add ` data-coreui-toggle="loading-button" ` to a ` button ` element.
53+
54+ ``` html
55+ <button type =" button" class =" btn btn-primary" data-coreui-toggle =" loading-button" >Submit</button >
56+ ```
57+
58+ ### Via JavaScript
59+
60+ Call the loading button via JavaScript:
61+
62+ ``` html
63+ <div class =" btn btn-primary btn-loading" ></div >
64+ ```
65+
66+ ``` js
67+ const loadingButtonElementList = Array .prototype .slice .call (document .querySelectorAll (' .btn-loading' ))
68+ const loadingButtonList = loadingButtonElementList .map (loadingButtonEl => {
69+ return new coreui.DatePicker (loadingButtonEl)
70+ })
71+ ```
72+
4473### Options
4574
4675{{< markdown >}}
@@ -50,10 +79,9 @@ other_frameworks: loading-button
5079{{< bs-table >}}
5180| Name | Type | Default | Description |
5281| --- | --- | --- | --- |
53- | ` disabledOnLoading ` | boolean| ` false ` | |
54- | ` spinner ` | boolean| ` true ` | |
55- | ` spinnerType ` | string| ` 'border' ` | |
56- | ` timeout ` | boolean \| number| ` false ` | |
82+ | ` disabledOnLoading ` | boolean | ` false ` | Makes button disabled when loading. |
83+ | ` spinnerType ` | 'border', 'grow' | ` 'border' ` | Sets type of spinner. |
84+ | ` timeout ` | boolean, number | ` false ` | Automatically starts loading animation and stops after a determined amount of milliseconds. |
5785{{< /bs-table >}}
5886
5987### Methods
0 commit comments