Skip to content

fix(core): a theme sets the room between a checkbox or a switch and its label - #12455

Closed
josephfarina wants to merge 2 commits into
mainfrom
core-checkbox-input-gap
Closed

josephfarina wants to merge 2 commits into
mainfrom
core-checkbox-input-gap

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Record change: component:CheckboxInput FR9 and component:Switch FR2 each gain one sentence (gap on the field target sets the room between the control and its label, routed to the row).
Picture check: the seven official themes, light and dark, with and without forced colors, render pixel-identical to main (28 of 28).

User impact

A theme could not set the room between a checkbox or a switch and its label. It is 8px, and a compact or classic look (a native-style 3px) had no way to change it: the gap sits on an inner row that no theming target reaches, and the only lever, the --spacing-2 token, also changes the padding of the status message under the control. With this change a theme writes gap on the checkbox-input or switch-field target, for example components: {'checkbox-input': {base: {gap: '3px'}}}, and only the room between the control and its label changes.

Problem and solution fit

  • Why does the defect occur? The checkbox-input and switch-field targets are the outer field, which holds the row (control and label) and the status message below it; the row with the gap has no target.
  • Why does it harm the task? A theme that writes gap on the field gets nothing (the field is no flex row), and the token route moves the status box too.
  • Why does that matter? The control-to-label room is part of a control's look, and RadioList and CheckboxList rows already let a theme set it on their row target.

Expected behavior and authority

component:CheckboxInput FR9 and component:Switch FR2 each gain one sentence: gap on the field target sets the room between the control and its label; the compiler routes it to the row through a private variable (architecture:theme-compilation INV5), so the status message keeps its own spacing; with the label hidden the row keeps no gap; best effort under architecture:component-theming-surface INV9. This is the pattern Icon uses for width and height.

Smallest restoration

  • derivedVarRegistry: checkbox-input and switch-field map gap to --_checkbox-input-gap and --_switch-field-gap, replacing the raw property on the field.
  • CheckboxInput and Switch: the row's gap reads that variable, falling back to --spacing-2.
  • The component docs list the variable and the derived entry.
  • No public API, prop, default, target or token changes.

Evidence

  • Unchanged: the seven official themes, light and dark, with and without forced colors, render checkboxes, switches (with and without a status message), radio rows and indicators pixel-identical to main (28 of 28 screenshots byte-identical).
  • After, measured in Chromium with a theme that sets gap: 3px on both targets: the room between the box and its label, and between the switch and its label, is 3px (8px before); the status message's padding stays 8px.
  • Tests: generateThemeRules.test.ts checks each target's gap becomes its variable with no raw gap on the field; labelGap.source-build.test.mjs compiles CheckboxInput, Switch and FieldStatus and checks the row gap reads the variable with the --spacing-2 fallback, a hidden label keeps 0, and the status padding does not read it. The derived-variable consistency test covers both docs.

Writing rubric results

Covers the CheckboxInput FR9 and Switch FR2 sentences and their evidence rows.

  • R1 narration: none; the added sentences state what the system does, in the present tense.
  • R2 research in the record: none.
  • R3 evidence naming a change: none; the new evidence row names its tests.
  • R4 rejected alternatives over one line or outside a decision: none.
  • R5 pull request or issue references remaining: none.
  • R6 ruled open questions still listing options: none.
  • R7 project status (build status or work order): none.

Scope

Components: CheckboxInput, Switch

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • vitest run packages/core/src/CheckboxInput packages/core/src/Switch packages/core/src/theme: 39 files, 2,048 tests pass.
  • pnpm check:knowledge, pnpm check:changesets, Prettier, ESLint and tsc --noEmit for Core pass.

@vercel

vercel Bot commented Nov 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 Nov 18, 2026 9:30pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 17, 2026
@astracat-bot

astracat-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 18, 2026, 9:44 PM UTC

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 17, 2026
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 17, 2026
@josephfarina
josephfarina marked this pull request as ready for review November 17, 2026 22:05
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 59c0580

Storybook · Sandbox · built from this PR's head

Current run: The current CI run concluded cancelled. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@josephfarina

Copy link
Copy Markdown
Contributor Author

Owner decision (engineering owner, covering this pull request): a theme's gap on the checkbox-input target, and on Switch in the same way, reaches the space between the box and its label through a private derived variable, without touching the status box. There is no new target, and the default output is byte-identical. The CheckboxInput record (FR9) and the Switch record (FR2) state this, with tests for the gap and the status padding of both components.

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 35c0396

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 17, 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: one piece of evidence the repository requires for record changes is missing, and the code itself checks out.

  • The description has no ## Writing rubric results section, which every pull request that changes a knowledge record must report; add one line per rubric item (R1–R7) covering the CheckboxInput FR9 and Switch FR2 edits.

The route works as described: with a theme gap of 3px both rows measure 3px (8px before), the status message keeps its spacing, a hidden label keeps no gap, the new tests fail on the base and pass here, and default rendering is unchanged. Two non-blocking notes: the new row comments in CheckboxInput.tsx and Switch.tsx can keep only the reason (suggestions inline), and FR9 and FR2 cite theme-compilation INV5, which covers guaranteed properties, while calling gap best effort.

Claims and files checked

Review mode: full; reason: no-earlier-review

Claims:

  • A theme's gap on the checkbox or switch field target sets the room between the control and its label: verified (3px measured in Chromium; new compiler and source-build tests).
  • Before, the gap sat on an inner row no target reached, and the spacing token was the only lever, which also moved the status padding: verified (base row styles read the token; the detached status padding reads the same token).
  • The default room stays 8px: verified (token fallback; default stories pixel-identical).
  • A hidden label keeps no gap: verified (0px measured under a theme gap).
  • The field target holds the row and the status, so a gap there did nothing: verified (the field is a block box; measured).
  • RadioList and CheckboxList rows already take a theme gap on their row target: verified (their targets sit on the Item row that carries the gap).
  • Each target maps gap to a private variable and drops the raw property: verified (registry entries and compiler test).
  • The rows read the variable with the spacing token as fallback: verified (both row styles; source-build test).
  • The component docs list the variable and the derived entry: verified (both locales of both docs).
  • No public API, prop, default, target or token changes: verified (built API surface shows no change).
  • The official themes render as before: verified (the seven official theme stylesheets build byte-identical; default stories pixel-identical).
  • The tests cover the gap route, the hidden label and the status padding: verified (the four new route cases fail on the base and pass here).
  • The CheckboxInput, Switch and theme test folders pass with 39 files and 2,048 tests: verified (same counts).
  • The knowledge, changeset, formatting, lint and type checks pass: verified (lint shows only an existing warning).
  • One defect is restored, with no hidden API, visual, default or interaction change: verified.
  • Public text carries no internal context: verified.

Files:

  • .changeset/checkbox-switch-label-gap.md: clear
  • docs/specs/components/CheckboxInput/CheckboxInput.spec.md: clear content; rubric report missing from the description
  • docs/specs/components/Switch/Switch.spec.md: clear content; rubric report missing from the description
  • packages/core/src/CheckboxInput/CheckboxInput.doc.mjs: clear
  • packages/core/src/CheckboxInput/CheckboxInput.tsx: comment suggestion (non-blocking)
  • packages/core/src/CheckboxInput/labelGap.source-build.test.mjs: clear
  • packages/core/src/Switch/Switch.doc.mjs: clear
  • packages/core/src/Switch/Switch.tsx: comment suggestion (non-blocking)
  • packages/core/src/theme/derivedVarRegistry.test.ts: clear
  • packages/core/src/theme/derivedVarRegistry.ts: clear
  • packages/core/src/theme/generateThemeRules.test.ts: clear

Automated review (maintainer link)

Comment on lines +84 to +87
// The room between the box and its label. A theme sets it with gap on
// the `checkbox-input` target, which the compiler hands to this row as
// --_checkbox-input-gap (derivedVarRegistry): the target is the outer
// field, which also holds the status message below the row.

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 (INV29): the first sentence restates gap, and the second runs to 35 words across two topics. A shorter version that keeps only the reason:

// The `checkbox-input` target is the outer field, which also holds the
// status message. So a theme's gap reaches this row only through
// --_checkbox-input-gap.

Comment on lines +259 to +262
// The room between the switch and its label. A theme sets it with gap on
// the `switch-field` target, which the compiler hands to this row as
// --_switch-field-gap (derivedVarRegistry): the target is the outer field,
// which also holds the status message below the row.

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 (INV29): same as CheckboxInput. A shorter version that keeps only the reason:

// The `switch-field` target is the outer field, which also holds the
// status message. So a theme's gap reaches this row only through
// --_switch-field-gap.

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 59c0580

@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 admission check stopped the run while CI was full, so the CI jobs need a re-run before merge.

The description now reports the writing rubric results for the CheckboxInput and Switch record edits, which was the one item the earlier review asked for, and the route itself checks out: with a theme gap of 3px both rows measure 3px (8px before), the status message keeps its spacing, a hidden label keeps no gap, the new tests fail on the base and pass here, and default rendering is unchanged. Two earlier notes stay non-blocking: the row comments in CheckboxInput.tsx and Switch.tsx can keep only the reason (suggestions inline), and the two record sentences cite theme-compilation INV5, which covers guaranteed properties, while calling gap best effort.

Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0): none

Claims:

  • The CheckboxInput FR9 and Switch FR2 rows each gain one sentence on the gap route: verified (both record diffs).
  • A theme could not set the 8px room between a checkbox or switch and its label: verified (the row reads the spacing token; no target reaches the row).
  • The spacing token was the only lever and also moved the status message's padding: verified (the detached status padding and Switch's status margin read the same token).
  • The field targets hold the row and the status, so a theme gap there did nothing: verified (the field is a block box; measured 8px between box and label under a 3px theme gap on the base).
  • With this change a theme gap on either target changes only the room between the control and its label: verified (3px measured for both; status padding and offset unchanged).
  • RadioList and CheckboxList rows already take a theme gap on their row target: verified (their targets sit on the Item row that carries the gap).
  • The route goes through a private variable, so the status keeps its spacing and a hidden label keeps no gap, best effort: verified (registry entries, row styles, hidden-label style).
  • This is the same pattern Icon uses for width and height: verified (Icon's registry entries route width and height to private variables the same way).
  • Each target maps gap to its private variable and drops the raw property on the field: verified (registry entries; compiler test).
  • The rows read the variable with the spacing token as fallback: verified (both row styles; source-build test).
  • The component docs list the variable and the derived entry: verified (both locales of both docs).
  • No public API, prop, default, target or token changes: verified (built API surface shows no change in Core, build or the seven themes).
  • The seven official themes render pixel-identical to main: verified (all seven built theme stylesheets are byte-identical, the only Core rule change falls back to the same token, and the default CheckboxInput and Switch stories are pixel-identical).
  • The tests cover the gap route, the hidden label and the status padding, and the consistency test covers both docs: verified (the four route cases fail on the base and pass here; the status case and the consistency test pass on both).
  • The CheckboxInput, Switch and theme test folders pass with 39 files and 2,048 tests: verified (same counts).
  • The knowledge, changeset, formatting, lint and type checks pass: verified (lint shows only an existing warning on an untouched line).
  • The writing rubric results R1 to R7 find nothing in the two changed rows: verified (present tense, no research, test-named evidence, no references, no open questions, no project status).
  • One defect is restored, with no hidden API, visual, default or interaction change: verified.
  • Public text carries no internal context: verified.
  • Changeset: a theme sets the room with gap on either target; before, only the spacing token could, which also moved the status padding; the default stays 8px and a hidden label keeps no gap: verified.

Files:

  • .changeset/checkbox-switch-label-gap.md: clear
  • docs/specs/components/CheckboxInput/CheckboxInput.spec.md: clear (INV5 citation note, non-blocking)
  • docs/specs/components/Switch/Switch.spec.md: clear (INV5 citation note, non-blocking)
  • packages/core/src/CheckboxInput/CheckboxInput.doc.mjs: clear
  • packages/core/src/CheckboxInput/CheckboxInput.tsx: comment suggestion (non-blocking)
  • packages/core/src/CheckboxInput/labelGap.source-build.test.mjs: clear
  • packages/core/src/Switch/Switch.doc.mjs: clear
  • packages/core/src/Switch/Switch.tsx: comment suggestion (non-blocking)
  • packages/core/src/theme/derivedVarRegistry.test.ts: clear
  • packages/core/src/theme/derivedVarRegistry.ts: clear
  • packages/core/src/theme/generateThemeRules.test.ts: clear

Automated review (maintainer link)

josephfarina added a commit that referenced this pull request Nov 19, 2026
josephfarina added a commit that referenced this pull request Nov 19, 2026
- #12072 fix(templates): payment form and checkout wrap the summary below the form on a narrow first paint
  Author: Joey Farina <[email protected]>
- #12274 fix(core): cap the Selector family's trigger-width list minimum at the viewport
  Author: josephfarina <[email protected]>
- #12215 fix(cli): advise keeping one dependency when two packages declare one provider ID
  Author: Joey <[email protected]>
- #12322 [experimental] export --reverse: use the project's own copy of an aliased file, or restore the page's copy with its paths entry
  Author: josephfarina <[email protected]>
- #12403 docs(core): Text's as and PowerSearch's statusVariant list every value their types allow
  Author: Joey Farina <[email protected]>
- #12494 fix(templates): dashboard templates use page sections, not cards, for page regions
  Author: Joey Farina <[email protected]>
- #12282 fix(cli): theme build --check and doctor ignore which CLI release, and which command name, built a theme
  Author: Joey Farina <[email protected]>
- #12420 fix(Chat): ChatToolCalls and ChatDictationButton without a required prop name it and the fix in development
  Author: Joey Farina <[email protected]>
- #12205 fix(cli): equally scored icons put first one whose id the query names in full
  Author: Joey Farina <[email protected]>
- #12455 fix(core): a theme sets the room between a checkbox or a switch and its label
  Author: josephfarina <[email protected]>
- #12658 perf(cli): the first theme build after a CLI upgrade reuses the JavaScript it compiled from a theme's local modules
  Author: Joey <[email protected]>
- #12323 [experimental] export: React logs no render timings while the export draws a page
  Author: Joey Farina <[email protected]>
@josephfarina

Copy link
Copy Markdown
Contributor Author

Landed in #12713.

@github-actions
github-actions Bot deleted the core-checkbox-input-gap branch November 19, 2026 06:04

This branch was successfully deployed

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

Labels

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.

1 participant