Skip to content

fix(theme): text follows the reader's text size in Safari on iPhone, in every theme - #10416

Merged
cixzhang merged 17 commits into
mainfrom
lane4/ios-dynamic-type
Nov 8, 2026
Merged

cixzhang merged 17 commits into
mainfrom
lane4/ios-dynamic-type

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

People using Safari on iPhone who choose a text size in Settings (Display & Text Size, then Larger Text) get Astryx text at that size, in every theme. Native apps already follow that setting, but Astryx pages don't: a reader who needs 53 px body text still gets 16 px. At the default size, and in every other browser, nothing changes.

Supersedes #8230 (by vjeux), rebased onto current main with Co-authored-by. #8230 was closed only in a stale-PR triage, and nobody else is working on it.

What changes

  • theme/dynamicType.ts and theme/uikitTypography.ts (from fix(core): text follows the reader's text size on iOS in every theme #8230): the UIKit point-size table per text style, the category a measured Body size names, and each raw font-size step's curve and scale.
  • generateThemeRules.ts: every theme writes each raw font-size step as its own value times the scale of the UIKit text style that step plays. A semantic size a theme fixes at a length, such as Butter, Stone and Y2K's 12 px supporting text, scales on its default step's curve. Every scale is 1 unless the root sets it.
  • Theme.tsx: the root Theme keeps the scales current through syncReaderTextSize. Nested Themes don't.
  • New since fix(core): text follows the reader's text size on iOS in every theme #8230:
    • the probe's resize is observed through Core's shared resize observer (observeResize), not a ResizeObserver of its own;
    • all root Themes in one document share one probe and one stylesheet, and the last one to unmount removes them;
    • the probe's mark lives in a private-attribute owner module (privateAttributes/textSizeProbe.stylex.ts);
    • the header comments no longer cite records.
  • Story "Core/Themes/Dynamic Type", the type-scale CLI doc, and a [fix] changeset for core and cli.

The probe element (INV7)

The spec owners ruled the probe allowed, as a consistency point. This PR adds their carve-out to architecture:component-style-authoring INV7, word for word: "The theme runtime may own one shared, empty, aria-hidden probe element per document, outside every component's DOM, used only to read a platform text size; it renders no content, is not a theming target, and is removed with the last root Theme."

It also adds a verification row: one probe per document; none from a nested Theme; removed with the last root Theme; absent where font: -apple-system-body is unsupported. Each is backed by dynamicType.test.ts and Theme.test.tsx.

The probe itself:

  • What it is: one <span aria-hidden="true">, empty and 1em square, with visibility: hidden, position: fixed and pointer-events: none. It carries font: -apple-system-body and renders no text.
  • Ownership and mount point: owned by the theme runtime, one per document, shared by all root Themes. It mounts on <body>, outside any component's DOM.
  • Lifetime: from the first root Theme's mount to the last one's unmount, and only where the engine supports font: -apple-system-body.

Evidence

Category Body Heading 2 Heading 1 Display 1
xs 13.18 19.00 23.22 38.30
l (default) 16 22 26 42
ax5 49.88 53.86 53.86 74.12
Theme xs l (default) ax3 ax5
Neutral (Dynamic Type story) 13.18 / 12.92 16 / 14 37.65 / 35.54 49.88 / 47.38
Butter (12 px supporting; Core/Text All Types) 13.18 / 12 16 / 13 37.65 / 33 49.88 / 44
Y2K fixed 12 px supporting 11.08 12 30.46 40.62

At l, no text-size scale applies. The phone values are larger than desktop Chromium's 14 / 12 because each theme has its own touch type sizes.

  • Live change: the page opened at l (16 px body). After switching Settings › Larger Text to xxxl and returning to Safari, body text measured 21.65 px in the same page load.
  • macOS Safari at its default text size: a recorded follow-up verification, not a merge gate. Cindy's visual pass on Nov 8, 05:16 PT, at the default text size is the owner check, in her words: "i can't tell the difference between before and after". A macOS Safari reading of the -apple-system-body probe and the Dynamic Type story's body and supporting sizes is a recorded follow-up. Expected: a fixed 13 px Body that names no category, so every scale stays 1. The dynamicType.test.ts case "scales nothing where the keyword follows no reader setting (a fixed 13px Body, as on a Mac)" covers that path.
  • Browsers without the keyword (Chrome, Firefox, Edge on desktop and Android): they never mount the probe or the stylesheet. The capability-gate cases in dynamicType.test.ts and Theme.test.tsx cover this.
  • Bundle cost, from fix(core): text follows the reader's text size on iOS in every theme #8230's measurement: import {Theme} grew by about 1.6 kB gzip of JavaScript, with no CSS.

Tests

  • dynamicType.test.ts: the category table and curves, the gate, the scales, follow-on-resize, cleanup, and a new case where two root Themes share one probe and the last one out removes it.
  • Green locally: Core theme suites (1739), the CLI build-theme adaptation and isolation tests (65), and tsc -p packages/core. Strict eslint is clean.

Writing rubric results

  • spec:AST-102 Current-state impact: the Dynamic Type line states the shipped, recorded state, what stays unverified (Safari on iPad and other iOS browsers) and the recorded follow-up verification (macOS Safari at its default text size), in the present tense and with no references to pull requests.

  • R1 narration: none; the INV7 sentence is in the present tense and was supplied verbatim by the spec owners.

  • R2 research in the record: none; the simulator numbers stay in this description.

  • R3 evidence naming a change: none.

  • R4 rejected alternatives: none added.

  • R5 pull request or issue references remaining: none.

Supersedes #8230, rebased onto main. On iPhone and iPad the root Theme
measures the reader's text size from one hidden, empty probe with
font: -apple-system-body and gives the page that category's scales in an
adopted stylesheet. Every theme writes its font sizes as its own values
times the scale of the UIKit text style each plays, so only sizes move,
and every scale is 1 at the default size and in every other browser.

Changes from #8230's last head: root Themes in one document share the one
probe and stylesheet, and the last one out removes them; the probe's mark
moves to a private-attribute owner module; the header comments no longer
cite records.

Co-authored-by: Christopher Chedeau <[email protected]>
@vercel

vercel Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 8, 2026 7:30pm UTC

Request Review

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 6, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 0719c5b

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
Toast 97.0 kB (+7 B) · 10.2 kB CSS (0) — — · — · —
lab/DialogHeroHeader 81.8 kB (+2 B) · 372 B CSS (0) — — · — · —
lab/ListInput 100.5 kB (+2 B) · 1.6 kB CSS (0) — — · — · —
5 more components
Component Size LoC Visual · A11y · RTL
Markdown 179.5 kB (+1 B) · 20.3 kB CSS (0) — — · — · —
Overlay 22.3 kB (0) · 3.9 kB CSS (0) — — · — · —
charts/Chart 197.9 kB (−1 B) · 494 B CSS (0) — — · — · —
lab/Comments 339.5 kB (−7 B) · 2.5 kB CSS (0) — — · — · —
lab/CommentThread 332.7 kB (−10 B) · 2.4 kB CSS (0) — — · — · —

Package size:

  • @astryxdesign/cli 3.52 MB packed (+604 B); no new dependencies
  • @astryxdesign/core 7.03 MB packed (+15.7 kB); no new dependencies
  • @astryxdesign/theme-butter 46.1 kB packed (+303 B); no new dependencies
6 more packages
  • @astryxdesign/theme-chocolate 13.8 kB packed (+217 B); no new dependencies
  • @astryxdesign/theme-gothic 32.8 kB packed (+207 B); no new dependencies
  • @astryxdesign/theme-matcha 28.2 kB packed (+208 B); no new dependencies
  • @astryxdesign/theme-neutral 36.6 kB packed (+239 B); no new dependencies
  • @astryxdesign/theme-stone 38.0 kB packed (+302 B); no new dependencies
  • @astryxdesign/theme-y2k 35.1 kB packed (+208 B); no new dependencies

API changes: none in this pull request

Committed API report behind this build: cli 29 rows, core 35 rows, theme-butter 1 row, theme-y2k 1 row; run pnpm api:report.

Wide change (shared styles: packages/core/src/theme/Theme.tsx, packages/core/src/theme/dynamicType.ts, packages/core/src/theme/generateThemeRules.ts, and 1 more): add ci:run-visual or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

…be per document

The spec owners' carve-out, verbatim, plus a verification row: one probe
per document, none from a nested Theme, removed with the last root Theme,
absent where font: -apple-system-body is unsupported.
@astracat-bot

astracat-bot Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 8, 2026, 7:42 PM UTC

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 7, 2026
@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 7, 2026
@cixzhang

cixzhang commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 0d5da03

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 7, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested. The approach matches spec:AST-102 FR3, and the INV7 carve-out has an engineering owner's approval for this head. Three things need fixing before approval:

  • packages/core/src/theme/dynamicType.ts:408-414 creates its own ResizeObserver for the probe; use Core's shared observeResize (utils/sharedResizeObserver.ts) instead, so text-size sync stays on the one resize-observation path (architecture:react-component-runtime INV16).
  • The changeset says this works "On iPhone and iPad" and in "all" iPhone and iPad browsers, but the only device evidence is Safari on an iPhone simulator, so either add iPad Safari to the new run or narrow the wording.
  • The only Safari-on-iOS run comes from the earlier pull request, recorded before the private --_scaled-* caps and the shared probe, so please re-record Safari on iOS at this head (xs, default and an accessibility size, a branded theme, a live Settings change) and show that macOS Safari is unchanged, as spec:AST-102's browser evidence asks.

On this head, an emulated run in Chromium and WebKit matches the earlier simulator numbers and leaves the default size pixel-identical to main. Three small comment suggestions are inline.

[Automated review]

Comment thread packages/core/src/theme/dynamicType.ts Resolved
Comment thread .changeset/theme-dynamic-type.md Resolved
Comment thread packages/core/src/theme/dynamicType.ts Resolved
@cixzhang
cixzhang marked this pull request as ready for review November 7, 2026 00:43
…he changeset claims only what is evidenced

The probe's resize now goes through observeResize, which also takes the
first reading. The changeset names Safari on iPhone, where the evidence
was recorded, instead of every iPhone and iPad browser.
@cixzhang

cixzhang commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 71f6cd3

@cixzhang
cixzhang marked this pull request as draft November 7, 2026 00:52
@cixzhang

cixzhang commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 36e968a

@github-actions github-actions Bot added needs:spec-owner-review Current knowledge records await owner approval and removed needs:spec-owner-review Current knowledge records await owner approval labels Nov 7, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested. The shared observeResize and the narrowed changeset fix two of the three earlier findings, and the record edits have an engineering owner's approval for this head. Two things remain:

  • Miss: packages/cli/assets/docs/tree/type-scale.doc.mjs:155, the Dynamic Type story's description and the pull request title still say this works on iPhone and iPad and in every iOS browser, while the evidence and this pull request's own spec:AST-102 line cover only Safari on iPhone, so narrow them to Safari on iPhone as the changeset now does.
  • spec:AST-102 names Safari on iOS as the proof for FR3 and the only Safari run is of an earlier revision, so please record Safari on iPhone at this head (xs, default and an accessibility size, a branded theme, a live Settings change) and show that macOS Safari is unchanged.

An emulated run in Chromium on this head matches the earlier simulator numbers and leaves the default size pixel-identical to main. Two small non-blocking suggestions are inline.

[Automated review]

Comment thread packages/core/src/theme/dynamicType.ts Resolved
Comment thread packages/core/src/theme/Theme.test.tsx Resolved
@cixzhang
cixzhang marked this pull request as ready for review November 7, 2026 01:45
@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 85f12c8

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 8, 2026

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested. The Dynamic Type scaling still matches spec:AST-102 FR3 on this head; two items remain before approval.

  • Regression: the type-scale doc section (packages/cli/assets/docs/tree/type-scale.doc.mjs:159) says Button keeps a fixed height so its label can overflow, but a labelled Button grows with its label under component:Button FR4, so please drop Button from that sentence.
  • Please record one macOS Safari reading at the default text size on this code (the probe's computed font-size, and the Dynamic Type story's body and supporting sizes against the theme's own), which the spec:AST-102 FR3 verification row requires because the probe and the scale sheet also mount in macOS Safari.

The non-blocking notes on the long file headers and comments and the 12px wording are still open inline. CI is still running on this head; the jobs that have finished pass.

[Automated review]

The Dynamic Type section listed Button among the fixed-height controls,
but under component:Button FR4 a labelled Button grows with its label.
@cixzhang
cixzhang marked this pull request as draft November 8, 2026 16:09
@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 80433a1

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the Dynamic Type scaling matches spec:AST-102 FR3 and the record edits carry an engineering owner's approval for this head, but one item remains before approval.

  • Please record one macOS Safari reading at the default text size on this code (the probe's computed font-size, and the Dynamic Type story's body and supporting sizes against the theme's own), which the spec:AST-102 FR3 verification row requires because the probe and the scale sheet also mount in macOS Safari and dynamicType.ts:25 states its 13px Body as fact.

The description now calls that reading a follow-up, but the FR3 verification row still lists macOS Safari at this head and the M1 visual pass it cites names no browser and measures no size; if the owners defer the reading, that belongs in the record with an owner's approval for the head. The non-blocking notes on the long file headers and comments, the 12px wording and the doc's "labels" wording are open inline. CI has not run on this head: its jobs were skipped while the pull request is a draft.

[Automated review]

@cixzhang
cixzhang marked this pull request as ready for review November 8, 2026 18:00
…3's row

The FR3 verification row lists macOS Safari at its default text size as
covered by dynamicType.test.ts (its fixed 13 px Body names no category,
so every scale stays 1), with a browser reading as a recorded follow-up.
The changeset and story name 0.75rem, which main now writes, and four
comments are shorter.
@cixzhang
cixzhang marked this pull request as draft November 8, 2026 18:22
@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 79d7baf

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this head yet, because its jobs were skipped while the pull request is a draft.

The Dynamic Type scaling matches spec:AST-102 FR3, and the record edits carry an engineering owner's approval for this head, including the FR3 verification row that records the macOS Safari reading as a follow-up; that row settles the reading the last review asked for.

Non-blocking: the two long file headers in dynamicType.ts and uikitTypography.ts are still open inline, and an issue for the macOS Safari follow-up would keep it from being lost.

[Automated review]

| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| FR1 | Source check over Core and Lab component styles plus token review | family, size, and line height of rendered text in component styles; an inherited value; a `1em` icon size; coarse and fine pointer; a platform font keyword; the iOS text-entry floor | A Core or Lab web component sets the family, size, or line height of text it renders outside typography tokens and not by inheritance, or applies a platform font keyword directly; icon sizing, the family floor, and a hidden internal element that only measures a platform text style are not failures |
| FR2 | Theme token review plus Safari on iOS, top-level document | an unbranded shipped theme using the system body font family; a branded theme; the default theme | A branded theme's body font replaced by the system font, or a system body font applied by a component instead of a theme token |
| FR3 | Safari on iOS across Dynamic Type categories; Chrome on Android in the emulator with font scale; a desktop browser with a larger default font size and with zoom; theme review; `scripts/check-theme-text-size-units.test.mjs` (no first-party theme sets a text or font size in px) | a branded and an unbranded theme; no size set; default category; a size set on each platform; macOS Safari at its default text size, whose fixed 13 px Body names no category, so every scale stays 1 (`dynamicType.test.ts`; a browser reading is a recorded follow-up) | Text that ignores a size the person set; text that differs from the theme's family or size when none is set, other than the `family:input-fields` FR9 iOS text-entry floor; a theme family replaced; a public option, prop, or document attribute; a changed root font size |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: no issue tracks this follow-up; the defect line at :114-116 is its only record. An issue for the macOS Safari reading at the default text size (the probe's computed font-size, and the Dynamic Type story's body and supporting sizes against the theme's own) keeps it from being lost.

The Current-state defects line still listed macOS Safari at its default
text size as unverified. FR3's verification row records a browser
reading there as a recorded follow-up, so the line now names it a
recorded follow-up verification. Safari on iPad and other iOS browsers
stay unverified.
@cixzhang
cixzhang marked this pull request as ready for review November 8, 2026 19:11
@cixzhang
cixzhang marked this pull request as draft November 8, 2026 19:24
@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 0719c5b

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this head yet, because every job is skipped while the pull request is a draft; marking it ready for review runs CI.

The Dynamic Type scaling matches spec:AST-102 FR3, and the record edits carry an engineering owner's approval for this head. The AST-102 defect line now names the macOS Safari reading a recorded follow-up, matching the FR3 verification row.

Non-blocking:

  • Miss: the paragraph added to the Theme.tsx file header (lines 21-24) repeats useRootTextSizeSync's JSDoc in one 41-word sentence; dropping it keeps the header within architecture:knowledge-contracts INV29.
  • The long file headers in dynamicType.ts and uikitTypography.ts are still open inline.
  • An issue for the macOS Safari reading would keep that follow-up from being lost.

[Automated review]

Comment on lines +21 to +24
* The root Theme also reads the reader's text size (iOS Dynamic Type) from a
* hidden, empty `font: -apple-system-body` probe and keeps the page's scales
* in an adopted stylesheet; every theme's font sizes follow them, and no
* attribute is written (see dynamicType.ts).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking. Miss: earlier reviews did not flag this unchanged paragraph. The file header already runs past architecture:knowledge-contracts INV29's limit of about 12 lines, and this 41-word sentence repeats what useRootTextSizeSync's JSDoc (lines 326-331) says. Drop the paragraph:

 *   outside the Theme wrapper (portals, toast fallback viewports).
 *
 * For RSC / SSR, set `data-theme` on `<html>` in your root server layout

@cixzhang
cixzhang marked this pull request as ready for review November 8, 2026 20:03
@cixzhang cixzhang added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Nov 8, 2026
@cixzhang cixzhang closed this Nov 8, 2026
@cixzhang cixzhang reopened this Nov 8, 2026
@cixzhang
cixzhang merged commit 7bdeb06 into main Nov 8, 2026
167 of 198 checks passed
@github-actions
github-actions Bot deleted the lane4/ios-dynamic-type branch November 9, 2026 06:03

This branch was successfully deployed

1 active deployment
Preview — 0719c5b5 Deployed Nov 8, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants