# `LedgerUI.Components.Checkbox`
[🔗](https://github.com/devaction-labs/ledger_ui/blob/v0.2.0/lib/ledger_ui/components/checkbox.ex#L1)

`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>`.

# `checkbox`

## Attributes

* `field` (`Phoenix.HTML.FormField`) - Defaults to `nil`.
* `id` (`:string`) - Defaults to `nil`.
* `name` (`:string`) - Defaults to `nil`.
* `value` (`:any`) - Defaults to `nil`.
* `checked` (`:boolean`) - Defaults to `nil`.
* `indeterminate` (`:boolean`) - Defaults to `nil`.
* `checked_value` (`:string`) - Defaults to `"true"`.
* `unchecked_value` (`:string`) - Defaults to `"false"`.
* `hidden_input` (`:boolean`) - Defaults to `true`.
* `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 to `false`.
* `shape` (`:string`) - Defaults to `"square"`. Must be one of `"square"`, or `"circle"`.
* `size` (`:string`) - Defaults to `"md"`. Must be one of `nil`, `"xs"`, `"sm"`, `"md"`, or `"lg"`.
* `label` (`:string`) - Defaults to `nil`.
* `label_class` (`:any`) - Defaults to `nil`.
* `description` (`:string`) - Defaults to `nil`.
* `errors` (`:list`) - Defaults to `[]`.
* `disabled` (`:boolean`) - Defaults to `false`.
* `wrapper_class` (`:any`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* `style` (`:string`) - Inline style of the `lu-check` label, not of the input. Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["form", "required", "autofocus"]`.
## Slots

* `inner_block`

# `checkbox_group`

## Attributes

* `field` (`Phoenix.HTML.FormField`) - Defaults to `nil`.
* `id` (`:string`) - Defaults to `nil`.
* `name` (`:string`) - Defaults to `nil`.
* `value` (`:any`) - Defaults to `nil`.
* `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 to `false`.
* `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 to `nil`.
* `label_class` (`:any`) - Defaults to `nil`.
* `help` (`:string`) - Defaults to `nil`.
* `errors` (`:list`) - Defaults to `[]`.
* `disabled` (`:boolean`) - Defaults to `false`.
* `wrapper_class` (`:any`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `checkbox` - Accepts attributes:

  * `value` (`:any`)
  * `label` (`:string`)
  * `color` (`:string`)
  * `disabled` (`:boolean`)
  * `description` (`:string`)
  * `count` (`:any`)
  * `icon` (`:string`)

---

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