Skip to content

Instantly share code, notes, and snippets.

@zastrow
Created March 7, 2021 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zastrow/64a9317aba21c3e69f7cc2257f18c1fc to your computer and use it in GitHub Desktop.
Save zastrow/64a9317aba21c3e69f7cc2257f18c1fc to your computer and use it in GitHub Desktop.
// This function pairs with the `motion` mixin
// to convert a `true` or `false` value to the
// appropriate media query value for reduce motion.
@function motion($value) {
@if $value {
@return 'no-preference';
}
@else {
@return 'reduce';
}
}
@mixin motion($value: true) {
@media (prefers-reduced-motion: motion($value)) {
@content;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment