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

Border specification for container and widget styling.

A border has three properties:

  * `color` - hex color string (e.g. `"#ff0000"`). `nil` means no color override.
  * `width` - border width in pixels. Default: `0`.
  * `radius` - corner radius. Either a uniform number or a per-corner
    `radius_map()` from `radius/4`. Default: `0`.

## Wire format

The encoded border is a map:

    %{"color" => "#ff0000", "width" => 2, "radius" => 8}

Radius can be a uniform number or a per-corner map:

    %{"top_left" => 8, "top_right" => 8, "bottom_right" => 0, "bottom_left" => 0}

## Example

    border = Toddy.Iced.Border.new()
             |> Toddy.Iced.Border.color("#3366ff")
             |> Toddy.Iced.Border.width(2)
             |> Toddy.Iced.Border.rounded(8)

# `radius_map`

```elixir
@type radius_map() :: %{
  top_left: number(),
  top_right: number(),
  bottom_right: number(),
  bottom_left: number()
}
```

Per-corner radius map.

# `t`

```elixir
@type t() :: %Toddy.Iced.Border{
  color: Toddy.Iced.Color.t() | nil,
  radius: number() | radius_map(),
  width: number()
}
```

Border specification with color, width, and radius.

# `color`

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

Sets the border color. Accepts a hex string or named color atom.

# `encode`

```elixir
@spec encode(border :: t()) :: map()
```

Encodes a border to the wire format. Per-corner radius maps are converted to string keys.

# `new`

```elixir
@spec new() :: t()
```

Creates a new border with default values (no color, zero width, zero radius).

# `radius`

```elixir
@spec radius(
  top_left :: number(),
  top_right :: number(),
  bottom_right :: number(),
  bottom_left :: number()
) :: radius_map()
```

Creates a per-corner radius map.

# `rounded`

```elixir
@spec rounded(border :: t(), radius :: number()) :: t()
```

Sets a uniform corner radius in pixels.

# `width`

```elixir
@spec width(border :: t(), width :: number()) :: t()
```

Sets the border width in pixels.

---

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