Toggle switch component — accessible boolean input.
Renders as a styled checkbox that looks like a native iOS/Android switch.
Works with phx-change for real-time LiveView updates.
Examples
<.toggle name="dark_mode" checked={@settings.dark_mode} label="Dark mode" />
<.toggle
field={@form[:notifications]}
label="Email notifications"
hint="Receive updates via email"
/>
<.toggle name="enabled" checked={false} label="Auto-deploy" size="lg" />
Summary
Functions
Renders a toggle switch for boolean input.
Functions
Renders a toggle switch for boolean input.
Attributes
id(:any) - Defaults tonil.name(:any) - Defaults tonil.value(:any) - Defaults to"true".checked(:boolean) - Defaults tofalse.label(:string) - Defaults tonil.hint(:string) - Defaults tonil.size(:string) - Defaults to"md". Must be one of"sm","md", or"lg".class(:string) - Defaults tonil.field(Phoenix.HTML.FormField) - Binds from a Phoenix form field.- Global attributes are accepted. Supports all globals plus:
["phx-change", "phx-blur", "disabled"].