Web Preferences API
- Category
- Miscellaneous
- Type
- New or changed feature
- Status
- Proposed (Chrome Proposed)
- Intent stage
- None
Summary
The Web Preference API aims to provide a way for sites to override the value for a given user preference (e.g. color-scheme preference) in a way that fully integrates with existing Web APIs.
Motivation
Currently, website authors have a choice when wishing to honour a user's preference for a given setting. They can choose to "use the platform" where the user must indicate their preference via their OS or, if lucky, they can override in the browser. This comes with a number of issues: - Relies on the user's OS or browser offering the ability to change the setting - Relies on the user knowing how to change the setting in their OS or browser - No ability to override the setting for a specific site - No ability to sync preferences for a site across devices Alternatively, sites can and do offer site-level settings, but this currently comes with a number of issues: - No integration with CSS preference media queries - No integration with conditional resource loading (e.g. using <source media="(prefers-contrast: more)">) - No integration with JS APIs for retrieval of these preferences (e.g. matchMedia) - No integration with User Preference Client Hints - No integration with the color-scheme CSS property - The various client storage mechanisms that could store these preferences can be cleared in a number of scenarios The Web Preferences API aims to solve this by providing a way for sites to indicate a user preference for a given pre-defined setting.
Standards & signals
- Specification: https://drafts.csswg.org/mediaqueries-5/#auto-pref%E2%91%A0
- Firefox: No signal
- Safari: Oppose
- Web developers: Positive — There's a variety of blog posts and tweets that talk about wanting the ability to override user preferences (mainly color scheme but not always).
- Tracking bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1479201
Ecosystem
- Web Platform Tests: https://wpt.fyi/results/?q=web-preferences-api
- Chrome Platform Showcase: https://chrome-platform-showcase.paulkinlan-ea.deno.net/features
- GenDN reference: https://gendn.paulkinlan-ea.deno.net/features
- chrome.dev demos search: https://www.google.com/search?q=site%3Achrome.dev+Web%20Preferences%20API
- MDN Web Docs: https://developer.mozilla.org/en-US/search?q=Web%20Preferences%20API
- Baseline status: https://webstatus.dev/?q=Web%20Preferences%20API
Samples: https://demo.lukewarlow.dev/web-preferences-api
Explainers: https://github.com/WICG/web-preferences-api