PreferenceManager
User Preferences API
User Preferences API
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
- : A PreferenceObject used to override the user's preference for the color scheme of the site.
- PreferenceManager.contrast
- : A PreferenceObject used to override the user's preference for the contrast of the site.
- PreferenceManager.reducedMotion
- : A PreferenceObject used to override the user's preference for the reduced motion of the site.
- PreferenceManager.reducedTransparency
- : A PreferenceObject used to override the user's preference for the reduced transparency of the site.
- PreferenceManager.reducedData
- : 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.
if (navigator.preferences.colorScheme.value === "dark") {
// The user prefers a dark color scheme.
} else {
// The user prefers a light color scheme.
}