SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

motionReduce

Sugar over media("(prefers-reduced-motion: reduce)", input).

tsx
import { motionReduce } from "@sdxc/u/responsive";

Quick reference

Every documented call, beside the CSS it emits.

CallCSS
u.motionReduce(u.transitionDuration("0s"))css({ "@media (prefers-reduced-motion: reduce)": { transitionDuration: "0s" } })

Examples

Basic example

Use motionReduce(...) to apply utilities when the reader asks for less motion, like stopping an animation. Turn on Reduce motion in your system's accessibility settings to stop the square:

tsx
<div
	mix={[
		animation({
			keyframes: { to: { rotate: "1turn" } },
			duration: "1.5s",
			easing: "linear",
			iterationCount: "infinite",
		}),
		motionReduce(raw({ animationName: "none" })),
		is(16),
		bs(16),
		...,
	]}
/>

Removing a transition

Remove a transition with motionReduce(transitionProperty("none")), so the change still happens without the animation. Hover the card, then try again with Reduce motion on:

Hover me
tsx
<div
	mix={[
		transition("transform", { duration: 300 }),
		motionReduce(transitionProperty("none")),
		hover(translateY(-2)),
		...,
	]}
>
	Hover me
</div>

Applying on a state

Wrap the call in a state utility to scope it to one selector.

typescript
u.hover(u.motionReduce(u.transitionDuration("0s")))

Signature

typescript
u.motionReduce(input: UtilityInput<Node>)
@sdxc/u

Can’t find it? Contact us