Tailwind CSS Box Shadow

The tailwind box shadow utility class allows you to add shadows to elements, giving them a three-dimensional effect and enhancing their visual appearance. With Tailwind's box-shadow class, you can easily customize and apply different types of shadows to elements.

Applying Tailwind Box Shadow

To apply a tailwind box shadow to an element, you can use the shadow-{value} utility class, where {value} represents the desired shadow style. Here are the available options:

  • shadow-sm: Applies a small shadow.
  • shadow: Applies a medium shadow (default).
  • shadow-md: Applies a medium shadow.
  • shadow-lg: Applies a large shadow.
  • shadow-xl: Applies an extra-large shadow.
  • shadow-2xl: Applies a 2x extra-large shadow.
  • shadow-inner: Applies an inset shadow.
html
<div class="flex">
<div class="shadow-md">Item 1</div>
<div class="shadow-xl">Item 2</div>
<div class="shadow-2xl">Item 3</div>
</div>

Preview

Item 1
Item 2
Item 3

Customizing Tailwind Box Shadow

Tailwind CSS also provides utility classes to customize the color and size of the box shadow. You can use the following utility classes in conjunction with the shadow class:

  • shadow-{color}: Applies a custom color to the shadow. For example, shadow-red-500 applies a red-colored shadow.
  • shadow-{size}: Applies a custom size to the shadow. For example, shadow-offset-2 moves the shadow 2 units from its default position.
html
<div>
<div class="shadow-xl shadow-blue-500">
Item 1
</div>
</div>

Preview

Item 1

Responsive Tailwind Box Shadow

Tailwind CSS allows you to apply box shadow classes responsively at different breakpoints. To use responsive tailwind box shadow classes, you can append the breakpoint prefix to the utility class. For example, md:shadow-lg applies a large shadow starting from the medium breakpoint and above.

html
<div class="shadow-lg md:shadow-xl">
<!-- Content here -->
</div>

In the above example, the shadow applied to the <div> element is large by default (shadow-lg), but starting from the medium breakpoint and above, it changes to an extra-large shadow (md:shadow-xl).

Tailwind Box-shadow Class Table

ClassProperties
shadow-smbox-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
shadowbox-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
shadow-mdbox-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
shadow-lgbox-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
shadow-xlbox-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
shadow-2xlbox-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
shadow-innerbox-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.05);
shadow-nonebox-shadow: 0 0 #0000;

Windframe Tailwind blocks

Content

Build modern projects using Bootstrap 5 and Contrast

Trying to create components and pages for a web app or website from scratch while maintaining a modern User interface can be very tedious. This is why we created Contrast, to help drastically reduce the amount of time we spend doing that. so we can focus on building some other aspects of the project.

Contrast Bootstrap PRO consists of a Premium UI Kit Library featuring over 10000+ component variants. Which even comes bundled together with its own admin template comprising of 5 admin dashboards and 23+ additional admin and multipurpose pages for building almost any type of website or web app.
See a demo and learn more about Contrast Bootstrap Pro by clicking here.

ad-banner