> ## Documentation Index
> Fetch the complete documentation index at: https://rive.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Layout

A scripted Layout which can function just like a [Node](/scripting/api-reference/interfaces/node) but
also has the ability to fit into a layout box provided via
resize. It can also be intrinsically sized allowing hosting
layouts to attempt to fit to its size by using the measure
function to report desired dimensions.

For more information, see [Layout Scripts](/scripting/protocols/layout-scripts).

## Methods

### `measure`

<div class="signature">
  ```lua theme={null}
  measure(self: T) -> Vector
  ```
</div>

When provided this Layout can be intrinsically sized/request
to be a specific size. This is not guaranteed as the layout
may have min/max dimensions. Resize will be called with the
granted size after being measured.

```lua theme={null}
-- Measure the computed size of the layout on resize
function measure(self: MyLayout): Vector
  return Vector.xy(100, 100)
end
```

### `resize`

<div class="signature">
  ```lua theme={null}
  resize(self: T, size: Vector) -> ()
  ```
</div>

Guaranteed to be called to set initial size and also called
whenever the size changes.

```lua theme={null}
-- Called when the layout resizes based on the content
-- This only applies to Layouts with a fit type of Hug
function resize(self: MyLayout, size: Vector)
  print('Resize:', size)
end
```
