- Docs
- enzUI framework
- Developers
Motion
What animates by default, visibility transitions, springs, animated lists and images, and how to animate a custom widget.
Framework widgets animate their own state changes, so most apps write no motion code. When you want more, wrap an element in a motion helper, or drive a spring yourself. Everything follows the theme's motion scale and the user's reduced-motion preference.

What animates by default
| Widget | Motion | Duration |
|---|---|---|
Buttons, icon buttons, segmented controls, tabs, menu rows, links, pagination and every other control built on FocusButton | Fill, text, border and shadow fade between rest, hover, release and selected; a press lands at once | motion-fast |
| Text, search, password, chip, time and autocomplete fields | Border and fill fade between rest, hover and focus | motion-fast |
| Checkbox, radio | Fill, border and dot fade; the tick or dot pops in and shrinks away | motion-fast, 160 ms pop |
| Switch, toggle | The thumb slides | motion-normal |
| Slider, range slider | Thumbs glide to a value set by a key or the app (a drag stays direct); the knob swells under the pointer | motion-fast, 140 ms |
| Progress bar | The fill glides; with .busy(true) a highlight sweeps along a part-done fill | motion-normal |
| Gauge | The ring sweeps to a new value | motion-normal |
| Disclosure, expander, tree rows | The chevron turns; the section expands | 160 ms, motion-normal |
| Menus, popovers, pickers, combo box, context menus | Open with a fade and a small scale from the anchored edge | 140 ms |
| Toasts | Rise into the stack and fade in | theme spring |
| Navigation split view drawer | Slides in over a fading scrim | theme spring |
| Carousel, wizard | The new page or step fades in | motion-normal |
Changing the defaults
- The whole app: the theme's motion scale.
motion.reduced_motion = true(in code onEnzTheme.motion, or in the user'senzui/theme.toml) lands every change at once; the desktop's reduced-motion setting does the same unless the theme says otherwise.fast_ms,normal_ms,slow_msandeasingretime every widget at once. - One widget:
.reduced_motion(true)on a builder (FocusButton,FieldChrome,EnzToggle,EnzGauge, lists, trees, menus, spinners and others) lands that widget's changes at once;falseanimates it even under a reduced-motion theme. A progress bar takes.animated(false). - For a session:
ENZUI_MOTION_SCALE=4multiplies every duration, to watch motion slowly while developing.
Showing and hiding
enzui_widgets::motion::motion(child, visible, effect) animates an element's visibility with a MotionEffect: Slide, Size, Scale or Fade. Effects compose by nesting. The wrapper keeps the child while it exits and removes its tree once hidden, requests frames only while needed, and applies reduced motion without an app timer.
use enzui_widgets::motion::{MotionEffect, SlideDirection, motion};
let panel = motion(
container(enz_text("A panel on the same spring")).padding(16),
self.panel,
MotionEffect::Slide(SlideDirection::Left),
)
.spring(Some(spring));Sizechanges reserved layout space. By default it holds the wider endpoint and lays out once, at the end;.reflow(true)lays the reservation out on every frame instead, so a list beside an inspector narrows with it.- Slide, scale and fade do not invalidate layout on every frame.
.enter_on_mount()gives an element an entrance the first time it appears.cross_fadekeeps both endpoints and reserves their larger size, so budget for two trees.
Three more helpers:
motion::animated(child)springs a child to the offset and opacity each view gives it, and.enters_from(offset, opacity)gives it an entrance when first mounted.motion::fade_on_change(key, child)fades a child in wheneverkeychanges (another item, another step) and gives it fresh widget state.keyed_column(rows).animate_moves()slides rows to their new places when rows arrive, leave or reorder, with exact layout on every frame.
Springs
enzui_theme::Spring describes a spring by stiffness and damping ratio; duration() and bounce() give the equivalent perceptual parameters. Presets include Spring::SMOOTH, Spring::SNAPPY and Spring::BOUNCY, and ExpressiveMotion provides Material 3 expressive and standard springs (ExpressiveMotion::DefaultSpatial.spring(), .standard_spring()).
motion::SpringAnimation<T> drives a value on a spring and handles reversals mid-flight without stopping. With enzui_core::velocity::VelocityTracker it can carry the speed of a throw:
// Pointer released: hand the measured speed to the spring.
self.tracker.add(now, [at.x, at.y]);
let [vx, vy] = self.tracker.velocity(now);
self.card.release(from, Point::new(vx, vy), target, now);
// While it moves, ask for frames.
fn subscription(&self) -> Subscription<Message> {
if self.card.is_animating(Instant::now()) {
iced::window::frames().map(Message::Frame)
} else {
Subscription::none()
}
}snap(value) moves it at once (to follow a held pointer), set_spring(..) changes the spring, and value(now) reads the current position.
Animated images and SVG
enz_animated_image and enz_animated_svg play GIF, APNG, animated WebP and SVG (SMIL and CSS) animation. They draw only when the picture changes, pause out of view, and show their first frame under reduced motion. See Media and images.
enz_frame_clock wraps any element so it animates itself from frame timestamps, with no app-side tick and no per-frame view() rebuild.
Animating a custom widget
A widget that animates itself from update on Event::Window(RedrawRequested(now)) asks the shell for its next frame. Which request it makes decides how that frame is produced:
- Its paint or layout changes:
shell.request_redraw(). A caret, a counter, a meter, or any widget that moves, resizes or reflows content itself. The frame is drawn. - It only moves, fades, scales, rotates or clips a recorded node:
shell.request_track_frame()withshell.publish_track(..). The widget takes a node once (motion::next_scene_node()), records its paint under it indraw, and the runtime moves the last recorded frame along the tracks on the render lane, off the UI thread. Until the node has been recorded once, ask forrequest_redraw()instead. - Its siblings must move too:
shell.invalidate_layout(), once rather than every frame where possible. - Later:
shell.request_redraw_at(instant).
The rule: if a frame would look wrong when the last recorded picture is moved along the published tracks, use request_redraw(). enzui_frame_check::FrameCheck tests this by comparing replayed frames with full redraws; see Testing.