Implementation of a switch/toggle component.
A switch is a control that allows users to toggle between checked and not checked states.
Component events
:on-checked-changed- Maps thechecked-changedevent. Fired when the switch is toggled.
Server commands
"toggle"- Toggles the switch between checked and unchecked.
Summary
Functions
Renders a switch component.
Functions
Renders a switch component.
Props
:id- The id to be applied to the input element:name- The name to be applied to the input element:class- Additional CSS classes:value- The current value of the switch:default-value- The default value of the switch:field- Phoenix form field:disabled- Whether the switch is disabled:on-checked-changed- Handler for value change event
Component events
:on-checked-changed- Fired when the switch is toggled.
Server commands
"toggle"- Toggles the switch between checked and unchecked.
Attributes
id(:string) - Defaults tonil.name(:string) - Defaults tonil.class(:string) - Defaults tonil.value(:any) - Defaults tonil.default-value(:any) - Defaults tofalse.Must be one oftrue,false,"true", or"false".checked(:boolean)disabled(:boolean) - Defaults tofalse.on-checked-changed(:any) - Handler for value change event. Defaults tonil.field(Phoenix.HTML.FormField) - a form field struct retrieved from the form, for example: @form[:active].- Global attributes are accepted.