Visually Align Buttons

Optical alignment over measured alignment: trim padding until icons, labels and shapes look centred, then keep the numbers that got them there. Buttons first, then anything else the eye judges.

Skills

How it works

A box is a rectangle. A glyph is a shape with empty corners, a slanted edge or a heavy side. The eye reads the shape, so when the two disagree, the shape wins.

The skill builds the clean version first, then trims by the smallest amount that looks right, and keeps that trim as a named value next to the thing it trims. Buttons are the case everyone sees. The same rule runs through every other place the eye judges.

Measured against optical

Measuredleft reads loose
top
10
left
16
right
16
bottom
10
content … · seen gap 18 / 16
Opticallooks even
top
10
left
14
right
16
bottom
10
content … · seen gap 16 / 16

Blue is padding, drawn at 1.5× so the numbers under it are the real ones. The amber line is where the left gap is seen to end: the glyph’s ink, which starts 2px inside its 16px box. Measured padding of 16 leaves a seen gap of 18 against 16. Trimming the glyph’s side to 14 makes both 16, and the button comes out 2px narrower on purpose.

What you get

Skill fileThe method: build clean, look, find what is lying, nudge, name the nudge, re-check every state.
Case tableTwelve cases, each with its measured answer and its optical answer.
ButtonAn icon slot that trims its own side by the glyph's inset, start or end, RTL-safe.
TokensOne inset per glyph set, one padding scale. The trim is a name, never a bare number.
Optical helpersMass-centred nudges for play, arrows and chevrons; inner radius = outer - padding.
ChecklistEight checks to run before a button or badge ships, in both themes.

Not just buttons

box centred
mass centred

Play triangle in a circle

A triangle's box is centred, but its mass sits left of the box. Shift it right by about an eighth of its width.

Next
16 / 16
Next
16 / 14

Trailing icon

The arrow's ink stops short of its box on the end side. Trim that side so the gap matches the start.

20 in 20
12 in 20

Nested radius

Inner radius is outer minus padding, so the two corners run parallel instead of pinching.

36 and 36
36 and 40

Circle beside a square

A circle reads smaller than its box. Give it one step more size so the two look the same.

Files it creates

app/globals.css
:root {
/* How far a glyph's ink sits inside its own box, per side. Trim by this much. */
--icon-inset: 2px;
--button-pad-x: 1rem; /* 16px, the measured padding */
--button-pad-y: 0.625rem; /* 10px */
}