> ## 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.

# Parameters

> Layout parameters can broadly be grouped into one of two categories — those that affect the parent layout, and those that affect the child layouts.

export const UseCase = ({title, children}) => {
  return <aside class="callout my-4 px-5 py-4 overflow-hidden rounded-2xl flex gap-3 border border-neutral-200 bg-neutral-50 dark:border-neutral-700 dark:bg-white/10" data-callout-type="info">
      <div class="mt-0.5 w-4" data-component-part="callout-icon">
        <svg width="11" height="14" viewBox="0 0 11 14" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="text-neutral-800 dark:text-neutral-300 w-3.5 h-auto" aria-label="Tip"><path d="M3.12794 12.4232C3.12794 12.5954 3.1776 12.7634 3.27244 12.907L3.74114 13.6095C3.88471 13.8248 4.21067 14 4.46964 14H6.15606C6.41415 14 6.74017 13.825 6.88373 13.6095L7.3508 12.9073C7.43114 12.7859 7.49705 12.569 7.49705 12.4232L7.50055 11.3513H3.12521L3.12794 12.4232ZM5.31288 0C2.52414 0.00875889 0.5 2.26889 0.5 4.78826C0.5 6.00188 0.949566 7.10829 1.69119 7.95492C2.14321 8.47011 2.84901 9.54727 3.11919 10.4557C3.12005 10.4625 3.12175 10.4698 3.12261 10.4771H7.50342C7.50427 10.4698 7.50598 10.463 7.50684 10.4557C7.77688 9.54727 8.48281 8.47011 8.93484 7.95492C9.67728 7.13181 10.1258 6.02703 10.1258 4.78826C10.1258 2.15486 7.9709 0.000106649 5.31288 0ZM7.94902 7.11267C7.52078 7.60079 6.99082 8.37878 6.6077 9.18794H4.02051C3.63739 8.37878 3.10743 7.60079 2.67947 7.11294C2.11997 6.47551 1.8126 5.63599 1.8126 4.78826C1.8126 3.09829 3.12794 1.31944 5.28827 1.3126C7.2435 1.3126 8.81315 2.88226 8.81315 4.78826C8.81315 5.63599 8.50688 6.47551 7.94902 7.11267ZM4.87534 2.18767C3.66939 2.18767 2.68767 3.16939 2.68767 4.37534C2.68767 4.61719 2.88336 4.81288 3.12521 4.81288C3.36705 4.81288 3.56274 4.61599 3.56274 4.37534C3.56274 3.6515 4.1515 3.06274 4.87534 3.06274C5.11719 3.06274 5.31288 2.86727 5.31288 2.62548C5.31288 2.38369 5.11599 2.18767 4.87534 2.18767Z"></path></svg>
      </div>
      <div class="text-sm prose dark:prose-invert min-w-0 w-full [&_kbd]:bg-background-light dark:[&_kbd]:bg-background-dark [&_code]:!text-current [&_kbd]:!text-current [&_a]:!text-current [&_a]:border-current [&_strong]:!text-current text-neutral-800 dark:text-neutral-300" data-component-part="callout-content">
        <strong>Example{title && ` - ${title}`}</strong>

        {children}
      </div>
    </aside>;
};

export const YouTube = ({id, timestamp}) => {
  const videoSrc = timestamp ? `https://www.youtube.com/embed/${id}?start=${timestamp}` : `https://www.youtube.com/embed/${id}`;
  return <iframe width="100%" height="400" src={videoSrc} title="YouTube video player" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerPolicy="strict-origin-when-cross-origin" allowFullScreen />;
};

<Tip>In Rive, it's important to remember that layout parameters generally only affect other layout containers. This can often result in the nesting of layouts for desired results, but unlocks opportunities to blend with Rive's more freeform canvas in creative ways.</Tip>

***

## Absolute vs relative

To control the flow of child Layouts in a Row, Column, Grid, or Stack requires the Layout children to be Relative, i.e. not have their Absolute position option enabled. Use the icon in the top right of the Layout inspector to toggle between an Absolute and Relative Layout.

<img src="https://mintcdn.com/rive/KnNrDuhU1mIj7cOb/images/editor/layouts/3412f52f-c283-4617-b6c5-f5af8ad1ddcc.webp?fit=max&auto=format&n=KnNrDuhU1mIj7cOb&q=85&s=46c53838c7a95341935f1a5e2402bde9" alt="Image" width="1280" height="720" data-path="images/editor/layouts/3412f52f-c283-4617-b6c5-f5af8ad1ddcc.webp" />

* **Absolute:** An Absolute Layout positions itself within an artboard or parent Layout container. It can have 2 or more of it’s edges pinned to the container.
* **Relative:** A Relative Layout has it’s position defined by the parent artboard or Layout. Changing the flex properties on the parent will determine the child layout behaviour.

## Scale types

A layout’s width and height can make use of 3 different scale behaviours:

* **Fixed:** A fixed width or height for the Layout. The defined value can be either a point or percentage value. Use the unit toggle within the fields to toggle between value types.
* **Hug:** The width and/or height of the Layout shrinks to fit its children. For example, you may want a Layout to hug a text object; resizing itself based on the length of the text inside.
* **Fill:** The width and/or height of the Layout expands to fill the available space within the parent Layout or artboard. The fill option switches the width/height fields to be represented in `fr` (fill ratio) units and reveals a base size field. The fill ratio values make it possible to control the fill behaviour between a number of children with the fill scale behaviour. For example, you may want the children to fill the available space equally, or perhaps have one child scale at a greater factor than the rest.

Options to set the scale type are below the width and height fields in the inspector.

<img src="https://mintcdn.com/rive/KnNrDuhU1mIj7cOb/images/editor/layouts/083d008d-6a87-4988-bd2f-5d14ce367217.webp?fit=max&auto=format&n=KnNrDuhU1mIj7cOb&q=85&s=758aaafaa380a28ed8f0bc394cd90da5" alt="Image" width="1280" height="720" data-path="images/editor/layouts/083d008d-6a87-4988-bd2f-5d14ce367217.webp" />

<Info>Hug and Fill options will only surface when applicable. For example, a Layout without any children won’t surface the option to hug, while only a Layout with another Layout as its parent can be set to Fill.</Info>

<YouTube id="eOGfPV7zBbQ" />

## Size constraints

Use the icon above the absolute toggle to add minimum and/or maximum width and height values. As with the width and height values themselves, these can be defined as either points or percentages.

<img src="https://mintcdn.com/rive/KnNrDuhU1mIj7cOb/images/editor/layouts/d6898bfa-62bf-4d4c-9769-5c68d439e03a.webp?fit=max&auto=format&n=KnNrDuhU1mIj7cOb&q=85&s=a7edd9b0513662f15a0b455c2ee681cc" alt="Image" width="1280" height="720" data-path="images/editor/layouts/d6898bfa-62bf-4d4c-9769-5c68d439e03a.webp" />

## Clip

The clip toggle hides any child elements within the layout that extend beyond the bounds of the Layout.

<img src="https://mintcdn.com/rive/KnNrDuhU1mIj7cOb/images/editor/layouts/80299f91-7525-42cc-ba64-20ca7ea7e5ad.webp?fit=max&auto=format&n=KnNrDuhU1mIj7cOb&q=85&s=6d18306f482d545a84ca0167911acd75" alt="Image" width="1280" height="720" data-path="images/editor/layouts/80299f91-7525-42cc-ba64-20ca7ea7e5ad.webp" />

## Position (absolute Layouts only)

Absolute Layouts provide additional options to set their position within the artboard or parent Layout. The position is defined by at least 2 pinned edges — one horizontal and one vertical, however additional edges can also be enabled.

Set the desired edges to pin by selecting the markers within the inspector graphic, or via the fields below. You can hold `shift` while selecting a marker to add a second edge along the same axis. The distance values from a chosen edge can be provided as points or percentages by selecting the chosen unit type within the field.

<img src="https://mintcdn.com/rive/KnNrDuhU1mIj7cOb/images/editor/layouts/987f6999-4db4-487e-a8f0-c8760b037012.webp?fit=max&auto=format&n=KnNrDuhU1mIj7cOb&q=85&s=05699bb4608fa7633f4f7d79a7360c7c" alt="Image" width="2560" height="1440" data-path="images/editor/layouts/987f6999-4db4-487e-a8f0-c8760b037012.webp" />

## Padding and margin

<Info>Padding ONLY affects Layout children. For example if you want to have a button with a label, the text should be wrapped in a Layout and that Layout should be the child of another Layout that applies the padding.</Info>

<Info>Margin affects the Layout to which the margin is applied relative to its parent Layout.</Info>

Padding and margin can be applied symmetrically along an axis, or to individual edges. Use the edge toggle to reveal fields for each edge plus options to use point or percent values.

* **Padding:** Inner space between the Layout bounds and any relative Layout children.
* **Margin:** Outer space between the Layout bounds and a relative parent Layout.

<video width="640" controls>
  <source src="https://ucarecdn.com/a489bd85-d55b-424b-8f7a-1a1a7aab37f6/" type="video/mp4" />

  Padding and Margin
</video>

## Layout children

<Note>A layout’s flex parameters are only applied to its Layout children. Shapes, text, and images can become Layout children directly by selecting **Layout** instead of **Node** at the top of the **Inspector**. Other content, such as groups and paths, must be wrapped in an additional layout container to generate rows, columns, and grids of content that reflow.</Note>

## Layout type

The layout type determines how a Layout arranges its relative Layout children.

* **Row:** Lay out children along the horizontal axis.
* **Column:** Layout children along the vertical axis.
* **Row Reverse:** Lay out children horizontally, in reverse order.
* **Column Reverse:** Lay out children vertically, in reverse order.
* **Grid:** Lay out children in cells defined by columns and rows. See [Grid](#grid).
* **Stack:** Place all children in the same space, layered on top of each other. See [Stack](#stack).

<img src="https://mintcdn.com/rive/KnNrDuhU1mIj7cOb/images/editor/layouts/c64d65de-0d9e-4325-a1b3-ef7d3310c842.webp?fit=max&auto=format&n=KnNrDuhU1mIj7cOb&q=85&s=588d8d77ddaef5e6dd2d82f8937cc4cf" alt="Image" width="1280" height="720" data-path="images/editor/layouts/c64d65de-0d9e-4325-a1b3-ef7d3310c842.webp" />

<YouTube id="54fj9_zUemc" />

## Grid

A Grid Layout arranges its children into columns and rows. When you set a Layout to Grid, it starts with one column and one row. Increase the number of columns and rows to build out the grid. While the Layout is selected, the stage shows guides for each cell and shading for the gaps between them.

Children are placed into the grid in hierarchy order, filling each row from left to right before moving to the next row.

### Columns and rows

Each column and row (or *track*) has its own size, using the same [scale types](#scale-types) as Layouts:

* **Fill:** The track expands to fill the available space, measured in `fr` (fill ratio) units. For example, three columns set to `1fr` share the width equally, while a `2fr` column takes twice the space of a `1fr` column.
* **Fixed:** The track has a fixed width or height.
* **Hug:** The track shrinks to fit the content inside it.

Drag tracks to reorder them. To edit several tracks at once, hold <kbd>Shift</kbd> and click their track numbers.

Use [Gap](#gap) to add space between columns and rows.

### Grid cell

Children of a Grid Layout show **Grid Cell** options in the inspector:

* **Position:** The column and row the child is placed in. By default, children are placed automatically in the next available cell.
* **Span:** The number of columns and/or rows the child occupies.

When a child spans multiple cells, the children after it are pushed to the next available cells. If there are more children than cells, Rive adds rows to fit them. To control how these extra rows are sized, add them to the grid explicitly and set their scale type.

<Tip>To make a child fill its cell, set its width and height to **Fill**. A component instance in **Layout** mode set to Fill will fill its cell, but to use Grid Cell options such as span, wrap the instance in a Layout and give that Layout a Fill width and height.</Tip>

<Info>The number of columns and rows in a grid can't be animated. Track sizes, gaps, and Grid Cell spans and positions can be keyed, which lets you animate children reflowing within the grid.</Info>

## Stack

A Stack Layout places all of its children in the same space, layered on top of each other. Children are drawn in hierarchy order: the topmost child in the hierarchy is drawn in front, and the bottommost is drawn at the back.

Use [Alignment](#alignment) to position the children within the Stack. Children set to **Fill** expand to cover the whole Stack, while Fixed or Hug children are positioned by the alignment.

Stacks are useful for components made of layered parts.

<UseCase title="Inventory item card">
  An item card is a Stack with four layers: a badge, the item info, the item art, and a background. Each layer is a Layout set to Fill, so they all cover the card. Each layer uses its own padding and alignment to place its content: the badge sits in the top-left corner, and the item name and category are aligned to the bottom. An inventory screen then places these cards in a Grid, with one card spanning two columns.
</UseCase>

## Wrap

Wrap applies to Row and Column Layouts.

* **No Wrap:** When the content reaches the bounds of the layout, continue to extend beyond it.
* **Wrap:** When the content reached the bounds of the layout, place the next item on below or alongside the currently row/column.
* **Wrap Reverse:** Same as wrap, but display the content in reverse order.

<img src="https://mintcdn.com/rive/KnNrDuhU1mIj7cOb/images/editor/layouts/87c797aa-bce4-4e39-b649-63bd382ffb69.webp?fit=max&auto=format&n=KnNrDuhU1mIj7cOb&q=85&s=45a36bca53177a65eea0a11c193f295b" alt="Image" width="1280" height="720" data-path="images/editor/layouts/87c797aa-bce4-4e39-b649-63bd382ffb69.webp" />

## Alignment

Select the desired point on the inspector widget to align content within a layout container.

<img src="https://mintcdn.com/rive/KnNrDuhU1mIj7cOb/images/editor/layouts/3018db3d-fb86-4a24-9d67-8c16ac6270bd.webp?fit=max&auto=format&n=KnNrDuhU1mIj7cOb&q=85&s=0b24813365f5fb54f9e72dd6f6146fe2" alt="Image" width="1280" height="720" data-path="images/editor/layouts/3018db3d-fb86-4a24-9d67-8c16ac6270bd.webp" />

## Justify

Click on the current alignment position to expand the content to fill the available space. Selecting the one of the active tiles again collapses the content back down.

![Image](https://ucarecdn.com/d79e6712-f751-4526-951a-0408f9fca6c0/)

## Gap

Spacing between content (gaps) can be set both horizontally and vertically, and as either points or percentages of the container width/height.

<img src="https://mintcdn.com/rive/KnNrDuhU1mIj7cOb/images/editor/layouts/84dba879-e23b-4144-963a-3d4e5f50a144.webp?fit=max&auto=format&n=KnNrDuhU1mIj7cOb&q=85&s=a2aed1aef04eb4df06df07aaec67babe" alt="Image" width="1280" height="720" data-path="images/editor/layouts/84dba879-e23b-4144-963a-3d4e5f50a144.webp" />

## Left-to-right/right-to-left

<YouTube id="oLjFOu-UFxM" />

Determines the horizontal direction for this Layout and will also be cascaded down to its child Layouts (when its child Layouts are set to Inherit). This will change the direction of Row based Layouts as well as Text alignment within any Layouts. This is useful when there is a requirement to support Right-to-Left languages.

## Styles

Layouts can have fills, strokes, feathers, blend modes, and corner radii, just like other objects in Rive.

Styles can be rendered in the **background**, behind the Layout's children, or in the **foreground**, in front of them. For example, you might place a fill and feathered shadow behind the children while rendering a stroke in front.

Corner radius applies to the Layout's styles as well as its clipping bounds.
