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:
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
-
alignment
(Alignment | None
) –Alignment for the animation in the Rive control.
-
animations
(list[str]
) –List of animations to play; default animation is played if empty.
-
artboard
(str | None
) –The name of the artboard to use.
-
clip_rect
(Rect | None
) –Clip the artboard to this rect.
-
enable_antialiasing
(bool
) –Whether to enable anti-aliasing when rendering.
-
fit
(BoxFit | None
) –The animation's fit.
-
headers
(dict[str, str] | None
) –Headers for network requests.
-
placeholder
(Control | None
) –Control displayed while the Rive is loading.
-
speed_multiplier
(Number
) –A multiplier for controlling the speed of the Rive animation playback.
-
src
(str
) –The source of your rive animation.
-
state_machines
(list[str]
) –List of state machines to play; none will play if empty.
-
use_artboard_size
(bool
) –Determines whether to use the inherent size of the artboard,
Properties#
animations
#
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.
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
#
List of state machines to play; none will play if empty.