상자 그림자
shadow-sm부터 shadow-2xl까지 사용해 깊이감을 추가하고, 삽입 효과에는 shadow-inner를 사용하며, shadow-none으로 그림자를 제거합니다.
상자 그림자은(는) CoddyKit의 무료 Tailwind CSS Academy 강의입니다. 이것은 4개 중 3번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Tailwind CSS Academy 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Tailwind CSS Academy 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
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>shadow-inner for Inset Shadows
shadow-inner applies an inward shadow, making an element look recessed or pressed into the surface. This is the visual opposite of the standard elevation shadows. Common uses include pressed button states, search input fields to indicate they are active, concave containers, and toggle switch tracks that should look sunken to contrast with the raised knob element.
<!-- Inset shadow for recessed / pressed effects -->
<div class="flex gap-4">
<!-- Search input looking recessed -->
<div class="flex-1 bg-gray-100 rounded-lg px-4 py-3 shadow-inner flex items-center gap-2">
<svg class="w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-4.35-4.35M17 11A6 6 0 111 11a6 6 0 0116 0z" />
</svg>
<span class="text-gray-400 text-sm">Search...</span>
</div>
<!-- Pressed button state -->
<button class="bg-gray-200 shadow-inner px-4 py-2 rounded-lg font-medium text-gray-700">
Pressed
</button>
</div>shadow-none to Remove Shadows
shadow-none removes all box shadows from an element. This is useful when you need to override an inherited shadow (for example, removing a card shadow on mobile where the card is full-width and the shadow looks awkward at the screen edges). The pattern shadow-md md:shadow-lg uses a smaller shadow on mobile and a larger one on desktop, where floating cards look better.
<!-- Remove shadow on mobile, restore on tablet+ -->
<div class="bg-white p-4 rounded-none sm:rounded-xl shadow-none sm:shadow-lg">
<h3 class="font-bold">Responsive Card Shadow</h3>
<p class="text-gray-600 mt-1">No shadow on mobile, shadow on larger screens.</p>
</div>Colored Box Shadows
Tailwind v3 introduced colored shadows: shadow-blue-500 makes the shadow appear in blue. This creates vibrant, glow-like effects popular in dark themes and landing pages. The shadow color is applied using the --tw-shadow-color CSS variable, so you still need a shadow-* size utility alongside the color class — for example, shadow-lg shadow-blue-500/50.
<!-- Colorful glow effects with colored shadows -->
<div class="flex gap-6 p-8 bg-gray-900 justify-center">
<button class="bg-blue-500 text-white px-6 py-3 rounded-xl font-bold shadow-lg shadow-blue-500/50">
Blue Glow
</button>
<button class="bg-purple-500 text-white px-6 py-3 rounded-xl font-bold shadow-lg shadow-purple-500/50">
Purple Glow
</button>
<button class="bg-pink-500 text-white px-6 py-3 rounded-xl font-bold shadow-lg shadow-pink-500/50">
Pink Glow
</button>
</div>Hover-Lifted Card Pattern
One of the most common interactive patterns is the hover-lift effect: a card starts with a subtle shadow and gains a deeper shadow on hover, creating the illusion of lifting. Combine shadow-md hover:shadow-xl with transition-shadow duration-300 for a smooth animation. This signals to users that the card is interactive and makes dashboards and product listings feel polished.
<!-- Interactive card with hover-lift effect -->
<div class="grid grid-cols-3 gap-6 p-6">
<div class="bg-white rounded-xl p-5 shadow-md hover:shadow-xl transition-shadow duration-300 cursor-pointer">
<div class="w-10 h-10 bg-blue-100 rounded-lg flex items-center justify-center mb-3">
<span class="text-blue-600">📊</span>
</div>
<h3 class="font-bold">Analytics</h3>
<p class="text-sm text-gray-500 mt-1">View your stats</p>
</div>
</div>Drop Shadow vs Box Shadow
Tailwind provides both box shadows (shadow-*) and drop shadows (drop-shadow-*). The key difference: shadow-* applies to the element's bounding box (rectangle), while drop-shadow-* is a CSS filter that follows the element's actual visible shape, including transparent areas. drop-shadow-* is ideal for irregularly shaped elements like PNG icons with transparent backgrounds.
<!-- Box shadow (rectangular) vs drop shadow (shape-aware) -->
<div class="flex gap-8 p-6 items-center">
<!-- Box shadow on transparent PNG -->
<div>
<p class="text-sm mb-2">shadow-lg (rectangular)</p>
<svg class="w-16 h-16 text-blue-500 shadow-lg" viewBox="0 0 24 24" fill="currentColor">
<path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5" />
</svg>
</div>
<!-- Drop shadow follows shape -->
<div>
<p class="text-sm mb-2">drop-shadow-lg (shape-aware)</p>
<svg class="w-16 h-16 text-blue-500 drop-shadow-lg" viewBox="0 0 24 24" fill="currentColor">
<path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5" />
</svg>
</div>
</div>Layering Multiple Shadows
CSS supports multiple shadows on one element, but Tailwind's built-in utilities provide only one shadow per class. For multiple layers, extend Tailwind's theme in tailwind.config.js with a custom shadow that includes a comma-separated list of shadow definitions. This allows sophisticated layering like a material design elevation effect or a subtle outer glow combined with an inner definition shadow.
/* In tailwind.config.js */
module.exports = {
theme: {
extend: {
boxShadow: {
/* Layered: outer glow + standard shadow */
'glow-blue': '0 0 20px rgba(59,130,246,0.5), 0 4px 6px rgba(0,0,0,0.1)',
/* Material elevation --*/
'material': '0 2px 1px rgba(0,0,0,0.05), 0 4px 8px rgba(0,0,0,0.1), 0 16px 24px rgba(0,0,0,0.06)',
}
}
}
}Shadows in Dark Mode
Shadows become less visible on dark backgrounds because they typically use translucent black. In dark mode, Tailwind colored shadows — or lighter shadow tones — maintain visibility. A common pattern is shadow-gray-700/50 in dark mode to create a visible shadow against a dark surface. Alternatively, use borders instead of shadows on dark backgrounds since borders remain visible regardless of background lightness.
<!-- Shadow strategies for dark mode -->
<div class="bg-gray-900 p-8 rounded-xl space-y-4">
<!-- Standard shadow (invisible on dark bg) -->
<div class="bg-gray-800 p-4 rounded-lg shadow-xl">
Shadow barely visible
</div>
<!-- Colored shadow for dark mode -->
<div class="bg-gray-800 p-4 rounded-lg shadow-lg shadow-gray-700/70">
Shadow visible with colored tint
</div>
<!-- Border instead of shadow on dark bg -->
<div class="bg-gray-800 border border-gray-700 p-4 rounded-lg">
Border as separator on dark backgrounds
</div>
</div>Focus Shadow for Accessibility
Visible focus indicators are required by WCAG 2.1 AA accessibility standards. While Tailwind's ring-* utilities are the preferred modern approach, box shadows can also serve as focus indicators. The pattern focus:shadow-[0_0_0_3px_rgba(59,130,246,0.5)] creates a blue halo — essentially what ring-2 ring-blue-500 does, but using the shadow property for legacy browser compatibility.
<!-- Accessible focus indicators using shadow and ring -->
<div class="flex gap-4 flex-wrap">
<!-- Using ring (preferred modern approach) -->
<button class="bg-blue-500 text-white px-4 py-2 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">
Ring Focus
</button>
<!-- Using shadow for legacy support -->
<button class="bg-purple-500 text-white px-4 py-2 rounded-lg focus:outline-none focus:shadow-[0_0_0_3px_rgba(168,85,247,0.5)]">
Shadow Focus
</button>
</div>Complete Shadow Hierarchy
In a real UI, consistent shadow assignment creates a clear visual hierarchy. Use a systematic approach: shadow-sm for subtle borders on inputs, shadow-md for content cards, shadow-lg for dropdown menus, shadow-xl for side drawers, and shadow-2xl for modal dialogs. This hierarchy helps users understand spatial relationships and which elements are contextual versus primary.
<!-- Dashboard showing shadow hierarchy -->
<div class="bg-gray-100 p-6 space-y-4">
<!-- Page-level card: shadow-md -->
<div class="bg-white rounded-xl shadow-md p-5">
<h2 class="font-bold text-lg">Analytics Overview</h2>
<!-- Inline component: shadow-sm -->
<div class="mt-4 grid grid-cols-3 gap-3">
<div class="bg-gray-50 rounded-lg p-3 shadow-sm text-center">
<div class="text-2xl font-bold text-blue-600">142</div>
<div class="text-xs text-gray-500">Users</div>
</div>
<div class="bg-gray-50 rounded-lg p-3 shadow-sm text-center">
<div class="text-2xl font-bold text-green-600">94%</div>
<div class="text-xs text-gray-500">Uptime</div>
</div>
<div class="bg-gray-50 rounded-lg p-3 shadow-sm text-center">
<div class="text-2xl font-bold text-purple-600">38</div>
<div class="text-xs text-gray-500">Issues</div>
</div>
</div>
</div>
</div>Quick Check
Test your understanding of Tailwind CSS Mastery concepts from this lesson.
Lesson Recap
In this lesson you learned: shadow-sm through shadow-2xl provide an elevation scale for depth, shadow-inner creates a recessed appearance for pressed states and search inputs, and colored shadows like shadow-lg shadow-blue-500/50 create glow effects for dark themes. Next up we explore outline and ring utilities for accessible focus indicators.
자주 묻는 질문
“상자 그림자” 강의는 무료인가요?
네 — “상자 그림자” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Tailwind CSS Academy 강의 전체를 잠금 해제할 수 있습니다. Tailwind CSS Academy 강의에는 총 4개의 강의가 포함되어 있습니다.
“상자 그림자”에서 뭘 배우나요?
shadow-sm부터 shadow-2xl까지 사용해 깊이감을 추가하고, 삽입 효과에는 shadow-inner를 사용하며, shadow-none으로 그림자를 제거합니다. 브라우저에서 직접 실행하는 실습 코드로 Tailwind CSS Academy을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Tailwind CSS Academy을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Tailwind CSS Academy은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 3번째 강의입니다.
“상자 그림자” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Tailwind CSS Academy 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Tailwind CSS Academy 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.