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

Canvas rectangle element with position, size, and optional styling.

# `option`

```elixir
@type option() ::
  ((((((({:x, number()} | {:y, number()}) | {:w, number()}) | {:h, number()})
      | {:fill, term()})
     | {:stroke,
        %Plushie.Canvas.Stroke{
          cap: term(),
          color: term(),
          dash: term(),
          join: term(),
          width: term()
        }
        | keyword()
        | map()})
    | {:opacity, number()})
   | {:fill_rule, String.t() | atom()})
  | {:radius, term()}
```

# `t`

```elixir
@type t() :: %Plushie.Canvas.Rect{
  fill:
    term()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  fill_rule:
    (String.t() | atom())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  h:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  id: String.t() | nil,
  opacity:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  radius:
    term()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  stroke:
    %Plushie.Canvas.Stroke{
      cap: term(),
      color: term(),
      dash: term(),
      join: term(),
      width: term()
    }
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  w:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  x:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  y:
    number()
    | 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.

# `fill`

```elixir
@spec fill(widget :: t(), value :: term() | nil) :: t()
```

Fill color or gradient.

Accepts `term()`.

# `fill_rule`

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

Fill rule: "non_zero" or "even_odd".

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

# `h`

```elixir
@spec h(widget :: t(), value :: number() | nil) :: t()
```

Height in pixels.

Accepts `number()`.

# `new`

# `new`

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

# `new`

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

# `opacity`

```elixir
@spec opacity(widget :: t(), value :: number() | nil) :: t()
```

Opacity from 0.0 (transparent) to 1.0 (opaque).

Accepts `number()`.

# `radius`

```elixir
@spec radius(widget :: t(), value :: term() | nil) :: t()
```

Corner radius. Uniform number or per-corner map.

Accepts `term()`.

# `stroke`

```elixir
@spec stroke(
  widget :: t(),
  value ::
    (%Plushie.Canvas.Stroke{
       cap: term(),
       color: term(),
       dash: term(),
       join: term(),
       width: term()
     }
     | keyword()
     | map())
    | nil
) :: t()
```

Stroke descriptor (color, width, cap, join).

Accepts `%Plushie.Canvas.Stroke{}`.

# `type_name`

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

Returns the element type string for the wire protocol.

# `w`

```elixir
@spec w(widget :: t(), value :: number() | nil) :: t()
```

Width in pixels.

Accepts `number()`.

# `with_options`

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

Applies keyword options to an existing widget struct.

# `x`

```elixir
@spec x(widget :: t(), value :: number() | nil) :: t()
```

X position in pixels.

Accepts `number()`.

# `y`

```elixir
@spec y(widget :: t(), value :: number() | nil) :: t()
```

Y position in pixels.

Accepts `number()`.

---

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