Monday, October 20, 2025

What Can We Truly Do With corner-shape?


After I first began messing round with code, rounded corners required 5 background photos or an picture sprite probably created in Photoshop, so when border-radius got here onto the scene, I bear in mind everyone pondering that it was the most effective factor ever. Internet designs had been very sq. on the time, so to have border-radius was tremendous cool, and it saved us plenty of time, too.

Chris’ border-radius article from 2009, which on the time of writing is 16 years outdated (wait, how outdated am I?!), consists of vendor prefixes for older net browsers, together with “outdated Konqueror browsers” (-khtml-border-radius). What a time to be alive!

We’re a lot much less enthusiastic about rounded corners these days. In truth, sharp corners have made a comeback and are simply as standard now, as are squircles (square-ish circles or circle-y squares, take your decide), which is precisely what the corner-shape CSS property permits us to create (along with many different cool UI results that I’ll be strolling you thru in the present day).

On the time of writing, solely Chrome 139 and above helps corner-shape, which have to be used with the border-radius property or/and any of the associated particular person properties (i.e., border-top-left-radius, border-top-right-radius, border-bottom-right-radius, and border-bottom-left-radius):

Snipped corners utilizing corner-shape: bevel

These snipped corners have gotten increasingly more standard as UI designers embrace brutalist aesthetics.

Black button with snipped corners at the upper-left and lower-right that reads ‘Grab your ticket.’

Within the instance above, it’s as simple as utilizing corner-shape: bevel for the snipped corners impact after which border-bottom-right-radius: 16px for the scale.

corner-shape: bevel;
border-bottom-right-radius: 16px;

We will do the identical factor and it actually works with a cyberpunk aesthetic:

A rectangular container with a medium bright red border flanked by two tab buttons above it with a beveled bottom-right corner.

Slanted sections utilizing corner-shape: bevel

Slanted sections is a visible impact that’s much more standard, in all probability not going wherever, and once more, helps components to look so much much less just like the containers that they’re.

Earlier than we dive in although, it’s necessary to understand that every border radii has two semi-major axes, a horizontal axis and a vertical axis, with a ‘level’ (to make use of vector terminology) on every axis. Within the instance above, each are set to 16px, so each factors transfer alongside their respective axis by that quantity, away from their nook after all, after which the beveled line is drawn between them. Within the slanted part instance under, nevertheless, we have to provide a special level worth for every axis, like this:

corner-shape: bevel;
border-bottom-right-radius: 100% 50px;

A large section heading against a solid purple background with white lettering. The container’s bottom-right corner is clipped, giving the container a slanted bottom edge.

The primary level strikes alongside 100% of the horizontal axis whereas the second level travels 50px of the vertical axis, after which the beveled line is drawn between them, creating the slant that you simply see above.

By the way in which, having totally different values for every axis and border radius is precisely how these cool border radius blobs are made.

Sale tags utilizing corner-shape: spherical bevel bevel spherical

You’ve see these sale tags on nearly each e-commerce web site, both as photos or with rounded corners and never the sharp half (different methods simply aren’t definitely worth the bother). However now we are able to carve out the right form utilizing two various kinds of corner-shape without delay, in addition to an entire set of border radius values:

Red rectangular box with rounded corners on the left and beveled corners on the right forming an arrow shape with the label ‘Sale’ in white.

You’ll want corner-shape: spherical bevel bevel spherical to begin off. The order flows clockwise, ranging from the top-left, as follows:

  • top-left
  • top-right
  • bottom-right
  • bottom-left

Similar to with border-radius. You can omit some values, inflicting them to be inferred from different values, however each the inference logic and ensuing worth syntax lack readability, so I’d simply keep away from this, particularly since we’re about to discover a extra advanced border-radius:

corner-shape: spherical bevel bevel spherical;
border-radius: 16px 48px 48px 16px / 16px 50% 50% 16px;

Left of the ahead slash (/) we have now the horizontal-axis values of every nook within the order talked about above, and on the proper of the /, the vertical-axis values. So, to be clear, the primary and fifth values correspond to the identical nook, as do the second and sixth, and so forth. You’ll be able to unpack the shorthand if it’s simpler to learn:

border-top-left-radius: 16px;
border-top-right-radius: 48px 50%;
border-bottom-right-radius: 48px 50%;
border-bottom-left-radius: 16px;

Up till now, we’ve probably not wanted to totally perceive the border radius syntax. However now that we have now corner-shape, it’s undoubtedly price doing so.

As for the precise values, 16px corresponds to the spherical corners (this one’s simple to grasp) whereas the 48px 50% values are for the bevel ones, which means that the corners are ‘drawn’ from 48px horizontally to 50% vertically, which is why and the way they head into some extent.

Relating to borders — sure, the sharp components would look nicer in the event that they had been barely rounded, however utilizing borders and defines on these components yields unpredictable (however I think supposed) outcomes because of how browsers draw the corners, which sucks.

Arrow crumbs utilizing the identical methodology

Yep, identical factor.

A rounded rectangular box in three purple arrow-shaped segments pointing towards the right. Each segment is a breadcrumb, labeled Step 1, Step 2, and Step 3 in white. The first segment is a darker shade of purple.

We primarily have a grid row with adverse margins, however as a result of we are able to’t create ‘inset’ arrows or use borders/outlines, we have now to create an impact the place the pretend borders of sure arrows bleed into the following. That is performed by nesting the very same form within the arrows after which making use of one thing to the impact of padding-right: 3px, the place 3px is the worth of the would-be border. The code feedback under ought to clarify it in additional element (the whole code in the Pen is sort of fascinating, although):

ol {
  /* Clip n’ spherical */
  overflow: clip;
  border-radius: 16px;

  li {
    /* Arrow colour */
    background: hsl(270 100% 30%);

    /* Reverses the z-indexes, making the arrows stack */
    /* Outcome: 2, 1, 0, ... (sibling-x requires Chrome 138+) */
    z-index: calc((sibling-index() * -1) + sibling-count());

    &:not(:last-child) {
      /* Arrow width */
      padding-right: 3px;

      /* Arrow form */
      corner-shape: bevel;
      border-radius: 0 32px 32px 0 / 0 50% 50% 0;

      /* Pull the following one into this one */
      margin-right: -32px;

    }

    a {
      /* Similar form */
      corner-shape: inherit;
      border-radius: inherit;

      /* Overlay background */
      background: hsl(270 100% 50%);
    }
  }
}

Tooltips utilizing corner-shape: scoop

Small purple button with white text and a red outline next to a red tooltip with white text floated to the right and a styled caret tip on the left side making it connected to the button.

To create this tooltip fashion, I’ve used a popover, anchor positioning (to place the caret relative to the tooltip), and corner-shape: scoop. The caret form is identical because the arrow form used within the examples above, so be at liberty to modify scoop to bevel for those who desire the basic triangle tooltips.

A fast walkthrough:





Don’t eat yellow snow

#tooltip {
  /* Outline anchor */
  anchor-name: --tooltip;

  /* Vital reset */
  margin: 0;

  /* Heart vertically */
  align-self: anchor-center;

  /* Pin to proper aspect + 15 */
  left: calc(anchor(proper) + 15px);

  &::after {
    /* Create caret */
    content material: "";
    width: 5px;
    peak: 10px;
    corner-shape: scoop;
    border-top-left-radius: 100% 50%;
    border-bottom-left-radius: 100% 50%;

    /* Anchor to tooltip */
    position-anchor: --tooltip;

    /* Heart vertically */
    align-self: anchor-center;

    /* Pin to left aspect */
    proper: anchor(left);

    /* Popovers have this already (required in any other case) */
    place: mounted;
  }
}

Should you’d reasonably these had been hover-triggered, the upcoming Curiosity Invoker API is what you’re searching for.

Life like highlighting utilizing corner-shape: squircle bevel

The component, used for semantic highlighting, defaults with a yellow background, but it surely doesn’t precisely create a highlighter impact. By including the next two strains of CSS, which admittedly I found by experimenting with fully random values, we are able to make it look extra like a hand-waved spotlight:

mark {
  /* A...squevel? */
  corner-shape: squircle bevel;
  border-radius: 50% / 1.1rem 0.5rem 0.9rem 0.7rem;

  /* Prevents background-break when wrapping */
  box-decoration-break: clone;
}

Text reading ‘Highlighted text’ in black against a yellow background containing no sharp edges.

We will additionally use squircle by itself to create these fancy-rounded app icons, or use them on buttons/playing cards/kind controls/and so on. for those who assume the ‘outdated’ border radius is beginning to look a bit stale:

Squircle shaped box filled with a linear gradient that goes from orange to blue with white text on top that says ‘CSS’.

Squircle-shaped purple button with a white label that says ‘Button.’

Hand-drawn containers utilizing the identical methodology

Similar factor, solely bigger. Type of appears like a hand-drawn field?

Solid white rectangular box with thick, black borders that look hand-drawn.

Admittedly, this impact doesn’t look as superior on a bigger scale, so for those who’re actually seeking to wow and create one thing extra akin to the Crimson Useless Redemption aesthetic, this border-image method could be higher.

Clip a background with corner-shape: notch

Notched border radii are ugly and I gained’t hear in any other case. I don’t assume you’ll need to use them to create a visible impact, however I’ve discovered that they’re helpful for background clipping for those who set the irrelevant axis to 50% and the axis of the aspect that you simply need to clip by the quantity that you simply need to clip it by. So for those who needed to clip 30px off the background from the left for instance, you’d select 30px for the horizontal axes and 50% for the vertical axes (for the -left-radius properties solely, after all).

corner-shape: notch;
border-top-left-radius: 30px 50%;
border-bottom-left-radius: 30px 50%;

The words ‘Clipped background’ in bold black letters with a thinly-bordered rectangle that nearly covers the text.

Conclusion

So, corner-shape is definitely a helluva lot of enjoyable. It definitely has extra makes use of than I anticipated, and little question with some experimentation you’ll provide you with some extra. With that in thoughts, I’ll go away it to you CSS-Tricksters to fiddle with (bear in mind although, you’ll have to be utilizing Chrome 139 or greater).

As a parting present, I go away you with this very cool however fully ineffective CSS Tie Fighter, made with corner-shape and anchor positioning:

Hexagon shape with six black segments forming the shape, separated by gaps of gray space. The negative space in the middle forms another hexagon.

Related Articles

Latest Articles