Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(layer): guard entry animations with prefers-reduced-motion (infra-6) (#3414)

Cindy Zhang1d8c622396fc
diff --git a/.changeset/layer-animations-reduced-motion.md b/.changeset/layer-animations-reduced-motion.md
new file mode 100644
index 0000000000..38d36168ca
--- /dev/null
+++ b/.changeset/layer-animations-reduced-motion.md
@@ -0,0 +1,6 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Layer/popover entry animations now honor `prefers-reduced-motion`. The shared layer slide/scale keyframes (used by DropdownMenu, Popover, HoverCard, Tooltip, Selector, and other popover surfaces) and the `useEntryAnimation` presets disable their keyframe animation under `prefers-reduced-motion: reduce`, so layers appear instantly instead of translating/scaling in (#3343).
+@cixzhang
diff --git a/packages/core/src/Layer/layerAnimations.stylex.ts b/packages/core/src/Layer/layerAnimations.stylex.ts
index 0d0b18b36a..08cad5f287 100644
--- a/packages/core/src/Layer/layerAnimations.stylex.ts
+++ b/packages/core/src/Layer/layerAnimations.stylex.ts
@@ -72,22 +72,38 @@ const animationBase = {
*
* Keyed by LayerPlacement ('above' | 'below' | 'start' | 'end')
* for easy lookup: `layerAnimations[placement]`.
+ *
+ * Each entry disables its keyframe animation under
+ * `prefers-reduced-motion: reduce` so the layer appears instantly instead of
+ * translating/scaling in (infra-6).
*/
export const layerAnimations = stylex.create({
below: {
- animationName: enterBelow,
+ animationName: {
+ default: enterBelow,
+ '@media (prefers-reduced-motion: reduce)': 'none',
+ },
...animationBase,
},
above: {
- animationName: enterAbove,
+ animationName: {
+ default: enterAbove,
+ '@media (prefers-reduced-motion: reduce)': 'none',
+ },
...animationBase,
},
end: {
- animationName: enterEnd,
+ animationName: {
+ default: enterEnd,
+ '@media (prefers-reduced-motion: reduce)': 'none',
+ },
...animationBase,
},
start: {
- animationName: enterStart,
+ animationName: {
+ default: enterStart,
+ '@media (prefers-reduced-motion: reduce)': 'none',
+ },
...animationBase,
},
});
diff --git a/packages/core/src/hooks/useEntryAnimation.ts b/packages/core/src/hooks/useEntryAnimation.ts
index 2a89e2fcce..fcbdf9bc37 100644
--- a/packages/core/src/hooks/useEntryAnimation.ts
+++ b/packages/core/src/hooks/useEntryAnimation.ts
@@ -61,25 +61,37 @@ const scaleIn = stylex.keyframes({
const styles = stylex.create({
slideDown: {
- animationName: slideDown,
+ animationName: {
+ default: slideDown,
+ '@media (prefers-reduced-motion: reduce)': 'none',
+ },
animationDuration: durationVars['--duration-fast-max'],
animationTimingFunction: easeVars['--ease-standard'],
animationFillMode: 'backwards',
},
slideUp: {
- animationName: slideUp,
+ animationName: {
+ default: slideUp,
+ '@media (prefers-reduced-motion: reduce)': 'none',
+ },
animationDuration: durationVars['--duration-fast-max'],
animationTimingFunction: easeVars['--ease-standard'],
animationFillMode: 'backwards',
},
fadeIn: {
- animationName: fadeIn,
+ animationName: {
+ default: fadeIn,
+ '@media (prefers-reduced-motion: reduce)': 'none',
+ },
animationDuration: durationVars['--duration-fast-max'],
animationTimingFunction: easeVars['--ease-standard'],
animationFillMode: 'backwards',
},
scaleIn: {
- animationName: scaleIn,
+ animationName: {
+ default: scaleIn,
+ '@media (prefers-reduced-motion: reduce)': 'none',
+ },
animationDuration: durationVars['--duration-fast-max'],
animationTimingFunction: easeVars['--ease-standard'],
animationFillMode: 'backwards',