# `PhoenixKitWeb.Components.Core.Checkbox`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.207/lib/phoenix_kit_web/components/core/checkbox.ex#L1)

Provides a default checkbox UI component.

daisyUI's `.checkbox` class only styles the `<input>` — it does not wrap it
in a `<label>`, so a hand-rolled checkbox + adjacent text is easy to get
wrong (clicking the text does nothing). This component always renders the
correct `<label><input/><span>...</span></label>` structure, plus the
hidden-false fallback input so an unchecked box still submits a value.

# `checkbox`

Renders a checkbox.

## Examples

    <.checkbox field={@form[:remember_me]} label="Keep me logged in" />

    <.checkbox
      name="settings[allow_registration]"
      checked={@settings["allow_registration"] == "true"}
      label="Anyone can register"
    />

    <%!-- Rich label content (badges, icons) via the default slot —
         overrides the `label` attr when given: --%>
    <.checkbox name="roles[admin]" checked={...} disabled={owner_role?}>
      <.role_badge role={role} size={:sm} /> {role.name}
      <:description>Grants full administrative access</:description>
    </.checkbox>

    <%!-- Locked (but still submitted) while a parent switch is off — use
         `wrapper_class`, not `disabled`, so the field's real stored value
         keeps submitting instead of collapsing to the hidden "false"
         fallback: --%>
    <.checkbox
      name="settings[oauth_google_enabled]"
      checked={@settings["oauth_google_enabled"] == "true"}
      label="Google Sign-In"
      wrapper_class={!@settings["oauth_enabled"] == "true" && "pointer-events-none"}
    />

## Attributes

* `field` (`Phoenix.HTML.FormField`)
* `id` (`:any`) - Defaults to `nil`.
* `name` (`:any`)
* `label` (`:string`) - Defaults to `nil`.
* `errors` (`:list`) - Defaults to `[]`.
* `checked` (`:boolean`) - Defaults to `nil`.
* `disabled` (`:boolean`) - Defaults to `false`.
* `title` (`:string`) - tooltip on the wrapping `<label>` (covers the box and the text), e.g. explaining why a checkbox is disabled. Defaults to `nil`.
* `class` (`:any`) - extra classes merged onto the `<input type="checkbox">` (e.g. `checkbox-sm`, `checkbox-accent`). Defaults to `nil`.
* `wrapper_class` (`:any`) - extra classes merged onto the wrapping `<label>` (e.g. spacing like `mb-3`, or `pointer-events-none` to lock the whole control — box and text — without excluding it from form submission the way `disabled` would). Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["readonly", "required"]`.
## Slots

* `inner_block` - Rich label content (badges, icons, multiple elements). Overrides `label` when given.
* `description` - Secondary helper text rendered below the label.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
