X Tutup

Navigator: preferences property

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

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.

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
# preferences-attribute

Browser compatibility

See also

X Tutup