Skip to content
On this page

usePreferredReducedMotion

响应式prefers-reduced-motion

Reactive prefers-reduced-motion media query.

例子

Preferred Motion:
no-preference

Usage

js
import { usePreferredReducedMotion } from '@vueuse/core'

const preferredMotion = usePreferredReducedMotion()
import { usePreferredReducedMotion } from '@vueuse/core'

const preferredMotion = usePreferredReducedMotion()

Component Usage

该函数还通过@vueuse/components提供了一个无渲染的组件版本。了解更多.

This function also provides a renderless component version via the @vueuse/components package. Learn more about the usage.

html
<UsePreferredReducedMotion v-slot="{ motion }">
  Preferred Color Scheme: {{ motion }}
<UsePreferredReducedMotion>
<UsePreferredReducedMotion v-slot="{ motion }">
  Preferred Color Scheme: {{ motion }}
<UsePreferredReducedMotion>

Type Declarations

typescript
export type ReducedMotionType = "reduce" | "no-preference"
/**
 * Reactive prefers-reduced-motion media query.
 *
 * @see https://vueuse.org/usePreferredReducedMotion
 * @param [options]
 */
export declare function usePreferredReducedMotion(
  options?: ConfigurableWindow
): ComputedRef<ReducedMotionType>
export type ReducedMotionType = "reduce" | "no-preference"
/**
 * Reactive prefers-reduced-motion media query.
 *
 * @see https://vueuse.org/usePreferredReducedMotion
 * @param [options]
 */
export declare function usePreferredReducedMotion(
  options?: ConfigurableWindow
): ComputedRef<ReducedMotionType>

Source

Category
Export Size
1.09 kB
Last Changed
8 months ago

SourceDemoDocs

贡献者(Contributors)

日志(Changelog)

No recent changes

Released under the MIT License.