v150 · Window Management
Custom Titlebar
The full VDI pattern: a bespoke titlebar drawn in HTML with app-region: drag, window-control buttons marked app-region: no-drag and wired to window.minimize/maximize/restore(), and a CSS @media (display-state: maximized) rule that swaps the maximize and restore buttons with zero JavaScript.
This titlebar is your app's own HTML. The label area is a draggable region; the four buttons are not.
In an installed app, dragging the label moves the OS window (app-region: drag), and the maximize button becomes a restore button automatically when (display-state: maximized) matches.
Reported display-state: reading…
Preview the CSS button-swap
Click a window control above to invoke the real API.
<header class="titlebar"> /* app-region: drag → moves the window */
<div class="win-controls"> /* app-region: no-drag → clickable buttons */
<button id="minimize-btn"></button>
<button id="maximize-btn"></button>
<button id="restore-btn"></button>
</div>
</header>
#restore-btn { display: none; }
@media (display-state: maximized) { /* pure-CSS toggle, no JS */
#restore-btn { display: block; }
#maximize-btn { display: none; }
}
minimizeBtn.onclick = () => window.minimize();
maximizeBtn.onclick = () => window.maximize();
restoreBtn.onclick = () => window.restore();