---name: fix-mobiledescription: Find and fix every mobile web bug you never see on a laptop: horizontal sideways drift (320-390px), iOS Safari input auto-zoom (<16px), 100vh bottom-bar clipping, stuck touch hover states, tiny tap targets (<44px), tap flash/delay, and mobile menus that push the page. Works on any React, Next.js, Vue, Svelte, Astro, or plain HTML/CSS/Tailwind app without changing your desktop design.license: MITmetadata: author: Hairline UI url: https://hairlineui.com/skills/fix-mobile version: "1.0.0"---# /fix-mobileFind and fix the mobile web bugs that slip past desktop development: sideways page drift under a thumb, iOS Safari zooming in on form fields, bottom bars clipped by mobile browser chrome, stuck hover states after tapping, tiny tap targets, and menus that shove the page down.This skill is **zero-redesign and zero-lock-in**. It preserves your desktop layout, colors, typography, and component library. It only fixes real mobile breakage and verifies the result in Chromium at `320px`, `375px`, and `390px`.## Guardrails (never break these)- **Never slap `overflow-x: hidden` on `html` or `body` to hide horizontal overflow.** `overflow-x: hidden` on an ancestor silently breaks every `position: sticky` header, table, and sidebar beneath it, and merely masks the broken element. Always fix the offending element itself; if a page wrapper genuinely needs edge clipping for a full-bleed animation, use `overflow-x: clip` (which preserves `position: sticky`).- **Never disable pinch-to-zoom** (`maximum-scale=1` or `user-scalable=no` in `<meta name="viewport">`). Fix iOS auto-zoom by keeping mobile input text at `>= 16px`, not by breaking accessibility.- **Never shrink or alter desktop layouts** unless a broken flex/grid constraint (`min-w-0`, `minmax(0, 1fr)`) is strictly safer at all widths.- **Never add external dependencies or UI libraries.** Every fix is plain CSS, Tailwind, or HTML.- **Never report a fix you did not verify.**---## Step 1 — Measure the baseline (browser + source scan)### 1A. Run the Chromium mobile verifier (recommended)If a local dev server is running (e.g. `http://localhost:3000`), fetch and run the standalone verifier across your main routes at `320px`, `375px`, and `390px` with touch emulation enabled:```bashcurl -sL https://hairlineui.com/skills/fix-mobile-check.mjs -o /tmp/fix-mobile-check.mjsnode /tmp/fix-mobile-check.mjs http://localhost:3000 --routes /,/pricing,/settings```*(On Windows PowerShell, use `curl.exe -sL https://hairlineui.com/skills/fix-mobile-check.mjs -o $env:TEMP\fix-mobile-check.mjs` then `node $env:TEMP\fix-mobile-check.mjs http://localhost:3000`.)*Save the output counts (overflowing elements by route/width, `<16px` inputs, sub-44px tap targets, raw `100vh` traps, unwrapped `:hover` rules, and menu-push distance). You will compare them at the end.### 1B. Static source scan (works even without a running server)Run these ripgrep checks from the project root and record the hit counts:```bashG='-g *.{tsx,jsx,ts,js,vue,svelte,astro,html,css} -g !node_modules -g !.next -g !dist'# 1. Horizontal overflow suspects: 100vw, bare flex-1 in responsive column-to-row, wide fixed widthsrg -n '\b(w-screen|min-w-screen|100vw)\b' $G .rg -n 'flex-col[^"\x27`]*\b(sm|md|lg):flex-row' $G .# 2. iOS Safari input auto-zoom (<16px inputs/selects/textareas)rg -n '<(input|textarea|select)\b[^>]*\btext-(xs|sm|\[1[0-5]px\])' $G .# 3. Viewport height clipping (raw 100vh instead of 100dvh / 100svh)rg -n '\b(h-screen|min-h-screen|max-h-screen|100vh)\b' $G .# 4. Fixed/sticky bottom bars potentially missing safe-area paddingrg -n '(fixed|sticky)[^"\x27`]*bottom-0' $G .# 5. Viewport meta tag anti-patternsrg -n 'user-scalable\s*=\s*no|maximum-scale\s*=\s*1(\.0)?\b' $G .# 6. Raw CSS :hover rules that may stick on touch devices (check if wrapped in @media (hover: hover))rg -n ':hover\b' -g '*.css' -g '!node_modules' -g '!.next' -g '!dist' .```---## Step 2 — Fix each class of bug properly### 2.1 Sideways phone drift (horizontal overflow at `320px`, `375px`, `390px`)Find every element whose right edge exceeds `document.documentElement.clientWidth`. Fix the actual layout cause:| Root cause | What it looks like | Proper fix || --- | --- | --- || **Flex child with `truncate` / long text / code** | `flex items-center` child overflows because flex items default to `min-width: auto` | Add `min-w-0` on the flex item (and every flex ancestor between it and the truncated element) || **CSS Grid track expanding past viewport** | `grid-cols-[1fr_auto]` or `grid-template-columns: 1fr 1fr` with long code/URL inside | Use `minmax(0, 1fr)` (Tailwind `grid-cols-2` already uses `minmax(0, 1fr)`, custom arbitrary tracks do not) || **`100vw` / `w-screen`** | Includes the vertical scrollbar width or escapes a padded parent | Replace with `w-full` (`100%`) || **Bare `flex-1` inside a `flex-col sm:flex-row` stack** | On narrow screens, `flex-1` sets `flex-basis: 0%` vertically and collapses inputs/panels | Scope it to the row breakpoint: `sm:flex-1` (or `@sm:flex-1`) || **Wide tables, code blocks, or tab strips** | `<pre>`, `<table>`, or horizontal pill lists widen the whole page | Wrap in `overflow-x-auto max-w-full` (`min-w-0` if inside flex/grid) with `-webkit-overflow-scrolling: touch` || **Decorative blurs / animated slides sticking past the edge** | Glows, rotated shapes, or `translateX(...)` entrance elements outside section bounds | Add `overflow-x-clip` (`overflow-x: clip`) on that specific section — never `overflow-x: hidden` on `body` || **Long unbroken URLs, emails, or hashes** | Single token wider than `288px` at `320px` viewport | Add `break-words` / `overflow-wrap: anywhere` (or `truncate` where appropriate) |### 2.2 iOS Safari input auto-zoom (`font-size < 16px`)On iOS Safari, tapping any `<input>`, `<textarea>`, or `<select>` whose computed `font-size` is under `16px` zooms the entire viewport in and leaves the page stuck zoomed after dismissal.- **Fix:** Ensure every text-entry `<input>`, `<textarea>`, and `<select>` computes to at least `16px` below `768px`, stepping back down on desktop if your design uses `14px`: - Tailwind: `text-base md:text-sm` (or `text-[16px] sm:text-sm`) - Plain CSS: ```css @media (pointer: coarse) { input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), textarea, select { font-size: max(16px, 1em); } } ```- **Skip:** `checkbox`, `radio`, `range`, `hidden`, `file`, `button`, `submit`, and inputs with `font-size >= 16px` already.### 2.3 `100vh` clipping & safe-area insets on bottom barsOn mobile Safari and Chrome, `100vh` equals the height *with the URL bar hidden*, which pushes sticky bottom CTAs, chat composers, and full-screen modals underneath the browser bar or iPhone home indicator.- **Fix full-height layouts, drawers, and modals:** - Replace `h-screen` / `min-h-screen` / `max-h-screen` with `h-dvh` / `min-h-dvh` / `max-h-dvh` (or `svh` for static hero frames that should not jump when the URL bar retracts). - In plain CSS, provide a fallback before `dvh`: ```css min-height: 100vh; min-height: 100dvh; ```- **Fix bottom-docked navs, sticky footers, sheets, and chat composers:** - Ensure `<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">` is set if the app uses full-bleed mobile chrome. - Add safe-area bottom padding so controls never collide with the iOS home indicator: ```css padding-bottom: max(0.75rem, env(safe-area-inset-bottom)); ``` (Tailwind arbitrary value: `pb-[max(0.75rem,env(safe-area-inset-bottom))]`.)### 2.4 Stuck hover states on touch devicesOn iOS and Android, tapping an element triggers `:hover` and leaves it stuck until the user taps elsewhere.- **Tailwind v4:** Built-in `hover:` utilities are already wrapped in `@media (hover: hover)` by default — leave those alone!- **Tailwind v3:** Enable `future: { hoverOnlyWhenSupported: true }` in `tailwind.config.*` if the project uses Tailwind v3.- **Custom CSS / CSS Modules / styled components:** Wrap pure visual `:hover` rules in `@media (hover: hover) and (pointer: fine)`: ```css @media (hover: hover) and (pointer: fine) { .row:hover { background-color: var(--muted); } } ```- **Always pair with an `:active` state** so taps still feel immediate on touch screens.### 2.5 Tiny tap targets (`< 44 × 44px`), tap delay, and grey tap flash- **Icon buttons, close buttons (`×`), compact pills, and mobile nav links** smaller than `44 × 44px` are frustrating to hit with a thumb.- **Keep the desktop look intact while expanding the touch hit area** using a centered pseudo-element (zero layout change!): ```css @media (pointer: coarse) { .icon-btn { position: relative; } .icon-btn::after { content: ""; position: absolute; inset: 50%; transform: translate(-50%, -50%); min-width: 44px; min-height: 44px; } } ``` Or bump mobile control height directly (`min-h-11 min-w-11 sm:min-h-8 sm:min-w-8`). Check that adjacent expanded targets do not overlap one another.- **Kill double-tap zoom delay and browser tap flash** in the global base stylesheet: ```css a, button, [role="button"], input, select, textarea, summary, label { touch-action: manipulation; -webkit-tap-highlight-color: transparent; } ```### 2.6 Mobile menus & drawers pushing the page or bleeding scroll- **Never push page content down** when opening a mobile menu: render the menu as a `fixed` or `absolute` overlay under the header, close on `Escape` and outside tap, and give links `44px–52px` row height.- **Stop scroll chaining** inside open mobile drawers, sheets, and scrollable popovers by adding `overscroll-behavior: contain` (`overscroll-contain`) on the scrollable drawer panel.---## Step 3 — Verify every fix1. Run your project's typecheck and build (`npm run typecheck` / `npm run build` or equivalent) to confirm zero regressions.2. Re-run the Chromium mobile verifier on the exact same routes: ```bash node /tmp/fix-mobile-check.mjs http://localhost:3000 --routes /,/pricing,/settings ```3. Confirm: - `0px` horizontal overflow at `320px`, `375px`, and `390px` (top and scrolled). - `0` inputs below `16px` on mobile. - `0` clipped bottom bars or mobile menus that push the page. - Desktop layout at `1440px` is visually unchanged.---## Step 4 — Report (keep it tight)Print a short Before → After receipt:```text/fix-mobile — verified at 320px, 375px, 390px Horizontal overflow elements: 6 → 0 Inputs < 16px (iOS zoom): 9 → 0 Sub-44px tap targets: 11 → 0 Raw 100vh / bottom-bar traps: 3 → 0 Unwrapped :hover rules: 4 → 0 Mobile menu page push: 148px → 0pxFiles changed:- src/components/Header.tsx — detached mobile drawer overlay, 48px rows- src/components/PricingTable.tsx — added min-w-0 on flex card header, overflow-x-auto wrapper- src/app/globals.css — touch-action: manipulation, tap-highlight resetNot checked:- Authenticated routes behind /dashboard (no local test session)```