Layout
Controlling the layout of your Rive animation
This article is out of date! Find the new version here.
Rive provides a number of ways to control how your animations are laid out in the canvas or view used to display them. Rive lets you control the fit, alignment, and offset of rendered content.
The Layout
object
Layout
objectMost runtimes have a Layout
object that enables you to configure Fit
and Alignment
. You typically provide layout data when instantiating a Rive object, but you can also update these values at any time.
See values and descriptions in the sections below for Fit
and Alignment
.
The runtime has named exports for Layout
, Fit
, and Alignment
.
Fit
Fit determines how the Rive content will be fitted to the view. There are a number of options available:
Cover
: Rive will cover the view, preserving the aspect ratio. If the Rive content has a different ratio to the view, then the Rive content will be clipped.Contain
: (Default) Rive content will be contained within the view, preserving the aspect ratio. If the ratios differ, then a portion of the view will be unused.Fill
: Rive content will fill the available view. If the aspect ratios differ, then the Rive content will be stretched.FitWidth
: Rive content will fill to the width of the view. This may result in clipping or unfilled view space.FitHeight
: Rive content will fill to the height of the view. This may result in clipping or unfilled view space.None
: Rive content will render to the size of its artboard, which may result in clipping or unfilled view space.ScaleDown
: Rive content is scaled down to the size of the view, preserving the aspect ratio. This is equivalent toContain
when the content is larger than the canvas. If the canvas is larger, thenScaleDown
will not scale up.
Alignment
Alignment determines how the content aligns with respect to the view bounds. The following options are available:
Center
(Default)TopLeft
TopCenter
TopRight
CenterLeft
CenterRight
BottomLeft
BottomCenter
BottomRight
Bounds
The bounds for the area in which the Rive content will render can be set by providing the minimum and maximum x and y coordinates. These coordinates are relative to the view in which the Rive content is contained, and all must be provided. These will override alignment settings.
minX
minY
maxX
maxY
Last updated