All SVG guides
Styling & motion
Advanced Vector Masking: ClipPaths, Masks, and Composition
Creating complex geometric interactions in vector layouts depends on clipping and masking operations. Here is a look at masking options.
1. ClipPath vs Mask
- ClipPath: Cuts coordinates strictly to a shape boundary (binary visible/invisible). Good for card thumbnails or rounded image blocks.
- Mask: Applies transparency shading (alpha channels) based on fill lightness. Ideal for soft shadows, custom reflections, and glassmorphism.
2. Vector Code Example: ClipPath setup
clipping_sample.svg
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<defs>
<!-- ClipPath cuts drawing to a circular region -->
<clipPath id="circleClip">
<circle cx="50" cy="50" r="40" />
</clipPath>
</defs>
<rect width="100" height="100" fill="#f97316" clip-path="url(#circleClip)" />
</svg>The same idea works from CSS: an SVG used as a mask-image over a background colour is the usual way to recolour an icon you cannot inline. That route, and how it behaves in forced-colours mode, is in changing the colour of an SVG background.