Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
The override read-only property of the PreferenceObject interface returns the override of a preference if one is set, null otherwise.
The override of the PreferenceObject interface, if set, or null if an override is not set.
This example demonstrates how to disambiguate between the color scheme preference set by the user agent vs a programmatic override.
if (navigator.preferences.colorScheme.override === null) {
console.log(
"The user agent set the following color scheme:",
navigator.preferences.colorScheme.value,
);
} else {
console.log(
"The following color scheme was set programmatically:",
navigator.preferences.colorScheme.override,
);
}