Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Multi-Window & Window Management

Perry supports creating multiple native windows and controlling their appearance and behavior. Every snippet below is excerpted from docs/examples/ui/multi_window/snippets.ts — CI compiles and runs it on every PR.

Creating Windows

Window(title, width, height) returns a window handle. Call .setBody() to set its content and .show() to display it:

const settings = Window("Settings", 500, 400)
settings.setBody(VStack(16, [
    Text("Settings panel"),
]))
settings.show()

Window Instance Methods

const win = Window("My Window", 600, 400)

win.setBody(Text("Hello"))   // Set the root widget
win.show()                    // Show the window
win.hide()                    // Hide without destroying
win.setSize(800, 600)         // Resize dynamically
win.onFocusLost(() => {       // Callback when the window loses focus
    win.hide()
})
win.close()                   // Close and destroy
MethodDescription
setBody(widget)Set the root widget of the window
show()Show the window
hide()Hide without destroying — call show() again to reveal
setSize(w, h)Resize dynamically
onFocusLost(cb)Register a callback that fires when focus leaves the window
close()Close and destroy

App Window Properties

The main App({}) config object accepts the same window properties for building launcher-style, overlay, or utility apps:

App({
    title: "QuickLaunch",
    width: 600,
    height: 80,
    body: VStack(8, [
        Text("Search..."),
        Button("Open Settings", () => settings.show()),
    ]),
})

App additionally accepts the optional fields frameless, level, transparent, vibrancy, activationPolicy, and icon. They map to the following native primitives:

frameless: true

Removes the window title bar and frame, creating a borderless window.

PlatformImplementation
macOSNSWindowStyleMask::Borderless + movable by background
WindowsWS_POPUP window style
Linuxset_decorated(false)

level: "floating" | "statusBar" | "modal" | "normal"

Controls the window’s z-order level relative to other windows.

LevelDescription
"normal"Default window level
"floating"Stays above normal windows
"statusBar"Stays above floating windows
"modal"Modal panel level
PlatformImplementation
macOSNSWindow.level (NSFloatingWindowLevel, etc.)
WindowsSetWindowPos with HWND_TOPMOST
Linuxset_modal(true) (best-effort)

transparent: true

Makes the window background transparent, allowing the desktop to show through non-opaque regions of your UI.

PlatformImplementation
macOSisOpaque = false, backgroundColor = .clear
WindowsWS_EX_LAYERED with SetLayeredWindowAttributes
LinuxCSS background-color: transparent

vibrancy: string

Applies a native translucent material to the window background. On macOS this uses the system vibrancy effect; on Windows it uses Mica/Acrylic.

macOS materials: "sidebar", "titlebar", "selection", "menu", "popover", "headerView", "sheet", "windowBackground", "hudWindow", "fullScreenUI", "tooltip", "contentBackground", "underWindowBackground", "underPageBackground"

PlatformImplementation
macOSNSVisualEffectView with the specified material
WindowsDwmSetWindowAttribute(DWMWA_SYSTEMBACKDROP_TYPE) — Mica, Acrylic, or Mica Alt depending on material (Windows 11 22H2+)
LinuxCSS alpha(@window_bg_color, 0.85) (best-effort)

activationPolicy: "regular" | "accessory" | "background"

Controls whether the app appears in the dock/taskbar.

PolicyDescription
"regular"Normal app with dock icon and menu bar (default)
"accessory"No dock icon, no menu bar activation — ideal for launchers and utilities
"background"Fully hidden from dock and app switcher
PlatformImplementation
macOSNSApp.setActivationPolicy()
WindowsWS_EX_TOOLWINDOW (removes from taskbar)
Linuxset_deletable(false) (best-effort)

Platform Notes

PlatformImplementation
macOSNSWindow
WindowsCreateWindowEx (HWND)
LinuxGtkWindow
WebFloating <div>
iOS/AndroidModal view controller / Dialog

On mobile platforms, “windows” are presented as modal views or dialogs since mobile apps typically use a single-window model.

Next Steps