Skip to main content

prefers_reduced_motion

Function prefers_reduced_motion 

Source
pub fn prefers_reduced_motion() -> bool
Expand description

Query whether the user prefers reduced motion.

Returns true when the OS accessibility setting indicates animations should be reduced or disabled. Returns false (allow animations) on unsupported platforms or when the query fails.

§Caching

The result is cached after the first call and reused on subsequent calls. Call invalidate_caches() to clear the cached value so the next call re-queries the OS. For live accessibility-change tracking, subscribe to OS accessibility events and call invalidate_caches() when notified.

§Platform Behavior

  • Linux: Queries gsettings get org.gnome.desktop.interface enable-animations. Returns true when animations are disabled (enable-animations is false).
  • macOS: Queries NSWorkspace.accessibilityDisplayShouldReduceMotion (requires macos feature).
  • Windows: Queries UISettings.AnimationsEnabled() (requires windows feature).
  • Other platforms: Returns false.

§Examples

let reduced = native_theme::prefers_reduced_motion();
// On this platform, the result depends on OS accessibility settings.
// The function always returns a bool (false on unsupported platforms).
assert!(reduced == true || reduced == false);