Class 27 of 48 • Core Components

Bootstrap 5 Spinners: Border, Growing & Button Loading Indicators

Spinners are lightweight CSS-only loading indicators used during asynchronous operations (such as AJAX/fetch requests, database queries, and page transitions). Unlike legacy animated GIFs, Bootstrap spinners are resolution-independent, support any theme color, and require zero external image assets.

Bootstrap 5 Border and Growing Loading Spinners
Figure 27: CSS-only spinners: rotating .spinner-border and pulsing .spinner-grow with accessibility screen-reader text.

1. Border Spinners vs Growing Spinners

Bootstrap 5 provides two visual styles of loaders:

<!-- 1. Border Rotating Spinner -->
<div class="spinner-border text-primary" role="status">
  <span class="visually-hidden">Loading data...</span>
</div>

<!-- 2. Growing Pulsing Spinner -->
<div class="spinner-grow text-success" role="status">
  <span class="visually-hidden">Loading data...</span>
</div>

2. Button Loading States (Async Feedback)

Embed small spinners inside buttons to prevent double-clicks during form submissions:

<button class="btn btn-primary" type="button" disabled>
  <span class="spinner-border spinner-border-sm me-2" aria-hidden="true"></span>
  <span role="status">Processing Payment...</span>
</button>

Explore Related Bootstrap Tutorials & Next Steps

Strengthen your responsive web design mastery by studying these connected classes:

Progress Bars Comparison

Choose between spinner animations and percentage progress bars.

Loading Spinners in Buttons

Show spinner-border-sm inside submit buttons during API requests.

Async Modals with Spinners

Display a centered spinner while modal content loads from an API.

Screen Reader Only Text (.visually-hidden)

Include hidden text so screen readers announce loading states.

Frequently Asked Questions (FAQ) - Student & Interview Review

Spinners are purely visual animations. Sighted users understand that data is loading, but visually impaired visitors rely on screen readers to announce the hidden 'Loading...' status text.
Wrap the spinner inside a flex container: <div class='d-flex justify-content-center my-5'><div class='spinner-border text-primary'></div></div>.
Override inline width and height: style='width: 3rem; height: 3rem;'.

Next Step in Your Bootstrap Learning Path:

Advance your practical frontend engineering skills with the next topic in our synchronized curriculum.

Continue to Class 28: List Groups → Previous: ← Class 26: Progress Bars | Full Syllabus

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Reddit

You may also like this!