# `Toddy.Iced.Widget.Checkbox`
[🔗](https://github.com/toddy-ui/toddy-elixir/blob/v0.3.0/lib/toddy/iced/widget/checkbox.ex#L1)

Checkbox -- toggleable boolean input.

## Props

- `checked` (boolean) -- whether the checkbox is checked. Default: false.
- `label` (string) -- text label displayed next to the checkbox.
- `spacing` (number) -- space between checkbox and label in pixels.
- `width` (length) -- widget width. Default: shrink. See `Toddy.Iced.Length`.
- `size` (number) -- checkbox size in pixels.
- `text_size` (number) -- label text size in pixels.
- `font` (string | map) -- label font. See `Toddy.Iced.Font`.
- `line_height` (number | map) -- label line height.
- `text_shaping` -- text shaping strategy. See `Toddy.Iced.Shaping`.
- `wrapping` -- text wrapping mode. See `Toddy.Iced.Wrapping`.
- `style` -- named preset (`:primary` (default), `:secondary`, `:success`,
  `:danger`) or `StyleMap.t()`. See `Toddy.Iced.StyleMap`.
- `icon` (map) -- custom icon for the check mark. Map with `:code_point` (required),
  and optional `:size`, `:line_height`, `:font`, `:shaping`.
- `disabled` (boolean) -- when true, the checkbox cannot be toggled. Default: false.
- `a11y` (map) -- accessibility overrides. See `Toddy.Iced.A11y`.

## Events

- `%Widget{type: :toggle, id: id, value: bool}` -- emitted on toggle, `value` is the new boolean state.

# `option`

```elixir
@type option() ::
  {:spacing, number()}
  | {:width, Toddy.Iced.Length.t()}
  | {:size, number()}
  | {:text_size, number()}
  | {:font, Toddy.Iced.Font.t()}
  | {:line_height, number() | map()}
  | {:text_shaping, Toddy.Iced.Shaping.t()}
  | {:wrapping, Toddy.Iced.Wrapping.t()}
  | {:style, style()}
  | {:icon, map()}
  | {:disabled, boolean()}
  | {:a11y, Toddy.Iced.A11y.t()}
```

# `preset`

```elixir
@type preset() :: :danger | :success | :secondary | :primary
```

# `style`

```elixir
@type style() :: preset() | Toddy.Iced.StyleMap.t()
```

# `t`

```elixir
@type t() :: %Toddy.Iced.Widget.Checkbox{
  a11y: Toddy.Iced.A11y.t() | nil,
  disabled: boolean() | nil,
  font: Toddy.Iced.Font.t() | nil,
  icon: map() | nil,
  id: String.t(),
  is_toggled: boolean(),
  label: String.t(),
  line_height: number() | map() | nil,
  size: number() | nil,
  spacing: number() | nil,
  style: style() | nil,
  text_shaping: Toddy.Iced.Shaping.t() | nil,
  text_size: number() | nil,
  width: Toddy.Iced.Length.t() | nil,
  wrapping: Toddy.Iced.Wrapping.t() | nil
}
```

# `a11y`

```elixir
@spec a11y(checkbox :: t(), a11y :: Toddy.Iced.A11y.t()) :: t()
```

Sets accessibility annotations.

# `build`

```elixir
@spec build(checkbox :: t()) :: Toddy.Iced.ui_node()
```

Converts this checkbox struct to a `ui_node()` map via the `Toddy.Iced.Widget` protocol.

# `disabled`

```elixir
@spec disabled(checkbox :: t(), disabled :: boolean()) :: t()
```

Sets whether the checkbox is disabled.

# `font`

```elixir
@spec font(checkbox :: t(), font :: Toddy.Iced.Font.t()) :: t()
```

Sets the label font.

# `icon`

```elixir
@spec icon(checkbox :: t(), icon :: map()) :: t()
```

Sets a custom icon for the check mark.

# `line_height`

```elixir
@spec line_height(checkbox :: t(), line_height :: number() | map()) :: t()
```

Sets the label line height.

# `new`

```elixir
@spec new(
  id :: String.t(),
  label :: String.t(),
  is_toggled :: boolean(),
  opts :: [option()]
) :: t()
```

Creates a new checkbox struct with the given label, toggle state, and optional keyword opts.

# `size`

```elixir
@spec size(checkbox :: t(), size :: number()) :: t()
```

Sets the checkbox size in pixels.

# `spacing`

```elixir
@spec spacing(checkbox :: t(), spacing :: number()) :: t()
```

Sets the spacing between checkbox and label.

# `style`

```elixir
@spec style(checkbox :: t(), style :: style()) :: t()
```

Sets the checkbox style.

# `text_shaping`

```elixir
@spec text_shaping(checkbox :: t(), text_shaping :: Toddy.Iced.Shaping.t()) :: t()
```

Sets the text shaping strategy.

# `text_size`

```elixir
@spec text_size(checkbox :: t(), text_size :: number()) :: t()
```

Sets the label text size in pixels.

# `width`

```elixir
@spec width(checkbox :: t(), width :: Toddy.Iced.Length.t()) :: t()
```

Sets the checkbox width.

# `with_options`

```elixir
@spec with_options(checkbox :: t(), opts :: [option()]) :: t()
```

Applies keyword options to an existing checkbox struct.

# `wrapping`

```elixir
@spec wrapping(checkbox :: t(), wrapping :: Toddy.Iced.Wrapping.t()) :: t()
```

Sets the text wrapping mode.

---

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