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.colorSchemeRead only Experimental-
A
PreferenceObjectused to override the user's preference for the color scheme of the site. PreferenceManager.contrastRead only Experimental-
A
PreferenceObjectused to override the user's preference for the contrast of the site. PreferenceManager.reducedMotionRead only Experimental-
A
PreferenceObjectused to override the user's preference for the reduced motion of the site. PreferenceManager.reducedTransparencyRead only Experimental-
A
PreferenceObjectused to override the user's preference for the reduced transparency of the site. PreferenceManager.reducedDataRead only Experimental-
A
PreferenceObjectused 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.
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> |