ShippedMedium

Add .switch toggle and .input-group (input with attached buttons/selects) form components

Proposed by Jonathan Miller 1 month agoFunding opened 1 month agoFunded 1 month agoShipped 1 month ago
Acceptance · round 1
Shipped
CINo checks
Automated reviewPass with concerns

Delivers a token-only `.switch` (a native checkbox with role=switch, RTL-aware thumb, and `:checked`/`:disabled` state) and a `.input-group` with overlapping borders, outer-only rounding and a raised focused child. Contract files, docs and tests are updated thoroughly and in line with repo conventions. However, no CI ran, the showcase was changed despite being out of scope by default, and whether input-group corner rules hold inside `.field` against higher-specificity `.field` control rules cannot be verified from the diff.

Acceptance criteria · 5 of 7 met
  • YES.switch is a native checkbox with role="switch", toggles with Space, is Tab-reachable, and shows a visible focus ringsrc/components.css styles `.switch > input[type="checkbox"]` with `appearance: none` and a `:focus-visible` outline from the `--focus-*` tokens, and check-components-browser.mjs tabs to the switch and presses Space to assert it toggles.
  • YES.switch reflects checked and disabled with no extra classesThe `:checked` rule sets a `--color-primary` track and the `:checked::before` rule moves the thumb via `inset-inline-start`, while `:disabled` and `.switch:has(> input:disabled)` handle opacity, cursor and the muted label.
  • YES.input-group joins an input with .button and/or <select> children with no doubled borders, rounded outer corners only, and no custom CSSChildren after the first get a `-1 × --border-width` start margin, inner corners are zeroed via `:not(:first-child)` / `:not(:last-child)` with logical radius properties, the input uses `flex: 1 1 auto; min-inline-size: 0`, selects and buttons use `flex: none`, and `:focus-visible` raises `z-index`.
  • PARTIALBoth components render correctly inside .field alongside .field-label, .field-help and .field-errorThe showcase demos put the switch in a fieldset.field with .field-help, and an input-group in a .field with .field-error and aria-invalid, which the browser check probes; this depends on specificity against `.field` rules that are not visible in the diff, and CI did not run.
  • YESOnly existing design tokens (or newly documented ones), no hard-coded coloursAll colours, sizes and durations are `var(--*)` tokens (unitless multipliers 1.75/0.75 and opacity 0.55 aside), no new tokens are introduced, and a test asserts that a named colour such as `white` fails lint.
  • PARTIALsynthcss.llm.md and synthcss.ai.json updated; all existing tests, lint, build and sync checks passVocabulary, Intent Mapping, rule 7 and the Form example are updated in both files with a sync test in verify-ai-contract.test.mjs, but no CI ran to confirm the checks pass.
  • YESTests added or extended following repo conventions to cover the new classescheck-components.mjs registers both classes and adds structural checks, check-components.test.mjs adds mutation-style failure tests, verify-ai-contract.test.mjs adds contract sync tests, and the browser check is extended.
Concerns
  • No CI ran on this commit. 'npm test passes' rests only on the builder's statement, and the Playwright browser check is optional and reportedly hit one sandbox-related failure.
  • Showcase updates (new `.switch` and `.input-group` demo articles, plus a revised token-count badge) were listed as out of scope unless the proposer confirmed them. They were added mainly so the browser check has targets to probe.
  • Specificity risk inside `.field`: the input-group corner, margin and radius rules use `:where()`, which gives them low specificity (0,1,0). If existing `.field input` / `.field select` rules set `border-radius`, `margin` or `inline-size` at higher specificity, inner corners could stay rounded inside `.field`. The diff does not show the `.field` rules, so this cannot be confirmed; the builder says the browser check passed for the in-field demos.
  • The lint rule in check-components.mjs was relaxed so margins may use `--border-width`. This is a reasonable, tested exception, but it changes a shared convention check.
  • The spec asked for exactly one new Valid Example per component. Because of the existing 4-example cap, the builder instead extended the Form example to contain both. Each component appears in exactly one example and a test asserts this, but backers may want to confirm this interpretation.
CI details
No CI checks ran on this commit.

BackersAccepted
1 accept · 0 rebuild · 0 not voted · quorum 1 of 1
MaintainerMerge

Accepted by the backers and merged by the maintainer.

Ballots · 1
AcceptJonathan Miller

Automated review cost $0.16, counted as builder cost.

Add .switch and .input-group form components

Motivation

.field covers labelled controls, but there is no toggle switch and no input with an attached button. In a benchmark, agents fell back to plain checkboxes and hand-wrote flex CSS for attached buttons, which violates AI Generation Rule 2 (no custom CSS). Both patterns should be first-class components.

Scope

.switch

Markup:

<label class="switch"><input type="checkbox" role="switch" checked> Require admin approval</label>
  • Styles the native input[type=checkbox] inside .switch with appearance: none, drawn as a track with a thumb (pseudo-element).
  • On state (:checked): the track uses --color-primary and the thumb moves to the end side.
  • :disabled gets reduced opacity and cursor: not-allowed. The label text is styled to match.
  • The thumb and track transition use --duration-fast and --ease-standard. Assumption: transitions are disabled under prefers-reduced-motion: reduce, if the framework already follows that pattern.
  • :focus-visible uses the existing --focus-* tokens.
  • Only existing tokens are used. Assumption: the switch dimensions are derived from existing size or spacing tokens, and new tokens are added only if they are documented in the token reference.

.input-group

Markup:

<div class="input-group"><input type="url" readonly value="…"><button type="button" class="button">Copy</button></div>
  • An inline flex row. Children can be input, select and .button.
  • Adjacent children share borders, with no doubled borders. Only the outer corners (first child's start and last child's end) are rounded. Inner corners are square.
  • Inputs grow (flex: 1 1 auto; min-width: 0). Buttons and selects keep their intrinsic size.
  • All children share a height that respects --input-height / --control-height.
  • A focused child's focus ring is not clipped by its neighbours (for example, by raising its z-index).
  • Assumption: non-button addons such as unit labels are out of scope unless the proposer confirms otherwise.

Contract and docs

  • Add both components to Component Vocabulary and Intent Mapping in synthcss.llm.md, with exactly one Valid Example each.
  • Mirror these additions in synthcss.ai.json so the existing sync verification passes.

Acceptance criteria

  • .switch is a native checkbox with role="switch". It toggles with Space, is reachable by Tab, and shows a visible focus ring.
  • .switch reflects checked and disabled with no extra classes.
  • .input-group joins an input with one or more .button and/or <select> children. The result has no doubled borders and rounded outer corners only, and needs no custom CSS.
  • Both components render correctly inside .field, alongside .field-label, .field-help and .field-error.
  • Both components use only existing design tokens (or newly documented ones). There are no hard-coded colours.
  • synthcss.llm.md and synthcss.ai.json are updated, and all existing tests, lint, build and sync-verification checks pass.
  • Tests are added or extended, following existing repo conventions (for example, CSS selector presence and contract sync), to cover the new classes.

Out of scope

  • JavaScript behaviour, such as copy-to-clipboard.
  • Size variants, vertical input groups, and addon text segments.
  • Showcase updates, unless the proposer confirms them.

No comments yet.