Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • BS5 Tutorial
  • BS5 Interview Questions
  • BS5 Layout
  • BS5 Content
  • BS5 Components
  • BS5 Helpers
  • BS5 Utilities
  • BS4 Tutorial
  • BS Tutorial
  • Bootstrap Cheatsheet
  • Tailwind
  • CSS Frameworks
  • HTML Formatter
Open In App

Bootstrap | Spinners Set-2

Last Updated : 28 Apr, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

Bootstrap provides us with various classes for creating different styles of the spinner to indicate the loading state. We can also modify the appearance, size, and placement of the spinners with the classes provided by Bootstrap.

Buttons with border spinner: We can place the border spinner within the button by using the spinner-border class within a <span> tag which is in turn nested inside a <button> tag having Bootstrap Button classes as given below.

HTML
<!DOCTYPE html> <html> <head>     <!-- Bootstrap CSS -->     <link rel="stylesheet" href= "https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"          integrity= "sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"          crossorigin="anonymous">     <title>Bootstrap | Spinner</title>     <style>         h1 {             color: green;             text-align: center;         }         div {             margin-top: 10px;         }     </style> </head> <body>     <div class="container">         <h1>GeeksForGeeks</h1>         <button type="button" class="btn btn-secondary" disabled>             <span class="spinner-border spinner-border-sm"                  role="status" aria-hidden="true"></span>             <span class="sr-only">Loading</span>         </button>         <button type="button" class="btn btn-primary" disabled>             <span class="spinner-border spinner-border-sm"                  role="status" aria-hidden="true"></span>             Processing...         </button>     </div> </body> </html> 

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.

Output:

button-spinner-border

Buttons with growing spinner: We can place the growing spinner within the button by using the spinner-grow class within a <span> tag which is in turn nested inside a <button> tag having Bootstrap Button classes as given below. 

Changing the size:

  • Using class: We can make the spinner smaller using the classes spinner-border-sm and spinner-grow-sm along with the spinner-border and spinner-grow classes, respectively, as given below.
HTML
<!DOCTYPE html> <html> <head>     <!-- Bootstrap CSS -->     <link rel="stylesheet" href= "https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"          integrity= "sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"          crossorigin="anonymous">     <title>Bootstrap | Spinner</title>     <style>         h1 {             color: green;             text-align: center;         }         div {             margin-top: 10px;         }     </style> </head> <body>     <div class="container">         <h1>GeeksForGeeks</h1>         <!-- spinner-border-sm -->         <div class="spinner-border text-primary spinner-border-sm"              role="status">             <span class="sr-only">Loading</span>         </div>         <!-- spinner-grow-sm -->         <div class="spinner-grow text-primary spinner-grow-sm"              role="status">             <span class="sr-only">Loading</span>         </div>     </div> </body> </html> 

Output:

change-size-class

  • Using CSS: We can also change the size of the spinner using CSS styling as given below.
HTML
<!DOCTYPE html> <html> <head>     <!-- Bootstrap CSS -->     <link rel="stylesheet" href= "https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"          integrity= "sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"          crossorigin="anonymous">     <title>Bootstrap | Spinner</title>     <style>         h1 {             color: green;             text-align: center;         }         div {             margin-top: 10px;         }     </style> </head> <body>     <div class="container">         <h1>GeeksForGeeks</h1>         <div class="spinner-border text-primary"              role="status" style="height:5rem; width:5rem;">             <span class="sr-only">Loading</span>         </div>         <div class="spinner-grow text-primary"              role="status" style="height:5rem; width:5rem;">             <span class="sr-only">Loading</span>         </div>     </div> </body> </html> 

Output:

change-size-css
Changing the alignment:

  • Using text alignment utilities: We can change the alignment of the spinner by placing it inside the <div> tag which uses the text alignment utility class to control the alignment of children elements as given below.
HTML
<!DOCTYPE html> <html> <head>     <!-- Bootstrap CSS -->     <link rel="stylesheet" href= "https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"          integrity= "sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"          crossorigin="anonymous">     <title>Bootstrap | Spinner</title>     <style>         h1 {             color: green;             text-align: center;         }         div {             margin-top: 10px;         }     </style> </head> <body>     <div class="container">         <h1>GeeksForGeeks</h1>         <!-- Changing alignment using text utilities class -->         <div class="text-center">             <div class="spinner-border text-primary"                  role="status">                 <span class="sr-only">Loading</span>             </div>         </div>     </div> </body> </html> 

Output:

change-alignment-text

  • Using float utilities: We can change the alignment of the spinner by placing it inside the <div> tag which uses the float utility class to control the alignment of children elements or use the float utility class directly within the <div> tag through which spinner is created as given below.
HTML
<!DOCTYPE html> <html> <head>     <!-- Bootstrap CSS -->     <link rel="stylesheet" href= "https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"          integrity= "sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"          crossorigin="anonymous">     <title>Bootstrap | Spinner</title>     <style>         h1 {             color: green;             text-align: center;         }         div {             margin-top: 10px;         }     </style> </head> <body>     <div class="container">         <h1>GeeksForGeeks</h1>         <!-- Changing alignment using text utilities class -->         <div class="clearfix float-right">             <div class="spinner-border text-primary"                  role="status">                 <span class="sr-only">Loading</span>             </div>         </div>     </div> </body> </html> 

Output:

change-alignment-float

  • Using flexbox utilities: We can change the alignment of the spinner by placing it inside the <div> tag which uses the flexbox utility class to control the alignment of children elements as given below.
HTML
<!DOCTYPE html> <html> <head>     <!-- Bootstrap CSS -->     <link rel="stylesheet" href= "https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"          integrity= "sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"          crossorigin="anonymous">     <title>Bootstrap | Spinner</title>     <style>         h1 {             color: green;             text-align: center;         }         div {             margin-top: 10px;         }     </style> </head> <body>     <div class="container">         <h1>GeeksForGeeks</h1>         <!-- Changing alignment using text utilities class -->         <div class="d-flex justify-content-center">             <div class="spinner-border text-primary"                  role="status">                 <span class="sr-only">Loading</span>             </div>         </div>     </div> </body> </html> 

Output:

change-alignment-flex

Supported Browser:

  • Google Chrome
  • Microsoft Edge
  • Firefox
  • Opera
  • Safari

H

Husban
Improve
Article Tags :
  • Web Technologies
  • Bootstrap

Similar Reads

    Bootstrap DropDowns and Responsive Tabs
    Introduction and InstallationGrid SystemButtons, Glyphicons, TablesVertical Forms, Horizontal Forms, Inline FormsProgress Bar and Jumbotron Dropdown Menu Using Bootstrap: In bootstrap, dropdowns are created using the class="dropdown". What we will do is create a button and then convert the button in
    3 min read
    Bootstrap Progress Bar and Jumbotron
    BootStrap articles : Introduction and Installation Grid System Buttons, Glyphicons, Tables Vertical Forms, Horizontal Forms, Inline Forms DropDowns and Responsive Tabs Progress Bar We all have seen a progress bar while executing some process in our computer. A progress bar shows how much of the proc
    2 min read
    Bootstrap Alerts , Wells, Pagination and Pager
    Introduction and InstallationGrid SystemButtons, Glyphicons, TablesVertical Forms, Horizontal Forms, Inline FormsDropDowns and Responsive TabsProgress Bar and Jumbotron Alerts: We often see certain alerts on some websites before or after completing an action. These alert messages are highlighted tex
    4 min read
    Bootstrap Badges, Labels, Page Headers
    Introduction and InstallationButtons, Glyphicons, TablesVertical Forms, Horizontal Forms, Inline FormsDropDowns and Responsive TabsProgress Bar and Jumbotron Badges: We all have seen some numerical indicators beside some links on various websites. These are called badges. These badges tell how many
    3 min read
    Bootstrap Tooltips
    In this article, we would be discussing the tooltip plugin provided by bootstrap. Tooltip is quite useful for showing the description of different elements in the webpage. Tooltip can be invoked on any element in a webpage. Tooltips on bootstrap depends on the 3rd party library Tether for positionin
    4 min read
    Bootstrap Navigation Bar
    Bootstrap Navigation Bar provides a responsive, customizable, and pre-styled navigation component for web applications. It incorporates features like branding, navigation links, dropdowns, and responsiveness, enabling developers to create effective and visually appealing navigation menus effortlessl
    6 min read
    Bootstrap Carousel
    Bootstrap Carousel enables slideshow functionality for images or content. Easily customizable with CSS and JavaScript. Supports responsive design and touch gestures, enhancing user experience in web development projects. It can be included in your webpage using "bootstrap.js" or "bootstrap.min.js".
    4 min read
    Bootstrap Cards
    A card is a flexible and extensible content container. It includes options for headers and footers, a wide variety of content, contextual background colors, and powerful display options. It replaces the use of panels, wells and thumbnails. All of it can be used in a single container called card . Ba
    2 min read
    Bootstrap | Badges and Breadcrumbs
    Badges: Badges are numbers associated with the link to indicate the number of items associated with the link. The notification number is seen when logged in to a particular website and tells the numbers of news or notifications to see by clicking it. Example: HTML <!DOCTYPE html> <html>
    4 min read
    Clearfix in Bootstrap
    One of the major problems with the structure of HTML is that if you have a child div inside parent div, the child div automatically flows around the parent div. The solution to this problem is using clear property of CSS. Bootstrap allows us to use a class named clearfix which is used to clear the f
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences