Skip to content

Window

Window creates and controls a native OS window.

import { Window } from 'uzumaki';
import { createRoot } from 'uzumaki-react';
const window = new Window('main', {
width: 960,
height: 680,
title: 'My App',
theme: 'system',
rootStyles: { bg: '#09090b', color: '#f4f4f5', fontSize: 14 },
});
const root = createRoot(window);
root.render(<App />);

The first argument is a unique label. Use it to find an existing window later.

new Window(label: string, options?: WindowOptions);
OptionDescription
width, heightInitial content size.
titleWindow title.
visibleWhether the window starts visible.
resizableWhether the window can be resized.
decorationsNative titlebar and frame.
transparentTransparent window background.
maximized, minimized, fullscreenInitial window state.
windowLevelnormal, alwaysOnTop, or alwaysOnBottom.
minWidth, minHeight, maxWidth, maxHeightSize constraints.
positionInitial { x, y } screen position.
themelight, dark, or system.
activeWhether the window should become active.
contentProtectedAsk the platform to prevent screen capture when supported.
closable, minimizable, maximizableNative window control availability.
rootStylesProps applied to the root element before render.
window.title = 'Renamed';
window.visible = true;
window.resizable = false;
window.decorations = true;
window.transparent = false;
window.maximized = false;
window.minimized = false;
window.fullscreen = false;
window.windowLevel = 'alwaysOnTop';
window.theme = 'dark';
window.contentProtected = false;
window.closable = true;
window.minimizable = true;
window.maximizable = true;
window.focus();
window.close();
window.requestRedraw();
window.setMinSize(720, 480);
window.setMaxSize(1600, 1200);
window.setPosition(120, 80);
GetterDescription
id, labelInternal id and the label you passed in.
innerWidth, innerHeightCurrent content size.
innerSize, outerSizeCurrent size objects.
positionCurrent window position.
scaleFactorPlatform scale factor.
activeWhether the window is active.
isDisposedWhether the window has been disposed.
rootRoot element of the window’s tree.
remBaseNumber of logical pixels used for 1rem.

remBase is mutable:

window.remBase = 18;
window.on('load', () => {});
window.on('resize', (event) => console.log(event.width, event.height));
window.on('close', () => {});

UI events bubble to the window, which is useful for global shortcuts.

import { Window, getWindow } from 'uzumaki';
const existing = getWindow('main');
const main = existing ?? new Window('main', { width: 800, height: 600 });

Use stable labels such as main, settings, or inspector.