The yellow — now teal — card in my hero has two cut-outs with rounded inverted corners: one top-right for a globe button, one bottom-left for a row of badges. My first version was wrong in an instructive way.
Attempt one: paint over it
The common trick is to place a small box with the page's background color in the corner, then add two pseudo-elements with a radial-gradient to fake the concave curves.
It looks fine in a screenshot. In reality:
- The card's
box-shadowstill follows the rectangle, so you see a shadow edge around the "hole". - Gradient edges anti-alias differently than the card's border radius, leaving faint seams.
- If the card tilts in 3D, the patch and the card drift apart.
Attempt two: cut the real shape
Instead of covering the card, clip it. clip-path: path() accepts an SVG path, and we can generate one from the card's size:
const d = [
`M 0 ${R}`,
`A ${R} ${R} 0 0 1 ${R} 0`,
// top edge → into the top-right notch
`L ${W - tw - r} 0`,
`A ${r} ${r} 0 0 1 ${W - tw} ${r}`,
`L ${W - tw} ${th - r}`,
`A ${r} ${r} 0 0 0 ${W - tw + r} ${th}`,
`L ${W - r} ${th}`,
`A ${r} ${r} 0 0 1 ${W} ${th + r}`,
// … right edge, bottom-left notch, back to start
`L ${bw} ${H - bh + r}`,
`A ${r} ${r} 0 0 0 ${bw - r} ${H - bh}`,
`L ${r} ${H - bh}`,
"Z",
].join(" ");
el.style.clipPath = `path("${d}")`;The only subtle part is the arc sweep flag (the fifth number after A). Walking clockwise around the shape, a right turn is 1 and a left turn — the concave corners inside the notch — is 0.
Shadows that follow the cut
box-shadow is clipped away along with everything else. Put a drop-shadow filter on the parent instead; filters apply to the rendered alpha of the children, so the shadow traces the notches exactly.
.wrapper {
filter: drop-shadow(0 28px 40px rgb(12 12 13 / 0.28));
}Keeping it responsive
path() uses absolute pixels, so rebuild it whenever the element resizes:
build();
const ro = new ResizeObserver(build);
ro.observe(el);