checkbox/1 (the lu-check box with label and description) and checkbox_group/1 (one
checkbox per option of a list field).
<.checkbox name="terms" label="I agree" />
<.checkbox field={@form[:remember]} label="Remember me" color="primary" />
<.checkbox name="pro" label="Pro plan" description="Billed yearly" color="primary" checked />
<.checkbox name="all" label="Select all (3 of 8)" indeterminate />
<.checkbox_group field={@form[:roles]} label="Roles"
options={[{"Admin", "admin"}, {"Editor", "editor"}]} />
<.checkbox_group field={@form[:channels]} variant="chip" color="primary" options={[
%{label: "E-mail", value: "email", count: 3}, %{label: "WhatsApp", value: "whatsapp"}]} />Inside a form a named checkbox sends unchecked_value through a hidden input when it is off
(hidden_input={false} skips it), so the field is always in the params. indeterminate
draws the dash of a partial selection (data-ind); the indeterminate property and
aria-checked="mixed" are set by the LedgerUI.Indeterminate hook
(priv/static/ledger_ui/hooks/indeterminate.js), so the box needs an id: it is taken from
id, the field, the name or the label. Pass false when the box can leave that state; a
click clears the dash.
Extra HTML attributes (form, required, phx-click, data-*...) go to the <input>.
Summary
Functions
Attributes
field(Phoenix.HTML.FormField) - Defaults tonil.id(:string) - Defaults tonil.name(:string) - Defaults tonil.value(:any) - Defaults tonil.checked(:boolean) - Defaults tonil.indeterminate(:boolean) - Defaults tonil.checked_value(:string) - Defaults to"true".unchecked_value(:string) - Defaults to"false".hidden_input(:boolean) - Defaults totrue.color(:string) - Defaults to"neutral". Must be one of"neutral","primary","secondary","info","success","warning", or"error".variant(:string) - Defaults to"basic". Must be one of"basic", or"outline".filled(:boolean) - Defaults tofalse.shape(:string) - Defaults to"square". Must be one of"square", or"circle".size(:string) - Defaults to"md". Must be one ofnil,"xs","sm","md", or"lg".label(:string) - Defaults tonil.label_class(:any) - Defaults tonil.description(:string) - Defaults tonil.errors(:list) - Defaults to[].disabled(:boolean) - Defaults tofalse.wrapper_class(:any) - Defaults tonil.class(:any) - Defaults tonil.style(:string) - Inline style of thelu-checklabel, not of the input. Defaults tonil.- Global attributes are accepted. Supports all globals plus:
["form", "required", "autofocus"].
Slots
inner_block
Attributes
field(Phoenix.HTML.FormField) - Defaults tonil.id(:string) - Defaults tonil.name(:string) - Defaults tonil.value(:any) - Defaults tonil.options(:list) - Defaults to[].color(:string) - Defaults to"neutral". Must be one of"neutral","primary","secondary","info","success","warning", or"error".variant(:string) - Defaults to"basic". Must be one of"basic","outline","card", or"chip".filled(:boolean) - Defaults tofalse.shape(:string) - Defaults to"square". Must be one of"square", or"circle".size(:string) - Defaults to"md". Must be one of"xs","sm","md", or"lg".label(:string) - Defaults tonil.label_class(:any) - Defaults tonil.help(:string) - Defaults tonil.errors(:list) - Defaults to[].disabled(:boolean) - Defaults tofalse.wrapper_class(:any) - Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
checkbox- Accepts attributes:value(:any)label(:string)color(:string)disabled(:boolean)description(:string)count(:any)icon(:string)