Fade edges, spotlight reveals, text shapes — all with gradient masks.
Choose a mask type and adjust the parameters. The CSS updates live. Key insight: black = visible, white/transparent = hidden.
Hard, sharp edge. Either fully visible or fully hidden. No partial transparency. Use for shapes.
Soft, graduated fade. Pixels can be partially visible. Use for fades, spotlight, feathered edges.
These are the production use cases. Scroll the first demo, hover the spotlight, click the wipe reveal.
Scroll left/right. The mask fades the edges, hinting at more content. The gradient stops control how far the fade extends.
The text fades at both edges — useful for marquee/ticker text or truncated content that hints at more.
A radial gradient mask centered at the cursor position creates a spotlight. Only mask-position changes on mouse move — no JS color math needed.
Softer than clip-path: polygon() — the diagonal edge feathers instead of cutting sharply. Ideal for overlapping hero sections.
Animating the gradient stop position in the mask creates a smooth wipe reveal — no JavaScript, no clip-path vertex counts.
A radial mask fades the edges of an image or section inward — the classic vignette effect without a separate overlay element.
When you stack multiple mask layers, mask-composite controls how they combine. And the Safari prefix uses completely different value names.
Alpha channel controls visibility. Use for PNG masks and CSS gradients (default behavior).
Brightness controls visibility. Use for SVG <mask> elements. Black=hidden, white=visible.
Both mask layers are combined — the element shows through anywhere either mask allows it.
The top layer is subtracted from the bottom — overlap areas are hidden, creating a punch-out effect.
Only where both masks overlap is visible — useful for complex shapes from simple gradients.
XOR — the overlap is hidden while non-overlapping areas show. Creates a ring/donut effect.
mask-composite values and the prefixed -webkit-mask-composite values use completely different names. You must include both with the correct names — they're not the same strings.
| Effect | Standard: mask-composite | Prefixed: -webkit-mask-composite |
|---|---|---|
| Combine both | add | source-over |
| Punch through | subtract | source-out |
| Overlap only | intersect | source-in |
| XOR ring | exclude | xor |
mask-image → -webkit-mask-imagemask-size → -webkit-mask-sizemask-repeat → -webkit-mask-repeatmask-position → -webkit-mask-positionmask-composite → -webkit-mask-composite (different value names!)mask-mode → -webkit-mask-modemask → -webkit-mask