Radius

Three roles, one base, and two rules that keep nested corners concentric at any radius.

Every corner belongs to a role. Controls are buttons, fields, selects, tabs and small marks like badges and checkboxes. Surfaces are cards, dialogs, drawers, popovers, toasts and tooltips. Items are the rows of menus, lists, trees and navigation. Each role multiplies its own value, so you can make every corner sharper or rounder, or round the controls and square the cards. Drag one below and watch the others stay put.

Three roles, three knobs
8px
rounded-control-md 8px
8px

Card

A surface

rounded-surface-md 11.2px
8px
Highlighted item
rounded-item-md 8px

Roles

ClassFactorUsed by
rounded-control-3xs×0.2Checkbox, Kbd xs
rounded-control-2xs×0.6Badge xs–sm, Kbd sm–md, date and time segments
rounded-control-xs×0.828px controls
rounded-control-sm to -lg×132 to 40px controls
rounded-control-xl×1.448px controls
rounded-surface-xs×0.8Tooltip, small alerts
rounded-surface-sm×1Card xs–sm
rounded-surface-md×1.4Card md, popovers, toasts
rounded-surface-lg×1.8Card lg, dialogs, drawers
rounded-surface-xl×2.2Card xl
rounded-item-xs to -xl×0.8, ×1, ×1.4rows by height, like controls

A factor multiplies the role's own value, which follows --radius until you set it. Every side and corner variant exists too: rounded-t-surface-lg, rounded-s-control-md. Pills, like Switch, Radio, Slider and Avatar, stay rounded-full whatever the radius.

Nested corners

A part close to its container's corner keeps the two corners concentric, and two utilities do the arithmetic. Drag the radius and watch both circles keep one centre:

Corners that never line up?
8px
  • rounded-inset-<radius>/<inset> for a part inside a frame, like the button in an InputGroup or the close button of a toast. It takes the outer radius less the inset, but never less than half the outer radius: square at --radius: 0, exactly concentric at a large radius, and never a square button next to round ones in between.
  • rounded-outset-<radius>/<inset> for a container around items, like a menu or the track of pill tabs. It takes the items' radius plus the padding, so the items keep the radius they have anywhere else. Square items make a square container.

The radius is a role step (control-md), a variable ((--frame-radius)) or a length ([12px]). The inset is a spacing step (/1.5 is 6px), a variable or a length.

<div class="rounded-surface-md p-1">
  <img class="rounded-inset-surface-md/1" />
</div>

A part further from the corner than the corner's radius, like the close button of a dialog, isn't concentric with anything. It takes its own role.

Customising

Set a role's value on :root to change it everywhere, or on any element to change it below that element:

:root {
  --radius: 0.5rem;
  --control-radius: 9999px; /* pill buttons and fields */
  --surface-radius: 0; /* square cards and dialogs */
}

The theme customiser in the header sets the same values, and Copy CSS writes the ones you changed.

VariableDefaultDescription
--radius0.5remThe base. Every role follows it until its own value is set.
--control-radiusvar(--radius)Buttons, fields, selects, tabs and small marks.
--surface-radiusvar(--radius)Cards, dialogs, drawers, popovers, toasts and tooltips.
--item-radiusvar(--radius)Rows in menus, lists, trees and navigation.

Next