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

Container layout -- wraps a single child with padding, sizing, and styling.

## Props

- `padding` (number | map) -- padding inside the container. See `Toddy.Iced.Padding`.
- `width` (length) -- container width. Default: shrink. See `Toddy.Iced.Length`.
- `height` (length) -- container height. Default: shrink.
- `max_width` (number) -- maximum width in pixels.
- `max_height` (number) -- maximum height in pixels.
- `center` (boolean) -- center child in both axes. Default: false.
- `clip` (boolean) -- clip child that overflows. Default: false.
- `align_x` -- horizontal alignment: `:left`, `:center`, `:right`. See `Toddy.Iced.Alignment`.
- `align_y` -- vertical alignment: `:top`, `:center`, `:bottom`. See `Toddy.Iced.Alignment`.
- `background` (color | gradient) -- background fill. Accepts a hex color string,
  `%{r, g, b, a}` map, or a gradient map. See `Toddy.Iced.Color`, `Toddy.Iced.Gradient`.
- `color` (color) -- text color override. See `Toddy.Iced.Color`.
- `border` (map) -- border specification: `%{color, width, radius}`. See `Toddy.Iced.Border`.
- `shadow` (map) -- shadow specification: `%{color, offset, blur_radius}`. See `Toddy.Iced.Shadow`.
- `style` -- named preset (`:transparent`, `:rounded_box`, `:bordered_box`,
  `:dark`, `:primary`, `:secondary`, `:success`, `:danger`, `:warning`)
  or `StyleMap.t()`. Overrides inline style props if both are set.
- `a11y` (map) -- accessibility overrides. See `Toddy.Iced.A11y`.

# `option`

```elixir
@type option() ::
  {:padding, Toddy.Iced.Padding.t()}
  | {:width, Toddy.Iced.Length.t()}
  | {:height, Toddy.Iced.Length.t()}
  | {:max_width, number()}
  | {:max_height, number()}
  | {:center, boolean()}
  | {:clip, boolean()}
  | {:align_x, Toddy.Iced.Alignment.t()}
  | {:align_y, Toddy.Iced.Alignment.t()}
  | {:background, Toddy.Iced.Color.input() | Toddy.Iced.Gradient.t()}
  | {:color, Toddy.Iced.Color.input()}
  | {:border, Toddy.Iced.Border.t()}
  | {:shadow, Toddy.Iced.Shadow.t()}
  | {:style, style()}
  | {:a11y, Toddy.Iced.A11y.t()}
```

# `preset`

```elixir
@type preset() ::
  :warning
  | :danger
  | :success
  | :secondary
  | :primary
  | :dark
  | :bordered_box
  | :rounded_box
  | :transparent
```

# `style`

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

# `t`

```elixir
@type t() :: %Toddy.Iced.Widget.Container{
  a11y: Toddy.Iced.A11y.t() | nil,
  align_x: Toddy.Iced.Alignment.t() | nil,
  align_y: Toddy.Iced.Alignment.t() | nil,
  background: Toddy.Iced.Color.t() | Toddy.Iced.Gradient.t() | nil,
  border: Toddy.Iced.Border.t() | nil,
  center: boolean() | nil,
  children: [Toddy.Iced.ui_node() | struct()],
  clip: boolean() | nil,
  color: Toddy.Iced.Color.t() | nil,
  height: Toddy.Iced.Length.t() | nil,
  id: String.t(),
  max_height: number() | nil,
  max_width: number() | nil,
  padding: Toddy.Iced.Padding.t() | nil,
  shadow: Toddy.Iced.Shadow.t() | nil,
  style: style() | nil,
  width: Toddy.Iced.Length.t() | nil
}
```

# `a11y`

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

Sets accessibility annotations.

# `align_bottom`

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

Aligns content to the bottom. Sets height and align_y: :bottom.

# `align_left`

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

Aligns content to the left. Sets width and align_x: :left.

# `align_right`

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

Aligns content to the right. Sets width and align_x: :right.

# `align_top`

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

Aligns content to the top. Sets height and align_y: :top.

# `align_x`

```elixir
@spec align_x(container :: t(), align_x :: Toddy.Iced.Alignment.t()) :: t()
```

Sets the horizontal alignment of the child.

# `align_y`

```elixir
@spec align_y(container :: t(), align_y :: Toddy.Iced.Alignment.t()) :: t()
```

Sets the vertical alignment of the child.

# `background`

```elixir
@spec background(
  container :: t(),
  background :: Toddy.Iced.Color.input() | Toddy.Iced.Gradient.t()
) :: t()
```

Sets the background fill (color or gradient).

# `border`

```elixir
@spec border(container :: t(), border :: Toddy.Iced.Border.t()) :: t()
```

Sets the border specification.

# `build`

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

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

# `center`

```elixir
@spec center(container :: t(), center :: boolean()) :: t()
```

Centers the child in both axes.

# `center_x`

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

Centers content horizontally. Sets width and align_x: :center.

# `center_y`

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

Centers content vertically. Sets height and align_y: :center.

# `clip`

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

Sets whether the child is clipped on overflow.

# `color`

```elixir
@spec color(container :: t(), color :: Toddy.Iced.Color.input()) :: t()
```

Sets the text color override.

# `extend`

```elixir
@spec extend(container :: t(), children :: [Toddy.Iced.ui_node() | struct()]) :: t()
```

Appends multiple children to the container.

# `height`

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

Sets the container height.

# `max_height`

```elixir
@spec max_height(container :: t(), max_height :: number()) :: t()
```

Sets the maximum height in pixels.

# `max_width`

```elixir
@spec max_width(container :: t(), max_width :: number()) :: t()
```

Sets the maximum width in pixels.

# `new`

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

Creates a new container struct with optional keyword opts.

# `padding`

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

Sets the container padding.

# `push`

```elixir
@spec push(container :: t(), child :: Toddy.Iced.ui_node() | struct()) :: t()
```

Appends a child to the container.

# `shadow`

```elixir
@spec shadow(container :: t(), shadow :: Toddy.Iced.Shadow.t()) :: t()
```

Sets the shadow specification.

# `style`

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

Sets the named style.

# `width`

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

Sets the container width.

# `with_options`

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

Applies keyword options to an existing container struct.

---

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