CSS border-shape: True Non-Rectangular Elements
Custom border shapes without clip-path hacks
clip-path masks an element into a shape but the underlying box stays rectangular. Shadows, borders, and outlines ignore the mask. border-shape redefines the geometry itself, so every visual property follows the shape.
The old hack vs the modern fix
View demo.tooltip {
background: var(--accent);
padding: 1rem;
padding-block-end: calc(1rem + 12px);
clip-path: polygon(0 0, 100% 0, 100% calc(100% - 12px), 60% calc(100% - 12px), 50% 100%, 40% calc(100% - 12px), 0 calc(100% - 12px));
}
/* clip-path masks the visual but the box is still rectangular for layout, shadows, and outlines */.tooltip {
border-shape: shape(from 0 0, hline to 100%, vline to calc(100% - 12px), line to 60% calc(100% - 12px), line to 50% 100%, line to 40% calc(100% - 12px), line to 0 calc(100% - 12px), close);
background: var(--accent);
padding: 1rem;
padding-block-end: calc(1rem + 12px);
}
/* the box itself is the shape, no clip-path needed */Border shape browser support
border-shape ships in Chrome 147 and Edge 147. Firefox and Safari don't support it yet, and the spec is still a Working Draft, so keep clip-path with the same coordinates as a fallback.
Live demo
Why the modern way wins
Shadows follow the shape
clip-path hides parts of the box, so a box-shadow on a tooltip still draws a rectangle. border-shape changes the geometry, so the shadow traces the actual outline.
Real borders and outlines
Borders and outlines hug the custom shape. With clip-path, both still draw on the original rectangle and get masked, leaving you no real border at all.
Same coordinates
The points in shape() match the ones you would write in a clip-path polygon. Keep the clip-path with the same coordinates as a fallback for browsers without border-shape.
- Old Approach
- clip-path
- Masks the visual, not the box
- Modern Approach
- border-shape
- Redefines element geometry
How it works
clip-path has been the only way to make non-rectangular elements in CSS for years, but it does something narrower than people expect. It masks the visual content of the element. The underlying box is still a rectangle, which means borders, outlines, and box-shadows all follow the rectangle, then get cut off by the mask. A tooltip clipped into an arrow shape ends up with a shadow that looks rectangular, with the arrow's shadow missing.
border-shape changes the element's geometry instead of masking it. The shape becomes the element. Borders trace the path. Outlines hug the path. Shadows offset the path correctly. Pointer events only fire inside the path. The shape() function uses an SVG-like grammar (from, line to, hline, vline, curve, arc, close) so the same shape can replace what clip-path-with-polygon used to do, but now everything else respects it.
Common cases that get easier: tooltips with arrows, chevron breadcrumbs, scalloped cards, speech bubbles, hexagonal avatars. With clip-path you wrote the polygon and then patched around the broken shadow and border. With border-shape you write the shape once.