ToggleSwitch
Description
The ToggleSwitch component is a button that toggles between two boolean states. It is meant to be used for settings that should cause an immediate update. If configured with a "src" attribute, the component will make a POST request containing data of the form "value: 0 | 1".
Arguments
| Name | Default | Description |
|---|---|---|
src | StringThe URL to POST to when the toggle switch is toggled. If | |
csrf_token | StringA CSRF token that will be sent to the server as "authenticity_token" when the toggle switch is toggled. Unused if | |
checked | BooleanWhether the toggle switch is on or off. | |
enabled | BooleanWhether or not the toggle switch responds to user input. | |
size | SymbolWhat size toggle switch to render. One of | |
status_label_position | SymbolWhich side of the toggle switch to render the status label. One of | |
turbo | BooleanWhether or not to request a turbo stream and render the response as such. | |
autofocus | BooleanWhether switch should be autofocused when rendered. | |
system_arguments | Hash | |
on_label | StringCustom label to show when the switch is ON. Defaults to On. Only customize this label if it makes the toggle’s state more meaningful in its specific context. For example, for a "Show images" setting, you might use "Hide" when the switch is ON. | |
off_label | StringCustom label to show when the switch is OFF. Defaults to ("Off"). Only customize this label if it makes the toggle’s state more meaningful in its specific context. For example, for a "Show images" setting, you might use "Show" when the switch is OFF. |