Window creation and management. Electron-compatible API.
import { BrowserWindow } from 'voltkit';
const win = new BrowserWindow({
width: 1024,
height: 768,
title: 'My Window',
});Options: WindowOptions (all optional)
| Option | Type | Default | Description |
|---|---|---|---|
width |
number |
800 |
Window width in pixels |
height |
number |
600 |
Window height in pixels |
title |
string |
'Volt' |
Window title |
resizable |
boolean |
true |
Whether the window is resizable |
decorations |
boolean |
true |
Show title bar and borders |
minWidth / minHeight |
number |
— | Minimum dimensions |
maxWidth / maxHeight |
number |
— | Maximum dimensions |
transparent |
boolean |
false |
Transparent background |
alwaysOnTop |
boolean |
false |
Always-on-top mode |
maximized |
boolean |
false |
Start maximized |
x / y |
number |
— | Initial position |
Load a URL in the window's WebView.
- Allowed protocols:
http:,https:,volt: - Throws if the URL is invalid or uses any other protocol (for example
javascript:ordata:)
Load a local file (creates a file:// URL).
Get the currently loaded URL.
Get the unique window ID (UUID).
Get or set the window title.
Get or set the window size. Setting emits 'resize'.
Get or set the window position. Setting emits 'move'.
Get or set whether the window is resizable.
Get or set always-on-top mode.
Maximize the window. Emits 'maximize'.
Minimize the window. Emits 'minimize'.
Restore from maximized/minimized state. Emits 'restore'.
Close and destroy the window.
Destroy the window and free resources. Emits 'closed'. Safe to call multiple times.
Check if the window has been destroyed. All methods except isDestroyed() throw after destruction.
Get all open windows.
Get the currently focused window, or null.
Find a window by its ID.
| Event | Description |
|---|---|
'closed' |
Window was destroyed |
'focus' |
Window gained focus |
'blur' |
Window lost focus |
'maximize' |
Window was maximized |
'minimize' |
Window was minimized |
'restore' |
Window was restored |
'resize' |
Window was resized |
'move' |
Window was moved |