Expand description
Shake — wraps a child and plays a damped horizontal oscillation
whenever an external trigger Signal<u32> is bumped. The classic
invalid-input feedback: wrong password, failed form validation,
“no more results” wall.
ⓘ
let shake_trigger = ctx.signal(0_u32);
ctx.add(
Shake::new(shake_trigger.clone())
.child(text_input_field),
);
// ...elsewhere, on validation failure:
shake_trigger.set(shake_trigger.get() + 1);§Layout semantics
Layout-stable: the wrapper reports the child’s full natural size and clips the oscillating-out-of-bounds excursions on each side. Siblings don’t reflow. The shake is a pure visual offset.
§Reduced motion
Honours prefers-reduced-motion: the trigger no-ops. The widget
is still focusable / interactive — the visual feedback just
doesn’t play. Pair with another a11y-friendly cue (red border,
error text) when error state must be communicated.
Structs§
- Shake
- Wraps a child and plays a damped horizontal-oscillation shake each time the trigger signal value changes.