Skip to content
Tauri

window

Provides APIs to create windows, communicate with other windows and manipulate the current window.

Events can be listened to using Window.listen:

import { getCurrentWindow } from "@tauri-apps/api/window";
getCurrentWindow().listen("my-window-event", ({ event, payload }) => { });

Re-exports Color

Re-exports DragDropEvent

Re-exports LogicalPosition

Re-exports LogicalSize

Re-exports PhysicalPosition

Re-exports PhysicalSize

Background throttling policy

2.0.0

Disabled: "disabled";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2051

Suspend: "suspend";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2053

Throttle: "throttle";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2052


Platform-specific window effects

2.0.0

Acrylic: "acrylic";

Windows 10/11

This effect has bad performance when resizing/dragging the window on Windows 10 v1903+ and Windows 11 build 22000.

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2167

AppearanceBased: "appearanceBased";

A default material appropriate for the view’s effectiveAppearance. macOS 10.14-

since macOS 10.14. You should instead choose an appropriate semantic material.

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2067

Blur: "blur";

Windows 7/10/11(22H1) Only

This effect has bad performance when resizing/dragging the window on Windows 11 build 22621.

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2159

ContentBackground: "contentBackground";

macOS 10.14+

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2139

Dark: "dark";

macOS 10.14-

since macOS 10.14. Use a semantic material instead.

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2079

FullScreenUI: "fullScreenUI";

macOS 10.14+

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2131

HeaderView: "headerView";

macOS 10.14+

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2115

HudWindow: "hudWindow";

macOS 10.14+

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2127

Light: "light";

macOS 10.14-

since macOS 10.14. Use a semantic material instead.

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2073

MediumLight: "mediumLight";

macOS 10.14-

since macOS 10.14. Use a semantic material instead.

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2085

Menu: "menu";

macOS 10.11+

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2103

Mica: "mica";

Windows 11 Only

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2151

Popover: "popover";

macOS 10.11+

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2107

Selection: "selection";

macOS 10.10+

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2099

Sheet: "sheet";

macOS 10.14+

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2119

Sidebar: "sidebar";

macOS 10.11+

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2111

Tabbed: "tabbed";

Tabbed effect that matches the system dark perefence Windows 11 Only

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2171

TabbedDark: "tabbedDark";

Tabbed effect with dark mode but only if dark mode is enabled on the system Windows 11 Only

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2175

TabbedLight: "tabbedLight";

Tabbed effect with light mode Windows 11 Only

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2179

Titlebar: "titlebar";

macOS 10.10+

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2095

Tooltip: "tooltip";

macOS 10.14+

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2135

UltraDark: "ultraDark";

macOS 10.14-

since macOS 10.14. Use a semantic material instead.

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2091

UnderPageBackground: "underPageBackground";

macOS 10.14+

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2147

UnderWindowBackground: "underWindowBackground";

macOS 10.14+

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2143

WindowBackground: "windowBackground";

macOS 10.14+

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2123


Window effect state macOS only

https://developer.apple.com/documentation/appkit/nsvisualeffectview/state

2.0.0

Active: "active";

Make window effect state always active macOS only

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2197

FollowsWindowActiveState: "followsWindowActiveState";

Make window effect state follow the window’s active state macOS only

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2193

Inactive: "inactive";

Make window effect state always inactive macOS only

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2201


Error: "error";

Error state. Treated as Normal on linux

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L190

Indeterminate: "indeterminate";

Indeterminate state. Treated as Normal on Linux and macOS

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L182

None: "none";

Hide progress bar.

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L174

Normal: "normal";

Normal state.

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L178

Paused: "paused";

Paused state. Treated as Normal on Linux

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L186


Attention type to request on a window.

1.0.0

Critical: 1;
  • macOS: Bounces the dock icon until the application is in focus.
  • Windows: Flashes both the window and the taskbar button until the application is in focus.

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L99

Informational: 2;
  • macOS: Bounces the dock icon once.
  • Windows: Flashes the taskbar button until the application is in focus.

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L105

new CloseRequestedEvent(event): CloseRequestedEvent
ParameterType
eventEvent<unknown>

CloseRequestedEvent

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L115

PropertyTypeDescriptionDefined in
eventEventNameEvent nameSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L110
idnumberEvent identifier used to unlistenSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L112

isPreventDefault(): boolean

boolean

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L124

preventDefault(): void

void

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L120


Create new window or get a handle to an existing one.

Windows are identified by a label a unique identifier that can be used to reference it later. It may only contain alphanumeric characters a-zA-Z plus the following special characters -, /, : and _.

import { Window } from "@tauri-apps/api/window"
const appWindow = new Window('theUniqueLabel');
appWindow.once('tauri://created', function () {
// window successfully created
});
appWindow.once('tauri://error', function (e) {
// an error happened creating the window
});
// emit an event to the backend
await appWindow.emit("some-event", "data");
// listen to an event from the backend
const unlisten = await appWindow.listen("event-name", e => {});
unlisten();

2.0.0

new Window(label, options): Window

Creates a new Window.

ParameterTypeDescription
labelstringThe unique window label. Must be alphanumeric: a-zA-Z-/:_.
optionsWindowOptions-

Window

The Window instance to communicate with the window.

import { Window } from '@tauri-apps/api/window';
const appWindow = new Window('my-label');
appWindow.once('tauri://created', function () {
// window successfully created
});
appWindow.once('tauri://error', function (e) {
// an error happened creating the window
});

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L298

PropertyTypeDescriptionDefined in
labelstringThe window label. It is a unique identifier for the window, can be used to reference it later.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L276
listenersRecord<string, EventCallback<any>[]>Local event listeners.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L279

center(): Promise<void>

Centers the window.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().center();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L835

clearEffects(): Promise<void>

Clear any applied effects if possible.

Promise<void>

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1223

close(): Promise<void>

Closes the window.

Note this emits a closeRequested event so you can intercept it. To force window close, use Window.destroy.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().close();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1144

destroy(): Promise<void>

Destroys the window. Behaves like Window.close but forces the window close instead of emitting a closeRequested event.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().destroy();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1160

emit<T>(event, payload?): Promise<void>

Emits an event to all targets.

Type Parameter
T
ParameterTypeDescription
eventstringEvent name. Must include only alphanumeric characters, -, /, : and _.
payload?TEvent payload.

Promise<void>

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().emit('window-loaded', { loggedIn: true, token: 'authToken' });

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L449

emitTo<T>(
target,
event,
payload?): Promise<void>

Emits an event to all targets matching the given target.

Type Parameter
T
ParameterTypeDescription
targetstring | EventTargetLabel of the target Window/Webview/WebviewWindow or raw EventTarget object.
eventstringEvent name. Must include only alphanumeric characters, -, /, : and _.
payload?TEvent payload.

Promise<void>

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().emit('main', 'window-loaded', { loggedIn: true, token: 'authToken' });

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L476

hide(): Promise<void>

Sets the window visibility to false.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().hide();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1126

innerPosition(): Promise<PhysicalPosition>

The position of the top-left hand corner of the window’s client area relative to the top-left hand corner of the desktop.

Promise<PhysicalPosition>

The window’s inner position.

import { getCurrentWindow } from '@tauri-apps/api/window';
const position = await getCurrentWindow().innerPosition();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L537

innerSize(): Promise<PhysicalSize>

The physical size of the window’s client area. The client area is the content of the window, excluding the title bar and borders.

Promise<PhysicalSize>

The window’s inner size.

import { getCurrentWindow } from '@tauri-apps/api/window';
const size = await getCurrentWindow().innerSize();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L570

isAlwaysOnTop(): Promise<boolean>

Whether the window is configured to be always on top of other windows or not.

Promise<boolean>

Whether the window is visible or not.

import { getCurrentWindow } from '@tauri-apps/api/window';
const alwaysOnTop = await getCurrentWindow().isAlwaysOnTop();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L817

isClosable(): Promise<boolean>

Gets the window’s native close button state.

  • iOS / Android: Unsupported.

Promise<boolean>

Whether the window’s native close button is enabled or not.

import { getCurrentWindow } from '@tauri-apps/api/window';
const closable = await getCurrentWindow().isClosable();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L750

isDecorated(): Promise<boolean>

Gets the window’s current decorated state.

Promise<boolean>

Whether the window is decorated or not.

import { getCurrentWindow } from '@tauri-apps/api/window';
const decorated = await getCurrentWindow().isDecorated();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L671

isEnabled(): Promise<boolean>

Whether the window is enabled or disabled.

Promise<boolean>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setEnabled(false);

2.0.0

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L927

isFocused(): Promise<boolean>

Gets the window’s current focus state.

Promise<boolean>

Whether the window is focused or not.

import { getCurrentWindow } from '@tauri-apps/api/window';
const focused = await getCurrentWindow().isFocused();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L655

isFullscreen(): Promise<boolean>

Gets the window’s current fullscreen state.

Promise<boolean>

Whether the window is in fullscreen mode or not.

import { getCurrentWindow } from '@tauri-apps/api/window';
const fullscreen = await getCurrentWindow().isFullscreen();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L609

isMaximizable(): Promise<boolean>

Gets the window’s native maximize button state.

  • Linux / iOS / Android: Unsupported.

Promise<boolean>

Whether the window’s native maximize button is enabled or not.

import { getCurrentWindow } from '@tauri-apps/api/window';
const maximizable = await getCurrentWindow().isMaximizable();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L708

isMaximized(): Promise<boolean>

Gets the window’s current maximized state.

Promise<boolean>

Whether the window is maximized or not.

import { getCurrentWindow } from '@tauri-apps/api/window';
const maximized = await getCurrentWindow().isMaximized();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L639

isMinimizable(): Promise<boolean>

Gets the window’s native minimize button state.

  • Linux / iOS / Android: Unsupported.

Promise<boolean>

Whether the window’s native minimize button is enabled or not.

import { getCurrentWindow } from '@tauri-apps/api/window';
const minimizable = await getCurrentWindow().isMinimizable();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L729

isMinimized(): Promise<boolean>

Gets the window’s current minimized state.

Promise<boolean>

import { getCurrentWindow } from '@tauri-apps/api/window';
const minimized = await getCurrentWindow().isMinimized();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L623

isResizable(): Promise<boolean>

Gets the window’s current resizable state.

Promise<boolean>

Whether the window is resizable or not.

import { getCurrentWindow } from '@tauri-apps/api/window';
const resizable = await getCurrentWindow().isResizable();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L687

isVisible(): Promise<boolean>

Gets the window’s current visible state.

Promise<boolean>

Whether the window is visible or not.

import { getCurrentWindow } from '@tauri-apps/api/window';
const visible = await getCurrentWindow().isVisible();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L766

listen<T>(event, handler): Promise<UnlistenFn>

Listen to an emitted event on this window.

Type Parameter
T
ParameterTypeDescription
eventEventNameEvent name. Must include only alphanumeric characters, -, /, : and _.
handlerEventCallback<T>Event handler.

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.

import { getCurrentWindow } from '@tauri-apps/api/window';
const unlisten = await getCurrentWindow().listen<string>('state-changed', (event) => {
console.log(`Got error: ${payload}`);
});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
unlisten();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L387

maximize(): Promise<void>

Maximizes the window.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().maximize();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1030

minimize(): Promise<void>

Minimizes the window.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().minimize();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1078

onCloseRequested(handler): Promise<UnlistenFn>

Listen to window close requested. Emitted when the user requests to closes the window.

ParameterType
handler(event) => void | Promise<void>

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.

import { getCurrentWindow } from "@tauri-apps/api/window";
import { confirm } from '@tauri-apps/api/dialog';
const unlisten = await getCurrentWindow().onCloseRequested(async (event) => {
const confirmed = await confirm('Are you sure?');
if (!confirmed) {
// user did not confirm closing the window; let's prevent it
event.preventDefault();
}
});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
unlisten();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1845

onDragDropEvent(handler): Promise<UnlistenFn>

Listen to a file drop event. The listener is triggered when the user hovers the selected files on the webview, drops the files or cancels the operation.

ParameterType
handlerEventCallback<DragDropEvent>

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.

import { getCurrentWindow } from "@tauri-apps/api/webview";
const unlisten = await getCurrentWindow().onDragDropEvent((event) => {
if (event.payload.type === 'over') {
console.log('User hovering', event.payload.position);
} else if (event.payload.type === 'drop') {
console.log('User dropped', event.payload.paths);
} else {
console.log('File drop cancelled');
}
});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
unlisten();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1883

onFocusChanged(handler): Promise<UnlistenFn>

Listen to window focus change.

ParameterType
handlerEventCallback<boolean>

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.

import { getCurrentWindow } from "@tauri-apps/api/window";
const unlisten = await getCurrentWindow().onFocusChanged(({ payload: focused }) => {
console.log('Focus changed, window is focused? ' + focused);
});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
unlisten();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1961

onMoved(handler): Promise<UnlistenFn>

Listen to window move.

ParameterType
handlerEventCallback<PhysicalPosition>

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.

import { getCurrentWindow } from "@tauri-apps/api/window";
const unlisten = await getCurrentWindow().onMoved(({ payload: position }) => {
console.log('Window moved', position);
});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
unlisten();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1816

onResized(handler): Promise<UnlistenFn>

Listen to window resize.

ParameterType
handlerEventCallback<PhysicalSize>

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.

import { getCurrentWindow } from "@tauri-apps/api/window";
const unlisten = await getCurrentWindow().onResized(({ payload: size }) => {
console.log('Window resized', size);
});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
unlisten();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1792

onScaleChanged(handler): Promise<UnlistenFn>

Listen to window scale change. Emitted when the window’s scale factor has changed. The following user actions can cause DPI changes:

  • Changing the display’s resolution.
  • Changing the display’s scale factor (e.g. in Control Panel on Windows).
  • Moving the window to a display with a different scale factor.
ParameterType
handlerEventCallback<ScaleFactorChanged>

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.

import { getCurrentWindow } from "@tauri-apps/api/window";
const unlisten = await getCurrentWindow().onScaleChanged(({ payload }) => {
console.log('Scale changed', payload.scaleFactor, payload.size);
});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
unlisten();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2001

onThemeChanged(handler): Promise<UnlistenFn>

Listen to the system theme change.

ParameterType
handlerEventCallback<Theme>

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.

import { getCurrentWindow } from "@tauri-apps/api/window";
const unlisten = await getCurrentWindow().onThemeChanged(({ payload: theme }) => {
console.log('New theme: ' + theme);
});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
unlisten();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2027

once<T>(event, handler): Promise<UnlistenFn>

Listen to an emitted event on this window only once.

Type Parameter
T
ParameterTypeDescription
eventEventNameEvent name. Must include only alphanumeric characters, -, /, : and _.
handlerEventCallback<T>Event handler.

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.

import { getCurrentWindow } from '@tauri-apps/api/window';
const unlisten = await getCurrentWindow().once<null>('initialized', (event) => {
console.log(`Window initialized!`);
});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
unlisten();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L422

outerPosition(): Promise<PhysicalPosition>

The position of the top-left hand corner of the window relative to the top-left hand corner of the desktop.

Promise<PhysicalPosition>

The window’s outer position.

import { getCurrentWindow } from '@tauri-apps/api/window';
const position = await getCurrentWindow().outerPosition();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L553

outerSize(): Promise<PhysicalSize>

The physical size of the entire window. These dimensions include the title bar and borders. If you don’t want that (and you usually don’t), use inner_size instead.

Promise<PhysicalSize>

The window’s outer size.

import { getCurrentWindow } from '@tauri-apps/api/window';
const size = await getCurrentWindow().outerSize();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L590

requestUserAttention(requestType): Promise<void>

Requests user attention to the window, this has no effect if the application is already focused. How requesting for user attention manifests is platform dependent, see UserAttentionType for details.

Providing null will unset the request for user attention. Unsetting the request for user attention might not be done automatically by the WM when the window receives input.

  • macOS: null has no effect.
  • Linux: Urgency levels have the same effect.
ParameterType
requestTypenull | UserAttentionType

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().requestUserAttention();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L861

scaleFactor(): Promise<number>

The scale factor that can be used to map physical pixels to logical pixels.

Promise<number>

The window’s monitor scale factor.

import { getCurrentWindow } from '@tauri-apps/api/window';
const factor = await getCurrentWindow().scaleFactor();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L521

setAlwaysOnBottom(alwaysOnBottom): Promise<void>

Whether the window should always be below other windows.

ParameterTypeDescription
alwaysOnBottombooleanWhether the window should always be below other windows or not.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setAlwaysOnBottom(true);

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1259

setAlwaysOnTop(alwaysOnTop): Promise<void>

Whether the window should always be on top of other windows.

ParameterTypeDescription
alwaysOnTopbooleanWhether the window should always be on top of other windows or not.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setAlwaysOnTop(true);

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1241

setBackgroundColor(color): Promise<void>

Sets the window background color.

  • Windows: alpha channel is ignored.
  • iOS / Android: Unsupported.
ParameterType
colorColor

Promise<void>

A promise indicating the success or failure of the operation.

2.1.0

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1553

setBadgeCount(count?): Promise<void>

Sets the badge count. It is app wide and not specific to this window.

  • Windows: Unsupported. Use @{linkcode Window.setOverlayIcon} instead.
ParameterTypeDescription
count?numberThe badge count. Use undefined to remove the badge.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setBadgeCount(5);

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1645

setBadgeLabel(label?): Promise<void>

Sets the badge cont macOS only.

ParameterTypeDescription
label?stringThe badge label. Use undefined to remove the badge.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setBadgeLabel("Hello");

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1664

setClosable(closable): Promise<void>

Sets whether the window’s native close button is enabled or not.

  • Linux: GTK+ will do its best to convince the window manager not to show a close button. Depending on the system, this function may not have any effect when called on a window that is already visible
  • iOS / Android: Unsupported.
ParameterType
closableboolean

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setClosable(false);

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L995

setContentProtected(protected_): Promise<void>

Prevents the window contents from being captured by other apps.

ParameterType
protected_boolean

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setContentProtected(true);

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1276

setCursorGrab(grab): Promise<void>

Grabs the cursor, preventing it from leaving the window.

There’s no guarantee that the cursor will be hidden. You should hide it by yourself if you want so.

  • Linux: Unsupported.
  • macOS: This locks the cursor in a fixed location, which looks visually awkward.
ParameterTypeDescription
grabbooleantrue to grab the cursor icon, false to release it.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setCursorGrab(true);

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1492

setCursorIcon(icon): Promise<void>

Modifies the cursor icon of the window.

ParameterTypeDescription
iconCursorIconThe new cursor icon.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setCursorIcon('help');

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1534

setCursorPosition(position): Promise<void>

Changes the position of the cursor in window coordinates.

ParameterTypeDescription
positionLogicalPosition | PhysicalPosition | PositionThe new cursor position.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow, LogicalPosition } from '@tauri-apps/api/window';
await getCurrentWindow().setCursorPosition(new LogicalPosition(600, 300));

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1568

setCursorVisible(visible): Promise<void>

Modifies the cursor’s visibility.

  • Windows: The cursor is only hidden within the confines of the window.
  • macOS: The cursor is hidden as long as the window has input focus, even if the cursor is outside of the window.
ParameterTypeDescription
visiblebooleanIf false, this will hide the cursor. If true, this will show the cursor.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setCursorVisible(false);

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1516

setDecorations(decorations): Promise<void>

Whether the window should have borders and bars.

ParameterTypeDescription
decorationsbooleanWhether the window should have borders and bars.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setDecorations(false);

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1177

setEffects(effects): Promise<void>

Set window effects.

ParameterType
effectsEffects

Promise<void>

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1213

setEnabled(enabled): Promise<void>

Enable or disable the window.

ParameterType
enabledboolean

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setEnabled(false);

2.0.0

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L908

setFocus(): Promise<void>

Bring the window to front and focus.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setFocus();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1418

setFullscreen(fullscreen): Promise<void>

Sets the window fullscreen state.

ParameterTypeDescription
fullscreenbooleanWhether the window should go to fullscreen or not.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setFullscreen(true);

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1401

setIcon(icon): Promise<void>

Sets the window icon.

ParameterTypeDescription
icon| string | number[] | ArrayBuffer | Uint8Array<ArrayBufferLike> | ImageIcon bytes or path to the icon file.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setIcon('/tauri/awesome.png');

Note that you may need the image-ico or image-png Cargo features to use this API. To enable it, change your Cargo.toml file:

[dependencies]
tauri = { version = "...", features = ["...", "image-png"] }

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1442

setIgnoreCursorEvents(ignore): Promise<void>

Changes the cursor events behavior.

ParameterTypeDescription
ignorebooleantrue to ignore the cursor events; false to process them as usual.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setIgnoreCursorEvents(true);

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1589

setMaxSize(size): Promise<void>

Sets the window maximum inner size. If the size argument is undefined, the constraint is unset.

ParameterTypeDescription
size| undefined | null | LogicalSize | PhysicalSize | SizeThe logical or physical inner size, or null to unset the constraint.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow, LogicalSize } from '@tauri-apps/api/window';
await getCurrentWindow().setMaxSize(new LogicalSize(600, 500));

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1332

setMaximizable(maximizable): Promise<void>

Sets whether the window’s native maximize button is enabled or not. If resizable is set to false, this setting is ignored.

  • macOS: Disables the “zoom” button in the window titlebar, which is also used to enter fullscreen mode.
  • Linux / iOS / Android: Unsupported.
ParameterType
maximizableboolean

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setMaximizable(false);

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L950

setMinSize(size): Promise<void>

Sets the window minimum inner size. If the size argument is not provided, the constraint is unset.

ParameterTypeDescription
size| undefined | null | LogicalSize | PhysicalSize | SizeThe logical or physical inner size, or null to unset the constraint.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow, PhysicalSize } from '@tauri-apps/api/window';
await getCurrentWindow().setMinSize(new PhysicalSize(600, 500));

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1312

setMinimizable(minimizable): Promise<void>

Sets whether the window’s native minimize button is enabled or not.

  • Linux / iOS / Android: Unsupported.
ParameterType
minimizableboolean

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setMinimizable(false);

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L972

setOverlayIcon(icon?): Promise<void>

Sets the overlay icon. Windows only The overlay icon can be set for every window.

Note that you may need the image-ico or image-png Cargo features to use this API. To enable it, change your Cargo.toml file:

[dependencies]
tauri = { version = "...", features = ["...", "image-png"] }
ParameterTypeDescription
icon?| string | number[] | ArrayBuffer | Uint8Array<ArrayBufferLike> | ImageIcon bytes or path to the icon file. Use undefined to remove the overlay icon.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setOverlayIcon("/tauri/awesome.png");

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1693

setPosition(position): Promise<void>

Sets the window outer position.

ParameterTypeDescription
positionLogicalPosition | PhysicalPosition | PositionThe new position, in logical or physical pixels.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow, LogicalPosition } from '@tauri-apps/api/window';
await getCurrentWindow().setPosition(new LogicalPosition(600, 500));

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1381

setProgressBar(state): Promise<void>

Sets the taskbar progress state.

  • Linux / macOS: Progress bar is app-wide and not specific to this window.
  • Linux: Only supported desktop environments with libunity (e.g. GNOME).
ParameterType
stateProgressBarState

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow, ProgressBarStatus } from '@tauri-apps/api/window';
await getCurrentWindow().setProgressBar({
status: ProgressBarStatus.Normal,
progress: 50,
});

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1721

setResizable(resizable): Promise<void>

Updates the window resizable flag.

ParameterType
resizableboolean

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setResizable(false);

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L889

setShadow(enable): Promise<void>

Whether or not the window should have shadow.

  • Windows:
    • false has no effect on decorated window, shadows are always ON.
    • true will make undecorated window have a 1px white border, and on Windows 11, it will have a rounded corners.
  • Linux: Unsupported.
ParameterType
enableboolean

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setShadow(false);

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1203

setSize(size): Promise<void>

Resizes the window with a new inner size.

ParameterTypeDescription
sizeLogicalSize | PhysicalSize | SizeThe logical or physical inner size.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow, LogicalSize } from '@tauri-apps/api/window';
await getCurrentWindow().setSize(new LogicalSize(600, 500));

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1294

setSizeConstraints(constraints): Promise<void>

Sets the window inner size constraints.

ParameterTypeDescription
constraintsundefined | null | WindowSizeConstraintsThe logical or physical inner size, or null to unset the constraint.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setSizeConstraints({ minWidth: 300 });

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1352

setSkipTaskbar(skip): Promise<void>

Whether the window icon should be hidden from the taskbar or not.

  • macOS: Unsupported.
ParameterTypeDescription
skipbooleantrue to hide window icon, false to show it.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setSkipTaskbar(true);

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1466

setTheme(theme?): Promise<void>

Set window theme, pass in null or undefined to follow system theme

  • Linux / macOS: Theme is app-wide and not specific to this window.
  • iOS / Android: Unsupported.
ParameterType
theme?null | Theme

Promise<void>

2.0.0

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1766

setTitle(title): Promise<void>

Sets the window title.

ParameterTypeDescription
titlestringThe new title

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().setTitle('Tauri');

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1013

setTitleBarStyle(style): Promise<void>

Sets the title bar style. macOS only.

ParameterType
styleTitleBarStyle

Promise<void>

2.0.0

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1749

setVisibleOnAllWorkspaces(visible): Promise<void>

Sets whether the window should be visible on all workspaces or virtual desktops.

  • Windows / iOS / Android: Unsupported.
ParameterType
visibleboolean

Promise<void>

2.0.0

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1737

show(): Promise<void>

Sets the window visibility to true.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().show();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1110

startDragging(): Promise<void>

Starts dragging the window.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().startDragging();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1606

startResizeDragging(direction): Promise<void>

Starts resize-dragging the window.

ParameterType
directionResizeDirection

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().startResizeDragging();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1622

theme(): Promise<null | Theme>

Gets the window’s current theme.

  • macOS: Theme was introduced on macOS 10.14. Returns light on macOS 10.13 and below.

Promise<null | Theme>

The window theme.

import { getCurrentWindow } from '@tauri-apps/api/window';
const theme = await getCurrentWindow().theme();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L801

title(): Promise<string>

Gets the window’s current title.

Promise<string>

import { getCurrentWindow } from '@tauri-apps/api/window';
const title = await getCurrentWindow().title();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L780

toggleMaximize(): Promise<void>

Toggles the window maximized state.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().toggleMaximize();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1062

unmaximize(): Promise<void>

Unmaximizes the window.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().unmaximize();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1046

unminimize(): Promise<void>

Unminimizes the window.

Promise<void>

A promise indicating the success or failure of the operation.

import { getCurrentWindow } from '@tauri-apps/api/window';
await getCurrentWindow().unminimize();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1094

static getAll(): Promise<Window[]>

Gets a list of instances of Window for all available windows.

Promise<Window[]>

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L345

static getByLabel(label): Promise<null | Window>

Gets the Window associated with the given label.

ParameterTypeDescription
labelstringThe window label.

Promise<null | Window>

The Window instance to communicate with the window or null if the window doesn’t exist.

import { Window } from '@tauri-apps/api/window';
const mainWindow = Window.getByLabel('main');

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L331

static getCurrent(): Window

Get an instance of Window for the current window.

Window

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L338

static getFocusedWindow(): Promise<null | Window>

Gets the focused window.

Promise<null | Window>

The Window instance or undefined if there is not any focused window.

import { Window } from '@tauri-apps/api/window';
const focusedWindow = Window.getFocusedWindow();

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L359

The window effects configuration object

2.0.0

PropertyTypeDescriptionDefined in
color?ColorWindow effect color. Affects Effect.Blur and Effect.Acrylic only on Windows 10 v1903+. Doesn’t have any effect on Windows 7 or Windows 11.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2226
effectsEffect[]List of Window effects to apply to the Window. Conflicting effects will apply the first one and ignore the rest.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2213
radius?numberWindow effect corner radius macOS OnlySource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2221
state?EffectStateWindow effect state macOS OnlySource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2217

Allows you to retrieve information about a given monitor.

1.0.0

PropertyTypeDescriptionDefined in
namenull | stringHuman-readable name of the monitorSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L49
positionPhysicalPositionthe Top-left corner position of the monitor relative to the larger full screen area.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L53
scaleFactornumberThe scale factor that can be used to map physical pixels to logical pixels.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L60
sizePhysicalSizeThe monitor’s resolution.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L51
workAreaobjectThe monitor’s work area.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L55
workArea.positionPhysicalPosition-Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L56
workArea.sizePhysicalSize-Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L57

PropertyTypeDescriptionDefined in
progress?numberThe progress bar progress. This can be a value ranging from 0 to 100Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L208
status?ProgressBarStatusThe progress bar status.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L204

The payload for the scaleChange event.

1.0.2

PropertyTypeDescriptionDefined in
scaleFactornumberThe new window scale factor.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L83
sizePhysicalSizeThe new window sizeSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L85

Configuration for the window to create.

1.0.0

PropertyTypeDescriptionDefined in
allowLinkPreview?booleanon macOS and iOS there is a link preview on long pressing links, this is enabled by default. see https://docs.rs/objc2-web-kit/latest/objc2_web_kit/struct.WKWebView.html#method.allowsLinkPreviewSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2418
alwaysOnBottom?booleanWhether the window should always be below other windows.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2299
alwaysOnTop?booleanWhether the window should always be on top of other windows or not.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2297
backgroundColor?ColorSet the window background color. #### Platform-specific: - Android / iOS: Unsupported. - Windows: alpha channel is ignored. Since 2.1.0Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2395
backgroundThrottling?BackgroundThrottlingPolicyChange the default background throttling behaviour. ## Platform-specific - Linux / Windows / Android: Unsupported. Workarounds like a pending WebLock transaction might suffice. - iOS: Supported since version 17.0+. - macOS: Supported since version 14.0+. see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578 Since 2.3.0Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2409
center?booleanShow window in the center of the screen..Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2244
closable?booleanWhether the window’s native close button is enabled or not. Defaults to true.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2350
contentProtected?booleanPrevents the window contents from being captured by other apps.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2301
decorations?booleanWhether the window should have borders and bars or not.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2295
disableInputAccessoryView?booleanAllows disabling the input accessory view on iOS. The accessory view is the view that appears above the keyboard when a text input element is focused. It usually displays a view with “Done”, “Next” buttons.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2425
focus?booleanWhether the window will be initially focused or not.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2283
fullscreen?booleanWhether the window is in fullscreen mode or not.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2281
height?numberThe initial height.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2252
hiddenTitle?booleanIf true, sets the window title to be hidden on macOS.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2331
javascriptDisabled?booleanWhether we should disable JavaScript code execution on the webview or not.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2413
maxHeight?numberThe maximum height. Only applies if maxWidth is also set.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2260
maxWidth?numberThe maximum width. Only applies if maxHeight is also set.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2258
maximizable?booleanWhether the window’s native maximize button is enabled or not. Defaults to true.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2342
maximized?booleanWhether the window should be maximized upon creation or not.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2291
minHeight?numberThe minimum height. Only applies if minWidth is also set.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2256
minWidth?numberThe minimum width. Only applies if minHeight is also set.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2254
minimizable?booleanWhether the window’s native minimize button is enabled or not. Defaults to true.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2346
parent?string | Window | WebviewWindowSets a parent to the window to be created. Can be either a Window or a label of the window. #### Platform-specific - Windows: This sets the passed parent as an owner window to the window to be created. From MSDN owned windows docs: - An owned window is always above its owner in the z-order. - The system automatically destroys an owned window when its owner is destroyed. - An owned window is hidden when its owner is minimized. - Linux: This makes the new window transient for parent, see https://docs.gtk.org/gtk3/method.Window.set_transient_for.html - macOS: This adds the window as a child of parent, see https://developer.apple.com/documentation/appkit/nswindow/1419152-addchildwindow?language=objcSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2364
preventOverflow?boolean | PreventOverflowMarginPrevent the window from overflowing the working area (e.g. monitor size - taskbar size) on creation, which means the window size will be limited to monitor size - taskbar size Can either be set to true or to a PreventOverflowMargin object to set an additional margin that should be considered to determine the working area (in this case the window size will be limited to monitor size - taskbar size - margin) NOTE: The overflow check is only performed on window creation, resizes can still overflow #### Platform-specific - iOS / Android: Unsupported.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2275
resizable?booleanWhether the window is resizable or not.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2277
shadow?booleanWhether or not the window has shadow. #### Platform-specific - Windows: - false has no effect on decorated window, shadows are always ON. - true will make undecorated window have a 1px white border, and on Windows 11, it will have a rounded corners. - Linux: Unsupported. Since 2.0.0Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2317
skipTaskbar?booleanWhether or not the window icon should be added to the taskbar.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2303
tabbingIdentifier?stringDefines the window tabbing identifier on macOS. Windows with the same tabbing identifier will be grouped together. If the tabbing identifier is not set, automatic tabbing will be disabled.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2338
theme?ThemeThe initial window theme. Defaults to the system theme. Only implemented on Windows and macOS 10.14+.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2323
title?stringWindow title.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2279
titleBarStyle?TitleBarStyleThe style of the macOS title bar.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2327
transparent?booleanWhether the window is transparent or not. Note that on macOS this requires the macos-private-api feature flag, enabled under tauri.conf.json > app > macOSPrivateApi. WARNING: Using private APIs on macOS prevents your application from being accepted to the App Store.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2289
visible?booleanWhether the window should be immediately visible upon creation or not.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2293
visibleOnAllWorkspaces?booleanWhether the window should be visible on all workspaces or virtual desktops. #### Platform-specific - Windows / iOS / Android: Unsupported. Since 2.0.0Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2373
width?numberThe initial width.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2250
windowEffects?EffectsWindow effects. Requires the window to be transparent. #### Platform-specific: - Windows: If using decorations or shadows, you may want to try this workaround https://github.com/tauri-apps/tao/issues/72#issuecomment-975607891 - Linux: UnsupportedSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2384
x?numberThe initial vertical position. Only applies if y is also set.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2246
y?numberThe initial horizontal position. Only applies if x is also set.Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2248

PropertyTypeDefined in
maxHeight?numberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L197
maxWidth?numberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L196
minHeight?numberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L195
minWidth?numberSource: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L194

type CursorIcon:
| "default"
| "crosshair"
| "hand"
| "arrow"
| "move"
| "text"
| "wait"
| "help"
| "progress"
| "notAllowed"
| "contextMenu"
| "cell"
| "verticalText"
| "alias"
| "copy"
| "noDrop"
| "grab"
| "grabbing"
| "allScroll"
| "zoomIn"
| "zoomOut"
| "eResize"
| "nResize"
| "neResize"
| "nwResize"
| "sResize"
| "seResize"
| "swResize"
| "wResize"
| "ewResize"
| "nsResize"
| "neswResize"
| "nwseResize"
| "colResize"
| "rowResize";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L129


type Theme: "light" | "dark";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L63


type TitleBarStyle: "visible" | "transparent" | "overlay";

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L64

function availableMonitors(): Promise<Monitor[]>

Returns the list of all the monitors available on the system.

Promise<Monitor[]>

import { availableMonitors } from '@tauri-apps/api/window';
const monitors = await availableMonitors();

1.0.0

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2504


function currentMonitor(): Promise<Monitor | null>

Returns the monitor on which the window currently resides. Returns null if current monitor can’t be detected.

Promise<Monitor | null>

import { currentMonitor } from '@tauri-apps/api/window';
const monitor = await currentMonitor();

1.0.0

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2454


function cursorPosition(): Promise<PhysicalPosition>

Get the cursor position relative to the top-left hand corner of the desktop.

Note that the top-left hand corner of the desktop is not necessarily the same as the screen. If the user uses a desktop with multiple monitors, the top-left hand corner of the desktop is the top-left hand corner of the main monitor on Windows and macOS or the top-left of the leftmost monitor on X11.

The coordinates can be negative if the top-left hand corner of the window is outside of the visible screen region.

Promise<PhysicalPosition>

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2520


function getAllWindows(): Promise<Window[]>

Gets a list of instances of Window for all available windows.

Promise<Window[]>

1.0.0

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L228


function getCurrentWindow(): Window

Get an instance of Window for the current window.

Window

1.0.0

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L216


function monitorFromPoint(x, y): Promise<Monitor | null>

Returns the monitor that contains the given point. Returns null if can’t find any.

ParameterType
xnumber
ynumber

Promise<Monitor | null>

import { monitorFromPoint } from '@tauri-apps/api/window';
const monitor = await monitorFromPoint(100.0, 200.0);

1.0.0

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2487


function primaryMonitor(): Promise<Monitor | null>

Returns the primary monitor of the system. Returns null if it can’t identify any monitor as a primary one.

Promise<Monitor | null>

import { primaryMonitor } from '@tauri-apps/api/window';
const monitor = await primaryMonitor();

1.0.0

Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2471


© 2025 Tauri Contributors. CC-BY / MIT