LanternUI.Components.Checkbox (LanternUI v0.4.0)

Copy Markdown View Source

Checkbox with label, description, and error states.

<.checkbox field={@form[:accept]} label="Accept the terms" />
<.checkbox name="notify" checked={@notify} label="Email me" description="At most one per day." />

The API mirrors Fluxon's checkbox/1 (field/name/checked, checked_value/unchecked_value, label/sublabel/description, errors), so a use Fluxon app can swap imports without template changes. A hidden input submits unchecked_value when the box is unchecked, so forms always receive the param. (checkbox_group/1 is not yet implemented.)

Summary

Functions

checkbox(assigns)

Attributes

  • id (:any) - Defaults to nil.
  • name (:string) - Defaults to nil.
  • value (:any) - Defaults to nil.
  • checked (:boolean) - Defaults to nil.
  • checked_value (:any) - Defaults to "true".
  • unchecked_value (:any) - Defaults to "false".
  • label (:string) - Defaults to nil.
  • sublabel (:string) - Defaults to nil.
  • description (:string) - Defaults to nil.
  • errors (:list) - Defaults to [].
  • class (:any) - Defaults to nil.
  • field (Phoenix.HTML.FormField) - Defaults to nil.
  • disabled (:boolean) - Defaults to false.
  • Global attributes are accepted.