Renders a switch as a button.
If you want to render a switch as part of a form, use the input/1
component
with the type "switch"
instead.
Note that this component only renders a button with a label, a state, and
<span>
with the class switch-control
. You will need to style the switch
control span with CSS in order to give it the appearance of a switch.
<.switch
label="Subscribe"
checked={true}
phx-click="toggle-subscription"
/>
<.switch label="Subscribe" checked phx_click="toggle-subscription"/> <.switch label="Subscribe" phx_click="toggle-subscription"/>
<.switch label="Subscribe" checked on_text="yes" phx_click="toggle-subscription"/> <.switch label="Subscribe" off_text="no" phx_click="toggle-subscription"/>