Create single and multiple CSS box shadows visually with live preview.
{{ cssOutput }}
The CSS property box-shadow adds one or more shadows to an element. Shadows create depth and make elements like cards, buttons and dialogs stand out from the background. You can control offset, blur radius, spread radius, color and the inset mode.
The syntax is: box-shadow: [inset] offset-x offset-y blur-radius spread-radius color;. Offset-X and Offset-Y determine the shadow position. Blur radius controls the softness, spread radius enlarges or shrinks the shadow. The inset keyword creates an inner shadow. Multiple shadows are separated by commas.
The box-shadow property is specified in CSS Backgrounds and Borders Module Level 3. The full syntax is box-shadow: [inset?] <offset-x> <offset-y> [<blur-radius>] [<spread-radius>] <color>. Offset-X moves the shadow horizontally (positive = right), offset-Y vertically (positive = down). The blur radius is the standard deviation of the Gaussian blur; larger means softer and more spread. The spread radius enlarges (positive) or shrinks (negative) the whole shadow uniformly — unlike blur, the edge stays hard.
The keyword inset flips the shadow inward — it appears inside the box, as if the surface were pressed in. Insets work well for inputs, pressed buttons, or recessed cards. Multiple shadows can be stacked comma-separated: box-shadow: 0 1px 2px #0001, 0 4px 8px #0001, 0 16px 32px #0001;. The browser paints back to front (last value bottom, first on top) — for believable elevation, layer three to four shadows with different blur values.
box-shadow automatically respects border-radius — a rounded box casts an appropriately rounded shadow. Important: the shadow does not enlarge the hit area and takes no layout space, which makes it predictable in grid and flex containers. Compared to filter: drop-shadow(), box-shadow is rectangular (follows the box outline), while drop-shadow is alpha-based and shadows transparent PNGs cleanly — but is more GPU-intensive. For simple UI cards, box-shadow is almost always the right choice.
With a few steps you get shadows that support your hierarchy instead of breaking it.
#00000033 = 20%). Pure black feels heavy; brand color + low alpha (e.g. #0d948833) feels more elegant.var(--shadow-elevation-2), so your design system manages the elevation scale centrally.These snippets are battle-tested and cover the most important elevation levels.
box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04); — Tailwind's shadow-sm.box-shadow: 0 2px 4px -1px #0003, 0 4px 6px #00000024, 0 1px 10px #0000001f;.box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); — fits floating dialogs in modern UIs.box-shadow: inset 0 2px 4px rgba(0,0,0,0.06); — light pressed effect, great for search bars.box-shadow: 0 10px 25px -5px rgba(13,148,136,0.25); combined with transform: translateY(-2px); for interactive feedback.box-shadow with blur is GPU-accelerated but not free: every blurred pixel must be computed as a Gaussian convolution over roughly 2 * blur pixels. At blur 64 px on a 1920x1080 display that means several hundred MB of memory bandwidth per frame. On older mobiles and iOS Safari this causes frame drops, especially when the shadow is animated. Tips: avoid animated box-shadow on slow devices — animate transform and opacity instead, which run on the compositor layer. If a shadow is static, its cost is minimal. On transparent backgrounds or wallpaper, a dark shadow can become invisible — test with dark mode and varied surface tones. Finally: shadows are purely decorative; WCAG does not mandate them, but they must not impair text legibility on the card — spread values above 10 px in brand color can reduce contrast at the card edge.
position: fixed containers correctly. Reduce blur below 50 px or use a non-fixed container for the shadow.::after with the prepared shadow and animate its opacity. The expensive Gaussian convolution stays static and only the GPU-cheap opacity changes.rgba(15, 23, 42, 0.15) instead of rgba(0,0,0,0.15).box-shadow: 0 0 20px rgba(255,255,255,0.05)) to signal depth instead.