· JavaScript
CSS corner-shape property lets developers create beveled corners using border-radius
The creation of a retro-sci-fi visual style, characterized by diagonal corners, can be achieved using the new "corner-shape" CSS property, though mastering it requires employing some rather…
The creation of a retro-sci-fi visual style, characterized by diagonal corners, can be achieved using the new "corner-shape" CSS property, though mastering it requires employing some rather intricate technical maneuvers.
This recent NPM package I released, dedicated to button UI sound effects, is heavily influenced by this retro-sci-fi aesthetic, and a significant contributor to that look is the presence of these diagonal beveled corners. While I constructed these bevels utilizing the novel corner-shape property, the process proved unexpectedly complex, demanding that we apply this new feature in somewhat unconventional ways to achieve certain visual effects. This article will delve into this new property, revealing the specific techniques I employed to generate this particular kind of user interface.
Regarding compatibility, as of this writing in late 2026, support for corner-shape is limited to Chromium browsers, though this situation is set to change soon; the property is already present in the beta builds of Safari (27.3) and Firefox 162 nightly. In the interim, I consider it perfectly acceptable to implement this property as a progressive enhancement. My "Button Sounds" project, for instance, does not appear as visually striking with standard rounded corners, yet I still find it acceptable.
It is important to note that if your browser lacks support for this property, the interactive playgrounds and specific demonstrations on this page may not render as intended. While I have incorporated fallback images in certain instances, if you happen to possess a browser that supports this feature, I strongly encourage you to consult this post.
To begin, here is a basic "Hello World" illustration:
<style> .box { corner-shape: bevel; border: 2px solid tomato; /* Try changing me! */ border-radius: 16px; } </style> <div class="box"></div>
When we assign `corner-shape: bevel`, it fundamentally alters the function of the `border-radius` property. Instead of rendering a rounded quarter-circle, it instead draws a diagonal line.
We are using the `border-radius` property to dictate the depth of the bevel, which is a semantically unusual application. Typically, the term "radius" denotes the distance from the center to the edge of a circle, and in this context, no circles are involved. If we were designing CSS from the ground up today, this setup would seem peculiar, but much like the evolution of CSS itself, we are building the framework as we proceed. Since developers are already familiar with and utilize `border-radius`, I am ultimately pleased that the CSSWG, the governing body for CSS specifications, opted to reuse an existing property rather than introduce a completely new one like `bevel-depth`. Initially, I also found it strange that the measurement is taken horizontally or vertically, rather than diagonally from the corner's center. However, this specific behavior ensures consistency across all corner-shape values—bevels, circles, and other variations not covered here—by limiting the value to a maximum of half the element's dimension. In this demonstration, since our box measures 150px across, the maximum `border-radius` is 75px, a limit that applies equally to both bevels and circles.
Another powerful aspect of corner-shape is that it modifies the element's actual border box. Consequently, other properties such as `box-shadow` and `outline` respect these newly formed beveled corners.
This aspect is a major reason why corner-shape is so distinctive. While we can employ widely supported properties like `clip-path` to shape our boxes, `clip-path` is processed subsequent to borders, outlines, and shadows. What happens when we alter the color of one of the box's sides? Let's test that:
In the case of traditional rounded corners, the color change occurs midway across the curve. With bevels, however, the transition is abrupt, shifting from one color to another precisely at the center of the bevel. I struggle to envision many practical scenarios where this sharp transition would prove beneficial. Nevertheless, a more intriguing outcome emerges when we apply the border to only one side.
When the border is tapered from the full width down to nothing along the diagonal edge, this opens up possibilities. By thoughtfully selecting lighter or darker hues for the top and bottom edges, we can effectively simulate the appearance of a raised platform.
As of December 1st, 2026, there is a known bug within Chrome where adjacent borders overlap when distinct colors are employed. Although this issue has been resolved in Chrome Canary, the official fix will not be delivered until Chrome 159 is released next week, on December 8th, 2026. Therefore, if one intends to implement this effect today, the borders must reside on separate elements. This can be accomplished using `::before` or `::after` pseudo-elements.
While this technique yields a rather neat visual effect, it is not typically what I seek for my applications. For my buttons project, I found it preferable for each corner to consistently match either the top or the bottom border color, rather than tapering across the diagonal. Essentially, the resulting eight-sided octagon must adhere to these rules: the top three edges must be a lighter tone, the bottom three edges a darker tone, and the two connecting vertical edges must fall somewhere in between. Achieving this proved somewhat challenging.
To begin, let's focus on the top and bottom edges, using highly contrasting colors to clearly observe the effect:
The `::before` pseudo-element constructs the white three-sided top edge, and the crucial technique here involves applying `border-radius` only to the top two corners, leaving the bottom two corners without radius, while also omitting the bottom border. By adjusting the pseudo-element's height, we can sculpt a trapezoidal shape that fits perfectly as the top border. Repeating this process for the bottom edge using `::after` involves inverting the procedure; we exclude the top border and apply `border-radius` exclusively to the bottom corners. Although we can use `::before` and `::after` for the top and bottom sections, they currently lack the necessary connecting side borders.
It is not as straightforward as simply applying a border to the main parent element. Applying a regular border results in the border wrapping around the top and bottom sections, and it also creates an unsightly gap between the two corners. The most straightforward remedy is to switch from using a border to using an outline. The outline possesses a helpful sibling property, `outline-offset`, which permits pushing the outline inward so that it sits beneath the top and bottom edges.
Why it matters
This new CSS property offers developers a powerful, albeit complex, way to achieve specific visual aesthetics like retro-sci-fi UIs. Developers should monitor browser adoption, as current support is limited, making progressive enhancement a key consideration for implementation.