Skip to main content

Choosing an Artboard

When a Rive object is instantiated or when a Rive file is rendered, you can specify the artboard to use. If no artboard is given, the default artboard, as set in the Rive editor, is used. If no default artboard is set, the first artboard is used. Only one artboard can be rendered at a time.
By default, the Rive composable will select and create the default artboard specified in the Rive editor. To specify a different artboard, you must first create an Artboard object from a loaded RiveFile.

Compose

Artboard objects can be created in Compose using the rememberArtboard function, which takes a Rive file and name of the artboard.
val artboard = rememberArtboard(myRiveFile, "My Artboard")

Outside of Compose

Alternatively, you can create an artboard outside of Compose contexts. Note that with this approach you are responsible for managing the artboard’s lifecycle and must eventually close it with Artboard::close() when no longer needed, or leveraging its AutoClosable interface with a use block.
val artboard = Artboard.fromFile(myRiveFile, "My Artboard")
...
artboard.close()

Using the Artboard

Once you have an artboard, you can pass it to the Rive composable via the artboard parameter.
setContent {
    Rive(
        myRiveFile,
        artboard = artboard
    )
}