Skip to content
On this page

usePreferredContrast

Category
Export Size
Last Changed
4 months ago

Reactive prefers-contrast media query.

Demo

Preferred contrast:
no-preference

Usage

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

const preferredContrast = usePreferredContrast()
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.

html
<UsePreferredContrast v-slot="{ contrast }">
  Preferred Color Scheme: {{ contrast }}
<UsePreferredContrast>
<UsePreferredContrast v-slot="{ contrast }">
  Preferred Color Scheme: {{ contrast }}
<UsePreferredContrast>

Type Declarations

typescript
export declare 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>
export declare 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

SourceDemoDocs

Contributors

Zhao

Changelog

v9.1.1 on 8/23/2022
6db05 - feat: new function (#2040)

Released under the MIT License.