Skip to content

usePreferredContrast ​

Category
Export Size
522 B
Last Changed
7 months ago

响应式的 prefers-contrast 媒体查询。

Demo ​

首选对比度:
no-preference

用法 ​

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

const preferredContrast = usePreferredContrast()

组件使用 ​

vue
<template>
  <UsePreferredContrast v-slot="{ contrast }">
    首选对比度: {{ contrast }}
  </UsePreferredContrast>
</template>

Type Declarations ​

typescript
export type ContrastType = "more" | "less" | "custom" | "no-preference"
/**
 * Reactive prefers-contrast media query.
 *
 * @see https://vueuse.org/usePreferredContrast
 * @param [options]
 */
export declare function usePreferredContrast(
  options?: ConfigurableWindow,
): ComputedRef<ContrastType>

Source ​

Source • Demo • Docs

Contributors ​

丶远方
Anthony Fu
Anthony Fu
vaakian X
Zhao

Changelog ​

0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)

Released under the MIT License.