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

Button -- clickable widget that emits `%Widget{type: :click, id: id}` events.

The button can contain either a text label (via the `label` or `content` prop)
or arbitrary child content (if children are provided, the first child is rendered).

## Props

- `label` (string) -- text label displayed on the button. Also accepts `content` as an alias.
- `style` -- named preset atom (`:primary` (default), `:secondary`, `:success`,
  `:warning`, `:danger`, `:text`, `:background`, `:subtle`) or `StyleMap.t()`
  for custom styling. See `Toddy.Iced.StyleMap`.
- `width` (length) -- button width. Default: shrink. See `Toddy.Iced.Length`.
- `height` (length) -- button height. Default: shrink.
- `padding` (number | map) -- internal padding. See `Toddy.Iced.Padding`.
- `clip` (boolean) -- clip child content that overflows. Default: false.
- `disabled` (boolean) -- disable the button (no click events). Default: false.
- `enabled` (boolean) -- inverse of disabled. Default: true.
- `a11y` (map) -- accessibility overrides. See `Toddy.Iced.A11y`.

## Events

- `%Widget{type: :click, id: id}` -- emitted on press (unless disabled).

# `option`

```elixir
@type option() ::
  {:width, Toddy.Iced.Length.t()}
  | {:height, Toddy.Iced.Length.t()}
  | {:padding, Toddy.Iced.Padding.t()}
  | {:clip, boolean()}
  | {:style, style()}
  | {:disabled, boolean()}
  | {:enabled, boolean()}
  | {:a11y, Toddy.Iced.A11y.t()}
```

# `preset`

```elixir
@type preset() ::
  :subtle
  | :background
  | :text
  | :danger
  | :warning
  | :success
  | :secondary
  | :primary
```

# `style`

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

# `t`

```elixir
@type t() :: %Toddy.Iced.Widget.Button{
  a11y: Toddy.Iced.A11y.t() | nil,
  clip: boolean() | nil,
  disabled: boolean() | nil,
  height: Toddy.Iced.Length.t() | nil,
  id: String.t(),
  label: String.t(),
  padding: Toddy.Iced.Padding.t() | nil,
  style: style() | nil,
  width: Toddy.Iced.Length.t() | nil
}
```

# `a11y`

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

Sets accessibility annotations.

# `build`

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

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

# `clip`

```elixir
@spec clip(button :: t(), clip :: boolean()) :: t()
```

Sets whether child content is clipped on overflow.

# `disabled`

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

Sets whether the button is disabled.

# `height`

```elixir
@spec height(button :: t(), height :: Toddy.Iced.Length.t()) :: t()
```

Sets the button height.

# `new`

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

Creates a new button struct with the given label and optional keyword opts.

# `padding`

```elixir
@spec padding(button :: t(), padding :: Toddy.Iced.Padding.t()) :: t()
```

Sets the button padding.

# `style`

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

Sets the button style. Accepts a preset atom or `StyleMap`.

# `width`

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

Sets the button width.

# `with_options`

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

Applies keyword options to an existing button struct.

---

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