The Wayback Machine - https://web.archive.org/web/20241006014141/https://www.geeksforgeeks.org/bootstrap-5-spinners/
Open In App

Bootstrap 5 Spinners

Last Updated : 25 Jul, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

In this article, we will implement spinners in the website using Bootstrap & will also see the implementation of different types of spinners through the example. The spinners are used to specify the loading state of a component or webpage. Bootstrap facilitates the various classes for creating different styles of spinners by modifying the appearance, size, and placement.

Syntax:

  • For spinner-border:
<div class="spinner-border" role="status"></div>
  • For spinner-grow:
<div class="spinner-grow" role="status"></div>

Approach: We will use a div element for spinners & declare the bootstrap classes called spinner-border and spinner-grow, inside the div section in order to use the spinners. The spinner-border class is used for rotating spinner and the spinner-grow is used for growing spinners. They are used for showing that some content is loading.

Example 1: This example illustrates the spinner-border in Bootstrap.

HTML
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content=
        "width=device-width">

    <link href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
        rel="stylesheet">
</head>

<body>
    <h1 class="text-success text-center">
        GeeksforGeeks
    </h1>
    
    <h4 class="text-info text-center">
        Bootstrap Spinner Border
    </h4>
    
    <div class="d-flex justify-content-center">
        <div class="spinner-border text-secondary"
            role="status">
        </div>
        
        <span>Please Wait </span>
    </div>
</body>

</html>

Output:

spinner-border

Example 2: This example describes the spinner-grow in Bootstrap. 

HTML
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" 
        content="width=device-width">

    <link href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
        rel="stylesheet">
</head>

<body>
    <h1 class="text-success text-center">
        GeeksforGeeks
    </h1>
    
    <h4 class="text-info text-center">
        Bootstrap Spinner Grow
    </h4>
    
    <div class="d-flex justify-content-center">
        <span>
            <h5>Processing</h5>
        </span>
        <div class="spinner-grow text-primary"
            role="status">
        </div>
    </div>
</body>

</html>

Output:

spinner-grow

Now we will learn how to align the spinners in the webpage according to our needs.

Alignment

Margin

We can add margin to the spinners in Bootstrap using the margin utilities class in Bootstrap. Here is an example given below:

HTML
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>

<body>
    <h1 class="text-success text-center">
        GeeksforGeeks
    </h1>

    <h4 class="text-info text-center">
        Adding margin to Bootstrap Spinners
    </h4>


    <div class="spinner-border m-5" role="status">

    </div>
</body>

</html>

Output:

Placement

We can place the spinner at different positions like the center, end or start using the text placement or flex box classes. Below given is the example in which we have used flexbox and text placement classes: 

HTML
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">

    <link href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" 
          rel="stylesheet">
</head>

<body>
    <h1 class="text-success text-center">
        GeeksforGeeks
    </h1>

    <h4 class="text-info text-center">
        Spinner Placement using Bootstrap classes
    </h4>
    <h4 class=" text-center">
        Using the Text Placement Classes
    </h4>

    <div class="text-center">
        <div class="spinner-border m-5 " role="status">
        </div>

    </div>
    <h4 class="text-center">
        Using the Flex Box Classes
    </h4>
    <div class="d-flex justify-content-center">
        <div class="spinner-border" role="status">
        </div>
    </div>
</body>

</html>

Output:


Size

We can also adjust the size of the spinners according to our needs using the Bootstrap classes or by using the inline CSS styling.

We can add the .spinner-border-sm and .spinner-grow-sm classes to make smaller spinners that can fit inside different components. Here is an example:

HTML
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>

<body>
    <h1 class="text-success text-center">
        GeeksforGeeks
    </h1>

   
    
    <div class="text-center">
        <h3>Making smaller Spinners using the Bootstrap Classes</h3>
        <div class="spinner-border spinner-border-sm" role="status">
            <span class="visually-hidden">Loading...</span>
        </div>
        <div class="spinner-grow spinner-grow-sm" role="status">
            <span class="visually-hidden">Loading...</span>
        </div>

    </div>
</body>

</html>

Output:


We can also increase or decrease size of spinners using the inline CSS styling by defining the width and height attributes. Here is an example where we increased the size of the spinner using the inline CSS styling:

HTML
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h2>Welcome To GFG</h2>



<p>Default code has been loaded into the Editor.</p>



</body>
</html>
a<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>

<body>
    <h1 class="text-success text-center">
        GeeksforGeeks
    </h1>

   
    
    <div class="text-center">
        <h3>Increasing the size of Spinners using inline CSS</h3>
        <div class="spinner-border" style="width: 4rem; height: 4rem;" role="status">
            <span class="visually-hidden">Loading...</span>
          </div>
          <div class="spinner-grow" style="width: 4rem; height: 4rem;" role="status">
            <span class="visually-hidden">Loading...</span>
          </div>

    </div>
</body>

</html>

Output:

Supported Browsers:

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


Previous Article
Next Article

Similar Reads

Adding spinners using react-spinners-kit package in React JS
Discover how to elevate your React.js applications by seamlessly integrating and customizing dynamic spinners from the react-spinners-kit package. This article offers a concise, step-by-step guide to enhancing user experience through engaging loading indicators in your React projects. Prerequisites:Node JS or NPMReact JSReact useStateApproach: Impo
3 min read
Bootstrap | Spinners Set-1
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. Types of Spinners: Border spinner: We can create a lightweight bordered spinner using the class spinner-border as given
4 min read
Bootstrap | Spinners Set-2
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
4 min read
Bootstrap 4 | Spinners
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
7 min read
Bootstrap 5 Spinners Alignment
Bootstrap 5 Spinners Alignment is used to set the alignment of the spinner element. The spinner element can easily be resized, recolored, and quickly aligned. Spinners Alignment: Margin Alignment: Spinner margin is used to create spinners in different margins.Spinners Placement: Spinners Placement is used to set the position of spinners where you w
2 min read
Bootstrap 5 Spinners Placement
Bootstrap 5 Spinners Placement is used to set the position of spinners where you want to place them according to the need. It uses three utilities flexbox utilities, float utilities, or text alignment to place the items. Placement Utilities: Flex: It is used to set the position of spinners using flexbox placement classes.Float: It is used to set th
3 min read
Bootstrap 5 Spinners Floats Placements
Bootstrap 5 Spinners Float Placements are used to set the position of spinner elements to left, right, or none depending on the requirements. It is mostly used for responsive design. Spinners Floats Placements used Classes: .float-start: It is used to set the position of spinner elements to start..float-end: It is used to set the position of spinne
2 min read
Bootstrap 5 Spinners Growing
Bootstrap 5 Spinner is used to show the loading stage of the component, these spinners are built only with HTML and CSS. The Growing Spinner does not technically spin like regular spinners, it repeatedly grows. You can easily change its appearance with color utilities. Bootstrap 5 Spinners Growing Classes: spinner-grow: This class is used to add th
2 min read
Bootstrap 5 Spinners Buttons
Bootstrap 5 Spinners are used to display the loading state of a component or a page. The spinners within buttons are used to represent an action that is currently processing. Spinners Buttons used Classes: .btn: It is used to create a button..spinner-border: It is used to create a spinner with the border..spinner-grow: It is used to create a grow a
2 min read
Bootstrap 5 Spinners Margin
Bootstrap 5 Spinners Margin is used to create spinners in different margins. For margin spinners, we will use .m class with five different sizes from 0 to 5. Also, auto is used for margin auto. For different sides of the margin, we will use t (for top), b (for bottom), s (for start), e (for end), x (for both left and right), y (for top and bottom),
2 min read
Bootstrap 5 Spinners Flex Placements
Bootstrap5 Spinner Flex Placements is a display utility that is used to place the spinner in a flexbox, where the spinner is placed inside the flexbox container using the .d-flex class. Spinners Flex Placements Class: d-flex: This is a flexbox helper class and it is used to have the Flex Placement.Syntax: <div class="d-flex"> <div class="s
2 min read
Bootstrap 5 Spinners SASS
Bootstrap 5 Spinners SASS has a set of variables with default values and keyframes which are used to create CSS animations for the spinners. Bootstrap 5 Spinners Sass: Variables: $spinner-height, $spinner-width, $spinner-border-width, etc variables are used to customize the spinners. You can find the whole list of variables and their default values
3 min read
Bootstrap 5 Spinners Border Colors
Bootstrap 5 Spinner is used to show the loading stage of the component, these spinners are built only with HTML and CSS. The Border Spinner is used for a lightweight loading indicator. There are various colors of spinners provided by Bootstrap 5 spinners. Spinner Border Colors Classes: spinner-border: This class is used to add the spinner border us
2 min read
Bootstrap 5 Spinners Text align Placements
Bootstrap 5 Spinners Text align placements are used to set the alignment of the spinner component. To set the text alignment of the spinner element, we will use text alignment classes. Spinners Text Align Placements used Classes: .text-start: It is used to set the alignment of the spinner element to start..text-center: It is used to set the alignme
2 min read
Bootstrap 5 Spinners Size
Bootstrap 5 Spinners Size is used to create spinners in different sizes. For small-size spinners, we will use .spinner-border-sm class, and for small-size grow to shrink spinners, we will use .spinner-grow-sm class. Spinners Size used Classes: .spinner-border-sm: It is used to create small-size spinners..spinner-border-md: It is used to create medi
2 min read
Bootstrap 5 Spinners Border
Bootstrap 5 Spinner is used to show the loading stage of the component, these spinners are built only with HTML and CSS. The Border Spinner is used for a lightweight loading indicator. To change, etc. the spinners color we need to use the Bootstrap 5 Text Color classes, like text-primary, text-success Spinner Border Classes: spinner-border: This cl
2 min read
Semantic-UI Icon Set Spinners
Semantic UI is a UI framework based on less and jQuery. It is used to make beautiful and responsive websites. In this article, we will be seeing the Spinners Icon Set provided by Semantic UI. There are a total of 15 icons in the Spinners Icon Set which can be used to tell the user that something is loading in the background. Semantic-UI Icon Set Sp
5 min read
ReactJS Reactstrap Spinners Component
Reactstrap is a popular front-end library that is easy to use React Bootstrap 4 components. This library contains the stateless React components for Bootstrap 4. The Spinner component allows the user to show the loading effect. It is used for the purpose of indicating a loading state. We can use the following approach in ReactJS to use the ReactJS
3 min read
React animated loading/splash screen using 'react-spinners'
Displaying a loading or splash screen during response time from the server is an excellent way to interact with the user. But making a loading/splash screen becomes difficult when we want to practically use an animated loader, where we need to make extra efforts to write down its styling file. To overcome this problem, we use a bunch of predefined
2 min read
Include Bootstrap in AngularJS using ng-bootstrap
AngularJS can be integrated with Bootstrap CSS and Javascript and can be used to create creative forms, tables, navigation bars, etc. Steps: Make sure the Angular CLI present in your system if not then run the command in the terminal to do so. npm install -g @angular/cli Create a new project on visual studio code by running the code ng new project-
2 min read
Difference between bootstrap.css and bootstrap-theme.css
Bootstrap is an HTML, CSS and JS front-end-framework used for developing responsive and mobile-first projects on the web. It is the framework that comes up with predefined terms, thus giving you the ability to use these codes instead of having to create the codes from scratch. It is a collection of HTML, CSS and JS code that is designed to help bui
5 min read
Difference Between Bootstrap 3 and Bootstrap 4
Bootstrap: Bootstrap was developed by Mark Otto and Jacob Thorton at Twitter in August 2011. It is an open-source framework that is used to design responsive websites faster and easier. It is the most popular open-source framework that includes HTML, CSS, and JavaScript. It can create web applications with any server-side Technology like Java, PHP,
2 min read
Difference between Bootstrap 4 and Bootstrap 5
What is Bootstrap? It is an open-source framework from late 2011 that is used for designing responsive websites with a mobile-first approach faster and easier. Bootstrap is available for HTML, CSS, and JS. According to server-side languages like PHP, Node, etc. bootstrap helps to design the frontend. Bootstrap has made the work for developers easie
3 min read
Bootstrap Cheat Sheet - A Basic Guide to Bootstrap
Bootstrap is a free, open-source, potent CSS framework and toolkit used to create modern and responsive websites and web applications. It is the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites. Nowadays, websites are perfect for all browsers and all sizes of screens. What is Bootstrap Cheat Sheet?A
15+ min read
Bootstrap Buttons, Glyphicons, Tables
Introduction and Installation Grid System Vertical Forms, Horizontal Forms, Inline Forms DropDowns and Responsive Tabs Progress Bar and Jumbotron After the previous article, one should be familiar with the Grid System of Bootstrap. Now, we'll learn about making Buttons, the all new Glyphicons and Tables. Lets get started. Beautiful Buttons: We can
4 min read
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 into a dropdown.As already stated in the last few tu
3 min read
Bootstrap 5 Reboot Misc elements
Bootstrap 5 Reboot Misc elements are some other tags that are used to reset browser defaults and can be used when we do not want to specify CSS explicitly. Reboot Misc Elements: Address: Reboot Address element is used to change the font style from italic to normal text. It inherits line height and the margin-bottom is set to 1 rem.Blockquote: This
2 min read
How to get circular buttons in bootstrap 4 ?
It is an open source toolkit for developing with the HTML, CSS, and JS. It includes several types of buttons, styles, fonts each of them serving its own semantic purpose which is predefined, with a few extras thrown for more control. You can use Bootstrap custom button styles to create your buttons and more with support for multiple sizes, states,
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 texts that are important to take into consideration w
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 items are available or associated with the link. T
3 min read