Bootstrap Shadows
Shadow utilities add box-shadow depth to elements without writing custom CSS. This lesson covers the shadow scale and where it's commonly applied.
Bootstrap Shadows Overview
Bootstrap provides four shadow utilities: shadow-sm for a subtle, barely-there shadow, shadow for a standard, noticeable shadow, shadow-lg for a more pronounced, elevated shadow, and shadow-none to explicitly remove any shadow, often used to override a shadow inherited from a component's default styling.
Shadows are most effective when used sparingly to create visual hierarchy, drawing attention to elevated elements like modals, dropdowns, and featured cards, rather than being applied uniformly across every element on a page.
| Concept | Description | Common Usage |
| shadow-sm | Subtle, small box-shadow | Cards, list items needing gentle separation |
| shadow | Standard, medium box-shadow | Buttons on hover, floating panels |
| shadow-lg | Large, pronounced box-shadow | Modals, popovers, featured elements |
| shadow-none | Removes any box-shadow | Overriding a component's default shadow |
| Hover-triggered shadows | Shadow applied via a hover state class | Interactive cards or buttons |
Bootstrap Shadows Example
<div class="card shadow-sm p-3 mb-3">Subtle shadow card</div>
<div class="card shadow p-3 mb-3">Standard shadow card</div>
<div class="card shadow-lg p-3">Pronounced shadow, feels elevated</div>
<button class="btn btn-primary shadow-none">No shadow button</button>
The three cards demonstrate the shadow scale from subtle to pronounced, useful for signaling increasing visual importance or elevation. The button example shows shadow-none explicitly removing a shadow that might otherwise be applied by custom theme styles.
Top 10 Bootstrap Shadows Examples
These are the shadow utility patterns you'll use to add depth and elevation to UI elements.
| # | Example | Syntax |
| 1 | Subtle shadow | <div class="shadow-sm">...</div> |
| 2 | Standard shadow | <div class="shadow">...</div> |
| 3 | Large shadow | <div class="shadow-lg">...</div> |
| 4 | No shadow | <div class="shadow-none">...</div> |
| 5 | Shadow on a card | <div class="card shadow-sm">...</div> |
| 6 | Shadow on an image | <img class="img-fluid rounded shadow" src="a.jpg" alt="..."> |
| 7 | Shadow on a modal dialog | <div class="modal-content shadow-lg">...</div> |
| 8 | Shadow on a floating button | <button class="btn btn-primary rounded-circle shadow">+</button> |
| 9 | Shadow on a dropdown menu | <ul class="dropdown-menu shadow">...</ul> |
| 10 | Shadow removed on hover override | <div class="shadow-sm" style="transition: box-shadow .2s;">...</div> |
Popular Real-World Bootstrap Shadows Examples
These shadow patterns commonly add depth to cards, overlays, and floating UI elements.
| Scenario | Pattern |
| Elevated pricing card | <div class="card shadow-lg border-0">Featured Plan</div> |
| Sticky navbar with subtle depth | <nav class="navbar shadow-sm">...</nav> |
| Product card hover effect | <div class="card shadow-sm" onmouseover="this.classList.add('shadow')">...</div> |
| Floating action button | <button class="btn btn-primary rounded-circle shadow-lg">+</button> |
| Search bar with soft elevation | <div class="input-group shadow-sm">...</div> |
| Modal dialog default elevation | <div class="modal-content shadow">...</div> |
| Dropdown menu elevation | <ul class="dropdown-menu shadow">...</ul> |
| Testimonial card with depth | <div class="card shadow-sm p-4">"Great service!"</div> |
Best Practices
- Use shadows to signal elevation or importance, not as a purely decorative default on every element.
- Keep shadow intensity consistent for elements of similar importance across a page.
- Use shadow-sm for everyday cards and shadow-lg only for genuinely elevated content like modals.
- Pair shadows with border-0 on cards for a cleaner, purely shadow-based separation instead of double borders.
- Use shadow-none to intentionally override a shadow inherited from a component's default class.
- Test shadows against both light and dark backgrounds, since contrast affects visibility.
- Avoid combining multiple heavy shadow utilities on nested elements, which can look muddy.
Common Mistakes
- Applying shadow-lg everywhere, flattening the visual hierarchy shadows are meant to create.
- Combining a heavy border and a heavy shadow on the same element, creating a busy, double-outlined look.
- Not testing shadows on dark backgrounds, where default shadows can become nearly invisible.
- Forgetting shadow-none when a component's default theme shadow doesn't fit a specific design.
- Using inconsistent shadow levels for visually similar cards across the same page.
- Relying on shadows alone to indicate interactivity without using cursor or hover state utilities as well.
Key Takeaways
- Bootstrap provides four shadow levels: shadow-sm, shadow, shadow-lg, and shadow-none.
- Shadows should communicate elevation and importance rather than being applied everywhere.
- shadow-none explicitly removes shadows that might come from a component's default styling.
- Consistent shadow usage across similar elements maintains a coherent visual hierarchy.
- Shadows pair well with border-0 for a softer, modern card appearance.
Pro Tip
Reserve shadow-lg for at most one or two focal elements per screen, like a featured pricing card or an open modal, so the shadow scale keeps its meaning as a signal of importance rather than becoming visual noise.