You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A [media query](/docs/svelte/svelte-reactivity#MediaQuery) that matches if the user [prefers reduced motion](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion).
21
+
22
+
```svelte
23
+
<script>
24
+
import { prefersReducedMotion } from 'svelte/motion';
The spring function in Svelte creates a store whose value is animated, with a motion that simulates the behavior of a spring. This means when the value changes, instead of transitioning at a steady rate, it "bounces" like a spring would, depending on the physics parameters provided. This adds a level of realism to the transitions and can enhance the user experience.
Copy file name to clipboardExpand all lines: apps/svelte.dev/content/docs/svelte/98-reference/21-svelte-reactivity.md
+130-1Lines changed: 130 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -27,14 +27,83 @@ Svelte provides reactive versions of various built-ins like `SvelteMap`, `Svelte
27
27
```js
28
28
// @noErrors
29
29
import {
30
+
MediaQuery,
30
31
SvelteDate,
31
32
SvelteMap,
32
33
SvelteSet,
33
34
SvelteURL,
34
-
SvelteURLSearchParams
35
+
SvelteURLSearchParams,
36
+
createSubscriber
35
37
} from'svelte/reactivity';
36
38
```
37
39
40
+
## MediaQuery
41
+
42
+
<blockquoteclass="since note">
43
+
44
+
Available since 5.7.0
45
+
46
+
</blockquote>
47
+
48
+
Creates a media query and provides a `current` property that reflects whether or not it matches.
49
+
50
+
Use it carefully — during server-side rendering, there is no way to know what the correct value should be, potentially causing content to change upon hydration.
51
+
If you can use the media query in CSS to achieve the same effect, do that.
0 commit comments