Shadow utilities add depth and focus to elements by creating shadows around them. They help make parts of a webpage stand out visually.
Shadow utilities in Bootsrap
class="shadow" class="shadow-sm" class="shadow-lg" class="shadow-none"
shadow adds a regular shadow around the element.
shadow-sm adds a smaller, lighter shadow.
shadow-lg adds a larger, stronger shadow.
shadow-none removes any shadow.
<div class="shadow p-3 mb-5 bg-white rounded">Regular shadow</div>
<button class="btn btn-primary shadow-sm">Small shadow button</button>
<div class="shadow-lg p-3 mb-5 bg-light rounded">Large shadow box</div>
<div class="shadow-none p-3 mb-5 bg-white rounded">No shadow here</div>
This page shows four elements with different shadow utilities from Bootstrap. You see how shadows change the look and feel of boxes and buttons.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Bootstrap Shadow Utilities Example</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" /> </head> <body> <main class="container py-5"> <h1 class="mb-4">Shadow Utilities Demo</h1> <div class="shadow p-3 mb-4 bg-white rounded">Regular shadow box</div> <button class="btn btn-primary shadow-sm mb-4">Small shadow button</button><br /> <div class="shadow-lg p-3 mb-4 bg-light rounded">Large shadow box</div> <div class="shadow-none p-3 mb-4 bg-white rounded border">No shadow box with border</div> </main> </body> </html>
Shadow utilities only affect the box shadow CSS property.
Use shadow-none to remove shadows if you want a clean look.
Shadows can improve accessibility by helping users see focus or active states.
Shadow utilities add shadows to elements to create depth.
Use shadow-sm, shadow, and shadow-lg for different shadow sizes.
Use shadow-none to remove shadows.
Practice
shadow-lg do to an element?Solution
Step 1: Understand shadow utility classes
Bootstrap provides shadow classes to add shadows of different sizes to elements.Step 2: Identify the effect of
Theshadow-lgshadow-lgclass adds a large shadow, making the element appear raised and deeper.Final Answer:
Adds a large shadow around the element to create depth -> Option DQuick Check:
shadow-lg means large shadow [OK]
- Confusing shadow-lg with shadow-none
- Thinking shadow-lg changes background color
- Mixing shadow-lg with shadow-sm
Solution
Step 1: Recall Bootstrap shadow removal class
Bootstrap usesshadow-noneto remove shadows from elements.Step 2: Check the options for the correct class
Onlyshadow-noneis a valid Bootstrap class to remove shadows.Final Answer:
Add class shadow-none -> Option BQuick Check:
shadow-none removes shadows [OK]
- Using non-existent classes like shadow-remove
- Confusing shadow-none with shadow-zero
- Trying to remove shadow by removing other classes
<div class="shadow-sm p-3 mb-5 bg-white rounded">Small Shadow Box</div>
Solution
Step 1: Identify the shadow class used
The classshadow-smis applied, which means a small shadow.Step 2: Understand the visual effect
The box will have a subtle, small shadow giving slight depth.Final Answer:
A box with a small shadow around it -> Option CQuick Check:
shadow-sm means small shadow [OK]
- Thinking shadow-sm means no shadow
- Confusing shadow-sm with shadow-lg
- Ignoring other classes like p-3 or rounded
shadow-none. What will happen?Solution
Step 1: Understand the effect of shadow-none
The classshadow-noneremoves any shadow from the element.Step 2: Predict the button's shadow
Even if you wanted a medium shadow, shadow-none overrides and removes it.Final Answer:
The button will have no shadow -> Option AQuick Check:
shadow-none removes shadows [OK]
- Assuming shadow-none adds a shadow
- Mixing shadow-none with shadow classes
- Not realizing class order matters
<div class="?"> <header class="?">Card Header</header> <main>Card content</main> </div>
Solution
Step 1: Apply large shadow to the card container
Useshadow-lgon thedivto add a large shadow around the card.Step 2: Remove shadow from the header
Useshadow-noneon theheaderto ensure it has no shadow inside the card.Final Answer:
div: shadow-lg, header: shadow-none -> Option AQuick Check:
Large shadow on container, none on header [OK]
- Adding shadow to both div and header causing double shadows
- Using shadow-none on div removes all shadows
- Confusing shadow and shadow-lg classes
Ready to prove it?
Pass the test and this pattern moves unknown
