LanternUI.Components.Radio (LanternUI v0.8.2)

Copy Markdown View Source

Radio group for exclusive single selection. Mirrors Fluxon's radio_group/1 as radio/1 so templates call <.radio>.

<.radio name="plan" value={@plan} label="Plan">
  <:radio value="basic" label="Basic" />
  <:radio value="pro" label="Pro" sublabel="Popular" />
</.radio>

<.radio field={@form[:tier]} variant="cards" label="Tier">
  <:radio value="free" label="Free" description="Hobby projects" />
  <:radio value="team" label="Team" description="Collaboration" />
</.radio>

Summary

Functions

radio(assigns)

Attributes

  • id (:any) - Element id; derived from field or name when omitted. Defaults to nil.
  • name (:string) - Shared radio name; derived from field when omitted. Defaults to nil.
  • value (:any) - Currently selected option value. Defaults to nil.
  • label (:string) - Group label above the options. Defaults to nil.
  • sublabel (:string) - Secondary line under the group label. Defaults to nil.
  • description (:string) - Helper text under the group label. Defaults to nil.
  • errors (:list) - Validation messages; derived from field when used. Defaults to [].
  • variant (:string) - list is compact radios; cards is selectable panels. Defaults to "list". Must be one of "list", or "cards".
  • class (:any) - Extra classes merged onto the root element. Defaults to nil.
  • field (Phoenix.HTML.FormField) - Form field; derives id, name, value, and errors. Defaults to nil.
  • disabled (:boolean) - Render disabled and non-interactive. Defaults to false.
  • Global attributes are accepted. Arbitrary HTML/phx-* attributes passed through.

Slots

  • radio (required) - One exclusive option in the group. Accepts attributes:
    • value (:any) (required) - Option value submitted when selected.
    • label (:string) - Primary label for this option.
    • sublabel (:string) - Secondary label for this option.
    • description (:string) - Helper text under this option's labels.
    • disabled (:boolean) - Disable this option only.