Allow or prevent the user from resizing the window
Enabled by default. Only has a visual effect when .titled(true) is also set.
Pass false to prevent the user from resizing the window
Self for chaining
Set the aspect ratio mode for an image
"fit" (scales to fit within frame) or "fill" (scales to fill frame)
Self for chaining
Set the window's background color
Color as an HSColor object
Self for chaining
Add a button element
or an HSString object (from hs.ui.string()) for reactive text
The button label — a plain JS string for static text,
Self for chaining (apply .fill(), .cornerRadius(), .font(),
Show or hide the close button on the window
Requires .titled(true) to be visible. Enabled by default.
Pass false to hide the close button
Self for chaining
Close and destroy the window
Round the corners of a shape
Corner radius in points
Self for chaining
Fill a shape with a color
Color as an HSColor
Self for chaining
Set the font for a text element
An HSFont object (e.g., HSFont.title())
Self for chaining
Set the text color
Color as HSColor
Self for chaining
Set the frame (size) of an element
Dictionary with w and/or h (can be numbers or percentage strings like "50%")
Self for chaining
Hide the window (keeps it in memory)
Begin a horizontal stack (elements arranged left to right)
Self for chaining (call end() when done)
Add an image element
Image as HSImage object
Self for chaining (apply modifiers like resizable(), aspectRatio(), frame())
Set the window stacking level Controls where this window sits in the macOS window hierarchy.
The level name
Self for chaining
Show or hide the miniaturize (yellow) button on the window
Requires .titled(true) to be visible. Enabled by default.
Pass false to hide the miniaturize button
Self for chaining
Set a callback to fire when the element is clicked
A JavaScript function to call on click
Self for chaining
Set a callback to fire when the cursor enters or leaves the element
A JavaScript function called with true when the cursor enters and false when it leaves
Self for chaining
Set the opacity of an element
Opacity from 0.0 (transparent) to 1.0 (opaque)
Self for chaining
Add padding around a layout container
Padding in points
Self for chaining
Set spacing between elements in a stack
Spacing in points
Self for chaining
Add a stroke (border) to a shape
Color as an HSColor
Self for chaining
Add a text element
or an HSString object (from hs.ui.string()) for reactive text
The text to display — a plain JS string for static text,
Self for chaining (apply modifiers like font(), foregroundColor())
Show or hide the window's title bar
By default windows have a title bar. Pass false to create a borderless window.
.closable(), .miniaturizable(), and .allowResize() only take visual effect
when the window is titled.
Pass false to make the window borderless
Self for chaining
Begin a vertical stack (elements arranged top to bottom)
Self for chaining (call end() when done)
Embed a web browser element created with hs.ui.webview() (macOS 26+)
The element fills the available space in the window layout.
Keep a reference to the element to call navigation methods after the window is shown.
A UIWebView created via hs.ui.webview()
Self for chaining
Set the text shown in the window's title bar
Only visible when .titled(true) is set (the default).
The title bar text
Self for chaining
HSUIWindow
A custom window with declarative UI building*
HSUIWindowallows you to create custom windows with a SwiftUI-like declarative syntax. Build interfaces using shapes, text, images, and layout containers.Building UI Elements
Modifying Elements
Examples
Simple window with text and shapes:*
Window with image:*