TExcelTAD
Home › Bootstrap › BS5 Spinners

Bootstrap 5 Spinners

A spinner tells the user "something is happening, please wait" when you can't say how long it will take: loading data, submitting a form, processing a payment. Bootstrap's spinners are pure CSS — no JavaScript or images — and inherit the current text colour.

Border and grow spinners

There are two styles: .spinner-border (a rotating ring) and .spinner-grow (a pulsing dot).

html · try it yourself
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
  <div class="spinner-border" role="status">
    <span class="visually-hidden">Loading…</span>
  </div>
  <div class="spinner-grow" role="status">
    <span class="visually-hidden">Loading…</span>
  </div>
</body>
</html>

role="status" and the .visually-hidden text let screen readers announce "Loading…" — the spinner itself is only a picture.

Colours

Spinners use currentColor, so any .text-{color} class colours them.

html · try it yourself
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
  <div class="mb-3">
    <div class="spinner-border text-primary" role="status"><span class="visually-hidden">Loading…</span></div>
    <div class="spinner-border text-success" role="status"><span class="visually-hidden">Loading…</span></div>
    <div class="spinner-border text-danger" role="status"><span class="visually-hidden">Loading…</span></div>
    <div class="spinner-border text-warning" role="status"><span class="visually-hidden">Loading…</span></div>
  </div>
  <div>
    <div class="spinner-grow text-info" role="status"><span class="visually-hidden">Loading…</span></div>
    <div class="spinner-grow text-secondary" role="status"><span class="visually-hidden">Loading…</span></div>
    <div class="spinner-grow text-dark" role="status"><span class="visually-hidden">Loading…</span></div>
  </div>
</body>
</html>

Sizes and alignment

.spinner-border-sm and .spinner-grow-sm make small spinners for buttons and inline text. For any other size, set width and height with inline style. Flex and text utilities position spinners like any other element.

html · try it yourself
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
  <div class="d-flex align-items-center gap-3 mb-3">
    <div class="spinner-border spinner-border-sm" role="status"><span class="visually-hidden">Loading…</span></div>
    <div class="spinner-border" role="status"><span class="visually-hidden">Loading…</span></div>
    <div class="spinner-border text-primary" style="width: 3rem; height: 3rem;" role="status"><span class="visually-hidden">Loading…</span></div>
  </div>
  <div class="d-flex align-items-center border rounded p-2 mb-3">
    <strong role="status">Loading your files…</strong>
    <div class="spinner-border spinner-border-sm ms-auto" aria-hidden="true"></div>
  </div>
  <div class="text-center">
    <div class="spinner-grow text-primary" role="status"><span class="visually-hidden">Loading…</span></div>
  </div>
</body>
</html>

Spinners in buttons

A spinner inside a disabled button is a classic "submitting…" state. The example simulates a two-second request.

html · try it yourself
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
  <button class="btn btn-primary" id="pay" onclick="pay()">Pay $20</button>
  <script>
    function pay() {
      const btn = document.getElementById('pay');
      btn.disabled = true;
      btn.innerHTML = '<span class="spinner-border spinner-border-sm" aria-hidden="true"></span> <span role="status">Processing…</span>';
      setTimeout(() => {
        btn.disabled = false;
        btn.className = 'btn btn-success';
        btn.textContent = '✔ Paid';
        console.log('payment finished');
      }, 2000);
    }
  </script>
</body>
</html>

Class reference

Class Effect
.spinner-border Rotating ring
.spinner-grow Pulsing (growing and fading) dot
.spinner-border-sm / .spinner-grow-sm Small version
.text-{color} Spinner colour
role="status" + .visually-hidden text Accessible loading message
aria-hidden="true" Hide a purely decorative spinner when the text already says "Loading"

Tip: Users with prefers-reduced-motion enabled get slower spinner animations from Bootstrap automatically. Still, keep spinners small and avoid putting many on one page.

Test yourself

How do you make a red spinner?

  1. Add .spinner-danger
  2. Add .text-danger
  3. Add .bg-danger
  4. Set data-bs-color="red"

Which spinner style is a pulsing dot?

  1. .spinner-border
  2. .spinner-grow
  3. .spinner-dot
  4. .spinner-pulse

Why put a .visually-hidden "Loading…" span inside a spinner?

  1. To make it spin faster
  2. So screen readers can announce what the spinner means
  3. It's required for the animation
  4. To set the spinner's size