Repository navigation
Description
Problem
On an iPhone, tapping into a text field whose font size is below 16px makes Safari zoom the page in. The layout jumps sideways, the submit button goes off screen, and the visitor has to pinch back out before they can do anything else. It shows up on almost every checkout, login and newsletter form styled at 14px, which is a very common default: Tailwind's text-sm on an input is 14px, and many component libraries ship 14px fields.
The usual "fix" found online makes things worse: adding maximum-scale=1 to the viewport stops the auto-zoom by also stopping people who need zoom from using it. squirrel already flags that (mobile/viewport-zoom, a11y/zoom-disabled). The real fix is a 16px font size on the fields.
squirrel does not check field font sizes. mobile/font-size reads only inline style attributes, on any element, and only reports sizes under 12px, so a 14px input is never reported.
Proposal
New rule mobile/input-zoom.
- Warn: a text-entry
input, aselector atextareawhose font size is under 16px. One finding per page, listing the fields with their size and where it came from. - Fields checked:
select,textarea, andinputof any text-entry type (text, email, password, search, tel, url, number, date and time types, and aninputwith notype). Not checked:hidden,checkbox,radio,range,color,file, and the button types, which do not open a keyboard. - Says how the size was found. A static audit can read inline
styleattributes and<style>blocks only. When a field's size comes from an external stylesheet or a utility class the rule cannot resolve, it is not judged, and the result says how many fields went unread. - Rendered pages: when the audit renders pages at a phone width, the rule reads each field's computed font size instead, which covers external stylesheets, utility classes and inherited sizes.
- With a zoom-blocking viewport: a page with
maximum-scale=1hides the symptom on iOS, but the viewport rules ask for that to be removed, which brings the zoom back. The fields are still reported, and the finding says the 16px fix is what lets both findings be fixed together.
The rule's solution text recommends font-size: 16px (or 1rem on a 16px root) on form fields at phone widths, for example Tailwind's text-base md:text-sm, and never recommends disabling zoom.
Notes
- Cost: low. The static check walks the page's form fields and its
<style>blocks, which page rules already have. The rendered check needs computed styles from a rendered crawl, which the engine does not expose to rules yet; that half can follow once rendered page data reaches rules (see New rule: security/csp-violations - report what the browser actually blocked during rendered crawls #425). - False-positive risk: the static check only reports a size it reads plainly from a selector that matches the field, so its risk is missed fields, not wrong ones. It does not guess from class names.
- Related:
mobile/font-size(body text),mobile/viewport-zoomanda11y/zoom-disabled(the viewport workaround).
Acceptance Criteria
- Fixture:
<input type="email" style="font-size:14px">produces a warning naming the field and its 14px size - Fixture: a
<style>block withinput, select { font-size: 0.875rem }and a 16px root produces a warning for each matching field - Fixture: the same fields at
font-size: 16pxor1remproduce no finding -
type="checkbox",radio,range,color,file,hidden,submitandbuttoninputs at 12px produce no finding - Fixture: fields styled only by an external stylesheet produce no warning in a static audit, and the result reports them as not read
- Fixture: a page with
<meta name="viewport" content="width=device-width, maximum-scale=1">and 14px fields still gets the warning, and the finding mentions the viewport workaround - The rule's solution text recommends a 16px field size and does not suggest disabling zoom
- The rule has a docs page under
docs/rules/mobile/
Activity
fix(rules): input-zoom counts only focusable fields past the cap; dro…
fix(rules): input-zoom review: Mobile count on the SEO index, rule-co…
fix(rules): input-zoom is page-scoped, not fanned out across a templa…
docs(rules): input-zoom names the one limit of judging an inline size…
fix(rules): input-zoom skips print, noscript and template style blocks (
feat(rules): mobile/input-zoom reports form fields under 16px that ma…
fix(rules): input-zoom counts only focusable fields past the cap; dro…
fix(rules): input-zoom review: Mobile count on the SEO index, rule-co…
fix(rules): input-zoom is page-scoped, not fanned out across a templa…
docs(rules): input-zoom names the one limit of judging an inline size…
fix(rules): input-zoom skips print, noscript and template style blocks (
fix(rules): input-zoom caps every page-controlled path (#708)
feat(rules): mobile/input-zoom reports form fields under 16px that ma…
fix(rules): input-zoom counts only focusable fields past the cap; dro…
fix(rules): input-zoom review: Mobile count on the SEO index, rule-co…
fix(rules): input-zoom is page-scoped, not fanned out across a templa…
docs(rules): input-zoom names the one limit of judging an inline size…
fix(rules): input-zoom skips print, noscript and template style blocks (
fix(rules): input-zoom caps every page-controlled path (#708)