# `Plushie.Canvas.Layer`
[🔗](https://github.com/plushie-ui/plushie-elixir/blob/v0.7.2/lib/plushie/canvas/layer.ex#L1)

Canvas layer: a named container that groups shapes for independent
caching on the renderer side.

Each layer maps to an iced `Cache` on the Rust side; only changed
layers are re-tessellated. The `name` prop identifies the layer
for cache invalidation.

On the wire this encodes as `type: "__layer__"` to match what the
renderer expects.

## Example

    Layer.new("bg")
    |> Layer.push(rect(0, 0, 800, 600, fill: "#f0f0f0"))
    |> Layer.push(rect(10, 10, 50, 200, fill: "#3498db"))

# `option`

```elixir
@type option() :: {:name, String.t() | atom()}
```

# `t`

```elixir
@type t() :: %Plushie.Canvas.Layer{
  children: [Plushie.Widget.ui_node()],
  id: String.t() | nil,
  name:
    (String.t() | atom())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil
}
```

# `build`

```elixir
@spec build(widget :: t()) :: Plushie.Widget.ui_node()
```

Converts this widget struct to a `ui_node()` map.

# `extend`

```elixir
@spec extend(widget :: t(), children :: [Plushie.Widget.child()]) :: t()
```

Appends multiple children to the widget.

# `name`

```elixir
@spec name(widget :: t(), value :: (String.t() | atom()) | nil) :: t()
```

Layer name for renderer cache keying.

Accepts `String.t() | atom()`.

# `new`

```elixir
@spec new(opts :: [option()]) :: t()
```

Creates a new element without an explicit ID (auto-assigned by parent container).

# `new`

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

Creates a new element with the given ID and keyword options.

# `push`

```elixir
@spec push(widget :: t(), child :: Plushie.Widget.child()) :: t()
```

Appends a child to the widget.

# `type_name`

```elixir
@spec type_name() :: String.t()
```

Returns the element type string for the wire protocol.

# `with_options`

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

Applies keyword options to an existing widget struct.

---

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