Forms & inputs
Checkbox, radio & switch
Pick one, pick many, or flip a setting.
Checkbox
Fluxon-compatible, FormField-aware. A hidden input submits the
unchecked value so forms always receive the param.
Basic
Unchecked by default; label is optional.
<.checkbox id="ck-1" name="accept" label="Accept the terms" />
Checked with description
description renders under the label for longer helper copy.
<.checkbox
name="notify"
checked
label="Email me about activity"
description="At most one email per day."
/>
Disabled
Non-interactive; value still posts if the control is checked.
<.checkbox name="dis" label="Disabled" disabled />
Error state
Invalid chrome and error message under the control.
must be accepted
<.checkbox name="err" label="Required" errors={["must be accepted"]} />
API reference
Props and slots, introspected from the component.
| Prop | Type | Default | Description |
|---|---|---|---|
checked |
boolean |
nil |
Force checked state; else compares value to checked_value. |
checked_value |
any |
"true" |
Value submitted when the box is checked. |
class |
any |
nil |
Extra classes merged onto the root element. |
description |
string |
nil |
Helper text under the label stack. |
disabled |
boolean |
false |
Render disabled and non-interactive. |
errors |
list |
[] |
Validation messages; derived from field when used. |
field |
{:struct, Phoenix.HTML.FormField} |
nil |
Form field; derives id, name, value, and errors. |
id |
any |
nil |
Element id; derived from field when omitted. |
label |
string |
nil |
Primary label text beside the control. |
name |
string |
nil |
Form input name; derived from field when omitted. |
sublabel |
string |
nil |
Secondary label line under the primary label. |
unchecked_value |
any |
"false" |
Hidden input value submitted when unchecked. |
value |
any |
nil |
Current value used to derive checked state. |
Radio
Exclusive single selection — list (default) or cards variant.
List
Default list layout; sublabel annotates an option.
<.radio name="plan" value="pro" label="Plan" variant="list">
<:radio value="basic" label="Basic" />
<:radio value="pro" label="Pro" sublabel="Popular" />
<:radio value="enterprise" label="Enterprise" />
</.radio>
Cards
Card layout with optional per-option description.
<.radio name="tier" value="team" label="Tier" variant="cards">
<:radio value="free" label="Free" description="Hobby projects" />
<:radio value="team" label="Team" description="Collaboration" />
<:radio value="scale" label="Scale" description="Growing teams" />
</.radio>
API reference
Props and slots, introspected from the component.
| Prop | Type | Default | Description |
|---|---|---|---|
class |
any |
nil |
Extra classes merged onto the root element. |
controlled |
boolean |
false |
Server-driven value: `value` is truth, patches flow into the machine. |
description |
string |
nil |
Helper text under the group label. |
disabled |
boolean |
false |
Render disabled and non-interactive. |
errors |
list |
[] |
Validation messages; derived from field when used. |
field |
{:struct, Phoenix.HTML.FormField} |
nil |
Form field; derives id, name, value, and errors. |
id |
any |
nil |
Element id; derived from field or name when omitted. |
label |
string |
nil |
Group label above the options. |
name |
string |
nil |
Shared radio name; derived from field when omitted. |
on_change |
string |
nil |
Server event pushed on pick (`lantern:radio:set-value` replies). |
on_change_client |
string |
nil |
Bubbling DOM CustomEvent dispatched on pick. |
sublabel |
string |
nil |
Secondary line under the group label. |
value |
any |
nil |
Currently selected option value. |
variant |
list | cards |
"list" |
list is compact radios; cards is selectable panels. |
| Slots | |||
:radio* |
One exclusive option in the group. | ||
Switch
Toggle switch for binary settings. Sizes sm/md/lg,
with optional label and description.
Basic
Unchecked and checked. A hidden input always submits the off value.
<.switch name="sw_off" label="Unchecked" />
<.switch name="sw_on" checked label="Checked" />
Sizes
sm, md (default), and lg.
<.switch name="sw_sm" size="sm" label="sm" checked />
<.switch name="sw_md" size="md" label="md" checked />
<.switch name="sw_lg" size="lg" label="lg" checked />
Label & description
description sits under the label for longer helper copy.
At most one email per day.
<.switch
name="sw_desc"
checked
label="Email notifications"
description="At most one email per day."
/>
Disabled
Non-interactive switch.
<.switch name="sw_dis" label="Disabled" disabled />
API reference
Props and slots, introspected from the component.
| Prop | Type | Default | Description |
|---|---|---|---|
checked |
boolean |
nil |
Force on/off; else compares value to checked_value. |
checked_value |
any |
"true" |
Value submitted when the switch is on. |
class |
any |
nil |
Extra classes merged onto the root element. |
color |
string |
"accent" |
On-state track color token. |
controlled |
boolean |
false |
Server-driven checked state: `checked` is truth, patches flow into the machine. |
description |
string |
nil |
Helper text under the label stack. |
disabled |
boolean |
false |
Render disabled and non-interactive. |
errors |
list |
[] |
Validation messages; derived from field when used. |
field |
{:struct, Phoenix.HTML.FormField} |
nil |
Form field; derives id, name, value, and errors. |
id |
any |
nil |
Element id; derived from field when omitted. |
label |
string |
nil |
Primary label text beside the switch. |
name |
string |
nil |
Form input name; derived from field when omitted. |
on_change |
string |
nil |
Server event pushed on toggle (`lantern:switch:set-checked` replies). |
on_change_client |
string |
nil |
Bubbling DOM CustomEvent dispatched on toggle. |
size |
sm | md | lg |
"md" |
Track and thumb size. |
sublabel |
string |
nil |
Secondary label line under the primary label. |
unchecked_value |
any |
"false" |
Hidden input value submitted when off. |
value |
any |
nil |
Current value used to derive checked state. |