Check out our free templates made with AI and polished to perfection in Windframe

Get now
Last updated: 6 August 2025

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.


Tailwind 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. Useful for giving depth, separating UI layers, and improving visual hierarchy.

How to apply 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

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>

Preview

card

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).

Arbitrary Value Usage

You’re not limited to Tailwind’s predefined shadow utilities like shadow-md or shadow-xl. With arbitrary value support, you can use custom box-shadow values inline using square brackets.

html
<div class="shadow-[0_0_15px_3px_rgba(0,255,0,0.5)] p-6 rounded-lg bg-white">
Custom green glow
</div>

Preview

Custom green glow

Hover & Focus Interaction

You can apply shadows dynamically on interaction states:

html
<!-- Shadow appears on hover -->
<button class="bg-blue-500 text-white px-4 py-2 rounded hover:shadow-lg">
Hover Me
</button>

Preview

Tailwind also includes focus:shadow-*, hover:shadow-*, and you can combine them with transitions for smooth animations.

Customization in tailwind.config.js

You can define custom shadows under theme.extend.boxShadow:

js
// tailwind.config.js
module.exports = {
theme: {
extend: {
boxShadow: {
'card': '0_2px_12px_rgba(0,0,0,0.1)',
'deep': '0_8px_30px_rgba(0,0,0,0.2)',
},
},
},
}

Usage:

html
<div class="flex justify-between items-center">
<div class="shadow-card bg-white p-2 ....">Custom Card Shadow</div>
<div class="shadow-deep bg-white p-2...">Deep Shadow UI</div>
</div>

Preview

Custom Card Shadow
Deep Shadow UI

🌟 Real UI Component Examples

Product Card with Interactive Shadow

html
<div class="max-w-sm bg-white rounded-xl overflow-hidden shadow hover:shadow-xl transition-shadow duration-300">
<img src="https://via.placeholder.com/400x200" alt="Product" class="w-full">
<div class="p-4">
<h2 class="text-lg font-semibold">Smart Watch</h2>
<p class="text-gray-500 text-sm mt-1">Fitness tracking, alerts, and more.</p>
<button class="mt-4 bg-blue-600 text-white px-4 py-2 rounded hover:shadow-md">
Buy Now
</button>
</div>
</div>

Preview

Product

Smart Watch

Fitness tracking, alerts, and more.

📝 Example: Notification Toast with Inner Shadow

html
<div class="bg-green-500 shadow-inner border rounded p-4 max-w-sm">
<p class="text-sm text-white font-bold">💡 Tip: Use `ctrl + s` to save instantly.</p>
</div>

Preview

💡 Tip: Use ctrl + s to save instantly.

✅ Best Practices

  • Use subtle shadows (shadow-sm, shadow) for flat designs.

  • Reserve large shadows (shadow-xl, 2xl) for modals, overlays, or floating panels.

  • Avoid overusing shadows — too many can feel heavy or chaotic.

  • Combine with border, padding, and contrast to enhance clarity.

  • Use transition-shadow for smoother interactivity.

Tailwind Box-shadow Class Table

ClassProperties
shadow-smbox-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
shadow box-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;

✨ What's Next?

Now that you’ve mastered Tailwind Box Shadow, try experimenting with:

Windframe Tailwind blocks

Content

Windframe is an AI visual editor for rapidly building stunning web UIs & websites

Start building stunning web UIs & websites! 

Build from scratch or select prebuilt tailwind templates