We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0bbdd62 commit eaed758Copy full SHA for eaed758
packages/web-api-hooks/src/usePreferredMotionIntensity.ts
@@ -0,0 +1,21 @@
1
+import useMedia from './useMedia';
2
+
3
+/**
4
+ * Tracks motion intensity preference of the user.
5
+ *
6
+ * @returns Preferred motion intensity.
7
8
+ * @example
9
+ * function Component() {
10
+ * const preferReducedMotion = usePreferredMotionIntensity() === 'reduce';
11
+ * // ...
12
+ * }
13
+ */
14
+export default function usePreferredMotionIntensity():
15
+ | 'no-preference'
16
+ | 'reduce' {
17
+ const isReduce = useMedia('(prefers-reduced-motion: reduce)');
18
19
+ if (isReduce) return 'reduce';
20
+ return 'no-preference';
21
+}
0 commit comments