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.
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
- top
- 10
- left
- 16
- right
- 16
- bottom
- 10
- top
- 10
- left
- 14
- right
- 16
- bottom
- 10
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 file | The method: build clean, look, find what is lying, nudge, name the nudge, re-check every state. |
|---|---|
| Case table | Twelve cases, each with its measured answer and its optical answer. |
| Button | An icon slot that trims its own side by the glyph's inset, start or end, RTL-safe. |
| Tokens | One inset per glyph set, one padding scale. The trim is a name, never a bare number. |
| Optical helpers | Mass-centred nudges for play, arrows and chevrons; inner radius = outer - padding. |
| Checklist | Eight checks to run before a button or badge ships, in both themes. |
Not just buttons
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.
Trailing icon
The arrow's ink stops short of its box on the end side. Trim that side so the gap matches the start.
Nested radius
Inner radius is outer minus padding, so the two corners run parallel instead of pinching.
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
: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 */
}