pub fn prefers_reduced_motion() -> boolExpand 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. Returnstruewhen animations are disabled (enable-animationsisfalse). - macOS: Queries
NSWorkspace.accessibilityDisplayShouldReduceMotion(requiresmacosfeature). - Windows: Queries
UISettings.AnimationsEnabled()(requireswindowsfeature). - 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);