CSS Box Shadow: How to Create Realistic, Layered Shadows
Master CSS box shadow syntax, then build realistic layered shadows with tinted colors, elevation tokens and dark-mode variants that look natural in any UI.
Read GuideDeveloper
Design CSS box shadows visually with offset, blur, spread, color, and inset controls.
Developer
Getting depth right by trial and error in a code editor is slow, so this CSS box shadow generator lets you shape the shadow visually and copy a single finished box-shadow line. Sliders control horizontal and vertical offset, blur, spread and opacity, a color field sets the shadow tint, and an inset checkbox flips the shadow inside the element. The preview box updates as you drag, which helps front-end developers and UI designers dial in soft card shadows, crisp outlines or pressed-in effects.
Realistic shadows usually combine a low opacity, a generous blur and a slightly negative spread, which keeps the shadow tucked under the element instead of bleeding out on every side. For more depth, generate two shadows, one small and sharp and one large and soft, and join them in a single box-shadow declaration separated by a comma. Tinting the shadow with a dark version of the background hue keeps it from looking gray and dirty on colored pages.
FAQ
The order is an optional inset keyword, then horizontal offset, vertical offset, blur radius, spread radius and color. Only the two offsets are required, and blur and spread default to zero if omitted. For example, box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.2) creates a soft shadow that falls slightly below the element.
Blur controls how soft the edge of the shadow is, with larger values fading it out over a wider area, and it cannot be negative. Spread changes the size of the shadow before blurring, so positive values grow it and negative values shrink it. Combining a large blur with a negative spread produces a soft shadow that stays under the element.
The inset keyword draws the shadow inside the element border instead of outside it. This makes the element look pressed into the page, which suits input fields, wells and active button states. Offsets work in reverse visually, so a positive vertical offset darkens the top inner edge.
box-shadow follows the rectangular box of the element, including its border-radius, and supports spread and inset. The filter drop-shadow() function follows the actual visible shape of the content, such as the outline of a transparent PNG or an SVG icon. Use box-shadow for cards and buttons, and drop-shadow for irregular shapes.
Learn more
Master CSS box shadow syntax, then build realistic layered shadows with tinted colors, elevation tokens and dark-mode variants that look natural in any UI.
Read GuideLearn how HEX opacity works with 8-digit HEX codes, get a full transparency table from 100% to 0%, and know when to use #RRGGBBAA, rgba() or opacity.
Read Guide