コンテンツにスキップ

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 }) => { });

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

Background throttling policy

2.0.0

Disabled: "disabled";

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

Suspend: "suspend";

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

Throttle: "throttle";

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


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

Platform-specific window effects

2.0.0

Acrylic: "acrylic";

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

Windows 10/11

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

AppearanceBased: "appearanceBased";

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

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

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

Blur: "blur";

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

Windows 7/10/11(22H1) Only

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

ContentBackground: "contentBackground";

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

macOS 10.14+

Dark: "dark";

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

macOS 10.14-

since macOS 10.14. Use a semantic material instead.

FullScreenUI: "fullScreenUI";

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

macOS 10.14+

HeaderView: "headerView";

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

macOS 10.14+

HudWindow: "hudWindow";

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

macOS 10.14+

Light: "light";

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

macOS 10.14-

since macOS 10.14. Use a semantic material instead.

MediumLight: "mediumLight";

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

macOS 10.14-

since macOS 10.14. Use a semantic material instead.

Menu: "menu";

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

macOS 10.11+

Mica: "mica";

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

Windows 11 Only

Popover: "popover";

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

macOS 10.11+

Selection: "selection";

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

macOS 10.10+

Sheet: "sheet";

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

macOS 10.14+

Sidebar: "sidebar";

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

macOS 10.11+

Tabbed: "tabbed";

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

Tabbed effect that matches the system dark preference Windows 11 Only

TabbedDark: "tabbedDark";

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

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

TabbedLight: "tabbedLight";

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

Tabbed effect with light mode Windows 11 Only

Titlebar: "titlebar";

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

macOS 10.10+

Tooltip: "tooltip";

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

macOS 10.14+

UltraDark: "ultraDark";

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

macOS 10.14-

since macOS 10.14. Use a semantic material instead.

UnderPageBackground: "underPageBackground";

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

macOS 10.14+

UnderWindowBackground: "underWindowBackground";

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

macOS 10.14+

WindowBackground: "windowBackground";

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

macOS 10.14+


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

Window effect state macOS only

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

2.0.0

Active: "active";

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

Make window effect state always active macOS only

FollowsWindowActiveState: "followsWindowActiveState";

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

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

Inactive: "inactive";

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

Make window effect state always inactive macOS only


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

Error: "error";

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

Error state. Treated as Normal on linux

Indeterminate: "indeterminate";

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

Indeterminate state. Treated as Normal on Linux and macOS

None: "none";

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

Hide progress bar.

Normal: "normal";

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

Normal state.

Paused: "paused";

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

Paused state. Treated as Normal on Linux


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

The scrollbar style to use in the webview.

Windows: This option must be given the same value for all webviews.

2.8.0

Default: "default";

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

The default scrollbar style for the webview.

FluentOverlay: "fluentOverlay";

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

Fluent UI style overlay scrollbars. Windows Only

Requires WebView2 Runtime version 125.0.2535.41 or higher, does nothing on older versions, see https://learn.microsoft.com/en-us/microsoft-edge/webview2/release-notes/?tabs=dotnetcsharp#10253541


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

Attention type to request on a window.

1.0.0

Critical: 1;

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

Platform-specific

  • 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.

Informational: 2;

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

Platform-specific

  • 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#L138

new CloseRequestedEvent(event): CloseRequestedEvent;

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

Parameter Type
event Event<unknown>

CloseRequestedEvent

Property Type Description Defined in
event EventName Event name Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L140
id number Event identifier used to unlisten Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L142

isPreventDefault(): boolean;

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

boolean

preventDefault(): void;

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

void


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

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;

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

Creates a new Window.

Parameter Type Description
label string The unique window label. Must be alphanumeric: a-zA-Z-/:_.
options WindowOptions -

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
});
Property Type Description Defined in
label string The 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#L306
listeners Record<string, EventCallback<any>[]> Local event listeners. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L309

activityName(): Promise<string>;

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

Promise<string>

center(): Promise<void>;

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

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();

clearEffects(): Promise<void>;

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

Clear any applied effects if possible.

Promise<void>

close(): Promise<void>;

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

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();

destroy(): Promise<void>;

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

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();

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

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

Emits an event to all targets.

Type Parameter
T
Parameter Type Description
event string Event name. Must include only alphanumeric characters, -, /, : and _.
payload? T Event payload.

Promise<void>

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

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

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

Emits an event to all targets matching the given target.

Type Parameter
T
Parameter Type Description
target | string | EventTarget Label of the target Window/Webview/WebviewWindow or raw EventTarget object.
event string Event name. Must include only alphanumeric characters, -, /, : and _.
payload? T Event payload.

Promise<void>

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

hide(): Promise<void>;

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

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();

innerPosition(): Promise<PhysicalPosition>;

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

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();

innerSize(): Promise<PhysicalSize>;

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

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();

isAlwaysOnTop(): Promise<boolean>;

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

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();

isClosable(): Promise<boolean>;

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

Gets the window’s native close button state.

Platform-specific

  • 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();

isDecorated(): Promise<boolean>;

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

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();

isEnabled(): Promise<boolean>;

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

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

isFocused(): Promise<boolean>;

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

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();

isFullscreen(): Promise<boolean>;

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

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();

isMaximizable(): Promise<boolean>;

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

Gets the window’s native maximize button state.

Platform-specific

  • 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();

isMaximized(): Promise<boolean>;

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

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();

isMinimizable(): Promise<boolean>;

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

Gets the window’s native minimize button state.

Platform-specific

  • 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();

isMinimized(): Promise<boolean>;

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

Gets the window’s current minimized state.

Promise<boolean>

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

isResizable(): Promise<boolean>;

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

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();

isVisible(): Promise<boolean>;

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

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();

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

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

Listen to an emitted event on this window.

Type Parameter
T
Parameter Type Description
event EventName Event name. Must include only alphanumeric characters, -, /, : and _.
handler EventCallback<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();

maximize(): Promise<void>;

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

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();

minimize(): Promise<void>;

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

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();

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

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

Listen to an emitted event on this window only once.

Type Parameter
T
Parameter Type Description
event EventName Event name. Must include only alphanumeric characters, -, /, : and _.
handler EventCallback<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();

onCloseRequested(handler): Promise<UnlistenFn>;

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

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

Parameter Type
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();

onDragDropEvent(handler): Promise<UnlistenFn>;

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

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.

Parameter Type
handler EventCallback<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();

onFocusChanged(handler): Promise<UnlistenFn>;

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

Listen to window focus change.

Parameter Type
handler EventCallback<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();

onMoved(handler): Promise<UnlistenFn>;

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

Listen to window move.

Parameter Type
handler EventCallback<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();

onResized(handler): Promise<UnlistenFn>;

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

Listen to window resize.

Parameter Type
handler EventCallback<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();

onScaleChanged(handler): Promise<UnlistenFn>;

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

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.
Parameter Type
handler EventCallback<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();

onThemeChanged(handler): Promise<UnlistenFn>;

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

Listen to the system theme change.

Parameter Type
handler EventCallback<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();

outerPosition(): Promise<PhysicalPosition>;

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

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();

outerSize(): Promise<PhysicalSize>;

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

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();

requestUserAttention(requestType): Promise<void>;

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

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.

Platform-specific

  • macOS: null has no effect.
  • Linux: Urgency levels have the same effect.
Parameter Type
requestType | UserAttentionType | null

Promise<void>

A promise indicating the success or failure of the operation.

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

scaleFactor(): Promise<number>;

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

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();

sceneIdentifier(): Promise<string>;

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

Promise<string>

setAlwaysOnBottom(alwaysOnBottom): Promise<void>;

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

Whether the window should always be below other windows.

Parameter Type Description
alwaysOnBottom boolean Whether 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);

setAlwaysOnTop(alwaysOnTop): Promise<void>;

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

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

Parameter Type Description
alwaysOnTop boolean Whether 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);

setBackgroundColor(color): Promise<void>;

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

Sets the window background color.

Platform-specific:

  • Windows: alpha channel is ignored.
  • iOS / Android: Unsupported.
Parameter Type
color Color

Promise<void>

A promise indicating the success or failure of the operation.

2.1.0

setBadgeCount(count?): Promise<void>;

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

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

Platform-specific

  • Windows: Unsupported. Use @{linkcode Window.setOverlayIcon} instead.
Parameter Type Description
count? number The 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);

setBadgeLabel(label?): Promise<void>;

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

Sets the badge cont macOS only.

Parameter Type Description
label? string The 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");

setClosable(closable): Promise<void>;

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

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

Platform-specific

  • 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.
Parameter Type
closable boolean

Promise<void>

A promise indicating the success or failure of the operation.

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

setContentProtected(protected_): Promise<void>;

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

Prevents the window contents from being captured by other apps.

Parameter Type
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);

setCursorGrab(grab): Promise<void>;

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

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.

Platform-specific

  • Linux: Unsupported.
  • macOS: This locks the cursor in a fixed location, which looks visually awkward.
Parameter Type Description
grab boolean true 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);

setCursorIcon(icon): Promise<void>;

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

Modifies the cursor icon of the window.

Parameter Type Description
icon CursorIcon The 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');

setCursorPosition(position): Promise<void>;

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

Changes the position of the cursor in window coordinates.

Parameter Type Description
position | PhysicalPosition | LogicalPosition | Position The 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));

setCursorVisible(visible): Promise<void>;

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

Modifies the cursor’s visibility.

Platform-specific

  • 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.
Parameter Type Description
visible boolean If 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);

setDecorations(decorations): Promise<void>;

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

Whether the window should have borders and bars.

Parameter Type Description
decorations boolean Whether 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);

setEffects(effects): Promise<void>;

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

Set window effects.

Parameter Type
effects Effects

Promise<void>

setEnabled(enabled): Promise<void>;

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

Enable or disable the window.

Parameter Type
enabled boolean

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

setFocus(): Promise<void>;

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

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();

setFocusable(focusable): Promise<void>;

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

Sets whether the window can be focused.

Platform-specific

  • macOS: If the window is already focused, it is not possible to unfocus it after calling set_focusable(false). In this case, you might consider calling Window.setFocus but it will move the window to the back i.e. at the bottom in terms of z-order.
Parameter Type Description
focusable boolean Whether the window can be focused.

Promise<void>

A promise indicating the success or failure of the operation.

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

setFullscreen(fullscreen): Promise<void>;

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

Sets the window fullscreen state.

Parameter Type Description
fullscreen boolean Whether 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);

setIcon(icon): Promise<void>;

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

Sets the window icon.

Parameter Type Description
icon | string | Image | ArrayBuffer | Uint8Array<ArrayBufferLike> | number[] Icon 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"] }

setIgnoreCursorEvents(ignore): Promise<void>;

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

Changes the cursor events behavior.

Parameter Type Description
ignore boolean true 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);

setMaximizable(maximizable): Promise<void>;

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

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

Platform-specific

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

Promise<void>

A promise indicating the success or failure of the operation.

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

setMaxSize(size): Promise<void>;

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

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

Parameter Type Description
size | PhysicalSize | LogicalSize | Size | null | undefined The 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));

setMinimizable(minimizable): Promise<void>;

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

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

Platform-specific

  • Linux / iOS / Android: Unsupported.
Parameter Type
minimizable boolean

Promise<void>

A promise indicating the success or failure of the operation.

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

setMinSize(size): Promise<void>;

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

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

Parameter Type Description
size | PhysicalSize | LogicalSize | Size | null | undefined The 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));

setOverlayIcon(icon?): Promise<void>;

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

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"] }
Parameter Type Description
icon? | string | Image | ArrayBuffer | Uint8Array<ArrayBufferLike> | number[] Icon 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");

setPosition(position): Promise<void>;

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

Sets the window outer position.

Parameter Type Description
position | PhysicalPosition | LogicalPosition | Position The 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));

setProgressBar(state): Promise<void>;

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

Sets the taskbar progress state.

Platform-specific

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

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,
});

setResizable(resizable): Promise<void>;

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

Updates the window resizable flag.

Parameter Type
resizable boolean

Promise<void>

A promise indicating the success or failure of the operation.

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

setShadow(enable): Promise<void>;

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

Whether or not the window should have 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.
Parameter Type
enable boolean

Promise<void>

A promise indicating the success or failure of the operation.

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

setSimpleFullscreen(fullscreen): Promise<void>;

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

On macOS, Toggles a fullscreen mode that doesn’t require a new macOS space. Returns a boolean indicating whether the transition was successful (this won’t work if the window was already in the native fullscreen). This is how fullscreen used to work on macOS in versions before Lion. And allows the user to have a fullscreen window without using another space or taking control over the entire monitor.

On other platforms, this is the same as Window.setFullscreen.

Parameter Type Description
fullscreen boolean Whether the window should go to simple fullscreen or not.

Promise<void>

A promise indicating the success or failure of the operation.

setSize(size): Promise<void>;

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

Resizes the window with a new inner size.

Parameter Type Description
size | PhysicalSize | LogicalSize | Size The 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));

setSizeConstraints(constraints): Promise<void>;

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

Sets the window inner size constraints.

Parameter Type Description
constraints | WindowSizeConstraints | null | undefined The 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 });

setSkipTaskbar(skip): Promise<void>;

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

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

Platform-specific

  • macOS: Unsupported.
Parameter Type Description
skip boolean true 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);

setTheme(theme?): Promise<void>;

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

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

Platform-specific

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

Promise<void>

2.0.0

setTitle(title): Promise<void>;

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

Sets the window title.

Parameter Type Description
title string The 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');

setTitleBarStyle(style): Promise<void>;

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

Sets the title bar style. macOS only.

Parameter Type
style TitleBarStyle

Promise<void>

2.0.0

setVisibleOnAllWorkspaces(visible): Promise<void>;

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

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

Platform-specific

  • Windows / iOS / Android: Unsupported.
Parameter Type
visible boolean

Promise<void>

2.0.0

show(): Promise<void>;

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

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();

startDragging(): Promise<void>;

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

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();

startResizeDragging(direction): Promise<void>;

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

Starts resize-dragging the window.

Parameter Type
direction ResizeDirection

Promise<void>

A promise indicating the success or failure of the operation.

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

theme(): Promise<Theme | null>;

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

Gets the window’s current theme.

Platform-specific

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

Promise<Theme | null>

The window theme.

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

title(): Promise<string>;

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

Gets the window’s current title.

Promise<string>

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

toggleMaximize(): Promise<void>;

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

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();

unmaximize(): Promise<void>;

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

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();

unminimize(): Promise<void>;

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

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();

static getAll(): Promise<Window[]>;

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

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

Promise<Window[]>

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

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

Gets the Window associated with the given label.

Parameter Type Description
label string The window label.

Promise<Window | null>

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');

static getCurrent(): Window;

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

Get an instance of Window for the current window.

Window

static getFocusedWindow(): Promise<Window | null>;

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

Gets the focused window.

Promise<Window | null>

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#L2313

The window effects configuration object

2.0.0

Property Type Description Defined in
color? Color Window 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#L2331
effects Effect[] 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#L2318
radius? number Window effect corner radius macOS Only Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2326
state? EffectState Window effect state macOS Only Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2322

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

Allows you to retrieve information about a given monitor.

1.0.0

Property Type Description Defined in
name string | null Human-readable name of the monitor Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L49
position PhysicalPosition the Top-left corner position of the monitor relative to the larger full screen area, in physical pixels. Note that window creation options such as x, y, width and height expect logical pixels, so convert with Monitor.scaleFactor first: import { currentMonitor } from '@tauri-apps/api/window'; import { WebviewWindow } from '@tauri-apps/api/webviewWindow'; const monitor = await currentMonitor(); if (monitor) { const position = monitor.position.toLogical(monitor.scaleFactor); const webview = new WebviewWindow('my-label', { x: position.x, y: position.y }); } Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L75
scaleFactor number The scale factor that can be used to map physical pixels to logical pixels, e.g. monitor.position.toLogical(monitor.scaleFactor). Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L90
size PhysicalSize The monitor’s resolution in physical pixels. Use Monitor.scaleFactor to convert to logical pixels: const logicalSize = monitor.size.toLogical(monitor.scaleFactor); Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L58
workArea object The monitor’s work area (the monitor area excluding taskbars and docks) in physical pixels. Use Monitor.scaleFactor to convert to logical pixels as shown in Monitor.position. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L82
workArea.position PhysicalPosition - Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L83
workArea.size PhysicalSize - Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L84

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

Property Type Description Defined in
progress? number The progress bar progress. This can be a value ranging from 0 to 100 Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L238
status? ProgressBarStatus The progress bar status. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L234

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

The payload for the scaleChange event.

1.0.2

Property Type Description Defined in
scaleFactor number The new window scale factor. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L113
size PhysicalSize The new window size Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L115

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

Configuration for the window to create.

1.0.0

Property Type Description Defined in
activityName? string The name of the Android activity to create for this window. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2568
allowLinkPreview? boolean on 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.allowsLinkPreview Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2542
alwaysOnBottom? boolean Whether the window should always be below other windows. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2408
alwaysOnTop? boolean Whether 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#L2406
backgroundColor? Color Set the window background color. Platform-specific: - Android / iOS: Unsupported. - Windows: alpha channel is ignored. Since 2.1.0 Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2519
backgroundThrottling? BackgroundThrottlingPolicy Change 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.0 Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2533
center? boolean Show window in the center of the screen.. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2349
closable? boolean Whether 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#L2474
contentProtected? boolean Prevents the window contents from being captured by other apps. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2410
createdByActivityName? string The name of the Android activity that is creating this webview window. This is important to determine which stack the activity will belong to. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2574
decorations? boolean Whether the window should have borders and bars or not. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2404
disableInputAccessoryView? boolean Allows 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#L2549
focus? boolean Whether the window will be initially focused or not. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2388
focusable? boolean Whether the window can be focused or not. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2390
fullscreen? boolean Whether the window is in fullscreen mode or not. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2386
height? number The initial height in logical pixels. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2357
hiddenTitle? boolean If true, sets the window title to be hidden on macOS. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2455
javascriptDisabled? boolean Whether 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#L2537
maxHeight? number The maximum height in logical pixels. Only applies if maxWidth is also set. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2365
maximizable? boolean Whether 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#L2466
maximized? boolean Whether the window should be maximized upon creation or not. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2400
maxWidth? number The maximum width in logical pixels. Only applies if maxHeight is also set. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2363
minHeight? number The minimum height in logical pixels. Only applies if minWidth is also set. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2361
minimizable? boolean Whether 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#L2470
minWidth? number The minimum width in logical pixels. Only applies if minHeight is also set. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2359
noRedirectionBitmap? boolean This sets WS_EX_NOREDIRECTIONBITMAP. This can avoid the white flash that may appear before the webview content is rendered when using a transparent window. Windows only. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2419
parent? | string | Window | WebviewWindow Sets 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=objc Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2488
preventOverflow? boolean | PreventOverflowMargin Prevent 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#L2380
requestedBySceneIdentifier? string Sets the identifier of the UIScene that is requesting the creation of this new scene, establishing a relationship between the two scenes. By default the system uses the foreground scene. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2581
resizable? boolean Whether the window is resizable or not. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2382
scrollBarStyle? ScrollBarStyle Specifies the native scrollbar style to use with the webview. CSS styles that modify the scrollbar are applied on top of the native appearance configured here. Defaults to default, which is the browser default. ## Platform-specific - Windows: - fluentOverlay requires WebView2 Runtime version 125.0.2535.41 or higher, and does nothing on older versions. - This option must be given the same value for all webviews. - Linux / Android / iOS / macOS: Unsupported. Only supports Default and performs no operation. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2564
shadow? boolean Whether 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.0 Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2433
skipTaskbar? boolean Whether 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#L2412
tabbingIdentifier? string Defines 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#L2462
theme? Theme The 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#L2439
title? string Window title. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2384
titleBarStyle? TitleBarStyle The style of the macOS title bar. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2443
trafficLightPosition? LogicalPosition The position of the window controls on macOS. Requires titleBarStyle: 'overlay' and decorations: true. Since 2.4.0 Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2451
transparent? boolean Whether 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. On Windows, using noRedirectionBitmap can help avoid a white flash when creating a transparent window. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2398
visible? boolean Whether the window should be immediately visible upon creation or not. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2402
visibleOnAllWorkspaces? boolean Whether the window should be visible on all workspaces or virtual desktops. Platform-specific - Windows / iOS / Android: Unsupported. Since 2.0.0 Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2497
width? number The initial width in logical pixels. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2355
windowEffects? Effects Window 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: Unsupported Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2508
x? number The initial vertical position in logical pixels. Only applies if y is also set. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2351
y? number The initial horizontal position in logical pixels. Only applies if x is also set. Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2353

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

Property Type Defined in
maxHeight? number Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L227
maxWidth? number Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L226
minHeight? number Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L225
minWidth? number Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L224

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#L159


type Theme = "light" | "dark";

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


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

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

function availableMonitors(): Promise<Monitor[]>;

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

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


function currentMonitor(): Promise<Monitor | null>;

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

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


function cursorPosition(): Promise<PhysicalPosition>;

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

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>


function getAllWindows(): Promise<Window[]>;

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

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

Promise<Window[]>

1.0.0


function getCurrentWindow(): Window;

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

Get an instance of Window for the current window.

Window

1.0.0


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

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

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

Parameter Type
x number
y number

Promise<Monitor | null>

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

1.0.0


function primaryMonitor(): Promise<Monitor | null>;

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

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

Re-exports Color


Re-exports DragDropEvent


Re-exports LogicalPosition


Re-exports LogicalSize


Re-exports PhysicalPosition


Re-exports PhysicalSize


© 2026 Tauri Contributors. CC-BY / MIT