Skip to content

Commit b4a5bbf

Browse files
Jared-DevJared Malcolm
andauthored
Add check for CSS to respect a users anim prefs. (#799)
Co-authored-by: Jared Malcolm <[email protected]>
1 parent b896a31 commit b4a5bbf

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

website/src/pages/animation.mdx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ You can animate the "enter" phase with just a little CSS.
3030
.slide-down[data-reach-menu-list],
3131
.slide-down[data-reach-menu-items] {
3232
border-radius: 5px;
33-
animation: slide-down 0.2s ease;
33+
}
34+
35+
@media (prefers-reduced-motion: no-preference) {
36+
.slide-down[data-reach-menu-list],
37+
.slide-down[data-reach-menu-items] {
38+
animation: slide-down 0.2s ease;
39+
}
3440
}
3541
```
3642

@@ -64,8 +70,6 @@ First add the CSS to define the animation:
6470

6571
```css
6672
.slide-down {
67-
transition-property: transform, opacity;
68-
transition-duration: 300ms;
6973
opacity: 0;
7074
transform: translateY(-10px);
7175
}
@@ -78,6 +82,13 @@ First add the CSS to define the animation:
7882
.slide-down.exit {
7983
opacity: 0;
8084
}
85+
86+
@media (prefers-reduced-motion: no-preference) {
87+
.slide-down {
88+
transition-property: transform, opacity;
89+
transition-duration: 300ms;
90+
}
91+
}
8192
```
8293

8394
Then import the Phased component:

0 commit comments

Comments
 (0)