Back to Content

Navigator: preferences property

files/en-us/web/api/navigator/preferences/index.md

latest824 B
Original Source

{{APIRef("User Preferences API")}}{{SeeCompatTable}}

The preferences read-only property of the {{domxref("Navigator")}} interface returns a {{domxref("PreferenceManager")}} object for the current document. This is the entry point for the User Preferences API functionality.

Value

A {{domxref('PreferenceManager')}} object.

Examples

Get color scheme preference

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

{{Specifications}}

Browser compatibility

{{Compat}}

See also