lantern

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.

Checked with description

description renders under the label for longer helper copy.

Disabled

Non-interactive; value still posts if the control is checked.

Error state

Invalid chrome and error message under the control.

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.

Plan

Cards

Card layout with optional per-option description.

Tier

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.

Sizes

sm, md (default), and lg.

Label & description

description sits under the label for longer helper copy.

At most one email per day.

Disabled

Non-interactive switch.

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.