0PricingLogin
Tailwind CSS Academy · Lesson

Box Shadows

Add depth with shadow-sm through shadow-2xl, use shadow-inner for inset effects, and remove shadows with shadow-none.

Shadows and Visual Depth

Box shadows create a sense of depth and elevation in flat interfaces. They make elements appear to float above the page, drawing the user's eye and indicating hierarchy. Tailwind's shadow-* utilities provide a carefully designed scale of box shadows that work harmoniously together. The values range from the barely perceptible shadow-sm to the dramatic shadow-2xl, giving you full control over elevation.

<!-- Shadow elevation scale -->
<div class="grid grid-cols-2 gap-6 p-8 bg-gray-50">
  <div class="bg-white p-4 rounded-lg shadow-sm">shadow-sm</div>
  <div class="bg-white p-4 rounded-lg shadow">shadow</div>
  <div class="bg-white p-4 rounded-lg shadow-md">shadow-md</div>
  <div class="bg-white p-4 rounded-lg shadow-lg">shadow-lg</div>
  <div class="bg-white p-4 rounded-lg shadow-xl">shadow-xl</div>
  <div class="bg-white p-4 rounded-lg shadow-2xl">shadow-2xl</div>
</div>

Shadow Utility Reference

Each shadow in Tailwind's scale is designed for a specific elevation level. shadow-sm (very subtle, 1px blur) works for inputs and small UI elements. shadow and shadow-md suit cards and dropdowns. shadow-lg is ideal for popovers and modals. shadow-xl and shadow-2xl are reserved for large modals, full-screen overlays, and dramatic hero elements that need to appear significantly elevated.

<!-- Semantic shadow usage by component type -->
<div class="space-y-4 max-w-sm">
  <input class="w-full border border-gray-300 rounded-lg px-4 py-2 shadow-sm" placeholder="Input with shadow-sm" />
  <div class="bg-white border rounded-xl p-4 shadow-md">Card with shadow-md</div>
  <div class="bg-white rounded-2xl p-6 shadow-xl">Modal panel with shadow-xl</div>
</div>

All lessons in this course

  1. Border Width and Color
  2. Border Radius and Rounded Corners
  3. Box Shadows
  4. Outline and Ring Utilities
← Back to Tailwind CSS Academy