Basic
<Switch />
Switch
See Controlled & Uncontrolled Components and Checkbox Example (since
Switch
uses <input type="checkbox" />
). Passing checked
and onClick
work because of ...rest
.<Switch checked={checked} onClick={onClick} />
Disabled
Set
disabled
to either true
or false
. Defaults to false
.<Switch disabled />
Props
...rest
Required
false
Type
ComponentProps<"input">
Default
none
Notes
See the docs for rest parameters. For
Switch
, you could pass anything you normally would pass to <input type="checkbox" />
because the return value looks something like this:<input
type="checkbox"
class={className}
{...rest}
/>