Bootstrap provides various classes for creating different styles of “spinner” to display the loading state of projects. These classes are inbuilt with HTML and CSS so no need to write any JavaScript to create them. We can also modify the appearance, size, and placement of the spinners with the classes provided by Bootstrap.
Types of Spinner:
- Border spinner: We can create lightweight bordered spinner using the .spinner-border class as given below.
Syntax:
<div class="spinner-border" role="status"> <span class="sr-only">Loading</span> </div>Example:
<!DOCTYPE html><htmllang="en"><head><title>Bootstrap Spinners</title><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1"><linkrel="stylesheet"href=<scriptsrc=</script><scriptsrc=</script><scriptsrc=</script></head><body><center><h1style="color:green;text-align:center;">GeeksforGeeks</h1><!-- spinner-border --><divclass="spinner-border"role="status"><spanclass="sr-only">Loading</span></div></center></body></html>chevron_rightfilter_noneOutput:

Note: We have used the class .spinner-border inside <div> element. We have used the role=”status” attribute-value pair inside the <div> for accessibility purposes and a <span> tag with class=”sr-only”, which is a Bootstrap class which makes the container and it’s content visible only on screen-readers.
- Colored Spinners: We can change the color of the border spinner using text color utility classes of Bootstrap along with the .spinner-border class as given below.
Syntax:
<div class="spinner-border text-primary" role="status"> <span class="sr-only">Loading</span> </div>Example:
<!DOCTYPE html><htmllang="en"><head><title>Bootstrap Spinners</title><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1"><linkrel="stylesheet"href=<scriptsrc=</script><scriptsrc=</script><scriptsrc=</script></head><body><center><h1style="color:green;text-align:center;">GeeksforGeeks</h1><!-- spinner-border, #1 --><divclass="spinner-border text-primary"role="status"><spanclass="sr-only">Loading</span></div><!-- spinner-border, #2 --><divclass="spinner-border text-secondary"role="status"><spanclass="sr-only">Loading</span></div><!-- spinner-border, #3 --><divclass="spinner-border text-success"role="status"><spanclass="sr-only">Loading</span></div><!-- spinner-border, #4 --><divclass="spinner-border text-danger"role="status"><spanclass="sr-only">Loading</span></div><!-- spinner-border, #5 --><divclass="spinner-border text-warning"role="status"><spanclass="sr-only">Loading</span></div><!-- spinner-border, #6 --><divclass="spinner-border text-info"role="status"><spanclass="sr-only">Loading</span></div><!-- spinner-border, #7 --><divclass="spinner-border text-light"role="status"><spanclass="sr-only">Loading</span></div><!-- spinner-border, #8 --><divclass="spinner-border text-dark"role="status"><spanclass="sr-only">Loading</span></div></div></center></body></html>chevron_rightfilter_noneOutput:

Note: We have used the text color utility instead of border-color utilities because each border spinner specifies a transparent border for at least one side and the border-{color} utilities override that.
- Growing spinner: We can create growing spinner by using .spinner-grow class of Bootstrap. It displays as repeatedly grow.
Syntax:
<div class="spinner-grow" role="status"> <span class="sr-only">Loading</span> </div>Example:
<!DOCTYPE html><htmllang="en"><head><title>Bootstrap Spinners</title><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1"><linkrel="stylesheet"href=<scriptsrc=</script><scriptsrc=</script><scriptsrc=</script></head><body><center><h1style="color:green;text-align:center;">GeeksforGeeks</h1><!-- spinner-grow --><divclass="spinner-grow"role="status"><spanclass="sr-only">Loading</span></div></div><center></body></html>chevron_rightfilter_noneOutput:

Note: We have used the class .spinner-grow inside <div>. We have used the role=”status” attribute-value pair inside the <div> for accessibility purposes and a <span> tag with class=”sr-only”, which is a Bootstrap class which make the container and its content visible only on screen-readers.
- Colored growing spinner: We can change the color of growing spinner by using text color utility classes of Bootstrap along with the .spinner-grow class as given below.
Syntax:
<div class="spinner-grow text-primary" role="status"> <span class="sr-only">Loading</span> </div>Example:
<!DOCTYPE html><htmllang="en"><head><title>Bootstrap Spinners</title><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1"><linkrel="stylesheet"href=<scriptsrc=</script><scriptsrc=</script><scriptsrc=</script></head><body><center><h1style="color:green;text-align:center;">GeeksforGeeks</h1><!-- spinner-grow, #1 --><divclass="spinner-grow text-primary"role="status"><spanclass="sr-only">Loading</span></div><!-- spinner-grow, #2 --><divclass="spinner-grow text-secondary"role="status"><spanclass="sr-only">Loading</span></div><!-- spinner-grow, #3 --><divclass="spinner-grow text-success"role="status"><spanclass="sr-only">Loading</span></div><!-- spinner-grow, #4 --><divclass="spinner-grow text-danger"role="status"><spanclass="sr-only">Loading</span></div><!-- spinner-grow, #5 --><divclass="spinner-grow text-warning"role="status"><spanclass="sr-only">Loading</span></div><!-- spinner-grow, #6 --><divclass="spinner-grow text-info"role="status"><spanclass="sr-only">Loading</span></div><!-- spinner-grow, #7 --><divclass="spinner-grow text-light"role="status"><spanclass="sr-only">Loading</span></div><!-- spinner-grow, #8 --><divclass="spinner-grow text-dark"role="status"><spanclass="sr-only">Loading</span></div></center></body></html>chevron_rightfilter_noneOutput:

Note: The spinner is built with currentColor which is easily change its appearance with text color utilities.
- Buttons with border spinner: We can place the border spinner within the button with text or without text by using the .spinner-border class within a <span> tag.
Syntax:
<button type="button" class="btn btn-primary" disabled> <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"> </span> Text </button>Example:
<!DOCTYPE html><htmllang="en"><head><title>Bootstrap Spinners</title><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1"><linkrel="stylesheet"href=<scriptsrc=</script><scriptsrc=</script><scriptsrc=</script></head><body><center><h1style="color:green;text-align:center;">GeeksforGeeks</h1><divclass="container"><buttontype="button"class="btn btn-secondary"disabled><spanclass="spinner-border spinner-border-sm"role="status"aria-hidden="true"></span><spanclass="sr-only">Loading</span></button><buttontype="button"class="btn btn-primary"disabled><spanclass="spinner-border spinner-border-sm"role="status"aria-hidden="true"></span>Processing...</button></div></center></body></html>chevron_rightfilter_noneOutput:

Note: We have placed “disabled” attribute within the <button> tag to deactivate it and used “role” and “aria-hidden” attributes within <span> tag for accessibility purposes.
- Buttons with growing spinner: We can place the growing spinner within the button with text or without text by using the .spinner-grow class within a <span> tag.
Syntax:
<button type="button" class="btn btn-primary" disabled> <span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span> text </button>Example:
<!DOCTYPE html><htmllang="en"><head><title>Bootstrap Spinners</title><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1"><linkrel="stylesheet"href=<scriptsrc=</script><scriptsrc=</script><scriptsrc=</script></head><body><center><h1style="color:green;text-align:center;">GeeksforGeeks</h1><divclass="container"><buttontype="button"class="btn btn-secondary"disabled><spanclass="spinner-grow spinner-grow-sm"role="status"aria-hidden="true"></span><spanclass="sr-only">Loading</span></button><buttontype="button"class="btn btn-primary"disable><spanclass="spinner-grow spinner-grow-sm"role="status"aria-hidden="true"></span>Processing...</button></div></center></body></html>chevron_rightfilter_noneOutput:

Note: We have placed “disabled” attribute within the <button> tag to deactivate it and used “role” and “aria-hidden” attributes within <span> tag for accessibility purposes.
Changing the size:
- Using class: We can change the size using the classes .spinner-border-sm and .spinner-grow-sm along with the .spinner-border and .spinner-grow classes.
The list of size classes are given below:- sm
- md
- lg
Example:
<!DOCTYPE html><htmllang="en"><head><title>Bootstrap Spinners</title><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1"><linkrel="stylesheet"href=<scriptsrc=</script><scriptsrc=</script><scriptsrc=</script></head><body><center><h1style="color:green;text-align:center;">GeeksforGeeks</h1><div><!-- spinner-border-sm --><divclass="spinner-border text-primary spinner-border-sm"role="status"><spanclass="sr-only">Loading</span></div><!-- spinner-grow-lg --><divclass="spinner-grow text-primary spinner-grow-lg"role="status"><spanclass="sr-only">Loading</span></div></center></body></html>chevron_rightfilter_noneOutput:
- Using CSS: We can also change the size of spinner using CSS styling as given below.
Example:
<!DOCTYPE html><htmllang="en"><head><title>Bootstrap Spinners</title><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1"><linkrel="stylesheet"href=<scriptsrc=</script><scriptsrc=</script><scriptsrc=</script></head><body><center><divclass="container"><h1style="color:green;text-align:center;">GeeksforGeeks</h1><divclass="spinner-border text-primary"role="status"style="height:5rem; width:5rem;"><spanclass="sr-only">Loading</span></div><divclass="spinner-grow text-primary"role="status"style="height:5rem; width:5rem;"><spanclass="sr-only">Loading</span></div></div></center></body></html>chevron_rightfilter_noneOutput:
Changing the alignment:
- Using text alignment utilities: We can change the alignment of the spinner by placing it inside <div> tag which uses text alignment utility class to control the alignment of children elements as given below.
Example:
<!DOCTYPE html><htmllang="en"><head><title>Bootstrap Spinners</title><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1"><linkrel="stylesheet"href=<scriptsrc=</script><scriptsrc=</script><scriptsrc=</script></head><body><divclass="container"><h1style="color:green;text-align:center;">GeeksforGeeks</h1><!-- Changing alignment using text utilities class --><divclass="text-center"><divclass="spinner-border text-primary"role="status"><spanclass="sr-only">Loading</span></div></div></body></html>chevron_rightfilter_noneOutput:
- Using float utilities: We can change the alignment of spinner by placing it inside the <div> tag which uses float utilities class to control the alignment of children elements or use the float utilities class directly within the <div> tag through which spinner is created as given below.
Example:
<!DOCTYPE html><htmllang="en"><head><title>Bootstrap Spinners</title><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1"><linkrel="stylesheet"href=<scriptsrc=</script><scriptsrc=</script><scriptsrc=</script></head><body><divclass="container"><h1style="color:green;text-align:center;">GeeksforGeeks</h1><!-- Changing alignment using text utilities class --><divclass="clearfix float-right"><divclass="spinner-border text-primary"role="status"><spanclass="sr-only">Loading</span></div></div></div></body></html>chevron_rightfilter_noneOutput:
- Using flexbox utilities: We can change the alignment of the spinner by placing it inside <div> element which uses flexbox utility class to control the alignment of children elements as given below.
Example:
<!DOCTYPE html><htmllang="en"><head><title>Bootstrap Spinners</title><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1"><linkrel="stylesheet"href=<scriptsrc=</script><scriptsrc=</script><scriptsrc=</script></head><body><divclass="container"><h1style="color:green;text-align:center;">GeeksforGeeks</h1><!-- Changing alignment using text utilities class --><divclass="d-flex justify-content-center"><divclass="spinner-border text-primary"role="status"><spanclass="sr-only">Loading</span></div></div></div></body></html>chevron_rightfilter_noneOutput:
Recommended Posts:
- Bootstrap | Spinners Set-1
- Bootstrap | Spinners Set-2
- Include Bootstrap in AngularJS using ng-bootstrap
- Difference between bootstrap.css and bootstrap-theme.css
- Difference Between Bootstrap 3 and Bootstrap 4
- Difference between Bootstrap 4 and Bootstrap 5
- Beginning BootStrap (Part-1) | Introduction and Installation
- Beginning BootStrap (Part-2) | Grid System
- Bootstrap (Part-3) | Buttons, Glyphicons, Tables
- Bootstrap (Part-5) | DropDowns and Responsive Tabs
- Bootstrap (Part-4) | Vertical Forms, Horizontal Forms, Inline Forms
- How to get circular buttons in bootstrap 4 ?
- Bootstrap (Part-6) | Progress Bar and Jumbotron
- Bootstrap (Part-7) | Alerts , Wells, Pagination and Pager
- Bootstrap (Part-8) | Badges, Labels, Page Headers
- Bootstrap (Part-9) | Tooltips
- Bootstrap | Navigation Bar
- Bootstrap | Carousel
- Bootstrap | Cards
- Bootstrap | Badges and Breadcrumbs
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

