Bootstrap Spinner
Posted by Superadmin on April 30 2023 16:35:49

Bootstrap Spinner

By Mrunali PangeMrunali Pange
  

Bootstrap Spinner

Definition of Bootstrap Spinner

The bootstrap spinner is one component to shows loading the web pages in the web application. It is a loader that is displayed when a web page or web server delays to display a web application display screen. It is an animated component to show the user when displaying the loading state of the web pages.

Syntax:

<div class = "spinner-border"> </div>
<div class = "spinner-grow "> </div>
<div class = "spinner-border text-warning"> </div>
<button class = "btn btn-success">
<span class = "spinner-border"> </span>
</button>

How does Spinner work in Bootstrap?

<meta name = "viewport" content = "width = device-width, initial-scale = 1">
<link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
</script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js">
</script>
<script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js">
</script>

Syntax 1:

<div class = "spinner-border"> </div>

Syntax 2:

<button class = "btn btn-success">
<span class = "spinner-border"> </span>
</button>
<!DOCTYPE html>
<html>
<head>
<title> Bootstrap Spinner Example </title>
<meta name = "viewport" content = "width = device-width, initial-scale = 1">
<link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
</script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js">
</script>
<script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js">
</script>
</head>
<body>
<div class = "container">
<h2> Bootstrap Spinner Example </h2>
<div class = "spinner-border"> </div> <br>
<button class = "btn btn-success">
<span class = "spinner-border"> </span>
</button>
</div>
</body>
</html>

Examples

Below we will discuss some examples with output.

Example #1

Code:

<!DOCTYPE html>
<html>
<head>
<title> Bootstrap Spinner Example </title>
<meta name = "viewport" content = "width = device-width, initial-scale = 1">
<link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
</script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js">
</script>
<script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js">
</script>
</head>
<body>
<div class = "container">
<h2> Bootstrap Spinner Example </h2>
<div class = "spinner-border"> </div> <br>
<div class = "spinner-grow"> </div> <br>
<button class = "btn btn-success">
<span class = "spinner-border"> </span>
</button>
</div>
</body>
</html>

Output:

bootstrap spinner 1

Description:

The first spinner is a border spinner which is shown in the output. The second is a growing spinner which is also shown in the output. The third is a button spinner that is modified with a button tag.

Example #2 – Basic border spinner with Size

Code:

<!DOCTYPE html>
<html>
<head>
<title> Bootstrap Spinner Example </title>
<meta name = "viewport" content = "width = device-width, initial-scale = 1">
<link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
</script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js">
</script>
<script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js">
</script>
</head>
<body>
<div class = "container">
<h2> Bootstrap Border Spinner Example </h2>
<div class = "spinner-border"> </div>
<div class = "spinner-border spinner-border-sm"> </div> <br><br>
<button class = "btn btn-success">
<span class = "spinner-border"> </span>
</button>
<button class = "btn btn-success">
<span class = "spinner-border spinner-border-sm"> </span>
</button>
</div>
</body>
</html>

Output:

bootstrap spinner 2

Description:

The spinner-border class is used for the border spinner which is displayed in the output. The spinner-border-sm class is used for the display smaller size of the spinner.

Example #3 – Growing spinner

Code:

<!DOCTYPE html>
<html>
<head>
<title> Bootstrap Spinner Example </title>
<meta name = "viewport" content = "width = device-width, initial-scale = 1">
<link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
</script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js">
</script>
<script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js">
</script>
</head>
<body>
<div class = "container">
<h2> Bootstrap growing Spinner Example </h2>
<div class = "spinner-grow"> </div>
<div class = "spinner-grow spinner-grow-sm"> </div><br><br>
<button class = "btn btn-info">
<span class = "spinner-grow"> </span>
</button>
<button class = "btn btn-info">
<span class = "spinner-grow spinner-grow-sm"> </span>
</button>
</div>
</body>
</html>

Output:

bootstrap spinner 3

Description:

The spinner-grow class is used for bootstrap growing spinner which is display in the output. The spinner-grow-sm class is used for the display smaller size.

Example #4 – Colored spinner

Code:

<!DOCTYPE html>
<html>
<head>
<title> Bootstrap Spinner Example </title>
<meta name = "viewport" content = "width = device-width, initial-scale = 1">
<link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
</script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js">
</script>
<script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js">
</script>
</head>
<body>
<div class = "container">
<h2> Bootstrap colored Spinner Example </h2>
<button class = "btn btn-secondary">
<span class = "spinner-border"></span>
</button>
<div class = "spinner-grow text-warning"> </div>
<span class = "spinner-border text-primary"></span>
<br> <br>
<button class = "btn btn-info">
<span class = "spinner-border spinner-border-sm"></span>
</button>
<div class = "spinner-grow spinner-grow-sm text-danger"> </div>
<span class = "spinner-border spinner-grow-sm text-success">
</span>
</div>
</body>
</html>

Output:

example 4

Description:

The text-primary class is used for blue color which is display in the output. The contextual classes are used for a bootstrap spinner for design and modification.

Example #5 – Button with text

Code:

<!DOCTYPE html>
<html>
<head>
<title> Bootstrap Spinner Example </title>
<meta name = "viewport" content = "width = device-width, initial-scale = 1">
<link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
</script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js">
</script>
<script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js">
</script
</head>
<body>
<div class = "container">
<h2> Bootstrap colored Spinner Example </h2>
<button class = "btn btn-warning">
<span class = "spinner-border"></span>
Starting..
</button>
<br> <br>
<button class = "btn btn-info">
<span class = "spinner-border spinner-border-sm">
</span>
Loading..
</button>
<br> <br>
<button class = "btn btn-danger">
<span class = "spinner-grow">
</span>
Connecting..
</button>
<br> <br>
<button class = "btn btn-success">
<span class = "spinner-grow spinner-grow-sm">
</span>
Waiting..
</button>
</div>
</body>
</html>

Output:

example 5

Conclusion

This component used indicates the web page loading state to the user. It is utilized for getting information to the user about web page loading conditions. It is an animated component to get information in the symbolic form.