All Posts

How to use shadows in Tailwind CSS

Shadows are one of those design elements that seem simple but make a huge difference in how your interface feels. They add depth, create visual hierarchy, and help important elements stand out.

Without shadows, everything looks flat and stuck to the page. With them, you get that nice layered effect that makes interfaces feel more polished and professional.

Tailwind CSS gives you a bunch of shadow utilities right out of the box, and they're super easy to use. Let me show you how to work with them.

Basic shadow utilities

Tailwind comes with predefined shadow sizes that range from super subtle to pretty dramatic. The classes go from shadow-2xs (barely noticeable) all the way up to shadow-2xl (very prominent).

Here's the basic scale:

  • shadow-2xs and shadow-xs - Perfect for subtle hints of depth
  • shadow-sm and shadow-md - Your everyday shadows for cards and containers
  • shadow-lg and shadow-xl - When you want elements to really float
  • shadow-2xl - The big one for modals and overlays

You can also use shadow-none to remove shadows completely, which is handy when you need to override a shadow at different breakpoints.

<div class='max-w-4xl mx-auto space-y-6 p-6 bg-gray-50'>
  <div class='bg-white rounded-lg p-6 shadow-sm'>
    <p class='text-gray-800 font-medium mb-1'>shadow-sm</p>
    <p class='text-gray-600 text-sm'>Subtle shadow perfect for cards and containers that need just a hint of depth.</p>
  </div>

  <div class='bg-white rounded-lg p-6 shadow-md'>
    <p class='text-gray-800 font-medium mb-1'>shadow-md</p>
    <p class='text-gray-600 text-sm'>Medium shadow that works great for most UI elements. Nice balance.</p>
  </div>

  <div class='bg-white rounded-lg p-6 shadow-lg'>
    <p class='text-gray-800 font-medium mb-1'>shadow-lg</p>
    <p class='text-gray-600 text-sm'>Large shadow makes elements really float off the page.</p>
  </div>

  <div class='bg-white rounded-lg p-6 shadow-xl'>
    <p class='text-gray-800 font-medium mb-1'>shadow-xl</p>
    <p class='text-gray-600 text-sm'>Extra large shadow for prominent elements.</p>
  </div>

  <div class='bg-white rounded-lg p-6 shadow-2xl'>
    <p class='text-gray-800 font-medium mb-1'>shadow-2xl</p>
    <p class='text-gray-600 text-sm'>Maximum shadow effect for modals and overlays.</p>
  </div>
</div>

The nice thing about these predefined sizes is they're designed to work well together. You can use smaller shadows for nested elements and larger ones for top-level components without things looking weird.

Adding color to your shadows

By default, Tailwind shadows are black with some transparency. But you can add color to them, which opens up some really cool design possibilities.

The syntax is simple: shadow-[color]-[shade]. So if you want a blue shadow, you'd use something like shadow-blue-500. If you want it lighter, go with shadow-blue-300. Want it darker? Try shadow-blue-700.

You can use any color from Tailwind's palette - red, purple, green, pink, whatever fits your design. And the best part? You can combine the color with the size utilities.

Here's something neat. You can also control the opacity using the slash modifier like shadow-blue-500/50. That gives you a blue shadow at 50% opacity. Super useful for fine-tuning the effect.

<div class='max-w-4xl mx-auto grid grid-cols-1 md:grid-cols-2 gap-6 p-6 bg-gray-50'>
  <div class='bg-white rounded-lg p-6 shadow-lg shadow-blue-500/50'>
    <div class='size-12 bg-blue-500 rounded-lg mb-3'></div>
    <p class='text-gray-800 font-medium mb-1'>Blue Shadow</p>
    <p class='text-gray-600 text-sm'>shadow-lg shadow-blue-500/50</p>
  </div>

  <div class='bg-white rounded-lg p-6 shadow-lg shadow-purple-500/50'>
    <div class='size-12 bg-purple-500 rounded-lg mb-3'></div>
    <p class='text-gray-800 font-medium mb-1'>Purple Shadow</p>
    <p class='text-gray-600 text-sm'>shadow-lg shadow-purple-500/50</p>
  </div>

  <div class='bg-white rounded-lg p-6 shadow-lg shadow-pink-500/50'>
    <div class='size-12 bg-pink-500 rounded-lg mb-3'></div>
    <p class='text-gray-800 font-medium mb-1'>Pink Shadow</p>
    <p class='text-gray-600 text-sm'>shadow-lg shadow-pink-500/50</p>
  </div>

  <div class='bg-white rounded-lg p-6 shadow-lg shadow-green-500/50'>
    <div class='size-12 bg-green-500 rounded-lg mb-3'></div>
    <p class='text-gray-800 font-medium mb-1'>Green Shadow</p>
    <p class='text-gray-600 text-sm'>shadow-lg shadow-green-500/50</p>
  </div>

  <div class='bg-white rounded-lg p-6 shadow-lg shadow-orange-500/50'>
    <div class='size-12 bg-orange-500 rounded-lg mb-3'></div>
    <p class='text-gray-800 font-medium mb-1'>Orange Shadow</p>
    <p class='text-gray-600 text-sm'>shadow-lg shadow-orange-500/50</p>
  </div>

  <div class='bg-white rounded-lg p-6 shadow-lg shadow-cyan-500/50'>
    <div class='size-12 bg-cyan-500 rounded-lg mb-3'></div>
    <p class='text-gray-800 font-medium mb-1'>Cyan Shadow</p>
    <p class='text-gray-600 text-sm'>shadow-lg shadow-cyan-500/50</p>
  </div>
</div>

Colored shadows work best when they match or complement the element's main color. A blue button with a subtle blue shadow looks way more cohesive than a blue button with a gray shadow.

Box shadow vs drop shadow

Tailwind actually has two types of shadow utilities, and knowing when to use each one matters.

The shadow-* utilities we've been using? Those create box shadows. They work great for regular elements like divs, cards, and buttons. Box shadows create a rectangular shadow around the element's box.

But then there's drop-shadow-* utilities. These are different because they follow the actual shape of the element. This is super useful for SVG icons, images with transparency, or text elements.

Think of it this way: box shadow creates a shadow around the box, drop shadow creates a shadow around the actual visible content.

<div class='max-w-4xl mx-auto p-6 bg-gray-50'>
  <div class='grid grid-cols-1 md:grid-cols-2 gap-8'>
    <div class='bg-white rounded-lg p-6 text-center'>
      <p class='text-gray-800 font-medium mb-4'>Box Shadow (shadow-xl)</p>
      <div class='flex justify-center mb-3'>
        <div class='bg-gradient-to-br from-blue-500 to-purple-500 rounded-full size-24 shadow-xl'></div>
      </div>
      <p class='text-gray-600 text-sm'>Shadow creates a rectangular box around the element</p>
    </div>

    <div class='bg-white rounded-lg p-6 text-center'>
      <p class='text-gray-800 font-medium mb-4'>Drop Shadow (drop-shadow-xl)</p>
      <div class='flex justify-center mb-3'>
        <div class='bg-gradient-to-br from-blue-500 to-purple-500 rounded-full size-24 drop-shadow-xl'></div>
      </div>
      <p class='text-gray-600 text-sm'>Shadow follows the actual shape of the element</p>
    </div>
  </div>

  <div class='mt-8 bg-white rounded-lg p-6'>
    <p class='text-gray-800 font-medium mb-4 text-center'>Drop Shadow with SVG Icons</p>
    <div class='flex justify-center gap-6'>
      <svg class='drop-shadow-lg' width='48' height='48' viewBox='0 0 24 24' fill='none'>
        <path d='M12 2L2 7L12 12L22 7L12 2Z' fill='#3b82f6'/>
        <path d='M2 17L12 22L22 17' stroke='#3b82f6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/>
        <path d='M2 12L12 17L22 12' stroke='#3b82f6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/>
      </svg>
      <svg class='drop-shadow-lg' width='48' height='48' viewBox='0 0 24 24' fill='none'>
        <path d='M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z' fill='#ef4444'/>
      </svg>
      <svg class='drop-shadow-lg' width='48' height='48' viewBox='0 0 24 24' fill='none'>
        <circle cx='12' cy='12' r='10' fill='#10b981'/>
        <path d='M9 12l2 2 4-4' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/>
      </svg>
    </div>
  </div>
</div>

For most everyday use cases - cards, buttons, containers - stick with box shadow. Save drop shadow for when you're working with SVG, transparent images, or need the shadow to follow irregular shapes.

Creating custom shadow values

Sometimes the predefined shadows don't quite hit the mark for what you need. Good news: Tailwind lets you create custom shadows using arbitrary values.

The syntax uses square brackets: shadow-[your-custom-value]. Inside those brackets, you write standard CSS box-shadow values.

Want a really tight shadow? Try shadow-[0_2px_4px_rgba(0,0,0,0.3)]. Need an inner glow effect? Use shadow-[inset_0_0_10px_rgba(59,130,246,0.5)]. You can get creative here.

One popular effect is the neumorphic look, where shadows give elements a soft, raised appearance. Or you can stack multiple shadows by separating them with commas to create unique depth effects.

<div class='max-w-4xl mx-auto space-y-6 p-6 bg-gray-50'>
  <div class='bg-white rounded-lg p-6 shadow-[0_2px_8px_rgba(0,0,0,0.15)]'>
    <p class='text-gray-800 font-medium mb-1'>Tight Custom Shadow</p>
    <p class='text-gray-600 text-sm mb-2'>shadow-[0_2px_8px_rgba(0,0,0,0.15)]</p>
    <p class='text-gray-500 text-xs'>Perfect for subtle depth without too much drama.</p>
  </div>

  <div class='bg-gray-100 rounded-lg p-6 shadow-[6px_6px_12px_#bebebe,-6px_-6px_12px_#ffffff]'>
    <p class='text-gray-800 font-medium mb-1'>Neumorphic Effect</p>
    <p class='text-gray-600 text-sm mb-2'>shadow-[6px_6px_12px_#bebebe,-6px_-6px_12px_#ffffff]</p>
    <p class='text-gray-500 text-xs'>That soft, embossed look that was everywhere a few years back.</p>
  </div>

  <div class='bg-white rounded-lg p-6 shadow-[inset_0_0_20px_rgba(59,130,246,0.3)]'>
    <p class='text-gray-800 font-medium mb-1'>Inner Glow</p>
    <p class='text-gray-600 text-sm mb-2'>shadow-[inset_0_0_20px_rgba(59,130,246,0.3)]</p>
    <p class='text-gray-500 text-xs'>Creates a glowing effect from inside the element.</p>
  </div>

  <div class='bg-white rounded-lg p-6 shadow-[0_0_0_3px_rgba(59,130,246,0.1),0_4px_6px_rgba(0,0,0,0.1)]'>
    <p class='text-gray-800 font-medium mb-1'>Layered Shadows</p>
    <p class='text-gray-600 text-sm mb-2'>shadow-[0_0_0_3px_rgba(59,130,246,0.1),0_4px_6px_rgba(0,0,0,0.1)]</p>
    <p class='text-gray-500 text-xs'>Combining multiple shadows creates interesting depth.</p>
  </div>
</div>

Just remember that arbitrary values can get messy in your markup. If you find yourself using the same custom shadow in multiple places, it might be worth adding it to your Tailwind config instead.

Real-world shadow examples

Let me show you some practical examples of how shadows work in actual UI components. These are the kind of things you'll build all the time.

First up: cards. A simple card with shadow-md gives it that nice lifted feel without being too dramatic. Perfect for blog posts, product listings, or dashboard widgets.

Buttons benefit from shadows too. A subtle shadow-sm on a button makes it look clickable. Add hover:shadow-lg and you get that nice interactive lift effect when someone hovers over it.

Dropdown menus and modals need stronger shadows to indicate they're floating above other content. shadow-xl or shadow-2xl work great here because they really separate the element from the page.

<div class='max-w-5xl mx-auto p-6 space-y-8 bg-gray-50'>
  <!-- Cards Grid -->
  <div>
    <h3 class='text-lg font-semibold text-gray-800 mb-4'>Product Cards</h3>
    <div class='grid grid-cols-1 md:grid-cols-3 gap-6'>
      <div class='bg-white rounded-lg shadow-md hover:shadow-xl transition-shadow duration-300 p-6'>
        <div class='bg-gradient-to-br from-blue-400 to-blue-600 rounded-lg h-32 mb-4'></div>
        <h4 class='font-semibold text-gray-800 mb-2'>Blue Widget</h4>
        <p class='text-gray-600 text-sm mb-3'>Perfect for your dashboard</p>
        <p class='text-lg font-bold text-blue-600'>$29.99</p>
        <button class='mt-3 w-full bg-blue-500 text-white px-4 py-2 rounded shadow-sm hover:shadow-md transition-shadow'>Add to Cart</button>
      </div>

      <div class='bg-white rounded-lg shadow-md hover:shadow-xl transition-shadow duration-300 p-6'>
        <div class='bg-gradient-to-br from-purple-400 to-purple-600 rounded-lg h-32 mb-4'></div>
        <h4 class='font-semibold text-gray-800 mb-2'>Purple Plugin</h4>
        <p class='text-gray-600 text-sm mb-3'>Boost your productivity</p>
        <p class='text-lg font-bold text-purple-600'>$39.99</p>
        <button class='mt-3 w-full bg-purple-500 text-white px-4 py-2 rounded shadow-sm hover:shadow-md transition-shadow'>Add to Cart</button>
      </div>

      <div class='bg-white rounded-lg shadow-md hover:shadow-xl transition-shadow duration-300 p-6'>
        <div class='bg-gradient-to-br from-green-400 to-green-600 rounded-lg h-32 mb-4'></div>
        <h4 class='font-semibold text-gray-800 mb-2'>Green Gadget</h4>
        <p class='text-gray-600 text-sm mb-3'>Essential for developers</p>
        <p class='text-lg font-bold text-green-600'>$19.99</p>
        <button class='mt-3 w-full bg-green-500 text-white px-4 py-2 rounded shadow-sm hover:shadow-md transition-shadow'>Add to Cart</button>
      </div>
    </div>
  </div>

  <!-- Dropdown Menu -->
  <div>
    <h3 class='text-lg font-semibold text-gray-800 mb-4'>Dropdown Menu</h3>
    <div class='relative inline-block'>
      <button class='bg-white border border-gray-300 px-4 py-2 rounded shadow-sm'>
        Options
      </button>
      <div class='absolute left-0 mt-2 bg-white rounded-lg shadow-xl border border-gray-200 min-w-[200px] py-2'>
        <a href='#' class='block px-4 py-2 text-gray-700 hover:bg-gray-100'>Profile Settings</a>
        <a href='#' class='block px-4 py-2 text-gray-700 hover:bg-gray-100'>Billing</a>
        <a href='#' class='block px-4 py-2 text-gray-700 hover:bg-gray-100'>Team Members</a>
        <hr class='my-2 border-gray-200'>
        <a href='#' class='block px-4 py-2 text-red-600 hover:bg-gray-100'>Sign Out</a>
      </div>
    </div>
  </div>

  <!-- Notification Card -->
  <div>
    <h3 class='text-lg font-semibold text-gray-800 mb-4'>Notification Toast</h3>
    <div class='bg-white rounded-lg shadow-lg border-l-4 border-green-500 p-4 max-w-md'>
      <div class='flex items-start'>
        <div class='flex-shrink-0 bg-green-500 rounded-full size-8 flex items-center justify-center text-white font-bold'>✓</div>
        <div class='ml-3'>
          <p class='font-semibold text-gray-800'>Success!</p>
          <p class='text-sm text-gray-600 mt-1'>Your changes have been saved successfully.</p>
        </div>
      </div>
    </div>
  </div>
</div>

The key to using shadows well is subtlety. Start with smaller shadows and only go bigger when you really need to emphasize something. Too many strong shadows make your interface feel chaotic.

And don't forget about hover states. Adding transition-shadow with a shadow change on hover gives your UI that polished, interactive feel that users expect.

That's everything you need to know about working with shadows in Tailwind CSS. From basic utilities to custom effects, you now have the tools to add depth and polish to your designs.

Shadows might seem like a small detail, but they make a big difference in how professional your interfaces look. Start with the basics, experiment with colors, and don't be afraid to create custom values when you need something specific.

Now go make something that looks awesome!

Other posts you might like...

See more

Subscribe to our newsletter

Get notified when we add new templates, components, and more!

Thanks for subscribing!
Please check your email to confirm your subscription.

WindyBase Make development a breeze

WindyBase is a weekly curated Tailwind CSS template and tool directory built for the modern developer.

© 2026 WindyBase. All rights reserved.