
Responsive Vector Masks with the CSS shape Function
Whenever UI designs required custom curved cutouts, notched tabs, or asymmetric editorial frames via clip-path, web developers hit a frustrating wall with CSS path(). Because path() borrows raw SVG path strings, every coordinate inside it is locked to unitless pixel values—making it impossible to mix percentages with rem offsets, respond to container queries, or drive corner radii through CSS custom properties without recalculating SVG strings in JavaScript on every resize.
The CSS shape() function from the CSS Shapes specification—supported across Chromium and Safari engines since 2025 and expanding rapidly in 2026—bridges that gap by bringing native CSS units into vector geometry. Instead of opaque string commands, shape() accepts readable drawing verbs like from, line to, curve to, arc to, and close, paired with percentages, viewport units, calc() expressions, and custom properties. As a result, a single stylesheet declaration can anchor a curved badge cutout or angled hero mask to fixed rem corner dimensions while stretching fluidly across any container width.
Example
/* Responsive ticket card with fixed-size semicircular side notches */
.ticket-mask {
--notch-size: 1.25rem;
--notch-y: 65%;
clip-path: shape(
from 0% 0%,
line to 100% 0%,
line to 100% calc(var(--notch-y) - var(--notch-size)),
arc to 100% calc(var(--notch-y) + var(--notch-size)) of var(--notch-size) ccw,
line to 100% 100%,
line to 0% 100%,
line to 0% calc(var(--notch-y) + var(--notch-size)),
arc to 0% calc(var(--notch-y) - var(--notch-size)) of var(--notch-size) ccw,
close
);
}
Implementation
<article class="feature-panel">
<div class="feature-panel__media">
<img
src="/img/posts/css-shape-function-responsive-clip-paths.webp"
alt="Refractive geometric glass facade"
width="667"
height="518"
loading="lazy"
/>
</div>
<div class="feature-panel__body">
<span class="feature-panel__eyebrow">Vector Layout</span>
<h2 class="feature-panel__title">Fluid Architectural Masking</h2>
<p class="feature-panel__copy">
Fixed corner chamfers and smooth quadratic arcs scale cleanly across viewports using pure CSS geometry.
</p>
</div>
</article>
/* ==========================================================================
Responsive Vector Frame using CSS shape() with Polygon Fallback
========================================================================== */
.feature-panel {
--cutout-w: 4.5rem;
--cutout-h: 3rem;
--curve-softness: 1.5rem;
display: grid;
grid-template-columns: 1fr;
background: #0f172a;
color: #f8fafc;
border-radius: 1rem;
overflow: hidden;
max-width: 42rem;
}
.feature-panel__media {
position: relative;
aspect-ratio: 16 / 10;
overflow: hidden;
}
.feature-panel__media img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
/* Progressive enhancement baseline: sharp chamfered polygon */
clip-path: polygon(
0 0,
100% 0,
100% calc(100% - var(--cutout-h)),
calc(100% - var(--cutout-w)) 100%,
0 100%
);
}
@supports (clip-path: shape(from 0% 0%, line to 100% 100%)) {
.feature-panel__media img {
/* Upgrade to smooth unit-aware Bezier curve cutout when shape() is supported */
clip-path: shape(
from 0% 0%,
line to 100% 0%,
line to 100% calc(100% - var(--cutout-h) - var(--curve-softness)),
curve to calc(100% - var(--cutout-w)) 100%
with 100% calc(100% - var(--cutout-h) * 0.25)
calc(100% - var(--cutout-w) * 0.45) 100%,
line to 0% 100%,
close
);
transition: clip-path 320ms cubic-bezier(0.22, 1, 0.36, 1);
}
.feature-panel:hover .feature-panel__media img,
.feature-panel:focus-within .feature-panel__media img {
--cutout-w: 6rem;
--cutout-h: 3.75rem;
}
}
.feature-panel__body {
padding: 1.5rem;
}
.feature-panel__eyebrow {
display: inline-block;
font-size: 0.75rem;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #38bdf8;
margin-bottom: 0.5rem;
}
.feature-panel__title {
margin: 0 0 0.5rem;
font-size: 1.375rem;
}
.feature-panel__copy {
margin: 0;
color: #cbd5e1;
line-height: 1.6;
}
@media (prefers-reduced-motion: reduce) {
.feature-panel__media img {
transition: none;
}
}
Main Point: The CSS shape function replaces rigid unitless SVG path strings with unit-aware curves and arcs that respond natively to percentages, calc expressions, and custom properties.
Credits
Photo by Joel Filipe on Unsplash