Skip to content

Rive#

Render Rive animations in your Flet app with the flet-rive extension.

Platform Support#

Platform Windows macOS Linux iOS Android Web
Supported

Usage#

Add flet-rive to your project dependencies:

uv add flet-rive
pip install flet-rive  # (1)!
  1. After this, you will have to manually add this package to your requirements.txt or pyproject.toml.

Hosting Rive files

Host .riv files locally or load them from a CDN. Use placeholder to keep layouts responsive while animations load.

Example#

import flet_rive as ftr

import flet as ft


def main(page: ft.Page):
    page.add(
        ftr.Rive(
            src="https://cdn.rive.app/animations/vehicles.riv",
            placeholder=ft.ProgressBar(),
            width=300,
            height=200,
        ),
        ftr.Rive(
            src="vehicles.riv",
            placeholder=ft.ProgressBar(),
            width=300,
            height=200,
        ),
    )


ft.run(main)

Description#

Inherits: LayoutControl

Displays rive animations.

Properties

Properties#

alignment #

alignment: Alignment | None = None

Alignment for the animation in the Rive control.

animations #

animations: list[str] = field(default_factory=list)

List of animations to play; default animation is played if empty.

artboard #

artboard: str | None = None

The name of the artboard to use. If not specified, the default artboard of the provided src is used.

clip_rect #

clip_rect: Rect | None = None

Clip the artboard to this rect.

If not supplied it'll default to the constraint size provided by the parent control. Unless the Artboard has clipping disabled, then no clip will be applied.

enable_antialiasing #

enable_antialiasing: bool = True

Whether to enable anti-aliasing when rendering.

fit #

fit: BoxFit | None = None

The animation's fit.

headers #

headers: dict[str, str] | None = None

Headers for network requests.

placeholder #

placeholder: Control | None = None

Control displayed while the Rive is loading.

speed_multiplier #

speed_multiplier: Number = 1.0

A multiplier for controlling the speed of the Rive animation playback.

src #

src: str

The source of your rive animation.

Can either be a URL or a path to a local asset file.

state_machines #

state_machines: list[str] = field(default_factory=list)

List of state machines to play; none will play if empty.

use_artboard_size #

use_artboard_size: bool = False

Determines whether to use the inherent size of the artboard, i.e. the absolute size defined by the artboard, or size the control based on the available constraints only (sized by parent).