Skip to main content
In a Layout, the parent decides how its children are arranged, and each child decides its own size. This page covers the settings you set on a child: its width and height, size limits, margin, and whether it’s positioned relative to its siblings or pinned to its parent’s edges. These settings apply to anything that participates in a Layout: other Layouts, and shapes, text, and images set to Layout in the Inspector. Component instances in Layout mode use the same width and height options. See Component Sizing. For settings that control how a parent arranges its children, such as direction, padding, and gap, see Arranging Children.

Width and height

A child’s width and height each use one of three scale types: Fixed, Hug, or Fill. You can set width and height independently. For example, a button can hug its label horizontally while keeping a fixed height. Select the scale type below the width and height fields in the Inspector. Layout inspector with the width and height scale type dropdowns (Hug and Fixed) highlighted

Fixed

A Fixed width or height stays the same size regardless of the parent or the child’s content. Enter a value in points, or use the unit toggle in the field to switch to a percentage of the parent’s size. Percentages are useful when a child should scale with its parent but you don’t want it to take up all the available space, such as a panel that’s always 50% of the screen width.

Hug

A Hug width or height shrinks or grows to fit the child’s own content. Use Hug when the content should determine the size, such as a button that grows with its label or a list that gets taller as items are added. To Hug, a Layout needs content it can measure: child Layouts, text, or parametric shapes (rectangles, ellipses, triangles, polygons, and stars). If the Layout has nothing it can measure, the Hug option isn’t available. A Layout that hugs child Layouts always grows to fit them. Text and other content that Rive measures works differently: by default, a Hug child sized by that content stops growing at the edge of its parent, even if the content is larger. To let it grow to its full content size, select Hug past bounds. For example, a long block of text in a scroll region needs this option so it can grow taller than the visible area. This option appears when the width or height uses Hug. Min and max size constraints still apply. This tutorial uses Hug to build a button that resizes with its label:
An artboard can only Hug if it contains a relative Layout or a component instance in Layout mode.

Fill

A Fill width or height expands to take up the space available in the parent. Fill is only available on relative children inside a Layout. Absolute children can’t use Fill. How Fill behaves depends on whether the axis runs in the same direction as the parent’s arrangement:
  • Along the parent’s direction: In a Row parent, this is width. In a Column parent, it’s height. The child shares the leftover space with its siblings that also use Fill. The amount is measured in fr (fill ratio) units.
  • Across the parent’s direction: In a Row parent, this is height. In a Column parent, it’s width. The child stretches to the parent’s full size, minus padding.
Fill ratios decide how siblings split the leftover space. Three children set to 1fr each get an equal share of the leftover space. A child set to 2fr gets twice the space of a child set to 1fr. When a child uses Fill along its parent’s direction, the Inspector also shows a Base size field. The base size is the child’s starting size before the leftover space is shared out. Set it in points or as a percentage, or leave it on auto to start from the size of the child’s content.
With the base size on auto, siblings with the same fill ratio aren’t always the same size. Each child starts from the size of its content, and only the leftover space is shared equally. For example, if three 1fr children contain child Layouts of different sizes, the child with the largest content ends up the largest. To make them exactly the same size, set the Base size of each child to 0.

Aspect ratio

Use Ratio in the Inspector to lock a Layout’s width and height to an aspect ratio. Enter a ratio as 16:9, 16/9, or a decimal such as 1.78. The W/H button at the end of the field picks the axis you size yourself. That axis keeps its scale type and value. The other axis is calculated from the ratio, and its controls become read-only. For example, lock W on a Fill-width card with a 16:9 ratio, and its height follows as the card gets wider. If you pick an axis before entering a ratio, the ratio is taken from the Layout’s current size.

Size constraints

Size constraints set a minimum or maximum width or height. They’re most useful with Hug and Fill, when you want a child to respond to its content or parent but only up to a point. For example, a text field can fill its row but stop growing at 400 points wide. Click the icon above the absolute/relative toggle, then select Min width, Max width, Min height, or Max height. Like width and height, constraints can be set in points or percentages. Size constraints menu open in the Layout inspector, listing Min width, Max width, Min height, Max height, and Clear constraints

Margin

Margin adds space outside a child, between it and its parent’s edges or its siblings. Use the edge toggle to set margin on each side separately, and use the unit toggle to switch between points and percentages. Margin is set on the child, unlike padding and gap, which are set on the parent. To add the same space between all of a parent’s children, use the parent’s gap instead of giving each child a margin. Margins on neighboring siblings add together, so two children with a 10-point margin are 20 points apart. See Padding, gap, and margin.

Relative and absolute positioning

A child is positioned in one of two ways:
  • Relative: The parent places the child based on its direction, alignment, and gap. Relative children reflow when the parent resizes or when siblings are added or removed.
  • Absolute: The child ignores the parent’s arrangement and pins itself to the parent’s edges. Absolute children don’t take up space, so their siblings are arranged as if they weren’t there.
Use absolute positioning for things that should stay in place while other content reflows, such as a close button in the corner of a dialog or a badge on a card. Use the toggle at the top-right of the Layout section in the Inspector to switch between relative and absolute. The section’s heading shows the current mode: Position: Constrained by Parent for a relative child, or Position: Absolute for an absolute one. Layout inspector with the absolute/relative toggle highlighted in the top-right corner

Pinning to edges

An absolute child is pinned to at least two edges of its parent: one horizontal and one vertical. The distance from each pinned edge stays the same when the parent resizes. To choose which edges to pin, select the markers in the position widget in the Inspector, or use the fields below it. Hold Shift while selecting a marker to pin a second edge on the same axis, such as both left and right. Distances can be set in points or as a percentage of the parent’s size. You can also choose the pinned edges from the horizontal and vertical constraint dropdowns below the position widget:
  • Left, Right, Top, or Bottom: The child keeps its distance from that edge.
  • Left + Right or Top + Bottom: The child keeps its distance from both edges, so its width or height stretches with the parent.
  • Scale: The child keeps both distances as percentages of the parent, so its position and size scale with the parent.
Absolute Layout with all four edges pinned at 80 px, showing the position widget and Left + Right / Top + Bottom fields in the inspector

Hiding a Layout

Click the eye button in the Layout section header to hide a Layout and take it out of its parent’s arrangement. A hidden Layout takes up no space, so its siblings reflow to fill the gap. Click it again to show the Layout. This is different from lowering opacity, which leaves the Layout in place and still taking up space. You can key the button in animate mode or bind it, for example to collapse a row when there’s nothing to show.

Computed transform

Layouts and constraints can move and resize an object, so its Transform values don’t always match where it ends up. Expand the Computed Transform section in the Inspector to see the final world, artboard, and local position, and the final size of Layouts, text, and images. See Computed Transform for each value. The values are read-only, but you can bind them with Target to Source to write them into a view model. For example, bind a Layout’s computed width to a number property to read its size after layout in your app or in other bindings.