Toggle switch

Toggle switch is used to immediately toggle a setting on or off.

v0.21.0AlphaNot reviewed for accessibility

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

NameDefaultDescription
src

nil

String

The URL to POST to when the toggle switch is toggled. If nil, the toggle switch will not make any requests.

csrf_token

nil

String

A CSRF token that will be sent to the server as "authenticity_token" when the toggle switch is toggled. Unused if src is nil.

checked

false

Boolean

Whether the toggle switch is on or off.

enabled

true

Boolean

Whether or not the toggle switch responds to user input.

size

:medium

Symbol

What size toggle switch to render. One of :medium or :small.

status_label_position

:start

Symbol

Which side of the toggle switch to render the status label. One of :end or :start.

system_arguments

N/A

Hash

Examples