How to Build a Corner Radius & Border Token System in Modern CSS

The Quick Answer

To build a systematic border-radius token scale in CSS, define standardized curve variables ranging from micro to pill: --radius-sm: 4px, --radius-md: 8px, --radius-lg: 12px, --radius-xl: 16px, and --radius-full: 9999px. When nesting child elements inside a rounded card, always apply the Concentric Radius Formula: childRadius = parentRadius - padding. This prevents awkward corner gaps and maintains consistent concentric geometry.

Interactive Demo Live Preview
sm (4px)
md (10px)
lg (18px)
full

Step 1: The Concentric Radius Rule for Nested Containers

One of the most glaring visual flaws in amateur front-end design is mismatched corner radii between a parent card and its inner content. If your parent container has a border-radius of 16px and 12px internal padding, the inner element must have a border-radius of exactly 4px (16px - 12px). Giving both 16px creates disjointed, clunky visual gaps.

concentric-formula.css
.parent-card {
  --card-radius: 16px;
  --card-padding: 12px;

  border-radius: var(--card-radius);
  padding: var(--card-padding);
}

.inner-badge-or-image {
  /* Concentric Radius Formula: R_inner = R_outer - Padding */
  border-radius: calc(var(--card-radius) - var(--card-padding));
}

Step 2: Full Pill Contour: Why 9999px Beats 50%

Setting border-radius: 50% on an oblong rectangular button distorts the corners into an awkward stretched oval. To create clean, semi-circular pill ends that adapt to any text length, set border-radius: 9999px.

pill-button.css
.pill-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  /* 9999px clamps neatly to half of the element's height */
  border-radius: 9999px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid #6366f1;
  color: #c4b5fd;
}

Step 3: Standardizing Border Widths & Hairline Dividers

Border widths should follow strict token definitions: 1px for standard subtle component boundaries, 2px for active focus rings or selected states, and 4px for primary callout rails.

border-tokens.css
:root {
  --border-width-hairline: 1px;
  --border-width-focus:    2px;
  --border-width-thick:    4px;

  --border-color-subtle:   rgba(255, 255, 255, 0.08);
  --border-color-focus:    #6366f1;
}

Step 4: Apple-Grade Squircles with CSS corner-shape

Standard CSS border-radius produces circular arcs. Premium UI platforms like iOS utilize "squircles" (super-ellipses) which blend corners smoothly into straight lines with continuous curvature. The emerging CSS corner-shape: squircle specification brings this native capability to stylesheets.

squircle.css
.squircle-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  border-radius: 18px;
  /* Future-ready CSS squircle curvature smoothing */
  corner-shape: squircle;
}

Next-Level Addons: Elevating Your Implementation

Take this technique further by combining it with complementary design token studios and animation tools:

sm (4px) full (pill)

1. Radius Tokens Applied to Status Badges & Pill Tags

Explore in Badges, Tags & Status Dots →

See how --radius-sm, --radius-md, and --radius-full tokens dictate visual hierarchy across status dots, pill counters, and metadata chips.

Gradient Border Ring

2. Border Tokens Paired with Gradient Border Rings

Explore in Border, Gradient & Ring Studio →

Combine your border-radius tokens with animated gradient borders and double-ring focus states without clipping inner background graphics.

Concentric Nested Shape

3. Concentric Radius Geometry in Responsive Cards

Explore in Responsive Card Builder →

Inspect mathematically verified concentric radius scaling across nested card media thumbnails, action buttons, and author avatars.

Chaam
Chaam's Pro Tip

A trick I use in almost every project: don't fight specificity battles with !important. Leverage modern CSS cascade layers (@layer) and CSS variables as design tokens—it makes dark/light theme switching and responsive tuning effortless.

Why I Built the Radius & Border Width Tokens Studio

I got tired of guessing values and testing browser quirks in DevTools, so I built this tool to tweak and preview values in real time with 1-click code export.

Open in Radius & Border Width Tokens ↗

Frequently Asked Questions

Practical answers to common implementation questions, browser quirks, and performance tips.

What is the concentric corner radius formula?

The formula is innerRadius = outerRadius - padding. If a card has a 16px corner radius and 12px padding, the child container inside it must have a 4px corner radius to maintain uniform curved spacing.

Why should I use 9999px instead of 50% for pill-shaped buttons?

border-radius: 50% produces an ellipse on rectangular elements, creating deformed corners. border-radius: 9999px automatically caps at half the element's shortest dimension, guaranteeing perfect semi-circular pill ends.

What is an Apple squircle and can it be done in pure CSS?

A squircle (super-ellipse) smooths the abrupt transition between straight lines and circular curves. It is currently being standardized via the CSS corner-shape: squircle property and can also be approximated using SVG clip-paths.

Can border-radius have different horizontal and vertical curves?

Yes. By separating horizontal and vertical radii with a forward slash (e.g. border-radius: 30px / 10px), you create elliptical corners with independent X and Y curvature axes.

How many border-radius tokens should a design system maintain?

A clean design system typically maintains 5 tokens: --radius-sm (2px–4px), --radius-md (6px–8px), --radius-lg (12px–16px), --radius-xl (20px–24px), and --radius-full (9999px).

← Back to all blog guides Launch Generator Studio →