PreferenceManager

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The PreferenceManager interface of the User Preferences API provides access to PreferenceObject objects used to query and modify user preferences.

The PreferenceManager for the current document can be accessed via the Navigator.preferences property.

The PreferenceManager interface inherits from EventTarget.

Instance properties

PreferenceManager.colorScheme Read only Experimental

A PreferenceObject used to override the user's preference for the color scheme of the site.

PreferenceManager.contrast Read only Experimental

A PreferenceObject used to override the user's preference for the contrast of the site.

PreferenceManager.reducedMotion Read only Experimental

A PreferenceObject used to override the user's preference for the reduced motion of the site.

PreferenceManager.reducedTransparency Read only Experimental

A PreferenceObject used to override the user's preference for the reduced transparency of the site.

PreferenceManager.reducedData Read only Experimental

A PreferenceObject used to override the user's preference for the reduced data of the site.

Examples

Basic usage

This example demonstrates how to query the user's preferred color scheme.

js
if (navigator.preferences.colorScheme.value === "dark") {
  // The user prefers a dark color scheme.
} else {
  // The user prefers a light color scheme.
}

Specifications

Specification
Media Queries Level 5
# preference-manager

Browser compatibility