Repository navigation
Description
Summary
Establishing token naming conventions and defining how corner radii work in XDS OSS. The proposal introduces a three-layer radius system: a base scale, a theme-level multiplier, and a dynamic concentric radius function for nested elements.
Proposal
The system has three layers:
1. Base Radius Scale
The base radius unit is 4dp (radius-1). All other tokens are multiples of this base:
| Token | Value | Internal vanity | Scales with multiplier | Example components |
|---|---|---|---|---|
radius-0 |
0dp | radius-none | No — always 0 | Dividers, table cells, side panels, shared edges (button groups) |
radius-1 |
4dp | radius-content | Yes | Code blocks, inner content |
radius-2 |
8dp | radius-element | Yes | Buttons, inputs, text areas, tokens |
radius-3 |
12dp | radius-container | Yes | Cards, modals, popovers, dropdown menus, toasts |
radius-4 |
16dp | radius-page | Yes | Page sections, large containers |
radius-rounded |
9999dp | radius-rounded | No — always pill | Badges, avatars, status dots, toggles |
Note:
radius-0andradius-roundedare fixed — they are never affected by the multiplier.
2. Multiplier
A theme-level scalar (radius-multiplier) that scales the base radius and, by extension, all derived tokens. Ranges from 0 to 2:
| Multiplier | Effect |
|---|---|
radius-multiplier: 0 |
Sharp (everything becomes 0) |
radius-multiplier: 0.5 |
Subtle |
radius-multiplier: 1 |
Default |
radius-multiplier: 1.5 |
Rounded |
radius-multiplier: 2 |
Pill-like |
E.G.
The multiplier applies to the base unit. So at multiplier: 1.5:
radius-1= 4 × 1.5 = 6dpradius-2= 8 × 1.5 = 12dpradius-3= 12 × 1.5 = 18dpradius-4= 16 × 1.5 = 24dp
3. Dynamic Radius (Concentricity)
For nested elements, inner radii should follow the concentric radius function to maintain visual harmony:
innerRadius = max(0, outerRadius - padding)
This ensures nested corners don't look awkward when outer containers have large radii. E.g. A card with radius-3 (12dp) and 8dp padding would give its inner content max(0, 12 - 8) = 4dp inner radius.
Code
// --- Token definitions ---
const RADIUS_BASE = 4; // dp
const radiusScale = {
'radius-0': 0, // fixed, never scales
'radius-1': RADIUS_BASE * 1, // 4dp
'radius-2': RADIUS_BASE * 2, // 8dp
'radius-3': RADIUS_BASE * 3, // 12dp
'radius-4': RADIUS_BASE * 4, // 16dp
'radius-rounded': 9999, // fixed, never scales
} as const;
// --- Multiplier (set at theme level) ---
type RadiusToken = keyof typeof radiusScale;
function resolveRadius(token: RadiusToken, multiplier: number = 1): number {
const base = radiusScale[token];
// radius-0 and radius-rounded are immune to multiplier
if (token === 'radius-0' || token === 'radius-rounded') {
return base;
}
return base * multiplier;
}
// --- Dynamic concentric radius ---
function concentricRadius(outerRadius: number, padding: number): number {
return Math.max(0, outerRadius - padding);
}
// --- Usage examples ---
// Default theme (multiplier = 1)
resolveRadius('radius-3'); // → 12dp (card)
resolveRadius('radius-2'); // → 8dp (button inside card)
// Rounded theme (multiplier = 1.5)
resolveRadius('radius-3', 1.5); // → 18dp
resolveRadius('radius-2', 1.5); // → 12dp
// Sharp theme (multiplier = 0)
resolveRadius('radius-3', 0); // → 0dp
resolveRadius('radius-0'); // → 0dp (always)
resolveRadius('radius-rounded'); // → 9999dp (always)
// Concentric: card with 12dp radius and 8dp padding
const cardRadius = resolveRadius('radius-3'); // 12dp
const innerRadius = concentricRadius(cardRadius, 8); // max(0, 12-8) = 4dp/* CSS custom properties */
:root {
--xds-radius-base: 4px;
--xds-radius-multiplier: 1;
--xds-radius-0: 0px;
--xds-radius-1: calc(var(--xds-radius-base) * 1 * var(--xds-radius-multiplier));
--xds-radius-2: calc(var(--xds-radius-base) * 2 * var(--xds-radius-multiplier));
--xds-radius-3: calc(var(--xds-radius-base) * 3 * var(--xds-radius-multiplier));
--xds-radius-4: calc(var(--xds-radius-base) * 4 * var(--xds-radius-multiplier));
--xds-radius-rounded: 9999px;
}
/* Theme override — rounded */
[data-theme="rounded"] {
--xds-radius-multiplier: 1.5;
}
/* Theme override — sharp */
[data-theme="sharp"] {
--xds-radius-multiplier: 0;
}
/* Concentric radius utility */
.card-inner {
/* outerRadius - padding */
border-radius: max(0px, calc(var(--xds-radius-3) - 8px));
}Token Naming: Scale vs. Semantic
We're proposing numeric scale names (radius-0 through radius-4) rather than semantic names (radius-content, radius-element, radius-container, etc.).
For reference, the current internal XDS tokens use semantic names:
--radius-content: 4px,--radius-element: 8px,--radius-container: 12px
Why scale-based naming?
-
Semantic names don't fit every component cleanly. There are too many edge cases where a component doesn't map neatly to a single semantic category:
- Badges — contention on whether these should be
radius-roundedor a smaller radius - Checkboxes — can never be pill-shaped, but also don't fit a single semantic bucket
- Radio buttons — always circular, always
radius-rounded - Media / thumbnails — could be
radius-contentorradius-elementdepending on context - Avatars — contention on whether these should be
radius-roundedor a smaller radius
With semantic names, you'd need to either force-fit these into a category or add bespoke tokens — both of which bloat the system.
- Badges — contention on whether these should be
-
Fewer tokens, less ambiguity. Scale names let us keep a tight set of 6 tokens without needing to answer "is this a content radius or an element radius?" every time a new component is introduced.
-
Radius is baked into components. The intention is that the appropriate radii will be built into components and the consumer would not need to reason about which radius token to use.
Trade-offs
Scale-based (radius-1, radius-2, ...) |
Semantic (radius-content, radius-element, ...) |
|
|---|---|---|
| Ambiguity | Something likeradius-2 doesn't tell you why it's used |
Something likeradius-element communicates its purpose more clearly but can be ambiguous across component types |
| LLM understanding | Radii are baked into components, the LLM doesn't choose them | If the LLM does need to pick a token, semantic names guide it |
| Scalability | Adding something like radius-5 is trivial |
Naming a new semantic tier requires defining its role |
| Edge cases | Handled — components that don't fit just pick the closest number | Awkward — forces components into semantic buckets they may not belong to |
| Documentation overhead | Need to document internally what each number maps to | Names are self-explanatory |
References of things out in the wild
- Another internal library uses a single
--radiusbase value with 1×/2×/3× presets. Simpler but flatter: all components get the same radius. Our approach preserves hierarchy across the scale. - SwiftUI ConcentricRectangle — Apple's native support for concentric corner radii in nested views. Validates the concentric radius pattern.
Open Questions / Notes
- Is this a good default multiplier range?
0–2covers sharp-to-pill. - Should the concentric function be a built-in utility or left to component authors?
- How does this interact with the existing internal semantic tokens (
--radius-content,--radius-element,--radius-container)? - How will concentricity technically work with all the different paddings we have
- Any other open qs?
Activity
[-]RFC: Dynamic Corner Radius System — Token Scale, Multiplier & Concentricity[/-][+]Dynamic Radius — Token Scale, Multiplier & Concentricity[/+]cixzhang commentedon Mar 18, 2026
🧪 Vibe Test Results: Semantic vs Numeric Radius Token Naming
Ran an A/B vibe test to compare the current semantic naming (
--radius-container,--radius-element, etc.) against the proposed numeric scale (--radius-1through--radius-4) with 12 prompts across 3 categories: radius selection, theming, and composition.Results
Key Findings
1. Hierarchy gap → numeric wins
The semantic scheme has no token between
container(12px) androunded(9999px). In a nested layout test (page section > card > inputs), both page section and card collapsed to--radius-container, losing a hierarchy level. Numeric handled it cleanly with--radius-4(16px) >--radius-3(12px) >--radius-2(8px).2. Natural language mapping → semantic wins
When users describe elements semantically ("container-level elements"),
--radius-containeris an instant match. With numeric tokens, the LLM had to mentally translate through the docs table to reach--radius-3.3. Multiplier support → numeric enables
The theme switcher test (rad-9) naturally leveraged the multiplier concept with numeric tokens. Semantic names don't convey relative scale needed for multiplier patterns.
4. Both work equally well overall
100% success rate on both sides. The differences are in ergonomics, not correctness. LLMs can use either scheme effectively with proper documentation.
Bottom Line
The data supports moving to numeric naming:
The semantic scheme's advantage (natural language mapping) is real but mitigated by the fact that radius is baked into components — builders rarely pick radius tokens directly.
Test Infrastructure
internal/vibe-tests/results/7666ab7f/(semantic) and26b3b7f0/(numeric)*— via Navi on behalf of Cindy ·
feat: dynamic radius — numeric token scale, multiplier & radiusScale …
feat: dynamic radius — numeric token scale, multiplier & radiusScale …
feat: useConcentricRadius hook for harmonized nested corners (#669)
feat: dynamic radius — numeric token scale, multiplier & radiusScale …
feat: dynamic radius — numeric token scale, multiplier & radiusScale …
feat: dynamic radius — numeric token scale, multiplier & radiusScale …