Switch
On/off toggle with size and color variants.
Basic
Sublabel and description
Pair sublabel for a short inline qualifier with description for longer copy beneath the label.
Automatically save your changes every few seconds.
A summary of new features shipped with each release.
Sizes
The size attribute scales the track and thumb together. Pick sm for dense layouts, md as the default, and lg for touch surfaces or emphasized settings.
Colors
The color attribute tints the track when the switch is on, reinforcing the meaning of the setting being toggled.
Disabled
Add disabled to grey out the label, sublabel, and description, and disable the hidden mirror input so the field is omitted from the submitted payload.
This setting is included with the Pro plan.
Custom values
Override checked_value and unchecked_value when the schema expects 1/0 or tokens like on/off.
Submits 1 when on and 0 when off.
Submits on or off, matching the legacy schema.
Standalone toggle
Pair name with checked and phx-click to drive a LiveView event handler directly, without a backing changeset.
Settings panel
Stack switches in a vertical list to build a preferences surface. Each toggle reads as its own decision, and color reinforces the meaning of the setting.
Receive alerts when something needs your attention.
Daily digests and important account activity.
Hear about new features, launches, and the occasional sale.
Settings rows
Pass class="flex-row-reverse w-full justify-between" to push the toggle to the right of the row, the layout most account and notification settings pages reach for.
Require a verification code in addition to your password.
A summary of activity in your workspace, sent every Monday.
Allow other users on the platform to view your profile.
Form integration
Bind each switch to a Phoenix.HTML.FormField through field. The component derives id, name, and the current value, and a hidden mirror input keeps the field in form data even when the toggle is off.
Switch outside its form
Pass form="..." to bind the switch to a form by id when the toggle sits in a sticky footer, sidebar, or header outside the <form> element.