brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: the Rendering tab can emulate prefers-reduced-motion without touching your OS settings

Web-Development
~/tips/tip-devtools-emulate-reduced-motion

@media (prefers-reduced-motion: reduce) { .hero { animation: none; }}

Makes Chrome behave as if reduced motion is switched on, to test your CSS.

I want my animations to respect people who switch motion off, but changing a system setting each time I test is a hassle. DevTools can pretend for me.

Open the Rendering tab, for instance through the Command Menu with Ctrl+Shift+P (Command+Shift+P) and typing Rendering. Look for the entry Emulate CSS media feature prefers-reduced-motion and choose prefers-reduced-motion: reduce. Then scroll the page and watch the animations.

That makes this block in your stylesheet apply, so you can see whether the animation is really gone or only shortened:

@media (prefers-reduced-motion: reduce) {  .hero { animation: none; }}

The same tab has entries for more media features. prefers-color-scheme can be set to light or dark (the page needs a reload afterwards), forced-colors to active or none, prefers-contrast to more, less or custom, and color-gamut to srgb, p3 or rec2020. The emulated media type print gives you a print preview of the page.

There is a prefers-reduced-transparency entry as well.

Only the media query is emulated, though. Animations that you start from JavaScript are not stopped by it, so if your code does not check the setting itself, the motion stays. Test on a device with the setting really switched on before you call the page done.

Further reading: Chrome DevTools: emulate CSS media features

More Web-Development tips ab -n 200 -c 10 https://example.com/ console.assert(items.length > 0, 'cart is empty', items) document.designMode = "on" function save(item) { Save draft All Web-Development tips (67) All topics

Link