Skip to content

Animation

Every widget has animate() and transition(). animate plays one of 47 presets or a pz.Animation when the widget appears, on hover, press, focus, click or while active; transition animates property changes like CSS. pz.stagger cascades a list in and pz.presence animates content in and out when it changes. Everything runs natively, without calling Python per frame. See the Animation guide.

pz.Animation · Category: Content · Full reference →

AnimationAnimation
  • To show that something appeared, changed or needs attention: a toast, a new row, an error shake.
  • For hover and press feedback on cards and custom buttons.
  • For page and tab transitions with pz.presence.
import pyzed as pz
from pyzed import ui
class Inbox(pz.App):
errors = 0
page = 0
def view(self):
return pz.column([
ui.input(self.query, self.search).animate("shake", key=self.errors),
pz.presence(self.page_view(), key=self.page, enter="fade_in_right", exit="fade_out"),
ui.button("Record", self.record).animate("glow_pulse", active=self.recording),
], spacing=12)

Animation has no events of its own: it shows what you give it. Like every widget it also has the 18 common events (click, double_click, right_click, mouse_enter, drag, key_down, resize…), attached with .on(...): see Events and Events of every component.

@dataclass
class Animation(keyframes=(), duration=300, delay=0, easing='ease', repeat=1, direction='normal', fill='both', on='mount', category='custom', description='', _frames=())

A keyframe animation, like a CSS @keyframes rule with its timing.

Full reference →

stagger(items, animation='fade_in_up', *, step=40, delay=0, **options)

items with the same animation, each starting step milliseconds after the previous one (a list that cascades in)::

Full reference →

presence(
content,
key,
*,
enter='fade_in',
exit='fade_out',
id=None,
duration=None,
easing=None,
)

Shows content and, when key changes, animates the old content out (exit) while the new one comes in (enter), like page transitions::

Full reference →

define_animation(name, animation=None, **options)

Names an animation so animate(name) plays it; returns it.

Full reference →

set_reduced_motion(on=True)

Turns motion off (True) or back on: animations show their resting state at once.

Full reference →