Earlier this week, I released a new NPM package focused on button UI sound effects(opens in new tab):
I had a lot of fun coming up with this retro-sci-fi aesthetic, and a big part of what gives it that effect is all of the diagonal beveled corners:



I created these bevels using the brand-new corner-shape property, but it was surprisingly tricky. To get some of these effects, we need to use this new property in somewhat-unintuitive ways!
In this blog post, we’ll dig into this new property and I’ll share the secrets I used to create this sort of UI. ✨
Link to this headingThe basics
Let’s start with a “Hello World” type example:
Code Playground
<style> .box { corner-shape: bevel; border: 2px solid tomato; /* Try changing me! */ border-radius: 16px; } </style> <div class="box"></div>
When we set corner-shape: bevel, it changes how the border-radius property works. Instead of producing a rounded quarter-circle, it instead draws a diagonal line:
.box {
width: 150px;
height: 150px;
border: 4px solid;
border-radius: 32px;
corner-shape: bevel;
}One of the really cool things about corner-shape is that it changes the element’s actual border box. This means that other properties like outline and box-shadow respect the beveled corners:
Code Playground
<style> .box { --shadow-color: hsl(0deg 0% 0% / 0.5); corner-shape: bevel; border: 6px solid red; outline: 6px solid white; border-radius: 32px; box-shadow: 0px 2px 4px var(--shadow-color), 0px 4px 8px var(--shadow-color), 0px 8px 16px var(--shadow-color); } </style> <div class="box"></div>
This is a big part of what makes corner-shape so special. We can use long-supported properties like clip-path to cut all sorts of shapes into our boxes, but clip-path gets applied after borders/outlines/shadows.
Link to this headingMixing colors
What happens when we change the color of one of the box’s sides? Well, let’s give it a shot:
Code Playground
<style> .box { /* A white border... */ border: 2px solid white; /* ...except on top: */ border-top-color: red; border-radius: 16px; corner-shape: bevel; } </style> <div class="box"></div>
I actually don’t love this behaviour 😅. We transition harshly from one color to the other in the very center of the bevel. I can’t think of many situations where this would be useful.
That said, something more interesting happens if we only include the border itself on one side:
Code Playground
<style> .box { corner-shape: bevel; /* NOTE: Only border-top, no other borders. */ border-top: 6px solid red; border-radius: 32px; } </style> <div class="box"></div>
Now that’s useful! The width of the border tapers from the full border-width down to 0 along the diagonal edge.
By stategically picking lighter/darker colors for the top/bottom edges, we can create the illusion of a raised platform:
Unfortunately, as I write this on December 1st 2026, there’s a bug(opens in new tab) in Chrome that causes adjacent borders to overlap when different colors are used. That bug has been fixed in Chrome Canary, but the fix won’t ship until Chrome 159 is released next week, on December 8th 2026.
So, if we want to actually do this today, we need the borders to be on separate elements. We can use ::before/::after pseudo-elements for this:
Code Playground
<style> .box { position: relative; background: hsl(45deg 90% 60%); border-radius: 32px; corner-shape: bevel; &::before, &::after { content: ''; position: absolute; inset: 0; border-radius: inherit; corner-shape: inherit; pointer-events: none; } &::before { border-top: 6px solid hsl(50deg 100% 75%); } &::after { border-bottom: 6px solid hsl(35deg 60% 46%); } } </style> <div class="box"></div>
This is kind of a neat effect, but it’s actually not what I usually want. On my buttons project, I found I preferred having each corner match either the top or bottom border color:
Instead of tapering the diagonal corners, I want them to match either the top or bottom edge, all the way through. Essentially, our 8-sided octagon follows these rules:
- The top three edges are a lighter color.
- The bottom three edges are a darker color.
- The two vertical edges connecting them are somewhere in-between.
This turned out to be a bit tricky. Let's start with the top/bottom edges. I’ll choose high-contrast colors so we can really see what’s going on:
Code Playground
<style> .box { --r: 32px; position: relative; border-radius: var(--r); corner-shape: bevel; background: hsl(210deg 15% 15%); &::before, &::after { content: ''; position: absolute; left: 0; right: 0; height: var(--r); border-radius: inherit; corner-shape: inherit; pointer-events: none; } &::before { top: 0; border-radius: var(--r) var(--r) 0 0; border: 6px solid white; border-bottom: none; } &::after { bottom: 0; border-radius: 0 0 var(--r) var(--r); border: 6px solid gray; border-top: none; } } </style> <div class="box"></div>
The ::before pseudo-element creates the white three-sided top edge, and the key trick here is that we’re only applying border-radius to the top two corners. The bottom two corners have zero radius, and we also omit the bottom border.
Then, by adjusting the height of the pseudo-element, we can create a trapezoid shape that fits perfectly on top. Try reducing the height here:
If the height of the pseudo-element matches the top-left/top-right radius exactly, we’ll wind up with this three-sided shape that works perfectly as our top edge!
We repeat the same trick for the bottom edge with the ::after pseudo-element, but with everything flipped; we omit the top border and apply border-radius exclusively to the bottom corners.
Link to this headingAdding side borders
We can use ::before and ::after for the top/bottom edges, but right now, they don’t connect to anything. We’re missing our matching side borders!
Unfortunately, it isn’t as simple as slapping a border on the parent element:
Code Playground
<style> .box { --r: 32px; position: relative; border-radius: var(--r); /* 👇 Try adding a regular border: */ border: 6px solid darkgray; corner-shape: bevel; background: hsl(210deg 15% 15%); &::before, &::after { content: ''; position: absolute; left: 0; right: 0; height: var(--r); border-radius: inherit; corner-shape: inherit; pointer-events: none; } &::before { top: 0; border-radius: var(--r) var(--r) 0 0; border: 6px solid white; border-bottom: none; } &::after { bottom: 0; border-radius: 0 0 var(--r) var(--r); border: 6px solid gray; border-top: none; } } </style> <div class="box"></div>
Yikes! The border is wrapping around the top/bottom edges. We’re also winding up with an awkward gap between the two corners.
The simplest fix for this is for us to switch from border to outline. outline has a lovely sibling property called outline-offset which allows us to push the outline in, so that it sits underneath the top/bottom edges:
Code Playground
<style> .box { --r: 32px; --border-width: 6px; position: relative; border-radius: var(--r); corner-shape: bevel; background: hsl(210deg 15% 15%); /* 👇 Use outline instead: */ outline: var(--border-width) solid darkgray; outline-offset: calc(var(--border-width) * -1); &::before, &::after { content: ''; position: absolute; left: 0; right: 0; height: var(--r); border-radius: inherit; corner-shape: inherit; pointer-events: none; } &::before { top: 0; border-radius: var(--r) var(--r) 0 0; border: var(--border-width) solid white; border-bottom: none; } &::after { bottom: 0; border-radius: 0 0 var(--r) var(--r); border: var(--border-width) solid gray; border-top: none; } } </style> <div class="box"></div>
This complete approach isn’t quite perfect; ideally, the joint between top/bottom and sides would be angled, rather than drawing completely horizontally. But I’m using big chunky borders here to really demonstrate the technique. In practice, I tend to use borders that are only 1-2px thick, and at that scale, there’s no visible issue.
Link to this headingNested borders
A trick I discovered while building Button Sounds(opens in new tab) is that we can make platforms stand out by giving them an outer edge as well:
Code Playground
<style> .outer.box { --r: 16px; --top-color: hsl(210deg 30% 22%); --side-color: hsl(210deg 25% 30%); --bottom-color: hsl(210deg 20% 45%); padding: 3px; background: black; } .inner.box { --r: 14px; --top-color: hsl(210deg 35% 75%); --side-color: hsl(210deg 20% 35%); --bottom-color: hsl(210deg 25% 30%); width: 160px; height: 100px; background: hsl(210deg 15% 10%); } .box { --r: 32px; --border-width: 1px; position: relative; border-radius: var(--r); corner-shape: bevel; outline: var(--border-width) solid var(--side-color); outline-offset: calc( var(--border-width) * -1 ); &::before, &::after { content: ''; position: absolute; left: 0; right: 0; height: var(--r); border-radius: inherit; corner-shape: inherit; pointer-events: none; } &::before { top: 0; border-radius: var(--r) var(--r) 0 0; border: var(--border-width) solid var(--top-color); border-bottom: none; } &::after { bottom: 0; border-radius: 0 0 var(--r) var(--r); border: var(--border-width) solid var(--bottom-color); border-top: none; } } </style> <div class="outer box"> <div class="inner box"></div> </div>
In this playground, the outer box is flipped; it's darker on top and lighter on the bottom. This suggests the edge of a recessed area or a hole. It’s like our box is sitting within its own little cubbyhole!
It takes some trial and error to figure out all of the colors. I like to use the HSL color format for this purpose, since I can nudge the saturation/lightness percentages up/down until everything looks right.
Link to this headingAngled bevels
There’s one final little trick I want to share. we can create angled bevels by picking different horizontal/vertical radius valus.
This’ll be easier to explain with a demo:
.box {
width: 150px;
height: 150px;
border: 4px solid;
border-radius: 48px / 48px;
corner-shape: bevel;
}If you haven’t seen that / character used in CSS yet, it’s used as a delimiter, to separate different sets of values. It has nothing to do with division.
The snippet above is using a condensed form of the property. border-radius actually takes eight separate values, written as two sets of four:
.box {
/* Specifying all values at once: */
border-radius: 1px 2px 3px 4px / 5px 6px 7px 8px;
}The first four values specify the horizontal radius, while the last four specify the vertical radius. We typically only provide horizontal values, and in that case, the same values are copied for the vertical radii.
This has been a thing with border-radius for a long time; we can use it to create elliptical corners rather than circular ones:
Code Playground
<style> .box { border: 2px solid tomato; border-radius: 16px / 32px; } </style> <div class="box"></div>
Honestly, I never found myself doing this too often, since the ovals never quite looked right to me. But now, with corner-shape, it’s super useful!
It’s beyond the scope of this post, but corner-shape provides a whole set of interesting values. squircle produces much-more-satisfying rounded corners when we provide asymmetrical / elliptical values:
Code Playground
<style> .box { border: 2px solid tomato; border-radius: 32px / 64px; corner-shape: squircle; } </style> <div class="box"></div>
Link to this headingWhimsical Animations
If you’ve followed my work for a while, you know that I care a lot about polish and aesthetics. I really want my products to feel good to use.
A huge part of that comes from animations and interactions. I’ve spent nearly two decades figuring out how to use HTML/CSS, JavaScript, SVG, and Canvas to create one-of-a-kind user interfaces.
I share all of my secrets in my latest course, Whimsical Animations(opens in new tab).
This course is currently 40% off for Black Friday, but that sale ends on December 2nd. This is the first opportunity since the course launched earlier this year to pick it up at such a discounted price.
You can learn more here:
Last updated on
December 1st, 2026

