Skip to content

fix(theme-neutral): strengthen default control boundaries - #7662

Draft
rubyycheung wants to merge 1 commit into
mainfrom
ruby/control-boundary-contrast
Draft

rubyycheung wants to merge 1 commit into
mainfrom
ruby/control-boundary-contrast

Conversation

@rubyycheung

@rubyycheung rubyycheung commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

User impact

Neutral’s default TextInput, TextArea, Selector, FileInput, InputGroup, Checkbox, and Radio boundaries are too faint to reliably identify at rest. This changes Neutral to the lightest named palette stops that reach 3:1 against its control surface: Neutral 60 in light mode and Neutral 50 in dark mode.

Visual authority

The existing --color-border-emphasized role already reaches these Neutral controls. This draft changes only Neutral’s mapping; Core and the other six first-party themes remain unchanged.

Before and after

Neutral control-boundary comparison in light and dark mode

The matched browser capture shows the current and proposed values across TextInput, Selector, CheckboxInput, RadioList, and FileInput. It also names the other Neutral details that intentionally share the emphasized-border role.

State matrix

  • Neutral theme in light and dark appearance
  • Shared input family, Selector, FileInput, InputGroupText, unchecked CheckboxInput, and unchecked RadioList
  • Status, focus, checked/indeterminate, disabled, secondary, and ghost treatments remain outside this resting-boundary correction
  • Core and the other six first-party themes are unchanged

Scope

  • Appearance is the primary intent.
  • Behavior, API, interaction model, and unrelated layout changes were removed or split.
  • The evidence shows the changed pixels actively running, not only source or computed styles.
  • Public text and artifacts contain no internal Meta context.

Testing

  • Neutral contrast guard resolves 16 control targets in light and dark mode with no allowlist.
  • Neutral palette projection and generated CLI theme files are updated.
  • Focused Neutral, palette projection, and CLI parity tests pass.
  • Real-browser full-page comparison covers the changed control boundaries and the shared emphasized-border role.

@vercel

vercel Bot commented Oct 17, 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 Oct 17, 2026 7:42pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟡 Reviewed (for maintainers only) Nov 21, 2026, 3:01 PM UTC

@github-actions github-actions Bot added the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Oct 17, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 17, 2026
@rubyycheung rubyycheung changed the title fix(theme): strengthen default control boundaries fix(theme-neutral): strengthen default control boundaries Oct 17, 2026
@rubyycheung
rubyycheung force-pushed the ruby/control-boundary-contrast branch from 5ad5d55 to 8ffd763 Compare October 17, 2026 19:35
@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Oct 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

Preview availability: Storybook and Sandbox are not both ready on the exact-head Vercel preview.

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

107 of 478 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 754,077
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,188
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
RichTextEditor Markdown parity: side by side probe dark 94,866
RichTextEditor Markdown parity: side by side probe light 89,762
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
Markdown Default neutral dark 7,636
Markdown Default neutral light 7,631

and 87 more.


Generated by PR Enrichment workflow | View full report

@rubyycheung
rubyycheung marked this pull request as ready for review October 17, 2026 21:47

@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. Neutral's resting field, selector, checkbox and radio edges do need 3:1, and this head gets them there (3.15:1 light, 3.38:1 dark). Since this pull request opened, though, the repository has decided that form controls get their own border role instead of a stronger shared emphasized border, and the shared route also breaks ProgressBar contrast.

  • Regression: architecture:theme-tokens DEC-2 now gives control edges their own --color-border-control role and rejects raising --color-border-emphasized to 3:1, so keep the emphasized role at Neutral 85/35 and set --color-border-control to Neutral 55/50 in both theme copies (Neutral 60 is only 2.79:1 on the light page body), or fold this work into #11658, which makes that change.
  • Neutral's ProgressBar track follows the emphasized role, so the default accent bar drops from 3.08:1 to 1.45:1 against its track in light mode and a light neutral bar's fill matches its track, below the 3:1 every enabled fill must keep (component:ProgressBar DEC-3).
  • Newly live check: scripts/check-input-boundary-contrast.test.mjs writes its own colour parsing and contrast maths instead of using packages/core/src/theme/contrast.ts and packages/core/src/utils/color.ts (or scripts/lib/theme-contrast.mjs on main), and that copy still passes with an 8%-alpha or #eee8 edge and never measures a control's real fill.
  • Newly live check: the description says disabled treatments stay outside the change, but the disabled field edge (packages/core/src/Field/inputStyles.stylex.ts:70) and the hover rings take the new value, so correct that claim and the changeset when the change moves to the control role.

Rebasing also means regenerating both palette-ref copies and the stop count, since they conflict with main.

Claims and files checked

Review mode: full; reason: recipe-changed (many rules)

  • Claims
    • Changeset: Neutral's control edge reaches at least 3:1 against its surface: verified for field shells and indicators (3.15:1 light, 3.38:1 dark); the InputGroupText addon edge is 2.79:1 against its own fill.
    • Changeset: text fields, selectors, file inputs, input groups and unchecked checkbox and radio indicators use Neutral 60 light and Neutral 50 dark: verified (neutralTheme.ts:177 and the CLI copy).
    • Changeset: no behavior or public API change: public API verified unchanged; the note leaves out the Switch and ProgressBar tracks and the other surfaces that darken.
    • Description: these edges are too faint at rest: verified (1.48:1 light, 1.94:1 dark on the base; the new guard fails there).
    • Description: Neutral 60 and Neutral 50 are the lightest named stops that reach 3:1 on the control surface: verified (Neutral 65 is 2.68:1, Neutral 45 is 2.80:1).
    • Description: the emphasized-border role already reaches these controls: verified.
    • Description: only Neutral changes, and Core and the other six themes are unchanged: verified.
    • Description: the correction is already settled by objective accessibility authority: false; the 3:1 floor is settled, but the repository's theme-token decision picks a separate control role.
    • Description: status, focus, checked, disabled, secondary and ghost treatments stay outside the change: false for the disabled field edge, and the hover rings change too.
    • Description: the guard resolves 16 control targets in both modes with no allowlist: true as written, but every target uses one assumed colour pair and translucent edges pass.
    • Description: the palette projection and CLI theme files are updated and the focused tests pass: verified (96 stops in sync; 34 tests pass).
    • Description: the before and after image shows the changed pixels: not checked, as the image host was out of reach; this review's own captures show the control edges and the ProgressBar track.
  • Files
    • .changeset/control-boundary-contrast.md: the disabled-claim and changeset finding.
    • packages/themes/neutral/src/neutralTheme.ts: the control-role and ProgressBar findings.
    • packages/cli/assets/templates/themes/neutral/neutralTheme.ts: identical to the runtime copy; same findings.
    • packages/themes/neutral/src/neutralPaletteRefs.generated.ts: in sync at this head; conflicts with main.
    • packages/cli/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts: identical to the runtime copy; conflicts with main.
    • scripts/check-input-boundary-contrast.test.mjs: the guard finding.
    • scripts/generate-neutral-palette-refs.test.mjs: consistent with this head (96 stops); conflicts with main.

Automated review (maintainer link)

withAlpha(neutral.dark[100], '1A'),
],
'--color-border-emphasized': [neutral.light[85], neutral.dark[35]],
'--color-border-emphasized': [neutral.light[60], neutral.dark[50]],

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.

Neutral also aliases the ProgressBar track to this role ('progress-bar': {base: {'--color-background-muted': 'var(--color-border-emphasized)'}}, lines 442-445), so the track moves to Neutral 60/50 while the fills stay put. In light mode the default accent fill drops from 3.08:1 to 1.45:1 against the track, and a neutral-variant fill (--color-text-disabled, also Neutral 60) becomes identical to it. Consider pinning that override to the previous stops, for example a light-dark() value built from neutral.light[85] and neutral.dark[35], here and in the CLI template copy. The Switch off-track alias at lines 436-440 also moves; that one improves contrast, but it is worth naming in the changeset.

Comment on lines +74 to +77
function rgb(hex) {
let h = hex.slice(1);
if (h.length === 3) h = [...h].map(c => c + c).join('');
return [0, 2, 4].map(index => parseInt(h.slice(index, index + 2), 16));

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.

rgb() ignores the alpha byte of an 8-digit hex and returns NaN for a 4-digit hex, and a NaN ratio passes both assertions. With the boundary set to withAlpha(neutral.light[0], '14') (the form Neutral uses for --color-border) or '#eee8', both tests still pass. Failing on anything that is not an opaque 3- or 6-digit hex, or compositing alpha over the fill, would make the guard catch these.

Comment on lines +99 to +103
base.borderColor ?? 'var(--color-border-emphasized)',
modeIndex,
);
const surface = resolve(
base.backgroundColor ?? 'var(--color-background-surface)',

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.

None of the 16 targets has a Neutral override, so every row falls back to this same assumed pair. The real fills differ: InputGroupText paints --color-background-muted (packages/core/src/InputGroup/InputGroupText.tsx:36), where the new boundary is 2.79:1 in light mode. Neutral's ProgressBar and Switch aliases to this role are not covered at all. Reading each target's actual fill token and adding those alias pairs would let the guard observe what it claims.

'@astryxdesign/theme-neutral': patch
---

[fix] Raise Neutral’s default form-control boundary to at least 3:1 against its surface. Text fields, selectors, file inputs, input groups, and unchecked checkbox/radio indicators use Neutral 60 in light mode and Neutral 50 in dark mode without changing behavior or public API.

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.

The same Neutral value also restyles the Switch off track, the ProgressBar track, and the role's shared details (strong Divider, Blockquote rule, Kbd edge, TreeList branch lines, hover underlines). Naming them, or describing this as a change to Neutral's emphasized-border role, would keep the release note accurate.

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 8ffd763

@cixzhang cixzhang added lane:2 Astryx fix-loop lane 2 owns this ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) labels Nov 21, 2026

This branch was successfully deployed

1 active deployment
Preview — 8ffd763f Deployed Oct 17, 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-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. lane:2 Astryx fix-loop lane 2 owns this

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants