🧼 Bootstrap 5 – Placeholders: Simulate Content While Loading
🧲 Introduction – What Are Placeholders in Bootstrap 5?
Placeholders in Bootstrap 5 are utility classes used to show loading skeletons or fake content blocks while the real data is being fetched. They help maintain UI layout and improve user perception of performance by indicating that something is loading behind the scenes.
🎯 In this guide, you’ll learn:
- How to create text, image, and block placeholders
- Use animations for shimmer effects
- Match placeholder styles with components like cards and tables
- Best practices for responsive and accessible placeholders
✅ Example 1 – Basic Text Placeholder
<p>
<span class="placeholder col-6"></span>
</p>
🔍 Explanation:
| Class | Purpose |
|---|---|
.placeholder | Base class for all placeholders |
.col-6 | Sets width to 50% using Bootstrap grid |
✅ Example 2 – Animated Placeholders
<p class="placeholder-glow">
<span class="placeholder col-6"></span>
</p>
<p class="placeholder-wave">
<span class="placeholder col-6"></span>
</p>
| Class | Animation Style |
|---|---|
.placeholder-glow | Soft fade-in animation |
.placeholder-wave | Ripple or shimmer loading animation |
✅ Example 3 – Placeholder for Buttons
<a class="btn btn-primary disabled placeholder col-4" aria-disabled="true"></a>
- Use
.placeholderon buttons with.disabledto simulate UI buttons during loading.
✅ Example 4 – Placeholder Card Example
<div class="card" aria-hidden="true">
<img src="..." class="card-img-top" alt="..." />
<div class="card-body">
<h5 class="card-title placeholder-glow">
<span class="placeholder col-6"></span>
</h5>
<p class="card-text placeholder-glow">
<span class="placeholder col-7"></span>
<span class="placeholder col-4"></span>
<span class="placeholder col-4"></span>
<span class="placeholder col-6"></span>
<span class="placeholder col-8"></span>
</p>
<a class="btn btn-primary disabled placeholder col-6" aria-disabled="true"></a>
</div>
</div>
🔍 Use Case:
- Create complete loading cards before data (e.g., user profiles, product info) is ready.
- Use
aria-hidden="true"to skip placeholder content for screen readers.
✅ Placeholder Colors
Use Bootstrap’s background utility classes:
<span class="placeholder col-12 bg-primary"></span>
<span class="placeholder col-12 bg-success"></span>
<span class="placeholder col-12 bg-warning"></span>
| Class | Color |
|---|---|
bg-primary | Blue |
bg-success | Green |
bg-warning | Yellow |
🛠️ Best Practices for Placeholders
| Tip | Why It Helps |
|---|---|
| Use same layout as real content | Prevents layout shifts and jank |
| Pair with animations | Gives visual feedback during loading |
Add aria-hidden="true" | Hides placeholder from screen readers |
| Use matching component widths | Ensures alignment when real data loads in |
| Replace with real content ASAP | Avoid excessive skeleton delays |
📌 Summary – Simulate Content Load with Bootstrap Placeholders
Bootstrap 5 placeholders are modern skeleton screens used to indicate that content is loading. They offer visual feedback and maintain layout structure, enhancing UX on slower connections or dynamic content apps.
🔍 Key Takeaways:
- Use
.placeholderclasses to show loading UI blocks - Animate with
.placeholder-glowor.placeholder-wave - Combine with
.disabledfor buttons or cards - Hide from screen readers with
aria-hidden="true" - Control widths using Bootstrap grid classes (e.g.,
col-6,col-4)
⚙️ Ideal for loading dashboards, cards, tables, and interactive content.
❓ FAQs – Bootstrap 5 Placeholders
❓ What’s the difference between glow and wave animations?
✅ .placeholder-glow fades softly, while .placeholder-wave shows a ripple/shimmer effect.
❓ Can placeholders be used in buttons or navs?
✅ Yes. Apply .placeholder with .disabled and appropriate sizing (col-*).
❓ Are placeholders responsive?
✅ Yes. Use Bootstrap’s grid classes to adjust width across breakpoints (e.g., col-sm-4, col-md-6).
❓ Do placeholders affect accessibility?
✅ Use aria-hidden="true" so screen readers skip them during loading.
Share Now :
