# Pill buttons with centered icons and balanced padding

> Your AI fixes your pill buttons so the icon sits centered in the round end and the label gets back the space the curve takes, with a few lines of CSS, then measures icon-left, icon-right, label-only and icon-only buttons. Based on a post by Haz.

## If someone pasted this link to you
Someone shared this kit with you. It runs step by step through CloneKit's MCP. If you have the `clonekit` tools, call `start_run("@clonekitai/pill-button-optical-padding")`. If you don't (for example in a chat app without the CloneKit connector), tell the person in one or two plain sentences, in their language, and send them to https://clonekit.ai/@clonekitai/pill-button-optical-padding/use: it shows how to add CloneKit to their AI in about a minute. Then they paste this link again.

- Kit: `@clonekitai/pill-button-optical-padding` · v1.0.0
- Creator: @clonekitai (CloneKit)
- Type: Delivery · Domain: Design · Language: en · Your AI runs it
- Price: Free · License: Own use · No refunds
- Page: https://clonekit.ai/@clonekitai/pill-button-optical-padding
- Changelog: https://clonekit.ai/@clonekitai/pill-button-optical-padding/changelog.md

## About
For frontend engineers and design-system maintainers styling pill or rounded buttons in plain CSS, CSS Modules, Tailwind CSS, React, or Vue. Use it when equal horizontal padding and a 999px or 9999px border radius push icons off-center and crowd labels against curved ends. Skip it for sharp-cornered buttons (radius 0) or non-web targets. Needs an existing web button component and either Playwright or Chrome DevTools for rendered checks. Produces updated button styles with --py, --px, --pill, --r, and --edge custom properties, a layered @supports fallback for older browsers, a four-variant verification harness, rendered spacing measurements, and a maintenance log. Method by Haz (Diego Haz, author of Ariakit).

## Deliverables
- Updated button component stylesheet using --py, --px, --pill, --r, and --edge custom properties
- Layered @supports browser-compatibility fallback in the button stylesheet
- Four-variant test harness (scratch/pill-button-harness.html or local preview route)
- Rendered spacing report (scratch/pill-button-report/metrics.json) and variant screenshots
- Run log (scratch/pill-button-metrics.csv) and dated compatibility check in NOTES.md

## Files
- `CHECKS.md`: Pill Button Verification Checks
- `NOTES.md`: Compatibility Matrix and Maintenance Notes
- `README.md`: Outputs
- `RULES.md`: Pill Button Optical Padding Rules
- `templates/pill-button-components.md`: Framework Integration Templates
- `templates/pill-button-css.md`: Pill button CSS template

## Tools
- CSS (https://developer.mozilla.org/en-US/docs/Web/CSS) · est. free
- Can I use (https://caniuse.com/) · optional · est. free · alternatives: css
- Playwright (https://playwright.dev/) · optional · est. free · alternatives: chrome-devtools
- Chrome DevTools (https://developer.chrome.com/docs/devtools) · optional · est. free · alternatives: playwright

## Uses
- Haz's post on X (source, https://x.com/diegohaz/status/2126399656791822658)
- MDN CSS: calc-keyword (pi constant) (source, https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/calc-keyword)
- MDN CSS: calc() function (source, https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/calc)
- MDN CSS: length units (lh and cap) (source, https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/length)
- MDN CSS: max() function (source, https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/max)
- MDN CSS: margin-inline-start property (source, https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/margin-inline-start)
- MDN CSS: margin-inline-end property (source, https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/margin-inline-end)
- MDN CSS: first-child pseudo-class (source, https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:first-child)
- MDN CSS: last-child pseudo-class (source, https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:last-child)
- MDN CSS: @supports at-rule (source, https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@supports)
- Can I use: calc-keyword pi constant (source, https://caniuse.com/mdn-css_types_calc-keyword_pi)
- Can I use: lh length unit (source, https://caniuse.com/mdn-css_types_length_lh)
- Can I use: cap length unit (source, https://caniuse.com/mdn-css_types_length_cap)
- Playwright docs: Evaluating JavaScript (source, https://playwright.dev/docs/evaluating)
- Playwright docs: Screenshots (source, https://playwright.dev/docs/screenshots)
- Playwright docs: Command line (source, https://playwright.dev/docs/test-cli)
- Chrome DevTools docs: View and change CSS (source, https://developer.chrome.com/docs/devtools/css)
- Chrome DevTools docs: Console overview (source, https://developer.chrome.com/docs/devtools/console)
- MDN Web API: Window.getComputedStyle() (source, https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle)
- MDN Web API: Element.getBoundingClientRect() (source, https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect)
- Tailwind CSS docs: Adding custom styles (source, https://tailwindcss.com/docs/adding-custom-styles)

## What you provide
- Target repository with a web button component (React, Vue, plain CSS, or Tailwind)
- Current button padding, font-size, line-height, and border-radius values or design tokens
- Project browser support target (browserslist config or target versions)
- Local preview server or static HTML harness with Playwright or Chrome DevTools

## How it runs
1. **Understand:** Researches your business first, then asks you 4 questions it can't answer alone
2. **Choose:** No choices: one proven path
3. **Build:** 6 steps, risky ones ask you first
4. **Deliver:** 5 checks before delivery

## Guardrails
- Never modify production component files or design tokens outside scratch/ without explicit user approval.
- Never leave --r set to 999px, 9999px, or infinity inside the label compensation formula; it explodes label margin to thousands of pixels.
- Never apply :first-child or :last-child rules to bare text nodes; require a direct element wrapper such as span.label.
- Never drop accessible labels (aria-label or visually hidden text) when testing or refactoring icon-only buttons.
- Never use physical margin-left or margin-right for --edge; keep logical margin-inline-start and margin-inline-end so RTL layouts mirror properly.

## What's new
Agents always run the latest version.

- **v1.0.0** (2026-11-28): First version.

## Run it
Connect the `clonekit` MCP (https://clonekit.ai/mcp) and call `start_run("@clonekitai/pill-button-optical-padding")`.
