Box shadows are one of the most impactful CSS properties you can use to transform a flat, lifeless interface into something that feels polished and three-dimensional. A well-crafted shadow can guide the user's eye, communicate depth and hierarchy, and make elements feel interactive — all without adding a single image or extra element.
This guide covers everything you need to know about the CSS box-shadow property, from the syntax fundamentals to advanced multi-layer techniques, and shows you how to use a visual designer to create production-ready shadows in seconds.
The box-shadow property accepts a list of shadow definitions separated by commas. Each definition can include up to six values:
box-shadow: [inset] [offset-x] [offset-y] [blur] [spread] [color];
box-shadow: 4px 6px 12px rgba(0, 0, 0, 0.15);
This creates a shadow offset 4px to the right and 6px down, with a 12px blur and 15% black opacity — a classic card shadow.
The most common shadow pattern. It simulates a card floating slightly above the surface:
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08),
0 1px 3px rgba(0, 0, 0, 0.06);
The two-layer approach creates a more natural look: a tight, darker shadow near the element and a wider, softer shadow further away.
Zero blur creates a crisp, hard-edged shadow — popular in neumorphism and brutalist designs:
box-shadow: 8px 8px 0 #1e1e2e;
Large blur with a colored shadow creates a neon glow. Perfect for dark-themed interfaces:
box-shadow: 0 0 30px rgba(139, 92, 246, 0.5);
Inset shadows create a pressed-in or concave appearance, useful for input fields and buttons:
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
The most sophisticated UI shadows use multiple layers. Each layer serves a different purpose: one for the ambient occlusion (tight, dark shadow), one for the diffuse light (wide, soft shadow), and sometimes one for color tinting.
Google's Material Design defines shadow levels that map to elevation. Here are the key levels:
/* Level 1 — Cards, chips */ box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24); /* Level 2 — FABs, small dialogs */ box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23); /* Level 3 — Navigation drawers */ box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23); /* Level 4 — Modals */ box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
Apple's design language uses subtle, multi-layer shadows that feel almost invisible but contribute to a sense of depth:
box-shadow: 0 0 0 0.5px rgba(0,0,0,0.04),
0 2px 8px rgba(0,0,0,0.06),
0 20px 60px rgba(0,0,0,0.04);
The first layer (0.5px spread, very low opacity) acts as a border substitute. The middle layer provides immediate depth. The outer layer adds a sense of the element floating far above the surface.
While black shadows are the default, colored shadows can dramatically improve the visual quality of your design. The key principle: the shadow color should relate to the element's background color or the surface it sits on.
/* Purple button on a dark surface */
.purple-btn {
background: #8b5cf6;
box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
}
In realistic lighting, shadows are not neutral gray. They pick up color from their environment. A shadow on a warm surface will have a slightly warm tint; on a cool surface, a cool tint:
/* Warm shadow (suits light backgrounds) */ box-shadow: 0 4px 16px rgba(139, 92, 40, 0.1); /* Cool shadow (suits dark backgrounds) */ box-shadow: 0 4px 16px rgba(100, 100, 200, 0.15);
Box shadows are generally well-optimized by browsers. However, a few things can cause performance issues:
transform: translateY() to change elevation and apply the shadow statically, or use will-change: box-shadow sparingly.CSS filter: drop-shadow() is an alternative that follows the alpha shape of the element, including transparent areas. This is useful for PNG images with transparent backgrounds and for elements with non-rectangular clip-paths.
/* drop-shadow follows the shape */
.drop-icon {
filter: drop-shadow(4px 4px 8px rgba(0,0,0,0.3));
}
/* box-shadow follows the bounding box */
.box-icon {
box-shadow: 4px 4px 8px rgba(0,0,0,0.3);
}
For most UI elements (cards, buttons, inputs), box-shadow is the better choice because it is more performant and gives you finer control with spread and inset options.
While understanding the syntax is important, manually tweaking values and reloading the page to see the result is slow. A visual designer lets you adjust every parameter with sliders, see the shadow update in real time, and copy the final CSS with one click.
RiseTop's CSS Box Shadow Generator supports multiple shadow layers, inset/outside toggle, color picking with opacity, and preset templates for common patterns like Material Design elevation levels. It outputs clean, copy-ready CSS that you can paste directly into your stylesheet.
:root {
--shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
--shadow-md: 0 4px 12px rgba(0,0,0,0.1);
--shadow-lg: 0 10px 30px rgba(0,0,0,0.15);
}transition: box-shadow 0.2s ease;
&:hover { box-shadow: var(--shadow-lg); }Box shadows are a small detail with an outsized impact on UI quality. By understanding the syntax, mastering multi-layer techniques, and using a visual designer to iterate quickly, you can add a professional depth to any interface. The difference between a flat design and one that feels "right" often comes down to the shadows.
Try our free CSS Box Shadow Generator — design, preview, and copy production-ready CSS instantly.
Open CSS Box Shadow Generator →