When you apply box-shadow to a PNG icon, an SVG illustration, or any image with transparency, the shadow renders around the rectangular bounding box of the element rather than around the actual visible shape.
Loading Shadow Effect Builder…
Generates filter: drop-shadow() CSS for irregular shapes
Live preview showing shadow following actual element outline
Controls for offset, blur, and colour
Free and browser-based with no sign-up
Drop the Shadow Effect Builder into any page — blog post, product docs, intranet, school portal — with a single line of HTML. Your visitors get the full tool, processed entirely in their browser. No backend, no uploads, no signup.
Embed code
<iframe
src="https://www.fixtools.io/css-tool/shadow-effect-builder?embed=1"
width="100%"
height="780"
frameborder="0"
style="border:0;border-radius:16px;max-width:900px;"
title="Shadow Effect Builder by FixTools"
loading="lazy"
allow="clipboard-write"
></iframe>Attribution-friendly: a small "Powered by FixTools" link appears in the embed footer.
Box-shadow is applied to an element's CSS box model, which is always strictly rectangular regardless of the visual content inside it. This means that for a PNG file containing a star icon rendered against a transparent background, a box-shadow produces a rectangular shadow around the image file dimensions, not around the star shape itself. The transparent areas of the PNG are still considered inside the box from the CSS engine's perspective, so the shadow wraps the box and not the visible star. For icon-heavy interfaces, product photography with cutout backgrounds, organic illustrated characters, and SVG iconography, this rectangular shadow looks immediately wrong to any viewer, even one who could not articulate why. The mismatch between the visible content shape and the shadow shape breaks the basic visual contract that a shadow should belong to the object casting it.
The filter: drop-shadow() function works fundamentally differently. It processes the element after the browser has composited it, operating on the actual rendered pixel output rather than the CSS box. For a PNG with transparency, the browser first resolves the alpha channel, producing an internal pixel map where transparent areas have zero opacity and non-transparent areas have their full pixel values. The drop-shadow filter then creates a shadow derived from the non-transparent pixels, following their exact outline including curves, cutouts, and irregular boundaries. This means an irregular shape, whether a complex SVG path, a cutout PNG, or even a text element with custom glyph outlines, receives a shadow that wraps its visible content rather than its bounding box. The syntax is filter: drop-shadow(offsetX offsetY blur colour), mirroring the box-shadow value order but without spread or inset support.
One practical limitation worth understanding before deploying drop-shadow at scale: multiple drop-shadows require multiple filter() calls chained in the filter property, rather than the comma-separated list pattern used by box-shadow. Where box-shadow accepts box-shadow: 0 2px 4px rgba(0,0,0,0.2), 0 8px 16px rgba(0,0,0,0.1), filter requires filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2)) drop-shadow(0 8px 16px rgba(0,0,0,0.1)). Chaining too many filter functions on the same element adds GPU compositing cost, because each filter creates a new GPU layer and the browser composites them in sequence. Keep drop-shadow use to one or at most two layers on any element that animates or appears in long scrollable lists, and reserve more complex multi-layer compositions for static decorative content.
Drop-shadow integrates cleanly with the rest of the CSS filter property, which is a powerful but underused part of the platform. You can chain drop-shadow with grayscale, brightness, contrast, blur, hue-rotate, and saturate filters in a single declaration to create compound visual effects. The order of filters matters because each filter operates on the output of the previous one in the chain. Putting drop-shadow last means the shadow is calculated from the already-filtered pixel output, which is usually what you want. Putting drop-shadow first means subsequent filters apply to the shadow as well as the element, which can produce interesting effects like a tinted shadow but is rarely the right default.
Upload or select a PNG or SVG element in the preview, then adjust offset and blur sliders to position the shadow around the actual shape. Copy the filter CSS when the shadow follows your element's outline correctly.
Step-by-step guide to css drop shadow generator:
Identify the element needing a shape-following shadow
Confirm the element you are styling is a PNG with transparency, an inline SVG, an SVG used as an img source, or another irregularly shaped element where applying box-shadow would visibly produce a rectangular halo artifact around the element. If the element is a solid rectangular block with no transparency, box-shadow is the simpler and more efficient choice. Drop-shadow shines specifically when there is alpha transparency to follow.
Set offset values
Drag the X and Y offset sliders to position the shadow directionally relative to the element. Positive Y pushes the shadow downward and positive X pushes it rightward, implying a light source from the upper left. For a symmetric ambient glow with no directional offset, set both values to zero and rely on blur to create the halo. Establish offset direction before adjusting blur for the cleanest iteration loop.
Adjust blur and colour
Set the blur radius to match the desired edge softness for the shadow. Small icons at 16 to 24 pixels need only 2 to 4 pixels of blur, while large illustrations can absorb 12 pixels or more without losing detail. Choose a shadow colour with opacity appropriate for the background the element will sit on, favouring lower opacity on light backgrounds and higher opacity on coloured or photographic backgrounds.
Copy the filter CSS
Copy the generated filter: drop-shadow() declaration to your clipboard and paste it into the element's CSS rule. If the element previously had a box-shadow declaration, remove that property entirely to avoid rendering two shadows simultaneously, which produces a visibly doubled effect with the box-shadow rectangle showing alongside the drop-shadow contour. The filter CSS works in every modern browser without prefixes.
Common situations where this approach makes a real difference:
Navigation icon bar with SVG icons
A developer is building a bottom navigation bar with five SVG icons that need subtle shadows to lift them off the bar background and signal interactivity. Applying box-shadow to each icon produces an awkward rectangular shadow around the SVG element's bounding box, which immediately reads as wrong against the curved icon shapes. Switching to filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2)) makes the shadow follow each icon's actual path outlines precisely, producing clean shadows that read correctly on both light and dark tab bar background variants. The same drop-shadow values work uniformly across the entire icon set.
Product image with cutout background
An e-commerce developer is displaying product photos with transparent backgrounds on a clean white product detail page. Applying box-shadow adds a rectangular frame effect that immediately reveals the file boundary and makes the products look like they have been pasted onto the page rather than placed in a scene. Using filter: drop-shadow(4px 4px 10px rgba(0,0,0,0.15)) wraps the shadow around the actual product silhouette, making the product appear to lift naturally off the page without any visible bounding box artifact. The effect mimics studio product photography lighting and improves the perceived quality of the catalogue.
Logo on a hero section
A brand site places a PNG logo with transparent areas over a full-width photo background that varies in brightness across its width. The designer wants a subtle shadow to separate the logo from busy photo backgrounds and ensure brand legibility regardless of which part of the photo the logo overlaps. Drop-shadow at 0 offset and 8 pixel blur with rgba(0,0,0,0.4) creates a soft halo that follows the logo shape exactly, improving legibility without adding a solid background fill behind the logo. The result feels integrated with the photo rather than slapped on top of it.
Illustrated character in a game UI
A game developer is adding character sprites as PNG images with irregular transparent outlines to a browser-based game scene. Box-shadow produces ugly rectangular halos around each character that immediately break the illusion of the game world. Filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.4)) follows each character's irregular silhouette exactly, giving the sprites a grounded contact shadow that makes them feel placed in the scene rather than floating awkwardly above it. The same drop-shadow declaration applies uniformly to dozens of different character sprites without per-character tuning.
Use this when you need to add a shadow to a PNG with transparency, an SVG icon, or any irregularly shaped element where a box-shadow would produce an unwanted rectangular halo.
Get better results with these expert suggestions:
Spread is not available in drop-shadow
Unlike box-shadow, the filter: drop-shadow() function does not accept a spread value, which surprises developers migrating from box-shadow expecting feature parity. If you need a wider shadow, the workaround is to increase the blur radius significantly and reduce the colour opacity slightly to keep the overall intensity comparable. For a glow effect with no directional offset, push blur to 12 pixels or more with a saturated colour, for example drop-shadow(0 0 12px rgba(255,100,0,0.6)). The lack of spread makes drop-shadow less flexible than box-shadow for precision border-style effects but does not limit its usefulness for organic shape shadows.
Animate filter on :hover for icon interaction feedback
Adding transition: filter 0.15s ease to an SVG icon button and changing the drop-shadow values on :hover creates an immediate, clear interaction signal that confirms clickability. The shadow can deepen, shift colour, or grow into a brand-coloured glow as the user hovers, providing tactile feedback without needing a border change or background colour swap. Because drop-shadow follows the icon outline rather than a rectangular box, this animated interaction feels integrated with the icon itself rather than as a separate hover ring around the bounding box. Test on mid-range mobile to confirm smooth frame rate.
Chain drop-shadow with other filters for compound effects
The filter property can chain multiple functions in sequence: filter: grayscale(0.3) drop-shadow(0 4px 8px rgba(0,0,0,0.25)). The order in which functions appear matters because each function operates on the output of the previous one. Filters applied earlier in the chain affect the element pixels that later filters then process, so putting drop-shadow last in the chain processes the already-filtered pixel output and produces a shadow that respects the prior visual treatment. This composition pattern is how you achieve photo-treated looks like a desaturated product image with a soft cast shadow.
Use currentColor in drop-shadow for themed icons
Setting the drop-shadow colour to the currentColor keyword, as in filter: drop-shadow(0 2px 4px currentColor), makes the shadow automatically inherit the element's text colour. Combined with CSS custom properties for theme management, this lets a single icon component respond to light mode and dark mode theme changes without any per-theme shadow colour override. Drop the icon into a dark sidebar and the shadow darkens. Move it to a coloured callout and the shadow shifts to match. The technique reduces stylesheet duplication and is essential for systems that support many themes.
Use drop-shadow for SVG icons in navigation
SVG icons in navigation bars often sit against varied background colours. A drop-shadow that follows the SVG path remains correct whether the background is white, dark, or a photo, while a box-shadow would show a rectangular artifact on darker backgrounds.
Keep blur low for icons at small sizes
At 16px to 24px icon sizes, a blur radius of 2px to 4px is sufficient. Larger blur values at small icon sizes produce muddy shadows that obscure detail and can make the icon harder to read.
Test on multiple background colours
Drop-shadows on icons often look fine on white but disappear or look harsh on dark or coloured backgrounds. Test your drop-shadow values against the actual background colours used in your UI before finalising.
More use-case guides for the same tool:
Open the full Shadow Effect Builder — free, no account needed, works on any device.
Open Shadow Effect Builder →Free · No account needed · Works on any device