# `Plushie.Type.Padding`
[🔗](https://github.com/plushie-ui/plushie-elixir/blob/v0.7.2/lib/plushie/type/padding.ex#L1)

Padding specification with per-side values.

Maps to iced's `Padding` struct. Accepts a uniform number,
a `{vertical, horizontal}` tuple, an explicit four-side map,
or a `%Padding{}` struct with per-side overrides.

`cast/1` always normalises to the full four-side map.

## Struct form

The struct supports per-side padding via keyword construction:

    Padding.from_opts(top: 4, bottom: 8)

`nil` fields are stripped during encoding.

# `t`

```elixir
@type t() ::
  number()
  | {number(), number()}
  | %Plushie.Type.Padding{
      bottom: number() | nil,
      left: number() | nil,
      right: number() | nil,
      top: number() | nil
    }
```

# `cast`

```elixir
@spec cast(padding :: t()) :: {:ok, map()} | :error
```

Validates a padding value, returning it in its canonical stored form.

Numbers and tuples are validated and returned as-is (expansion to the
four-side map happens during encoding). Structs and maps are validated
and returned as four-side maps.

## Examples

    iex> Plushie.Type.Padding.cast(8)
    {:ok, 8}

    iex> Plushie.Type.Padding.cast({4, 12})
    {:ok, {4, 12}}

    iex> Plushie.Type.Padding.cast(%{top: 1, right: 2, bottom: 3, left: 4})
    {:ok, %{top: 1, right: 2, bottom: 3, left: 4}}

# `from_opts`

```elixir
@spec from_opts(Keyword.t()) :: %Plushie.Type.Padding{
  bottom: term(),
  left: term(),
  right: term(),
  top: term()
}
```

Constructs padding from a keyword list.

Raises `ArgumentError` if any key is not a valid padding field.

---

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