Firefox Tomorrow

web api instance property

PreferenceManager: colorScheme property

View on MDN ↗

Limited availabilitySecure context

The colorScheme read-only property of the PreferenceManager interface returns a PreferenceObject used to override the user’s preference for the color scheme of the site.

Valid colorScheme value settings are dark and light.

Value

A PreferenceObject used to override the user’s preference for the color scheme 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

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.