bootstrap
  1. bootstrap-shadow

Bootstrap Shadow

Bootstrap provides classes to add shadows to your elements. Shadows can be added to cards, buttons, and other components to give them depth and make them stand out on the page.

Syntax

To add a shadow to an element, you can use one of the following classes:

  • shadow: Adds a small shadow
  • shadow-lg: Adds a large shadow
  • shadow-none: Removes any existing shadow

Example

While shadows on components are disabled by default in Bootstrap and can be enabled via $enable-shadows.

<div class="shadow-none p-3 mb-5 bg-body-tertiary rounded">No shadow</div>
<div class="shadow-sm p-3 mb-5 bg-body-tertiary rounded">Small shadow</div>
<div class="shadow p-3 mb-5 bg-body-tertiary rounded">Regular shadow</div>
<div class="shadow-lg p-3 mb-5 bg-body-tertiary rounded">Larger shadow</div>
Try Playground

Example-2

Here is an example of how to add a shadow to a card element.

<div class="card shadow">
  <div class="card-body">
    <h5 class="card-title">Card with Shadow</h5>
    <p class="card-text">This card has a small shadow.</p>
    <a href="#" class="btn btn-primary">Learn More</a>
  </div>
</div>
Try Playground

Exaplanation

In the code above, we used the shadow class to add a small shadow to the card element. We also added some content to the card using various Bootstrap classes.

Use

  • Shadows can be used to add depth and dimension to your elements
  • Shadows can be added to cards, buttons, images, and other components
  • You can customize the size and color of your shadows using CSS variables

Important Points

  • Shadows can be added to your elements using the shadow class
  • You can control the size and color of your shadows using CSS variables
  • Shadows should be used sparingly and with purpose, as they can impact page load times and accessibility

Summary

Adding shadows to your elements can help create depth and dimension on your page. Bootstrap provides classes to easily add shadows to your components, and you can customize the size and color of your shadows using CSS variables. Consider using shadows intentionally and sparingly to enhance your design.

Published on: