Binary form control that exposes checked state and emits one canonical checked-change event.
Install @wyrd-company/react or the Flutter package and use it directly —
your DESIGN.md does the styling.
catalog/contracts/switch.ymlsource of truth · verbatim
$schema: https://thewyrdingway.dev/schemas/component-contract.schema.ymlcontractVersion: 0.1.0identity:name: Switchtag: wyrd-switchpackage: wyrd.component.switchtitle: Switchsummary: Binary form control that exposes checked state and emits one canonical checked-change event.relationships:related-to: - quality-parity-and-gatesclassification:category: form-fieldcomposition: multi-slotinteractive: truetarget-strategy:react: requiredflutter: requiredsurface:properties: - name: checkedtype:kind: booleanrequired: falsedefault: falsecontrolled: trueserializable: truesummary: Controlled checked state. - name: default-checkedtype:kind: booleanrequired: falsedefault: falseserializable: truesummary: Initial uncontrolled checked state. - name: is-disabledtype:kind: booleanrequired: falsedefault: falsereflects: trueserializable: truesummary: Prevents toggling and exposes disabled platform semantics. - name: is-requiredtype:kind: booleanrequired: falsedefault: falsereflects: trueserializable: truesummary: Marks the switch as required in form semantics.slots: - name: labelcontent: truerequired: truecardinality: exactly-oneaccepts: - text - nodesummary: Visible label and accessible-name source.events: - name: checked-changepayload:checked:kind: booleanaction:kind: action-refbubbles: truecomposed: truecancelable: falsesummary: Canonical checked-state change event carrying the next boolean value.states: - name: defaultsource: platformsummary: Enabled unchecked state. - name: checkedsource: propertysummary: Checked state derived from checked or default-checked. - name: focus-visiblesource: platformsummary: Keyboard-visible focus state. - name: disabledsource: propertysummary: Disabled state derived from is-disabled. - name: requiredsource: propertysummary: Required state derived from is-required.parts: - name: rootsummary: Label/control inline container.slots: - label - name: controlsummary: Interactive switch control. - name: tracksummary: Switch track. - name: thumbsummary: Switch thumb. - name: labelsummary: Label content container.slots: - labeltokens:root:gap: spacing.smtrack:width: spacing.xlheight: spacing.lgradius: rounded.fullbackground-unchecked: color.outlinebackground-checked: color.primarybackground-disabled: color.disabledthumb:size: spacing.mdbackground-unchecked: color.surfacebackground-checked: color.on-primarybackground-disabled: color.on-disabledlabel:color: color.on-surfacetext: typography.label-mdfocus:color: color.primarywidth: 2pxoffset: 2pxmessages: []obligations:accessibility:role: switchname: Label slot provides the accessible name.keyboard: - Space toggles the switch. - Tab moves focus into and out of the switch in document order.semantics: - Checked, required, and disabled states are exposed through platform semantics. - The accessible name remains stable as the checked state changes.behavior:model: inputinteractions: - Toggling emits checked-change with the next boolean value. - Disabled switches do not toggle or emit checked-change.hostEffects: - Dispatch checked-change event. - Bind checked to SDUI form state when present.conditions: - rtl - reduced-motion - cvd-deuteranopia - density-compact - text-expansionsdui:status: serializableserializableProperties: - checked - default-checked - is-disabled - is-requiredserializableSlots: - labeleventBindings: - checked-changenotes: Checked-change serializes to a named binding/action channel.examples: - name: uncheckedstate: defaultproperties:checked: falseslots:label: Email notifications - name: checkedstate: checkedproperties:default-checked: trueslots:label: Email notifications - name: disabledstate: disabledproperties:checked: trueis-disabled: trueslots:label: Email notifications
01
Examples
Generated from the contract's examples block.
Previews are the published @wyrd-company/react component, themed by the
brand's role tokens — flip the site's light/dark toggle and they follow.
Prevents toggling and exposes disabled platform semantics.
is-required
boolean
false
Marks the switch as required in form semantics.
03
Slots & events
Slot
Cardinality
Accepts
Summary
label
exactly-one
text, node
Visible label and accessible-name source.
Event
Payload
Summary
checked-change
checked, action
Canonical checked-state change event carrying the next boolean value.
04
Tokens
The contract's token bindings. Open the shared contextual sidebar from any example;
primary swatches reflect the color you pick there. Error swatches show the active
preset's values; editing any knob switches to custom and resets error to TWW · Ink.
Binding
Token
root.gap
spacing.sm
track.width
spacing.xl
track.height
spacing.lg
track.radius
rounded.full
track.background-unchecked
color.outline
track.background-checked
color.primary
track.background-disabled
color.disabled
thumb.size
spacing.md
thumb.background-unchecked
color.surface
thumb.background-checked
color.on-primary
thumb.background-disabled
color.on-disabled
label.color
color.on-surface
label.text
typography.label-md
focus.color
color.primary
focus.width
2px
focus.offset
2px
05
States
State
Source
Summary
default
platform
Enabled unchecked state.
checked
property
Checked state derived from checked or default-checked.
focus-visible
platform
Keyboard-visible focus state.
disabled
property
Disabled state derived from is-disabled.
required
property
Required state derived from is-required.
06
Accessibility
From the contract's accessibility obligations. Role switch; Label slot provides the accessible name.
Space toggles the switch.
Tab moves focus into and out of the switch in document order.
Checked, required, and disabled states are exposed through platform semantics.
The accessible name remains stable as the checked state changes.