CSS Box Shadow Examples
24 box shadows tuned by hand, from a 1px lift to layered elevation and hard brutalist offsets. Click any example to copy its CSS.
By Mohamed Farhan · Updated Oct 19, 2026
All shadows as code
0 1px 2px rgba(16, 24, 40, 0.06)0 1px 3px rgba(16, 24, 40, 0.1), 0 1px 2px rgba(16, 24, 40, 0.06)0 1px 0 rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.2)0 2px 4px -1px rgba(20, 20, 20, 0.12)0 4px 8px -2px rgba(16, 24, 40, 0.1), 0 2px 4px -2px rgba(16, 24, 40, 0.06)0 12px 24px -6px rgba(16, 24, 40, 0.18), 0 4px 8px -4px rgba(16, 24, 40, 0.08)0 1px 1px rgba(0,0,0,0.04), 0 2px 2px rgba(0,0,0,0.04), 0 4px 4px rgba(0,0,0,0.04), 0 8px 8px rgba(0,0,0,0.04)0 24px 32px -16px rgba(16, 24, 40, 0.18)inset 0 1px 2px rgba(0, 0, 0, 0.08)inset 0 2px 4px rgba(0, 0, 0, 0.12)0 0 0 3px rgba(37, 99, 235, 0.35)0 0 0 2px #ffffff, 0 0 0 4px #1d4ed80 0 0 1px rgba(16, 24, 40, 0.1)0 4px 10px -4px rgba(22, 101, 52, 0.35)0 4px 10px -4px rgba(29, 78, 216, 0.35)0 6px 12px -6px rgba(154, 52, 18, 0.35)0 2px 0 rgba(0, 0, 0, 0.1)4px 4px 0 #1111113px 3px 0 rgba(17, 17, 17, 0.2)inset 0 1px 0 rgba(255, 255, 255, 0.6)0 0 0 1px rgba(255, 255, 255, 0.06), 0 8px 16px -8px rgba(0, 0, 0, 0.6)0 6px 16px -8px rgba(16, 24, 40, 0.25), 0 0 0 1px rgba(16, 24, 40, 0.06)0 1px 2px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.04)6px 6px 12px rgba(163, 177, 198, 0.6), -6px -6px 12px rgba(255, 255, 255, 0.9)How to make shadows look real
Real shadows come from one light source, usually above. That means a small downward offset, almost no sideways offset, and a negative spread so the shadow does not peek out around the edges.
Tint shadows to the surface or the element's own color instead of using pure black, and stack two or three layers with increasing blur for a natural falloff. If you can see the outline of a box behind the element, the blur is too tight for the spread.
// tailwind.config.js
theme: {
extend: {
boxShadow: {
card: "0 1px 3px rgba(16, 24, 40, 0.1), 0 1px 2px rgba(16, 24, 40, 0.06)",
panel: "0 4px 8px -2px rgba(16, 24, 40, 0.1), 0 2px 4px -2px rgba(16, 24, 40, 0.06)",
dialog: "0 12px 24px -6px rgba(16, 24, 40, 0.18), 0 4px 8px -4px rgba(16, 24, 40, 0.08)",
},
},
}How the box-shadow property works
The box-shadow property takes up to five values: horizontal offset, vertical offset, blur radius, spread radius and color, plus an optional inset keyword. For example, box-shadow: 0 4px 8px -2px rgba(16, 24, 40, 0.1) moves the shadow 4px down, blurs it over 8px, shrinks it by 2px on every side and colors it a soft, slightly blue black at 10% opacity.
You can stack several shadows by separating them with commas. Layered shadows are the key to realistic depth: a tight, darker shadow close to the element and a wider, lighter one further away imitate how real light falls off.
Elevation: a shadow scale for your design system
Instead of inventing a new shadow for every component, define a small elevation scale and reuse it. A common set has four or five levels: a hairline for cards resting on the page, a low shadow for hovered cards and buttons, a medium shadow for dropdowns and popovers, a high shadow for dialogs, and an extra-high shadow for toasts or floating panels.
Higher elevation means more offset, more blur and slightly more opacity. Keep the same light direction (usually from above) at every level so the interface feels like one physical space.
Shadows in dark mode
Shadows are much less visible on dark backgrounds, because there is little contrast between a dark shadow and a dark surface. Dark themes usually communicate elevation with lighter surfaces instead: each raised layer is a step lighter than the one below. A subtle 1px light edge (for example, a white border at 6% opacity) does more work than a shadow.
If you do use shadows in dark mode, increase their opacity and keep them tight so they read as edges rather than haze.
Performance
Box shadows are cheap to render on their own, but animating large, heavily blurred shadows on many elements at once can cause jank on low-power devices. If you need to animate elevation on hover, a common technique is to put the larger shadow on a pseudo-element and animate its opacity instead of the shadow values themselves.
Avoid applying big blurred shadows to very large elements or long scrolling lists, and prefer tight, low-blur shadows for repeated components like cards in a grid.
Common box-shadow mistakes
- Pure black at high opacity. Shadows like rgba(0, 0, 0, 0.5) look heavy and dirty. Tint the shadow toward your surface color and keep opacity low.
- Large symmetric blur. A big, even glow around every side looks artificial. Add a vertical offset and negative spread so the light has a direction.
- Shadows that trace the element's shape. If you can see a blurred rounded rectangle behind the card, the blur is too small for the spread or offset.
- A different shadow on every component. Without an elevation scale, the interface feels inconsistent. Reuse a small set of shadows.
Sources and further reading
- MDN: box-shadow · Full syntax for offsets, blur, spread and inset.
- Tailwind CSS: box-shadow · Tailwind's shadow utilities and how to extend them.
- WCAG 2.1: Non-text Contrast · Contrast requirements for buttons, borders and icons.
Related tools and guides
Questions people ask
How do I add a box shadow in CSS?
Use box-shadow: x-offset y-offset blur spread color, for example box-shadow: 0 1px 3px rgba(0,0,0,0.1). Separate multiple shadows with commas.
How do I make a box shadow look realistic?
Keep offsets small, use a negative spread so the shadow does not peek out at the sides, tint it to the surface instead of pure black, and stack two or more layers with increasing blur.
How do I use a custom box shadow in Tailwind?
Use an arbitrary value with underscores for spaces, for example shadow-[0_1px_3px_rgba(0,0,0,0.1)], or add it to theme.extend.boxShadow in your Tailwind config.
Do box shadows affect layout?
No. box-shadow is painted outside the box model, so it never changes an element's size or position. That is why it is useful for focus rings and pseudo-borders.
What is the difference between box-shadow and drop-shadow?
box-shadow follows the element's rectangular box (including border-radius). The CSS filter drop-shadow() follows the visible shape, including transparent areas of images and SVGs.
Can I animate box-shadow?
Yes, but animating large shadows can be expensive. Animating the opacity of a pseudo-element that holds the shadow is usually smoother.

↘ Building Inspo AI | AI-Powered Design Research & Builder Platform | Design Engineer.