---name: fix-buttonsdescription: Find and fix every dead, jumpy, double-submitting button in your app — including the two silent bugs Tailwind v4 introduced (dropped cursor:pointer on buttons and active:scale-* snapping under transition-transform), async width jumps (Save -> Saving -> Saved), stuck mouse focus rings (focus: vs focus-visible:), icon-only buttons missing aria-label, and disabled buttons trapping tooltips. Works on any React, Next.js, Vue, Svelte, Astro, or Tailwind app.license: MITmetadata: author: Hairline UI url: https://hairlineui.com/skills/fix-buttons version: "1.0.0"---# /fix-buttonsFind and fix every button defect that makes a web app feel sluggish or half-finished: Tailwind v4's silent missing `cursor: pointer`, Tailwind v4's broken `active:scale-*` press transition, async `"Save" -> "Saving..." -> "Saved"` width jumps that shove neighboring buttons sideways, double-submit clicks, stuck blue focus rings on mouse click, icon buttons missing accessible names, and `disabled` buttons that kill explanatory tooltips.This skill is **zero-redesign and zero-lock-in**. It keeps your exact brand colors, border radii, shadows, and button design intact while fixing every mechanical interaction defect.## Guardrails (never break these)- **Do not restyle the project's button aesthetic.** Keep existing colors, shapes, heights, and design-system variants intact.- **Do not break form submission semantics.** Preserve `type="submit"` inside `<form>` and explicitly set `type="button"` on non-submit buttons inside forms so they never submit accidentally.- **Never remove keyboard focus rings.** Replace `focus:` rings with `focus-visible:` so mouse clicks stay clean while keyboard `Tab` stays unmistakably visible.- **Never add external animation or UI libraries.** Every fix is pure CSS, HTML, Tailwind, and React state.- **Verify every fix in Chromium before reporting.**---## Step 1 — Measure the baseline (browser + source scan)### 1A. Run the Chromium button verifier (recommended)With your local dev server running, fetch and run the verifier across your main routes:```bashcurl -sL https://hairlineui.com/skills/fix-buttons-check.mjs -o /tmp/fix-buttons-check.mjsnode /tmp/fix-buttons-check.mjs http://localhost:3000 --routes /,/settings,/billing```*(On Windows PowerShell: `curl.exe -sL https://hairlineui.com/skills/fix-buttons-check.mjs -o $env:TEMP\fix-buttons-check.mjs` then `node $env:TEMP\fix-buttons-check.mjs http://localhost:3000`.)*Save the baseline counts: buttons missing `cursor: pointer`, broken `scale` press transitions, mouse-click stuck focus rings, width-jumping controls, icon buttons without `aria-label`, and `disabled` buttons carrying tooltips.### 1B. Static source scan```bashG='-g *.{tsx,jsx,ts,js,vue,svelte,astro,html} -g !node_modules -g !.next -g !dist'# 1. Tailwind v4 broken press transitions: active:scale-* paired with transition-transform (snaps!)rg -n 'active:scale-[^\s"\x27`]+.*transition-transform|transition-transform.*active:scale-' $G .# 2. Mouse-click stuck focus rings (focus:ring / focus:outline instead of focus-visible:)rg -n '\bfocus:(ring|outline)-[a-z0-9]' $G .# 3. Async label swaps that jump button width without locking sizerg -n '\?\s*["\x27](Saving|Saved|Loading|Submitting|Deleting|Sending|Sent|Copied|Updating|Creating)' $G .# 4. Disabled buttons with title/tooltip attributes (tooltips never fire on disabled buttons)rg -n '<button[^>]*\bdisabled\b[^>]*\btitle=|<button[^>]*\btitle=[^>]*\bdisabled\b' $G .# 5. Buttons inside <form> missing an explicit type attributerg -n '<button(?![^>]*\btype=)' --pcre2 $G .```---## Step 2 — Fix each class of button bug### 2.1 Tailwind v4 dropped `cursor: pointer` on `<button>`Tailwind v4 intentionally changed `<button>` preflight from `cursor: pointer` to `cursor: default`. Half the buttons in migrated or newly scaffolded Tailwind v4 apps silently show the default arrow cursor on desktop.- **Fix (choose what fits the project):** - **Shared button primitive / components:** Add `cursor-pointer disabled:cursor-default aria-disabled:cursor-default` directly on interactive button components and `<button>` elements (keeps reusable components portable). - **App-wide safety net (if the project prefers global pointer on enabled buttons):** ```css @layer base { button:not(:disabled):not([aria-disabled="true"]), [role="button"]:not([aria-disabled="true"]) { cursor: pointer; } } ```### 2.2 Tailwind v4's silent `active:scale-*` snap bugIn Tailwind v4, `scale-*` writes the standalone CSS **`scale`** property (`scale: 0.97`), **not** `transform: scale(0.97)`. That means `transition-transform active:scale-[0.97]` silently snaps with zero easing!- **Fix:** Explicitly include `scale` in the transition list (and respect reduced motion): ```html transition-[background-color,color,border-color,opacity,scale] duration-150 ease-[cubic-bezier(0.16,1,0.3,1)] active:scale-[0.97] motion-reduce:transition-none motion-reduce:active:scale-100 ```- Also add subtle press feedback (`active:scale-[0.97]`) to primary and secondary action buttons that currently give zero visual acknowledgment when clicked.### 2.3 Async label width jumps & double-submit race conditionsSwapping `"Save"` -> `"Saving..."` -> `"Saved"` or `"Copy"` -> `"Copied!"` resizes the button instantaneously and pushes sibling buttons ("Cancel", toolbar icons) sideways. Worse, async `onClick` handlers without an in-flight guard let fast double-clicks fire duplicate API requests.- **Fix 1 — Lock button width across states using an overlapping CSS grid cell (zero JS measurement needed!):** ```tsx <button type="button" disabled={status === 'saving'} aria-busy={status === 'saving'} onClick={handleSave} className="inline-grid cursor-pointer place-items-center ... disabled:cursor-default" > {/* Every possible label reserves width in the same grid cell; only the active one is visible */} <span className="col-start-1 row-start-1 invisible" aria-hidden="true">Saving…</span> <span className="col-start-1 row-start-1 invisible" aria-hidden="true">Save changes</span> <span className="col-start-1 row-start-1"> {status === 'saving' ? 'Saving…' : status === 'saved' ? 'Saved' : 'Save changes'} </span> </button> ``` *(All states share the widest label's exact width, so sibling controls never budge by 1px.)*- **Fix 2 — Guard against double-submit with a ref lock (not React state alone, which lags by one render):** ```tsx const busyRef = useRef(false); const handleSave = async () => { if (busyRef.current) return; busyRef.current = true; setStatus('saving'); try { await save(); setStatus('saved'); } catch { setStatus('error'); } finally { busyRef.current = false; } }; ```### 2.4 Mouse-click stuck focus rings (`focus:` -> `focus-visible:`)Using `focus:ring-2` or `focus:outline` leaves a heavy ring stuck around a button after a normal mouse click.- **Fix:** Replace `focus:ring-*` / `focus:outline-*` on buttons and links with `outline-none focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-offset-2`. Mouse clicks stay spotless; pressing `Tab` shows a crisp keyboard focus ring.### 2.5 Icon-only buttons & `disabled` buttons killing tooltips- **Icon-only buttons:** Every `<button>` containing only an `<svg>` or icon glyph must have a clear `aria-label` (e.g. `aria-label="Close modal"`, `aria-label="Copy invite link"`), and mark the decorative `<svg aria-hidden="true">`.- **`disabled` buttons with tooltips:** Native `disabled` removes the button from pointer events and keyboard focus, so users can never see the tooltip explaining *why* it is disabled (e.g. "Fill in billing email first"). Replace `disabled` with **`aria-disabled="true"`**, guard `onClick` (`if (isDisabled) return;`), and style with `aria-disabled:opacity-50 aria-disabled:cursor-not-allowed` so tooltips still work for mouse and keyboard users.---## Step 3 — Verify every fix in Chromium1. Run your project's typecheck and build.2. Re-run the verifier across the same routes: ```bash node /tmp/fix-buttons-check.mjs http://localhost:3000 --routes /,/settings,/billing ```3. Confirm: - `0` enabled buttons missing `cursor: pointer`. - `0` broken Tailwind v4 `active:scale-*` + `transition-transform` rules. - `0` buttons showing stuck focus rings on mouse click. - `0` icon-only buttons missing an accessible name. - `0` `disabled` buttons trapping a `title` or tooltip.---## Step 4 — Report (keep it tight)```text/fix-buttons — verified in Chromium Missing cursor:pointer (TW v4): 18 → 0 Broken scale press transitions: 6 → 0 (added scale to transition-property) Mouse-click stuck focus rings: 9 → 0 (focus: → focus-visible:) Width-jumping async buttons: 4 → 0 (grid-stacked state width lock + ref guard) Icon buttons missing aria-label: 5 → 0 Disabled buttons hiding tooltips: 2 → 0 (disabled → aria-disabled)Files changed:- src/components/ui/button.tsx — cursor-pointer, transition-[...,scale], focus-visible ring- src/components/SettingsForm.tsx — width-locked Save button + double-submit ref guard- src/components/Toolbar.tsx — added aria-labels on 4 icon buttons, aria-disabled on ExportNot checked:- Checkout button inside hosted payment iframe```