CSS is about styling packing containers. In reality, the entire internet is made from packing containers, from the browser viewport to parts on a web page. However each on occasion a brand new characteristic comes alongside that makes us rethink our design method.
Article Continues Under
Spherical shows, for instance, make it enjoyable to play with round clip areas. Cell display notches and digital keyboards provide challenges to finest arrange content material that stays away from them. And twin display or foldable units make us rethink methods to finest use obtainable house in plenty of totally different system postures.

These current evolutions of the net platform made it each more difficult and extra attention-grabbing to design merchandise. They’re nice alternatives for us to interrupt out of our rectangular packing containers.
I’d like to speak a few new characteristic much like the above: the Window Controls Overlay for Progressive Net Apps (PWAs).
Progressive Net Apps are blurring the strains between apps and web sites. They mix the perfect of each worlds. On one hand, they’re secure, linkable, searchable, and responsive identical to web sites. Then again, they supply extra highly effective capabilities, work offline, and skim information identical to native apps.
As a design floor, PWAs are actually attention-grabbing as a result of they problem us to consider what mixing internet and device-native consumer interfaces might be. On desktop units specifically, we’ve got greater than 40 years of historical past telling us what purposes ought to seem like, and it may be exhausting to interrupt out of this psychological mannequin.
On the finish of the day although, PWAs on desktop are constrained to the window they seem in: a rectangle with a title bar on the prime.
Right here’s what a typical desktop PWA app seems like:

Positive, because the writer of a PWA, you get to decide on the colour of the title bar (utilizing the Net Software Manifest theme_color property), however that’s about it.
What if we might assume exterior this field, and reclaim the actual property of the app’s whole window? Doing so would give us an opportunity to make our apps extra lovely and really feel extra built-in within the working system.
That is precisely what the Window Controls Overlay gives. This new PWA performance makes it potential to reap the benefits of the complete floor space of the app, together with the place the title bar usually seems.
Concerning the title bar and window controls#section2
Let’s begin with a proof of what the title bar and window controls are.
The title bar is the world displayed on the prime of an app window, which often incorporates the app’s identify. Window controls are the affordances, or buttons, that make it potential to attenuate, maximize, or shut the app’s window, and are additionally displayed on the prime.
Window Controls Overlay removes the bodily constraint of the title bar and window controls areas. It frees up the complete top of the app window, enabling the title bar and window management buttons to be overlaid on prime of the applying’s internet content material.
In case you are studying this text on a desktop pc, take a fast take a look at different apps. Chances are high they’re already doing one thing much like this. In reality, the very internet browser you might be utilizing to learn this makes use of the highest space to show tabs.
Spotify shows album art work all the way in which to the highest fringe of the applying window.
Microsoft Phrase makes use of the obtainable title bar house to show the auto-save and search functionalities, and extra.
The entire level of this characteristic is to assist you to make use of this house with your personal content material whereas offering a option to account for the window management buttons. And it allows you to provide this modified expertise on a variety of platforms whereas not adversely affecting the expertise on browsers or units that don’t help Window Controls Overlay. In spite of everything, PWAs are all about progressive enhancement, so this characteristic is an opportunity to boost your app to make use of this further house when it’s obtainable.
Let’s use the characteristic#section3
For the remainder of this text, we’ll be engaged on a demo app to study extra about utilizing the characteristic.
The demo app known as 1DIV. It’s a easy CSS playground the place customers can create designs utilizing CSS and a single HTML ingredient.
The app has two pages. The primary lists the prevailing CSS designs you’ve created:
The second web page allows you to create and edit CSS designs:
Since I’ve added a easy internet manifest and repair employee, we are able to set up the app as a PWA on desktop. Here’s what it seems like on macOS:

And on Home windows:

Our app is trying good, however the white title bar within the first web page is wasted house. Within the second web page, it could be very nice if the design space went all the way in which to the highest of the app window.
Let’s use the Window Controls Overlay characteristic to enhance this.
Enabling Window Controls Overlay#section4
The characteristic remains to be experimental in the intervening time. To strive it, you must allow it in one of many supported browsers.
As of now, it has been carried out in Chromium, as a collaboration between Microsoft and Google. We will due to this fact use it in Chrome or Edge by going to the inner about://flags web page, and enabling the Desktop PWA Window Controls Overlay flag.
Utilizing Window Controls Overlay#section5
To make use of the characteristic, we have to add the next display_override member to our internet app’s manifest file:
{
"identify": "1DIV",
"description": "1DIV is a mini CSS playground",
"lang": "en-US",
"start_url": "/",
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display_override": [
"window-controls-overlay"
],
"icons": [
...
]
}
On the floor, the characteristic is absolutely easy to make use of. This manifest change is the one factor we have to make the title bar disappear and switch the window controls into an overlay.
Nevertheless, to offer an amazing expertise for all customers no matter what system or browser they use, and to take advantage of the title bar space in our design, we’ll want a little bit of CSS and JavaScript code.
Here’s what the app seems like now:
The title bar is gone, which is what we wished, however our emblem, search area, and NEW button are partially coated by the window controls as a result of now our format begins on the prime of the window.
It’s related on Home windows, with the distinction that the shut, maximize, and reduce buttons seem on the correct facet, grouped along with the PWA management buttons:
Utilizing CSS to maintain away from the window controls#section6
Together with the characteristic, new CSS setting variables have been launched:
titlebar-area-x
titlebar-area-y
titlebar-area-width
titlebar-area-height
You utilize these variables with the CSS env() operate to place your content material the place the title bar would have been whereas making certain it gained’t overlap with the window controls. In our case, we’ll use two of the variables to place our header, which incorporates the emblem, search bar, and NEW button.
header {
place: absolute;
left: env(titlebar-area-x, 0);
width: env(titlebar-area-width, 100%);
top: var(--toolbar-height);
}
The titlebar-area-x
variable offers us the gap from the left of the viewport to the place the title bar would seem, and titlebar-area-width
is its width. (Keep in mind, this isn’t equal to the width of the complete viewport, simply the title bar portion, which as famous earlier, doesn’t embody the window controls.)
By doing this, we be certain that our content material stays totally seen. We’re additionally defining fallback values (the second parameter within the env()
operate) for when the variables will not be outlined (comparable to on non-supporting browsers, or when the Home windows Management Overlay characteristic is disabled).
Now our header adapts to its environment, and it doesn’t really feel just like the window management buttons have been added as an afterthought. The app seems much more like a local app.
Altering the window controls background coloration so it blends in#section7
Now let’s take a better take a look at our second web page: the CSS playground editor.

Not nice. Our CSS demo space does go all the way in which to the highest, which is what we wished, however the way in which the window controls seem as white rectangles on prime of it’s fairly jarring.
We will repair this by altering the app’s theme coloration. There are a few methods to outline it:
- PWAs can outline a theme coloration within the internet app manifest file utilizing the theme_color manifest member. This coloration is then utilized by the OS in several methods. On desktop platforms, it’s used to offer a background coloration to the title bar and window controls.
- Web sites can use the theme-color meta tag as effectively. It’s utilized by browsers to customise the colour of the UI across the internet web page. For PWAs, this coloration can override the manifest
theme_color
.
In our case, we are able to set the manifest theme_color
to white to offer the correct default coloration for our app. The OS will learn this coloration worth when the app is put in and use it to make the window controls background coloration white. This coloration works nice for our foremost web page with the record of demos.
The theme-color
meta tag might be modified at runtime, utilizing JavaScript. So we are able to try this to override the white with the correct demo background coloration when one is opened.
Right here is the operate we’ll use:
operate themeWindow(bgColor) {
doc.querySelector("meta[name=theme-color]").setAttribute('content material', bgColor);
}
With this in place, we are able to think about how utilizing coloration and CSS transitions can produce a easy change from the record web page to the demo web page, and allow the window management buttons to mix in with the remainder of the app’s interface.
Dragging the window#section8
Now, eliminating the title bar solely does have an necessary accessibility consequence: it’s far more troublesome to maneuver the applying window round.
The title bar offers a large space for customers to click on and drag, however through the use of the Window Controls Overlay characteristic, this space turns into restricted to the place the management buttons are, and customers should very exactly purpose between these buttons to maneuver the window.
Fortuitously, this may be fastened utilizing CSS with the app-region
property. This property is, for now, solely supported in Chromium-based browsers and wishes the -webkit-
vendor prefix.
To make any ingredient of the app turn into a dragging goal for the window, we are able to use the next:
-webkit-app-region: drag;
Additionally it is potential to explicitly make a component non-draggable:
-webkit-app-region: no-drag;
These choices might be helpful for us. We will make the complete header a dragging goal, however make the search area and NEW button inside it non-draggable to allow them to nonetheless be used as regular.
Nevertheless, as a result of the editor web page doesn’t show the header, customers wouldn’t be capable to drag the window whereas enhancing code. So let’s use a unique method. We’ll create one other ingredient earlier than our header, additionally completely positioned, and devoted to dragging the window.
<div class="drag"></div>
<header>...</header>
.drag {
place: absolute;
prime: 0;
width: 100%;
top: env(titlebar-area-height, 0);
-webkit-app-region: drag;
}
With the above code, we’re making the draggable space span the complete viewport width, and utilizing the titlebar-area-height
variable to make it as tall as what the title bar would have been. This fashion, our draggable space is aligned with the window management buttons as proven under.
And, now, to verify our search area and button stay usable:
header .search,
header .new {
-webkit-app-region: no-drag;
}
With the above code, customers can click on and drag the place the title bar was. It’s an space that customers count on to have the ability to use to maneuver home windows on desktop, and we’re not breaking this expectation, which is nice.
Adapting to window resize#section9
It could be helpful for an app to know each whether or not the window controls overlay is seen and when its measurement adjustments. In our case, if the consumer made the window very slender, there wouldn’t be sufficient house for the search area, emblem, and button to suit, so we’d need to push them down a bit.
The Window Controls Overlay characteristic comes with a JavaScript API we are able to use to do that: navigator.windowControlsOverlay
.
The API offers three attention-grabbing issues:
navigator.windowControlsOverlay.seen
lets us know whether or not the overlay is seen.navigator.windowControlsOverlay.getBoundingClientRect()
lets us know the place and measurement of the title bar space.navigator.windowControlsOverlay.ongeometrychange
lets us know when the dimensions or visibility adjustments.
Let’s use this to concentrate on the dimensions of the title bar space and transfer the header down if it’s too slender.
if (navigator.windowControlsOverlay) {
navigator.windowControlsOverlay.addEventListener('geometrychange', () => {
const { width } = navigator.windowControlsOverlay.getBoundingClientRect();
doc.physique.classList.toggle('slender', width < 250);
});
}
Within the instance above, we set the slender
class on the physique
of the app if the title bar space is narrower than 250px. We might do one thing related with a media question, however utilizing the windowControlsOverlay
API has two benefits for our use case:
- It’s solely fired when the characteristic is supported and used; we don’t need to adapt the design in any other case.
- We get the dimensions of the title bar space throughout working programs, which is nice as a result of the dimensions of the window controls is totally different on Mac and Home windows. Utilizing a media question wouldn’t make it potential for us to know precisely how a lot house stays.
.slender header {
prime: env(titlebar-area-height, 0);
left: 0;
width: 100%;
}
Utilizing the above CSS code, we are able to transfer our header down to remain away from the window management buttons when the window is simply too slender, and transfer the thumbnails down accordingly.
Thirty pixels of thrilling design alternatives#section10
Utilizing the Window Controls Overlay characteristic, we have been in a position to take our easy demo app and switch it into one thing that feels a lot extra built-in on desktop units. One thing that reaches out of the same old window constraints and offers a customized expertise for its customers.
In actuality, this characteristic solely offers us about 30 pixels of additional room and comes with challenges on methods to take care of the window controls. And but, this further room and people challenges might be became thrilling design alternatives.
Extra units of all shapes and types get invented on a regular basis, and the net retains on evolving to adapt to them. New options get added to the net platform to permit us, internet authors, to combine increasingly more deeply with these units. From watches or foldable units to desktop computer systems, we have to evolve our design method for the net. Constructing for the net now lets us assume exterior the oblong field.
So let’s embrace this. Let’s use the usual applied sciences already at our disposal, and experiment with new concepts to offer tailor-made experiences for all units, all from a single codebase!
If you happen to get an opportunity to strive the Window Controls Overlay characteristic and have suggestions about it, you possibly can open points on the spec’s repository. It’s nonetheless early within the improvement of this characteristic, and you’ll assist make it even higher. Or, you possibly can check out the characteristic’s current documentation, or this demo app and its supply code.