Skip to content

usePreferredContrast ​

Category
Export Size
583 B
Last Changed
6 minutes ago

Reactive prefers-contrast media query.

Demo ​

Preferred contrast:
no-preference

Usage ​

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

const preferredContrast = usePreferredContrast()

Component Usage ​

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

vue
<template>
  <UsePreferredContrast v-slot="{ contrast }">
    Preferred 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 ​

v12.0.0-beta.1 on 11/21/2024
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)
v9.11.0 on 1/17/2023
d5321 - fix(components): mark defineComponent as pure (#2623)

Released under the MIT License.