MDN self-hosted library · e01.org

Navigator: preferences property

User Preferences API

Open notebook · 1 cells web-api-instance-property upstream source

User Preferences API

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

Value

A PreferenceManager object.

Examples

Get color scheme preference

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

Browser compatibility

See also