Creating Beveled Corners with “corner-shape”
On December 1st 2026, a new NPM package was released focused on button UI sound effects. The creator found diagonal beveled corners to be a fun effect, made possible by the new corner-shape property. However, using this property proved to be challenging, as it required somewhat unintuitive methods to achieve the desired results.
In this blog post, the author explains how to create beveled corners using corner-shape. They begin with a basic example, where setting corner-shape: bevel changes the border-radius property from producing a rounded quarter-circle to drawing a diagonal line.
One notable feature of corner-shape is that it alters the element's border box, allowing other properties like outline and box-shadow to respect the beveled corners. This is a significant advantage over traditional methods. The author also demonstrates how to use clip-path to cut shapes into boxes, but notes that these effects are applied after borders/outlines/shadows.
To create a three-sided top edge, the author uses the :before pseudo-element, applying border-radius to the top two corners and omitting the bottom border. The height of the pseudo-element is adjusted to create a trapezoid shape that fits perfectly on top. The same technique is applied to the bottom edge using the :after pseudo-element.
The author also discusses how to create matching side borders, addressing a potential issue where the outline wraps around the top/bottom edges and creates a gap between the corners. By switching to using outline with the outline-offset property, the author resolves this issue.
While the technique isn't perfect, the author explains that using thin borders (1-2px) minimizes visible issues. They also share a trick for making platforms stand out by using an outer edge with different colors.
Lastly, the author mentions an interesting feature of border-radius – the ability to create angled bevels by using different horizontal and vertical radius values. They note that this property has been available for a long time, but corner-shape makes it more useful.
Rewritten by urgent.news; may contain errors — check the original.
Source: joshwcomeau.com
Read the original at joshwcomeau.com →
Report a problem with this story
Get the day's news by email. Daily, weekly or monthly. Sign up