All articles
Design & UXNovember 26, 2026 6 min read

Optical Alignment: Why Your Perfectly Centered UI Still Looks Off

Mathematical centering is a lie your layout engine tells you. Here's how to fix the tiny visual misalignments that make polished UIs feel cheap — with concrete CSS, token, and Figma tactics.

Your button is centered. The CSS says so, the Figma inspector confirms it, the dev tools overlay agrees. And yet, something is off. The play icon inside that circular avatar drifts left. The dropdown caret sits half a pixel too high. The whole UI feels slightly drunk.

You are not imagining it. Mathematical centering and visual centering are different things, and the gap between them is where cheap UI lives.

The problem: your geometry is right, your eyes are not wrong

Browsers, Figma, and every layout engine on earth center things by bounding box. They take the rectangle around the glyph or shape, find its midpoint, and align that. Simple, deterministic, correct.

Human perception doesn't work that way. We center things by visual mass — where the weight of the shape actually lives. A triangle's bounding box center is nowhere near its perceived center. A capital letter with a descender-less shape sits visually higher than its box. An icon of a play button (a right-pointing triangle) has all its weight to the left of its geometric center.

This is called optical alignment, and once you start seeing it, you cannot unsee it.

The classic offenders

A few shapes break mathematical centering every single time:

  • Play icons inside circular buttons. The triangle's mass is left-biased; the geometric center looks shoved against the left edge.
  • Arrow and chevron icons in square hit areas. Direction equals asymmetry.
  • Typography inside pills and buttons — especially when the font has large side bearings or when you mix all-caps with mixed-case siblings.
  • Avatars and logos inside circular frames, when the logo itself isn't radially symmetrical.
  • Modal dialogs vertically centered in the viewport. True center looks bottom-heavy; slightly above center reads as balanced.

A quick test: the triangle demo

Drop this into any HTML scratchpad. The first button centers the triangle mathematically. The second nudges it by a few percent.

<div class="row">
  <!-- Mathematically centered -->
  <button class="play">
    <svg viewBox="0 0 24 24" width="20" height="20">
      <polygon points="6,4 20,12 6,20" fill="currentColor"/>
    </svg>
  </button>

  <!-- Optically centered -->
  <button class="play optical">
    <svg viewBox="0 0 24 24" width="20" height="20" style="transform: translateX(1.5px)">
      <polygon points="6,4 20,12 6,20" fill="currentColor"/>
    </svg>
  </button>
</div>

<style>
  .play {
    width: 56px; height: 56px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    background: #111; color: white;
    border: none;
  }
</style>

Stare at them side by side. The second one is centered. The first one is correct.

Fixing it in code without wrecking your design system

The wrong instinct is to sprinkle margin-left: 2px everywhere. Within a week you have 40 magic numbers and no one remembers why.

The right instinct is to bake optical correction into the primitive, so consumers never think about it.

Option 1: Correct inside the SVG itself

Shift the artwork within the viewBox so the icon's visual center matches the viewBox center. This is the cleanest fix because every downstream use inherits it.

<!-- Before: triangle sits visually left -->
<svg viewBox="0 0 24 24">
  <polygon points="6,4 20,12 6,20"/>
</svg>

<!-- After: shifted right by ~1.5 units -->
<svg viewBox="0 0 24 24">
  <polygon points="7.5,4 21.5,12 7.5,20"/>
</svg>

If you run an icon library — custom or something like Lucide, Phosphor, Heroicons — audit the asymmetric ones once. Fix them at the source. Done forever.

Option 2: Correct at the component level

Sometimes you cannot or should not change the icon file. Wrap the correction inside a component so it's invisible to app code.

export function PlayButton({ onClick }: { onClick: () => void }) {
  return (
    <button
      onClick={onClick}
      className="grid place-items-center w-14 h-14 rounded-full bg-black text-white"
    >
      <PlayIcon className="w-5 h-5 translate-x-[1.5px]" />
    </button>
  );
}

The translate-x-[1.5px] is a crime scene in isolation. Inside a well-named primitive, it's just the component doing its job.

Option 3: Design tokens for optical offsets

If you have a handful of asymmetric glyphs, formalise the offset.

export const opticalOffsets = {
  playTriangle: { x: 1.5, y: 0 },
  chevronRight: { x: 0.5, y: 0 },
  chevronDown:  { x: 0,   y: 0.5 },
} as const;

This gives you one place to tune, a searchable name, and a conversation starter when a designer asks "why is this nudged?"

Typography: the silent offender

Buttons are where this bites hardest. A button with text that looks centered in Figma often rides high or low in the browser because of line-height, font metrics, and the invisible space above capitals.

A few practical rules we follow:

  • Set line-height: 1 on button labels. Use padding to control height. This removes the inherited leading that pushes text off-center in short containers.
  • When mixing icon + text inside a button, align them with display: inline-flex; align-items: center; and then add a small negative margin or translate to the icon if the font has a tall x-height.
  • For pills with uppercase text, remember that caps have no descenders. The text looks bottom-heavy. Reduce bottom padding by 1 – 2 pixels relative to the top.
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 10px 16px 9px; /* 1px less at the bottom */
  line-height: 1;
}

Modals and overlays

A modal at top: 50%; transform: translateY(-50%) reads as too low. Bump it up — somewhere in the 40 – 45% range of viewport height tends to feel balanced, especially for shorter modals. The visual weight of the page sits above the fold, so true center looks sunken.

.modal {
  position: fixed;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
}

Test on tall and short viewports before shipping.

The Figma → Tailwind handoff problem

Most optical alignment bugs enter the codebase during handoff. The designer eyeballed the nudge in Figma using a translate on the layer, didn't write it down, and the dev inspected the auto-layout which reports zero offset.

Two things help:

  1. Make optical offsets a documented layer style in Figma. A component with a named variant like Icon / Play / Optical beats a mystery nudge. In dev mode, the offset shows up as an explicit transform.
  2. Review components in the browser together, not in Figma. Font rendering differs between Figma and Chrome. The only honest check is the real thing. We've killed entire rounds of "why does it look different in prod?" by doing a 15-minute pairing session on the rendered output.

If you want more on bridging that gap generally, our design systems work covers the handoff pipeline end-to-end.

Accessibility: don't undo your good work

Optical nudges are visual-only. Make sure they don't leak into things that matter for assistive tech:

  • Don't shift hit areas. If you translate an icon by 2px, the button's click target should still be the full button, not the shifted glyph.
  • Keep focus outlines on the container, not the inner icon. A focus ring that inherits a translate will drift and look like a bug.
  • Contrast ratios are unaffected by translation, but if you're tempted to fix "off" centering by shrinking an icon, remember WCAG target-size guidance — interactive targets should remain comfortably tappable (the 24px minimum under WCAG 2.2, 44px where you can manage it).

When to stop

Optical alignment is a diminishing-returns game. The play button in your hero? Worth 20 minutes. The icon in a tooltip that shows for 800ms? Probably not.

A practical heuristic: fix optical alignment on surfaces users stare at (primary CTAs, avatars, nav, empty states, modals) and leave the rest alone. Perfection in the wrong places is its own form of waste.

Where we'd start

If this article made you suspicious of your own UI, run this three-step audit next Monday:

  1. Screenshot your five most-used buttons and components at 2x. Blur your eyes slightly. Anything that looks off at a glance probably is.
  2. Audit your icon library for asymmetric glyphs — play, chevrons, arrows, send, speaker. Fix them in the SVG source, not downstream.
  3. Add one line to your component review checklist: "Does this look centered, or is it just mathematically centered?"

That question alone will catch more polish bugs than any linter.

#Design Systems#UX#CSS#Figma#Accessibility

Want a team like ours?

72Technologies builds production software for the kind of teams who actually read this blog.

Start a project