CKTIS / CSS
drop-shadow() — shadow from an alpha mask
`drop-shadow()` paints a shifted and optionally blurred copy of the input image’s alpha mask in a chosen color beneath the input.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
drop-shadow( [ <color>? && <length>{2,3} ] )drop-shadow() paints a shifted and optionally blurred copy of the input image’s alpha mask in a chosen color beneath the input.
The example renders drop-shadow(4px 0 0 rgb(255 0 0)): the source pixel is 0,0,255,255, a separate shadow pixel is 255,0,0,255, and space beyond both remains 0,0,0,0. drop-shadow(0 0 -1px red) is rejected because blur standard deviation cannot be negative.
Grammar: drop-shadow( [ <color>? && <length>{2,3} ] ).
Two offsets are required; the third length is Gaussian standard deviation, not the blur radius used by box-shadow. Omitted lengths are 0, and an omitted color uses currentColor. This level accepts neither spread nor a list of multiple shadows. The effect follows the content’s actual alpha silhouette, so it differs from a rectangular box shadow.
Examples
const render = async () => {
const svg = '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8"><foreignObject width="12" height="8"><div xmlns="http://www.w3.org/1999/xhtml" style="width:4px;height:4px;margin:1px;background:rgb(0 0 255);filter:drop-shadow(4px 0 0 rgb(255 0 0))"></div></foreignObject></svg>';
const image = new Image(); image.src = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg); await image.decode();
const canvas = document.createElement('canvas'); canvas.width=12; canvas.height=8;
const context=canvas.getContext('2d'); context.drawImage(image,0,0);
const pixel=(x,y)=>[...context.getImageData(x,y,1,1).data].join(',');
return {source:pixel(2,2),shadow:pixel(6,2),empty:pixel(10,2)};
};
const pixels=await render();
const invalidNegativeBlur=CSS.supports('filter','drop-shadow(0 0 -1px red)');
console.log('source='+pixels.source+'; shadow='+pixels.shadow+'; empty='+pixels.empty+'; negative-blur='+invalidNegativeBlur);Result
source=0,0,255,255; shadow=255,0,0,255; empty=0,0,0,0; negative-blur=false
`drop-shadow()` paints a shifted and optionally blurred copy of the input image’s alpha mask in a chosen color beneath the input.