Log No. 018 min read

Nested corners should share a centre.

An inner corner looks right when its hidden circle shares the centre of the outer one. That takes one subtraction, and the subtraction has edges.

In this entry

Section 1 of 7

Below are two cards side by side. Each has a rounded corner and an inner box that sits a little inside it. Only the corners of the two inner boxes differ. Flip between them, and pick the one that looks right.

Tap the card that looks right.

Fig.Pick the card whose inner corner looks right.

In one card the band around the inner box runs even. In the other it thickens at each corner. You already know which is which. This post is about why.

The numbers that appeared after your pick showed it. Both cards have a 24px corner and 8px of padding. The inner box that takes 16px keeps a gap of 8px at the corner, the same as along the sides. The inner box that takes 24px leaves about 11.3px.1

I noticed this by using border-radius and looking up the patterns for border radii online.

A corner is cut from a circle

border-radius: 24px sets the radius of a circle, and the corner is a quarter of it.2 The rest of that circle stays hidden behind the box. Its centre sits 24px in from the left edge and 24px down from the top edge.

Drag the inner radius below, and watch the circles behind the two corners.

11.3px8pxone centreouter centreinner centre
24px
Fig.Drag the inner radius, and watch the two hidden circles.

The dot of the inner circle slid along the diagonal as you dragged, and at 16px it landed on the dot of the outer one. Each visible curve is only a quarter of its circle. The centre you never see decides how the two curves sit together.

A shared centre is a subtraction

You just watched two circles become concentric: they share a centre. Apple uses the word the same way: a concentric corner "shares a common center with the containing shape's rounded corner radius".3

Draw a curve at a fixed distance from another curve, and you get its parallel curve. Picture a pipe bent around a corner. Its inner wall stays the same distance from its outer wall through the whole bend, so the pipe keeps its thickness. The inner wall is the parallel curve of the outer one.4 Offset a straight line, and you get a line. Offset a circle, and you get a smaller circle with the same centre.5

Your inner box sits 8px inside each edge of the card. Go back to the two dots on the slider. The outer dot sat 24px in from each edge. The inner box starts 8px in, so its dot sits 8px plus its own radius in. The dots met at 16px, because 8 + 16 = 24. There the inner corner is the parallel curve of the outer one: the same centre, a radius 8px smaller, and 8px of gap all the way round.6,7

text
inner radius = outer radius − gap

Apple computes its concentric corners this way, as the radius of the container minus the distance between the corners.8 You will also meet the rule the other way round in older guides: outer radius = inner radius + padding.4,9

The gap holds the border of the parent

Measure the gap from the outer edge of the parent to the outer edge of the child. CSS already runs this subtraction inside one box: the padding edge takes the outer radius minus the border width, and the content edge takes that minus the padding.2 So your gap is the padding of the parent plus the border of the parent.7 Try it on a card with a 1px border, 12px of padding, and a 20px corner. Its child takes 7px, not 8px.

Leave the border of the child out. border-radius shapes the outer edge of the border of the box you set it on.2 A margin on the child, or any other inset, goes into the gap.10

Which radius comes first

The rule runs in two directions, and which one you take depends on the design and the use case. Inward, you pick the radius of the outer layer and subtract the gap for each layer inside it. Apple and the CSS proposal for a border-radius keyword both run it inward, from the container.8,10 Outward, you pick the radius of the innermost layer and add the gap for each layer around it. A commenter in the CSS issue argues for the outward run, because a chain driven from the outside leaves the deepest children with no rounding at all.10

Add the layers one by one, from the button outward.

88R 8R 16R 24
1 of 3 · Button
  1. Button
  2. Toolbar
  3. Window
Fig.Drag to add the layers, from the button outward.

The button kept its 8px. The toolbar took 16px, and the window took 24px, three times the radius of the button.

That growth is the cost of the outward run: the outer radii grow with each layer you add. A heavily rounded container also loses usable space at its corners.11 The inward run pays at the other end, in the deepest children, as the next section shows. The CSS at the end of this post runs inward, from the card.

When the padding passes the radius

Give a card a 12px corner and 16px of padding. The rule asks for an inner radius of −4px.

Drag the padding past the radius below, then turn on the minimum.

Padding
8px
Inner radius
4px
Corner gap
8px
8px
8px
Fig.Drag the padding past 12px, then turn on the minimum.

With no minimum, the inner corner went square as soon as the padding reached the radius. With the minimum, it kept a curve, its centre walked away from the outer one, and the ruler read a gap wider than the padding.

The square is what CSS gives you. A calc() result out of range clamps to the allowed range, so border-radius: calc(8px - 16px) is a valid zero, not a dropped declaration.12

A minimum keeps a curve, but it gives up the shared centre. The CSS spec says so of a clamped inner curve: it might not share the centre of the outer one.2 Once the centres part, the gap at the corner widens again, as it did with the equal radii of the first card.

The edges of the rule

The shared centre was the means, and the even gap is the goal. A circular corner with even padding gets both. Give a card 8px of padding across and 16px down, and no circular radius keeps both gaps even. The concentric answer is an elliptical corner, border-radius: calc(R - 8px) / calc(R - 16px), horizontal first.7,2 Lea Verou noted in the CSS issue that the general case needs elliptical radii.10 That ellipse keeps the centre of the outer arc. It cannot keep the gap even, because the padding itself is uneven: the gap runs from 8px on one side to 16px on the other. It is concentric, but it is not the parallel curve of the outer arc.

Squircles bend the rule in another way. A squircle eases its curvature from the straight edge into the curve, where a circle jumps to its full curvature at once.13 The parallel curve of a squircle is not a squircle,5,14 so the same shape at R − d leaves you a gap that is only close to even. Nobody has measured how close.

Why the shared centre feels cohesive rests on the opinion of designers: Apple says aligned radii let shapes "comfortably nest".15 The one measured result is broader: people prefer objects with curved contours over sharp ones,16 and no study measures nested corners. This post reads the cohesive feel as that preference for curves, carried through each layer of the nest.

The CSS

Three custom properties on the parent hold the radius, the border, and the padding.6,9 The child subtracts the border of the parent as well as its padding, because the gap holds both, as the section on the gap showed.7

concentric.css
.card {
  --radius: 24px;
  --border: 1px;
  --padding: 8px;
  border: var(--border) solid;
  border-radius: var(--radius);
  padding: var(--padding);
}

.card > .inner {
  border-radius: calc(var(--radius) - var(--border) - var(--padding));
}

When the padding passes the radius, the calc() goes below zero, and CSS clamps it to a square corner.12 You need no max() for that. For a minimum above zero, wrap the subtraction in max():

concentric.css
.card > .inner {
  border-radius: max(4px, calc(var(--radius) - var(--border) - var(--padding)));
}

max(0, …) fails, because a bare 0 inside a math function is a number, not a length.12,7

Sources

  1. These numbers come from the geometry of the arcs, not from a source. Two arcs of equal radius 8px apart sit 8 × √2 apart along the diagonal of the corner. The same geometry gives the wider gap once a minimum parts the centres, and the uneven gap of the elliptical corner. ↩

  2. CSS Backgrounds and Borders Module Level 3, W3C, sections 4.1 to 4.3. ↩ ↩2 ↩3 ↩4 ↩5

  3. ConcentricRectangle, Apple Developer Documentation. ↩

  4. Ian Yates, Quick Tip: Rounded Corners Done Right, Envato Tuts+, 2012. ↩ ↩2

  5. Parallel curve, Wikipedia. ↩ ↩2

  6. Paul Hebert, The Math Behind Nesting Rounded Corners, Cloud Four, 2022. ↩ ↩2

  7. Daniel Cheong, The Concentric Border Radius Rule, DEV Community. ↩ ↩2 ↩3 ↩4 ↩5

  8. concentric(minimum:), Apple Developer Documentation. ↩ ↩2

  9. Angelos Chalaris, Nested border radius, 30 seconds of code, 2022. ↩ ↩2

  10. Adam Argyle and commenters, New border-radius value for perfectly matching nested radii, CSS Working Group, issue 7707. ↩ ↩2 ↩3 ↩4

  11. Reimar Servas, The law of the instrument, 2026. ↩

  12. CSS Values and Units Module Level 4, W3C, sections 10.9 and 10.12. ↩ ↩2 ↩3

  13. Daniel Furse, Desperately Seeking Squircles, Figma, 2018. ↩

  14. CSS Borders and Box Decorations Module Level 4, Editor's Draft. ↩

  15. Apple Design Team, Get to know the new design system, WWDC25. ↩

  16. Moshe Bar and Maital Neta, Humans prefer curved visual objects, Psychological Science, 2006. ↩

End of log No. 01

Know someone who would read this? Pass it on.