Preparing for the display modes of tomorrow
PWAs can use the "display_override" property to deal with special display modes.
A web app manifest is a JSON file that tells the browser about your Progressive Web App and how it should behave when installed on the user's desktop or mobile device. Via the display
property, you can customize what browser UI is shown when your app is launched. For example, you can hide the address bar and browser chrome. Games can even be made to launch full screen. As a quick recap, below are the display modes that are specified at the time this article was written.
Property | Use |
---|---|
fullscreen | Opens the web application without any browser UI and takes up the entirety of the available display area. |
standalone | Opens the web app to look and feel like a standalone app. The app runs in its own window, separate from the browser, and hides standard browser UI elements like the URL bar. |
minimal-ui | This mode is similar to standalone , but provides the user a minimal set of UI elements for controlling navigation (such as back and reload). |
browser | A standard browser experience. |
These display modes follow a well-defined fallback chain ("fullscreen"
→ "standalone"
→ "minimal-ui"
→ "browser"
). If a browser does not support a given mode, it falls back to the next display mode in the chain.
display
property
Shortcomings of the The problem with this hard-wired fallback chain approach is threefold:
- A developer cannot request
"minimal-ui"
without being forced back into the"browser"
display mode in case"minimal-ui"
is not supported by a given browser. - Developers have no way of handling cross-browser differences, like if the browser includes or excludes a back button in the window for
"standalone"
mode. - The current behavior makes it impossible to introduce new display modes in a backward compatible way, since explorations like tabbed application mode do not have a natural place in the fallback chain.
display_override
property
The These problems are solved by the display_override
property, which the browser considers before the display
property. Its value is a sequence of strings that are considered in-order, and the first supported display mode is applied. If none are supported, the browser falls back to evaluating the display
field.
The display_override
property is meant to solve special corner cases. In almost all circumstances the regular display
property is what developers should reach for.
In the example below, the display mode fallback chain would be as follows. (The details of "window-controls-overlay"
are out-of-scope for this article.)
"window-controls-overlay"
(First, look atdisplay_override
.)"minimal-ui"
"standalone"
(Whendisplay_override
is exhausted, evaluatedisplay
.)"minimal-ui"
(Finally, use thedisplay
fallback chain.)"browser"
{
"display_override": ["window-controls-overlay", "minimal-ui"],
"display": "standalone",
}
The browser will not consider display_override
unless display
is also present.
To remain backward compatible, any future display mode will only be acceptable as a value of display_override
, but not display
. Browsers that do not support display_override
fall back to the display
property and ignore display_override
as an unknown web app manifest property.
The display_override
property is defined independently from its potential values.
Useful links
Acknowledgments
The display_override
property was formalized by Daniel Murphy.