New component · Prototype available
User preferences panel
A proposed component that gives people a consistent way to choose appearance, text size, contrast, and motion without a third-party overlay.
Working demonstration
Open the demonstration No stable component is registered, so the evaluation workspace does not invent a baseline.
No stable component maps to this proposal. The demonstration page is the proposal.
The evaluation workspace does not mirror keyboard input. Open either implementation independently for keyboard and assistive-technology testing.
Proposal and context
Status: Prototype. Automated evidence may exist; human review is pending.
Category: New component
Baseline: No equivalent component in stable USWDS v3.14.0
Proposal: A native-control panel for appearance, text size, contrast, and motion.
Why this exists
USWDS issue #5069 asked for personalization: light/dark preferences, text controls, and settings documentation. It was closed as not planned amid limited maintainer capacity. Issue #4407 separately explored prefers-contrast.
Teams that need these controls often add third-party accessibility overlays. Those overlays can conflict with assistive technology, hide content, and create a parallel interface. A small, native, documented component is a more maintainable alternative.
What stable USWDS provides
Stable USWDS provides accessible primitives (radios, selects, fieldsets, buttons, status messages) and guidance for building forms. It does not provide a preferences panel, a storage contract, or a documented reset behavior.
The lab does not invent a baseline panel. The absence is stated as a capability gap.
What is proposed
A panel with four settings:
- Appearance: system, light, or dark.
- Text size: 100%, 112.5%, or 125% root scaling.
- Contrast: default or stronger borders/focus.
- Motion: follow system or reduce.
The panel uses native radios and selects, a labelled fieldset, a visible label for each control, a role="status" message, and a reset button. It stores only those four values in localStorage under uswds-lab-prefs. It does not store personal information and does not send data anywhere.
What changed in the lab
The shell uses semantic tokens and data-* attributes so the panel can change the lab interface. The fixture runtime reads the same stored preference, so a fixture opened from the panel reflects it. The stable baseline pane remains unchanged.
Scope boundaries
- This is not a replacement for accessible design or assistive technology.
- It does not override forced colors.
- It does not replace browser zoom or a user stylesheet.
- It is not a third-party overlay and does not hide page content.
- Storage is per origin and may be unavailable in private browsing; the page reports that failure and remains usable.
Evidence status
Automated tests check persistence, reset, keyboard operation, no-JavaScript readability, dark appearance, and focus. Evidence is published on the lab evidence page after collection. The decision record remains pending.
Known limitations
- The panel does not yet appear on every page as a floating utility; the page is the demonstration.
- Text size is a root font-size scale, not a full text-spacing override.
- Contrast preference is a small enhancement, not a high-contrast mode.
- A real screen-reader and speech-input session is outstanding.
Implementation guidance
Markup
<form id="prefs-form" aria-describedby="prefs-help">
<p id="prefs-help">Changes apply immediately and are stored in this browser.</p>
<fieldset>
<legend>Appearance</legend>
<label><input type="radio" name="theme" value="system" checked> System</label>
<label><input type="radio" name="theme" value="light"> Light</label>
<label><input type="radio" name="theme" value="dark"> Dark</label>
</fieldset>
<label for="pref-text-size">Text size</label>
<select id="pref-text-size">…</select>
<button type="button" id="prefs-reset">Reset to system defaults</button>
<p id="prefs-status" role="status" aria-live="polite"></p>
</form>
The real page uses labelled selects for text size, contrast, and motion, and a fieldset with native radios for appearance. Every control has a visible label. There is no custom role="radiogroup"; the native fieldset and input behavior are used.
Behavior
site/assets/prefs.js:
- reads
uswds-lab-prefsfromlocalStorageinsidetry/catch; - applies
data-theme,data-text-size,data-contrast, anddata-motionon<html>; - updates the page immediately on
change; - writes the four values back to storage;
- reports storage failure in the status region without breaking the page;
- resets by removing the key and returning to
system/default; - reloads the iframe preview so it reads the current preference.
An inline head script applies the stored values before CSS paints, which reduces a flash of the wrong theme. The module re-applies the same values after load.
CSS
The shell tokens are in site/assets/base.css:
:root[data-text-size="large"] { font-size: 112.5%; }
:root[data-text-size="x-large"] { font-size: 125%; }
:root[data-contrast="more"] { --border: currentColor; --muted: var(--ink); }
:root[data-motion="reduce"] * { animation-duration: .01ms !important; … }
Dark appearance is resolved by prefers-color-scheme for system and by data-theme="dark" for an explicit choice. The experiment fixtures read the same stored values in site/assets/fixture.js.
No-JavaScript behavior
The page, labels, and explanation remain readable. The controls are present but do not save; a <noscript> message says so. The fixtures remain readable and the dead disclosure buttons are hidden by CSS. This is a documented fallback, not a claim that preferences work without JavaScript.
Accessibility notes
- Native controls, visible labels, and a fieldset/legend for appearance.
- Status updates use
role="status"andaria-live="polite". - No color-only state; the selected radio is the state.
- The panel works at 320px and with long labels; controls are allowed to wrap.
- Storage failure is announced, not silent.
- The panel does not trap focus or open a modal.
What a real upstream component would need
A shared placement strategy, a documented storage key and version, a server-rendered fallback, a reset contract, and evidence that each setting actually helps the intended users. The panel must not imply that a user preference fixes an inaccessible component.
Known gaps
- No Voice Control or real screen-reader session.
- No cross-origin or server-side preference synchronization.
- No preference for language or writing direction; those belong to content, not a display panel.
Evidence and limitations
1 of 1 routes collected. Human review pending.
Open the evidence index for transcripts, screenshots, axe observations, and coverage gaps.
Automated evidence is not human approval. The decision record remains authoritative.
Related USWDS history
- #5069 Better personalization support (motivation)
- #4407 Support prefers-contrast (adjacent-requirement)
Experiment files
AI assistance disclosed by the contributor: issue research, initial implementation, test scaffolding, documentation drafting. A human reviewer must assess the evidence before any upstream proposal.