Switch
Unlike checkboxes, switches should deliver immediate results instead of requiring the user to click "Save" to see the results. See Toggle-Switch Guidelines for more information.
Consider using RFUI's
FormField
component with type="switch"
instead. If not, you'll probably want to use <label>
along with Switch
.import { Switch } from "rfui";
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
Prop | Required | Default | Type and notes |
---|---|---|---|
...rest | - | - |
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:
|