Skip to content
1 viewer
View
Component · Input

Switch

cre8.primitive.switch

Accessible binary toggle control.

Edit live
Category
Input
Slots
6
States
4
Writer
Shared

Preview

Live renderShared SSR + WASM writers
<Switch
  checked={true}
  label="Realtime WebSocket Streaming (:8788)"
  name="realtime_stream"
/>
Change this declaration and watch it render:open Switch in the playground

Props

The inputs the shared writer reads. `data-*` and `aria-*` attributes pass through and are not listed.

PropTypeRequiredDefaultAlso written
checkedboolOptional—defaultChecked
disabledboolOptional——
errortextOptional—errorText
helptextOptional—description, helpText
idtextOptional——
invalidboolOptional——
labeltextOptional——
nametextOptional——
requiredboolOptional——
9 rows

Anatomy

The named parts of the rendered markup. Recipes style these hooks, and every renderer keeps them stable.

SlotDOM class
root.primitive-switch
label.primitive-switch__label
input.primitive-switch__input
text.primitive-switch__text
help.primitive-switch__help
error.primitive-switch__error
6 rows
Modifier
primitive-switch--{state}
State attribute
data-statefrom the checkedState prop
Role
switch (on the input)

States and platforms

The states the contract publishes, the platforms it declares, and the style recipes that dress it.

States
checkeddisabledrequiredinvalid
Platforms
webnativeruntime-node
Recipes
unstyledruntime-console

Renderers

Shared writer
Switch renders through the one writer the server and the WASM DOM share, so both emit the same markup.

Every tag in the example above renders through a shared writer.

Declared adapters. A status is the manifest's declaration, not a measured parity result.

TargetRendererStatus
webreactexperimental
runtime-nodeview-nodeready
ssrhtml-form-controlready
terminalterminal-form-controlplanned
nativenative-adapterexperimental
5 rows

Accessibility

Uses switch semantics with explicit label and state wiring.

  • Checked and invalid states remain available to assistive tech.
  • Label, help text, and error text are linked through ids.