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

Toggler -- on/off switch.

## Props

- `is_toggled` (boolean) -- whether the toggler is on. Default: false.
- `label` (string) -- text label displayed next to the toggler.
- `spacing` (number) -- space between toggler and label in pixels.
- `width` (length) -- widget width. Default: shrink. See `Toddy.Iced.Length`.
- `size` (number) -- toggler 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` (atom) -- text shaping: `:basic`, `:advanced`, or `:auto`.
  See `Toddy.Iced.Shaping`.
- `wrapping` (atom) -- text wrapping: `:none`, `:word`, `:glyph`, `:word_or_glyph`.
  See `Toddy.Iced.Wrapping`.
- `text_alignment` (atom) -- horizontal label alignment: `:left`, `:center`, `:right`.
  See `Toddy.Iced.Alignment`.
- `style` (atom) -- named style. Currently only `:default`.
- `disabled` (boolean) -- when true, the toggler 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() ::
  {:label, String.t()}
  | {: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()}
  | {:text_alignment, Toddy.Iced.Alignment.t()}
  | {:style, style()}
  | {:disabled, boolean()}
  | {:a11y, Toddy.Iced.A11y.t()}
```

# `style`

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

# `t`

```elixir
@type t() :: %Toddy.Iced.Widget.Toggler{
  a11y: Toddy.Iced.A11y.t() | nil,
  disabled: boolean() | nil,
  font: Toddy.Iced.Font.t() | nil,
  id: String.t(),
  is_toggled: boolean(),
  label: String.t() | nil,
  line_height: number() | map() | nil,
  size: number() | nil,
  spacing: number() | nil,
  style: style() | nil,
  text_alignment: Toddy.Iced.Alignment.t() | 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(toggler :: t(), a11y :: Toddy.Iced.A11y.t()) :: t()
```

Sets accessibility annotations.

# `build`

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

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

# `disabled`

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

Sets whether the toggler is disabled.

# `font`

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

Sets the label font.

# `label`

```elixir
@spec label(toggler :: t(), label :: String.t()) :: t()
```

Sets the toggler label.

# `line_height`

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

Sets the label line height.

# `new`

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

Creates a new toggler struct with the given toggle state and optional keyword opts.

# `size`

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

Sets the toggler size in pixels.

# `spacing`

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

Sets the spacing between toggler and label.

# `style`

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

Sets the toggler style.

# `text_alignment`

```elixir
@spec text_alignment(toggler :: t(), text_alignment :: Toddy.Iced.Alignment.t()) ::
  t()
```

Sets the horizontal label text alignment.

# `text_shaping`

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

Sets the text shaping strategy.

# `text_size`

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

Sets the label text size in pixels.

# `width`

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

Sets the toggler width.

# `with_options`

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

Applies keyword options to an existing toggler struct.

# `wrapping`

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

Sets the text wrapping mode.

---

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