Window scaffold and chrome
Build full-window layouts and custom title bars with WindowScaffold, drag areas, WindowControls, and the macOS and Windows 11 materials.
WindowScaffold lays out a custom title bar and the window content, and keeps the native caption
zones, button order and drag behavior working. It comes with nucleus-application. Use it when
content reaches under the title bar or a design system draws its own chrome; a plain
DecoratedWindow with TitleBar keeps working.
Build a custom title bar
DecoratedWindow(onCloseRequest = ::exitApplication, title = "MyApp") {
MaterialTheme {
WindowBackground(MaterialTheme.colorScheme.background)
WindowScaffold(
titleBar = {
Box(Modifier.fillMaxWidth().height(48.dp).windowDragArea().padding(horizontal = 12.dp)) {
Text("MyApp", Modifier.align(Alignment.CenterStart))
WindowControls(Modifier.align(Alignment.CenterEnd))
}
},
titleBarPlacement = TitleBarPlacement.Overlay(),
) { contentPadding ->
Box(Modifier.fillMaxSize().padding(contentPadding)) { /* content */ }
}
}
}Make WindowScaffold the only child of the window content. It makes nothing draggable: mark the
move surface with windowDragArea.
Place the title bar
TitleBarPlacement | Layout |
|---|---|
Docked | Default. The bar takes its height and the content fills the rest. |
Overlay(autoHideInFullscreen = true, passThroughToContent = false) | The content fills the window, the bar floats on top, and the content gets the bar height as top padding. |
autoHideInFullscreenremoves the bar in fullscreen, and the chrome insets drop to zero.passThroughToContentalso hit-tests presses on the bar against the content below. Turn it on for controls in the title-bar band, such as a tab strip. Leave it off when content scrolls behind an opaque bar.controlButtonsDirection:Autofollows the platform,Rtlmoves the system buttons to the leading edge and flips the macOS traffic lights.
Add drag areas
Modifier.windowDragArea(doubleClickAction = WindowDoubleClickAction.ToggleMaximize)
VerticalScrollbar(adapter, Modifier.noWindowDrag())Buttons and text fields opt out on their own. Wrap scrollbars, sliders and resize handles in
noWindowDrag(). A double-click toggles maximize when the window is resizable and maximizable
or already maximized, except in fullscreen. WindowDoubleClickAction.None turns it off.
Place the window controls
WindowControls(direction = ControlButtonsDirection.Auto, renderer = WindowControlsRenderer.Platform)The buttons follow the window state and its resizable, maximizable and minimizable flags.
Close calls onCloseRequest. On Linux, Auto also follows the desktop's button layout. See
Set the window chrome. When KWin asks the window for no
decorations, WindowControls draws only the exit-fullscreen button and controlsInsets is zero.
See Follow the compositor's decorations.
Platform draws Fluent buttons on Windows and GNOME or KDE buttons on Linux. On macOS it draws
nothing and reserves the traffic-light space. To draw your own buttons, implement
WindowControlsRenderer.Control(type, state, onClick).
Match the window to the app theme
WindowBackground(MaterialTheme.colorScheme.background)
WindowAppearance(if (dark) WindowAppearanceMode.Dark else WindowAppearanceMode.Light)
val insets = LocalWindowChromeInsets.currentWindowBackgroundshows during live resize and wherever Compose paints nothing. Without it, a dark app can flash white while the user resizes.WindowAppearancemakes glass, traffic lights, menus and caption glyphs follow the app theme.Systemfollows the OS. No effect on Linux.insets.controlsInsetsis the space reserved for system controls andtitleBarHeightthe bar height. Both are zero outside aWindowScaffold. Pad with these insets or withWindowControls, not both.
Add a macOS glass region
Modifier.windowGlassRegion(WindowGlassRegionKind.Sidebar, cornerRadius = 12.dp)The region shows the wallpaper-tinted material of System Settings. Leave its background unpainted.
Kinds are Sidebar, ContentList and Inspector (macOS 14+, falls back to ContentList). There
is no full-window glass. No effect on other platforms.
Add a Windows 11 backdrop
WindowsBackdrop(
style = WindowsBackdropStyle.Mica, // Acrylic, MicaAlt, Default, None
tint = Color.Unspecified,
tier = WindowsBackdropTier.Auto, // Modern, LegacyMica, Windows10Acrylic
)The material shows wherever the app paints nothing, and WindowBackground is suspended meanwhile.
An unspecified tint leaves Mica untinted and gives Acrylic the window background at moderate
opacity. Older Windows versions degrade to the closest material. No effect on macOS and Linux.
Windows with a backdrop or transparent = true render grayscale text instead of ClearType.
Make a transparent, borderless window
DecoratedWindow(onCloseRequest = ::exitApplication, undecorated = true, transparent = true) { /* ... */ }transparent is a creation-time flag. Pixels left at alpha 0 show the desktop, and opaque
WindowBackground and title-bar clears become transparent. The Material and Jewel windows take the
same flag. For click-through windows, see Overlay windows.
What's next
- Windows:
DecoratedWindowparameters and the window chrome flags. - Toolkits: prebuilt title bars for Material and Jewel.
- Accessibility: Compose semantics exposed to VoiceOver, Narrator, and Orca.
Last updated on
Window state
Control and observe window size, position, placement, and screen with Compose's WindowState or the AWT-free window API v2 in dev.nucleusframework.window.tao.v2.
Dialogs and popups
Open modal dialogs with DecoratedDialog, DialogWindow, HostedDialog, or a toolkit dialog, and render Compose popups as native surfaces placed against the screen.