Nested Border-Radius Optimization

Keep nested radii concentric

Settings

Direction

The chosen side becomes the input and the other side is calculated

px
Padding mode
px
Presets

Preview

Optimal inner radius12px= max(0, 28px − 16px)

CSS

.outer {
  border-radius: 28px;
  padding: 16px;
}

.inner {
  border-radius: 12px;
}

What is Nested Border-Radius Optimization?

Given an outer radius and padding, this tool calculates the inner border-radius that keeps nested corners concentric. It keeps the gap between the outer and inner corners equal in nested cards and panels.

When the inner and outer radii are the same, the gap widens along the diagonal at the corners. Reducing the inner radius by the padding keeps the gap equal to the padding at every angle when the padding is uniform.

How to Use

  1. Choose whether to derive the inner radius from the outer radius or the outer radius from the inner radius.
  2. Enter the radius for the chosen side.
  3. Enter the padding.
  4. Check how the gap widens in the preview and copy the CSS.

How the Radius Is Calculated

The inner radius is the outer radius minus the padding. If the result is below zero, it becomes 0px (square). When the padding is split into vertical and horizontal values, the smaller one is used. When deriving the outer radius, the padding is added to the inner radius.

Main Settings

Direction

Switching carries the calculated value over to the input side.

Padding Mode

Uniform applies the same padding to all four sides, while V / H lets you set vertical and horizontal values separately.

CSS Format

Literal outputs the calculated numbers, while calc() expresses the inner radius with CSS variables and subtraction. Later changes to the outer radius or padding no longer require manually updating the inner radius. calc() is available only when the padding is uniform.

Presets

Selecting a commonly used combination of radius and padding sets the outer radius and padding, and resets the padding mode to uniform. Presets cannot be selected while deriving the outer radius.

Use Cases

  • Aligning the corners of a card frame and its inner container naturally
  • Matching the radius of elements inside modals and dialogs
  • Trying different vertical and horizontal padding combinations
  • Deciding radius-and-padding pairs for a design system

Things to Keep in Mind

  • The radius accepts values from 0 to 120px, and the padding accepts values from 0 to 80px
  • If deriving the outer radius produces a value above 120px, the CSS uses that value, but switching the direction rounds it down to 120px