Docs

Cinder UI

Forms.checkbox

Server-rendered

Renders a checkbox control with optional inline label content.

With FormField

<.checkbox field={@form[:active]} />

With label attr (inline)

<.checkbox field={@form[:active]} label="Active" />

With inner_block (takes precedence over label attr)

<.checkbox field={@form[:terms]}>
  I agree to the <a href="/terms">Terms of Service</a>
</.checkbox>

With explicit errors

<.checkbox field={@form[:terms]} errors={["must be accepted"]} />

Inside field composition

<.field>
  <:label><.label for={@form[:active].id}>Active</.label></:label>
  <.checkbox field={@form[:active]} />
</.field>

Basic checkbox

  <.checkbox id="terms" name="terms">Accept terms</.checkbox>

Checked state

  <.checkbox id="updates" name="updates" checked={true}>Notify me about product updates</.checkbox>

Attributes

Name Type Default Values Global Includes
checked :boolean false
class :string
disabled :boolean false
errors :list
field {:struct, Phoenix.HTML.FormField}
id :string
label :string
name :string
rest :global
value :string "true"

Slots

Slot Slot Attributes
inner_block