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 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>
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>
Strengthen your responsive web design mastery by studying these connected classes:
Choose between spinner animations and percentage progress bars.
Show spinner-border-sm inside submit buttons during API requests.
Display a centered spinner while modal content loads from an API.
Include hidden text so screen readers announce loading states.
<div class='d-flex justify-content-center my-5'><div class='spinner-border text-primary'></div></div>.
style='width: 3rem; height: 3rem;'.
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