Rive
Render Rive animations in your Flet app with the flet-rive extension.
Platform Support
| Platform | Windows | macOS | Linux | iOS | Android | Web |
|---|---|---|---|---|---|---|
| Supported | ✅ | ✅ | ✅ (x64 only) | ✅ | ✅ | ✅ |
Usage
Add flet-rive to your project dependencies:
- uv
- pip
uv add flet-rive
pip install flet-rive
Host .riv files locally or load them from a CDN. Use placeholder to keep layouts responsive while animations load.
Example
import flet as ft
import flet_rive as ftr
def main(page: ft.Page):
page.add(
ft.SafeArea(
content=ft.Column(
controls=[
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,
),
],
)
)
)
if __name__ == "__main__":
ft.run(main)
Description
Displays rive animations.
Inherits: LayoutControl
Properties
alignment- Alignment for the animation in the Rive control.animations- List of animations to play; default animation is played if empty.artboard- The name of the artboard to use.clip_rect- Clip the artboard to this rect.enable_antialiasing- Whether to enable anti-aliasing when rendering.fit- The animation's fit.headers- Headers for network requests.placeholder- Control displayed while the Rive is loading.speed_multiplier- A multiplier for controlling the speed of the Rive animation playback.src- The source of your rive animation.state_machines- List of state machines to play; none will play if empty.use_artboard_size- Determines whether to use the inherent size of the artboard, i.e.
Properties
animationsclass-attributeinstance-attribute
animations: list[str] = field(default_factory=list)List of animations to play; default animation is played if empty.
artboardclass-attributeinstance-attribute
artboard: Optional[str] = NoneThe name of the artboard to use.
If not specified, the default artboard of the provided src is used.
clip_rectclass-attributeinstance-attribute
clip_rect: Optional[Rect] = NoneClip 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_antialiasingclass-attributeinstance-attribute
enable_antialiasing: bool = TrueWhether to enable anti-aliasing when rendering.
headersclass-attributeinstance-attribute
headers: Optional[dict[str, str]] = NoneHeaders for network requests.
speed_multiplierclass-attributeinstance-attribute
speed_multiplier: Number = 1.0A multiplier for controlling the speed of the Rive animation playback.
srcinstance-attribute
src: strThe source of your rive animation.
Can either be a URL or a path to a local asset file.
state_machinesclass-attributeinstance-attribute
state_machines: list[str] = field(default_factory=list)List of state machines to play; none will play if empty.
use_artboard_sizeclass-attributeinstance-attribute
use_artboard_size: bool = FalseDetermines 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).