@tauri-apps/api/webviewWindow
Create and manipulate windows that host a single webview.
WebviewWindow is the type you want for ordinary multi-window apps: it
mixes together the Window and Webview APIs, so one object exposes
both the window methods (setTitle, maximize, close, …) and the webview
ones (setZoom, clearAllBrowsingData, …).
import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
const settings = new WebviewWindow('settings', { url: '/settings', title: 'Settings'});settings.once('tauri://created', () => console.log('window created'));settings.once('tauri://error', (e) => console.error(e));Unlike child webviews, this does not require the unstable
Cargo feature.
This package is also accessible with window.__TAURI__.webviewWindow when app.withGlobalTauri in tauri.conf.json is set to true.
Remarks
Section titled “Remarks”Creating a webview window requires the
core:webview:allow-create-webview-window permission, which is not included in
core:webview:default. The methods inherited from Window and
Webview each document their own permission.
Functions
Section titled “Functions”getAllWebviewWindows()
Section titled “getAllWebviewWindows()”function getAllWebviewWindows(): Promise<WebviewWindow[]>;Defined in: packages/api/src/webviewWindow.ts:69
Gets a list of instances of Webview for all available webview windows.
Returns
Section titled “Returns”Remarks
Section titled “Remarks”Uses the core:window:allow-get-all-windows permission, which is part
of core:window:default.
2.0.0
getCurrentWebviewWindow()
Section titled “getCurrentWebviewWindow()”function getCurrentWebviewWindow(): WebviewWindow;Defined in: packages/api/src/webviewWindow.ts:55
Get an instance of Webview for the current webview window.
Returns
Section titled “Returns”2.0.0
Classes
Section titled “Classes”WebviewWindow
Section titled “WebviewWindow”Defined in: packages/api/src/webviewWindow.ts:82
Create new webview or get a handle to an existing one.
Webviews 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 _.
Requires the unstable Cargo feature
Creating a webview with new Webview(...) adds a child webview to an existing
window, which is an unstable API gated behind the unstable feature of the
tauri crate:
[dependencies]tauri = { version = "2", features = ["unstable"] }Without it the call rejects with an “unstable feature not supported” error.
Getting a handle to an existing webview (Webview.getByLabel,
getCurrentWebview, getAllWebviews) and every method on this class
work without the feature. To create a window that hosts a single webview, use
WebviewWindow instead, which is stable.
Example
Section titled “Example”import { Window } from "@tauri-apps/api/window"import { Webview } from "@tauri-apps/api/webview"
const appWindow = new Window('uniqueLabel');
appWindow.once('tauri://created', async function () { // `new Webview` Should be called after the window is successfully created, // or webview may not be attached to the window since window is not created yet.
// loading embedded asset: const webview = new Webview(appWindow, 'theUniqueLabel', { url: 'path/to/page.html',
// create a webview with specific logical position and size x: 0, y: 0, width: 800, height: 600, }); // alternatively, load a remote URL: const webview = new Webview(appWindow, 'theUniqueLabel', { url: 'https://github.com/tauri-apps/tauri',
// create a webview with specific logical position and size x: 0, y: 0, width: 800, height: 600, });
webview.once('tauri://created', function () { // webview successfully created }); webview.once('tauri://error', function (e) { // an error happened creating the webview });
// emit an event to the backend await webview.emit("some-event", "data"); // listen to an event from the backend const unlisten = await webview.listen("event-name", e => { }); unlisten();});2.0.0
Extends
Section titled “Extends”Constructors
Section titled “Constructors”new WebviewWindow()
Section titled “new WebviewWindow()”new WebviewWindow(label: string, options?: Omit<WebviewOptions, "x" | "y" | "width" | "height"> & WindowOptions): WebviewWindow;Defined in: packages/api/src/webviewWindow.ts:115
Creates a new Window hosting a Webview.
Example
Section titled “Example”import { WebviewWindow } from '@tauri-apps/api/webviewWindow'const webview = new WebviewWindow('my-label', { url: 'https://github.com/tauri-apps/tauri'});webview.once('tauri://created', function () { // webview successfully created});webview.once('tauri://error', function (e) { // an error happened creating the webview});Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
label |
string |
The unique webview label. Must be alphanumeric: a-zA-Z-/:_. |
options |
Omit<WebviewOptions, "x" | "y" | "width" | "height"> & WindowOptions |
The window and webview configuration, see WindowOptions and WebviewOptions. |
Returns
Section titled “Returns”The WebviewWindow instance to communicate with the window and webview.
Remarks
Section titled “Remarks”Requires the core:webview:allow-create-webview-window permission
(not included in core:webview:default).
Inherited from
Section titled “Inherited from”Properties
Section titled “Properties”| Property | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|
label |
string |
The webview label. It is a unique identifier for the webview, can be used to reference it later. | Webview.label |
packages/api/src/webviewWindow.ts:86 |
listeners |
Record<string, EventCallback<any>[]> |
Local event listeners. | Webview.listeners |
packages/api/src/webviewWindow.ts:89 |
window |
Window |
The window hosting this webview. | Webview.window |
packages/api/src/webview.ts:211 |
Methods
Section titled “Methods”activityName()
Section titled “activityName()”activityName(): Promise<string>;Defined in: packages/api/src/window.ts:965
The name of the Android activity hosting this window.
On Android each window is backed by its own activity. Use this to tell windows
apart from native code, or to match a window with the activity declared in your
AndroidManifest.xml.
Platform-specific
- Android: Supported.
- Windows / Linux / macOS / iOS: Unsupported, the call rejects because the command is not registered.
See the mobile multiwindow guide.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const activity = await getCurrentWindow().activityName();Returns
Section titled “Returns”The activity name.
Remarks
Section titled “Remarks”Uses the core:window:allow-activity-name permission, which is part
of core:window:default.
2.11.0
Inherited from
Section titled “Inherited from”center()
Section titled “center()”center(): Promise<void>;Defined in: packages/api/src/window.ts:1020
Centers the window.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().center();Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-center permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”clearAllBrowsingData()
Section titled “clearAllBrowsingData()”clearAllBrowsingData(): Promise<void>;Defined in: packages/api/src/webview.ts:699
Clears all browsing data for this webview: cookies, localStorage, IndexedDB, caches and any other data the webview stores for the loaded origins.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().clearAllBrowsingData();Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:webview:allow-clear-all-browsing-data permission
(not included in core:webview:default).
Inherited from
Section titled “Inherited from”clearEffects()
Section titled “clearEffects()”clearEffects(): Promise<void>;Defined in: packages/api/src/window.ts:1512
Clear any applied effects if possible.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().clearEffects();Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-effects permission (not included
in core:window:default), the same one used by Window.setEffects.
2.0.0
Inherited from
Section titled “Inherited from”close()
Section titled “close()”close(): Promise<void>;Defined in: packages/api/src/webview.ts:513
Closes the webview.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().close();Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:webview:allow-webview-close permission (not
included in core:webview:default).
Inherited from
Section titled “Inherited from”destroy()
Section titled “destroy()”destroy(): Promise<void>;Defined in: packages/api/src/window.ts:1396
Destroys the window. Behaves like Window.close but forces the window close instead of emitting a closeRequested event.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().destroy();Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-destroy permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”emit()
Section titled “emit()”emit<T>(event: string, payload?: T): Promise<void>;Defined in: packages/api/src/webview.ts:393
Emits an event to all targets.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().emit('webview-loaded', { loggedIn: true, token: 'authToken' });Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
event |
string |
Event name. Must include only alphanumeric characters, -, /, : and _. |
payload? |
T |
Event payload. |
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”emitTo()
Section titled “emitTo()”emitTo<T>( target: string | EventTarget, event: string, payload?: T): Promise<void>;Defined in: packages/api/src/webview.ts:421
Emits an event to all targets matching the given target.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().emitTo('main', 'webview-loaded', { loggedIn: true, token: 'authToken' });Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| 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. |
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”hide()
Section titled “hide()”hide(): Promise<void>;Defined in: packages/api/src/webview.ts:618
Hide the webview.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().hide();Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:webview:allow-webview-hide permission (not
included in core:webview:default).
Inherited from
Section titled “Inherited from”innerPosition()
Section titled “innerPosition()”innerPosition(): Promise<PhysicalPosition>;Defined in: packages/api/src/window.ts:651
The position of the top-left hand corner of the window’s client area relative to the top-left hand corner of the desktop.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const position = await getCurrentWindow().innerPosition();Returns
Section titled “Returns”The window’s inner position.
Inherited from
Section titled “Inherited from”innerSize()
Section titled “innerSize()”innerSize(): Promise<PhysicalSize>;Defined in: packages/api/src/window.ts:684
The physical size of the window’s client area. The client area is the content of the window, excluding the title bar and borders.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const size = await getCurrentWindow().innerSize();Returns
Section titled “Returns”The window’s inner size.
Inherited from
Section titled “Inherited from”isAlwaysOnTop()
Section titled “isAlwaysOnTop()”isAlwaysOnTop(): Promise<boolean>;Defined in: packages/api/src/window.ts:931
Whether the window is configured to be always on top of other windows or not.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const alwaysOnTop = await getCurrentWindow().isAlwaysOnTop();Returns
Section titled “Returns”Whether the window is visible or not.
Inherited from
Section titled “Inherited from”isClosable()
Section titled “isClosable()”isClosable(): Promise<boolean>;Defined in: packages/api/src/window.ts:864
Gets the window’s native close button state.
Platform-specific
- iOS / Android: Unsupported.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const closable = await getCurrentWindow().isClosable();Returns
Section titled “Returns”Whether the window’s native close button is enabled or not.
Inherited from
Section titled “Inherited from”isDecorated()
Section titled “isDecorated()”isDecorated(): Promise<boolean>;Defined in: packages/api/src/window.ts:785
Gets the window’s current decorated state.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const decorated = await getCurrentWindow().isDecorated();Returns
Section titled “Returns”Whether the window is decorated or not.
Inherited from
Section titled “Inherited from”isEnabled()
Section titled “isEnabled()”isEnabled(): Promise<boolean>;Defined in: packages/api/src/window.ts:1124
Whether the window is enabled or disabled.
A disabled window ignores all user input; see Window.setEnabled.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const enabled = await getCurrentWindow().isEnabled();Returns
Section titled “Returns”true when the window accepts user input, false when it is disabled.
2.0.0
Inherited from
Section titled “Inherited from”isFocused()
Section titled “isFocused()”isFocused(): Promise<boolean>;Defined in: packages/api/src/window.ts:769
Gets the window’s current focus state.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const focused = await getCurrentWindow().isFocused();Returns
Section titled “Returns”Whether the window is focused or not.
Inherited from
Section titled “Inherited from”isFullscreen()
Section titled “isFullscreen()”isFullscreen(): Promise<boolean>;Defined in: packages/api/src/window.ts:723
Gets the window’s current fullscreen state.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const fullscreen = await getCurrentWindow().isFullscreen();Returns
Section titled “Returns”Whether the window is in fullscreen mode or not.
Inherited from
Section titled “Inherited from”isMaximizable()
Section titled “isMaximizable()”isMaximizable(): Promise<boolean>;Defined in: packages/api/src/window.ts:822
Gets the window’s native maximize button state.
Platform-specific
- Linux / iOS / Android: Unsupported.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const maximizable = await getCurrentWindow().isMaximizable();Returns
Section titled “Returns”Whether the window’s native maximize button is enabled or not.
Inherited from
Section titled “Inherited from”isMaximized()
Section titled “isMaximized()”isMaximized(): Promise<boolean>;Defined in: packages/api/src/window.ts:753
Gets the window’s current maximized state.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const maximized = await getCurrentWindow().isMaximized();Returns
Section titled “Returns”Whether the window is maximized or not.
Inherited from
Section titled “Inherited from”isMinimizable()
Section titled “isMinimizable()”isMinimizable(): Promise<boolean>;Defined in: packages/api/src/window.ts:843
Gets the window’s native minimize button state.
Platform-specific
- Linux / iOS / Android: Unsupported.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const minimizable = await getCurrentWindow().isMinimizable();Returns
Section titled “Returns”Whether the window’s native minimize button is enabled or not.
Inherited from
Section titled “Inherited from”isMinimized()
Section titled “isMinimized()”isMinimized(): Promise<boolean>;Defined in: packages/api/src/window.ts:737
Gets the window’s current minimized state.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const minimized = await getCurrentWindow().isMinimized();Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”isResizable()
Section titled “isResizable()”isResizable(): Promise<boolean>;Defined in: packages/api/src/window.ts:801
Gets the window’s current resizable state.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const resizable = await getCurrentWindow().isResizable();Returns
Section titled “Returns”Whether the window is resizable or not.
Inherited from
Section titled “Inherited from”isVisible()
Section titled “isVisible()”isVisible(): Promise<boolean>;Defined in: packages/api/src/window.ts:880
Gets the window’s current visible state.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const visible = await getCurrentWindow().isVisible();Returns
Section titled “Returns”Whether the window is visible or not.
Inherited from
Section titled “Inherited from”listen()
Section titled “listen()”listen<T>(event: EventName, handler: EventCallback<T>): Promise<UnlistenFn>;Defined in: packages/api/src/webviewWindow.ts:199
Listen to an emitted event on this webview window.
Example
Section titled “Example”import { WebviewWindow } from '@tauri-apps/api/webviewWindow';const unlisten = await WebviewWindow.getCurrent().listen<string>('state-changed', (event) => { console.log(`Got error: ${payload}`);});
// call unlisten when your handler goes out of scope e.g. the component is unmountedunlisten();Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
event |
EventName |
Event name. Must include only alphanumeric characters, -, /, : and _. |
handler |
EventCallback<T> |
Event handler. |
Returns
Section titled “Returns”A promise resolving to a function to unlisten to the event.
Remarks
Section titled “Remarks”The listener is removed automatically when this webview window is destroyed, so you do not need to unlisten just because the window is closing. Do call the returned function when the listener’s own scope ends, e.g. on page navigation or when a component unmounts.
Inherited from
Section titled “Inherited from”maximize()
Section titled “maximize()”maximize(): Promise<void>;Defined in: packages/api/src/window.ts:1242
Maximizes the window.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().maximize();Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-maximize permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”minimize()
Section titled “minimize()”minimize(): Promise<void>;Defined in: packages/api/src/window.ts:1299
Minimizes the window.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().minimize();Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-minimize permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”once()
Section titled “once()”once<T>(event: EventName, handler: EventCallback<T>): Promise<UnlistenFn>;Defined in: packages/api/src/webviewWindow.ts:237
Listen to an emitted event on this webview window only once.
Example
Section titled “Example”import { WebviewWindow } from '@tauri-apps/api/webviewWindow';const unlisten = await WebviewWindow.getCurrent().once<null>('initialized', (event) => { console.log(`Webview initialized!`);});
// call unlisten when your handler goes out of scope e.g. the component is unmountedunlisten();Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
event |
EventName |
Event name. Must include only alphanumeric characters, -, /, : and _. |
handler |
EventCallback<T> |
Event handler. |
Returns
Section titled “Returns”A promise resolving to a function to unlisten to the event.
Remarks
Section titled “Remarks”The listener removes itself after the first event and is also removed automatically when this webview window is destroyed. Do call the returned function if the listener’s own scope ends before the event arrives.
Inherited from
Section titled “Inherited from”onCloseRequested()
Section titled “onCloseRequested()”onCloseRequested(handler: (event: CloseRequestedEvent) => | void| Promise<void>): Promise<UnlistenFn>;Defined in: packages/api/src/window.ts:2365
Listen to window close requested. Emitted when the user requests to closes the window.
Example
Section titled “Example”import { getCurrentWindow } from "@tauri-apps/api/window";// `confirm` comes from the dialog plugin, which you have to add separately:// `pnpm tauri add dialog`import { confirm } from '@tauri-apps/plugin-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(); }});
// call unlisten when your handler goes out of scope e.g. the component is unmountedunlisten();Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
handler |
(event: CloseRequestedEvent) => | void | Promise<void> |
Returns
Section titled “Returns”A promise resolving to a function to unlisten to the event.
Remarks
Section titled “Remarks”The listener is removed automatically when this window is destroyed, so you do not need to unlisten just because the window is closing. Do call the returned function when the listener’s own scope ends, e.g. on page navigation or when a component unmounts.
Inherited from
Section titled “Inherited from”onDragDropEvent()
Section titled “onDragDropEvent()”onDragDropEvent(handler: EventCallback<DragDropEvent>): Promise<UnlistenFn>;Defined in: packages/api/src/webview.ts:769
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.
Example
Section titled “Example”import { getCurrentWebview } from "@tauri-apps/api/webview";const unlisten = await getCurrentWebview().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'); }});
// call unlisten when your handler goes out of scope e.g. the component is unmountedunlisten();When the debugger panel is open, the drop position of this event may be inaccurate due to a known limitation. To retrieve the correct drop position, please detach the debugger.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
handler |
EventCallback<DragDropEvent> |
Returns
Section titled “Returns”A promise resolving to a function to unlisten to the event.
Remarks
Section titled “Remarks”The listeners are removed automatically when this webview is destroyed. Do call the returned function when the listener’s own scope ends, e.g. on page navigation or when a component unmounts.
Inherited from
Section titled “Inherited from”onFocusChanged()
Section titled “onFocusChanged()”onFocusChanged(handler: EventCallback<boolean>): Promise<UnlistenFn>;Defined in: packages/api/src/window.ts:2491
Listen to window focus change.
Example
Section titled “Example”import { getCurrentWindow } from "@tauri-apps/api/window";const unlisten = await getCurrentWindow().onFocusChanged(({ payload: focused }) => { console.log('Focus changed, window is focused? ' + focused);});
// call unlisten when your handler goes out of scope e.g. the component is unmountedunlisten();Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
handler |
EventCallback<boolean> |
Returns
Section titled “Returns”A promise resolving to a function to unlisten to the event.
Remarks
Section titled “Remarks”The listener is removed automatically when this window is destroyed, so you do not need to unlisten just because the window is closing. Do call the returned function when the listener’s own scope ends, e.g. on page navigation or when a component unmounts.
Inherited from
Section titled “Inherited from”onMoved()
Section titled “onMoved()”onMoved(handler: EventCallback<PhysicalPosition>): Promise<UnlistenFn>;Defined in: packages/api/src/window.ts:2330
Listen to window move.
Example
Section titled “Example”import { getCurrentWindow } from "@tauri-apps/api/window";const unlisten = await getCurrentWindow().onMoved(({ payload: position }) => { console.log('Window moved', position);});
// call unlisten when your handler goes out of scope e.g. the component is unmountedunlisten();Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
handler |
EventCallback<PhysicalPosition> |
Returns
Section titled “Returns”A promise resolving to a function to unlisten to the event.
Remarks
Section titled “Remarks”The listener is removed automatically when this window is destroyed, so you do not need to unlisten just because the window is closing. Do call the returned function when the listener’s own scope ends, e.g. on page navigation or when a component unmounts.
Inherited from
Section titled “Inherited from”onResized()
Section titled “onResized()”onResized(handler: EventCallback<PhysicalSize>): Promise<UnlistenFn>;Defined in: packages/api/src/window.ts:2302
Listen to window resize.
Example
Section titled “Example”import { getCurrentWindow } from "@tauri-apps/api/window";const unlisten = await getCurrentWindow().onResized(({ payload: size }) => { console.log('Window resized', size);});
// call unlisten when your handler goes out of scope e.g. the component is unmountedunlisten();Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
handler |
EventCallback<PhysicalSize> |
Returns
Section titled “Returns”A promise resolving to a function to unlisten to the event.
Remarks
Section titled “Remarks”The listener is removed automatically when this window is destroyed, so you do not need to unlisten just because the window is closing. Do call the returned function when the listener’s own scope ends, e.g. on page navigation or when a component unmounts.
Inherited from
Section titled “Inherited from”onScaleChanged()
Section titled “onScaleChanged()”onScaleChanged(handler: EventCallback<ScaleFactorChanged>): Promise<UnlistenFn>;Defined in: packages/api/src/window.ts:2534
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.
Example
Section titled “Example”import { getCurrentWindow } from "@tauri-apps/api/window";const unlisten = await getCurrentWindow().onScaleChanged(({ payload }) => { console.log('Scale changed', payload.scaleFactor, payload.size);});
// call unlisten when your handler goes out of scope e.g. the component is unmountedunlisten();Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
handler |
EventCallback<ScaleFactorChanged> |
Returns
Section titled “Returns”A promise resolving to a function to unlisten to the event.
Remarks
Section titled “Remarks”The listener is removed automatically when this window is destroyed, so you do not need to unlisten just because the window is closing. Do call the returned function when the listener’s own scope ends, e.g. on page navigation or when a component unmounts.
Inherited from
Section titled “Inherited from”onThemeChanged()
Section titled “onThemeChanged()”onThemeChanged(handler: EventCallback<Theme>): Promise<UnlistenFn>;Defined in: packages/api/src/window.ts:2564
Listen to the system theme change.
Example
Section titled “Example”import { getCurrentWindow } from "@tauri-apps/api/window";const unlisten = await getCurrentWindow().onThemeChanged(({ payload: theme }) => { console.log('New theme: ' + theme);});
// call unlisten when your handler goes out of scope e.g. the component is unmountedunlisten();Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
handler |
EventCallback<Theme> |
Returns
Section titled “Returns”A promise resolving to a function to unlisten to the event.
Remarks
Section titled “Remarks”The listener is removed automatically when this window is destroyed, so you do not need to unlisten just because the window is closing. Do call the returned function when the listener’s own scope ends, e.g. on page navigation or when a component unmounts.
Inherited from
Section titled “Inherited from”outerPosition()
Section titled “outerPosition()”outerPosition(): Promise<PhysicalPosition>;Defined in: packages/api/src/window.ts:667
The position of the top-left hand corner of the window relative to the top-left hand corner of the desktop.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const position = await getCurrentWindow().outerPosition();Returns
Section titled “Returns”The window’s outer position.
Inherited from
Section titled “Inherited from”outerSize()
Section titled “outerSize()”outerSize(): Promise<PhysicalSize>;Defined in: packages/api/src/window.ts:704
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.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const size = await getCurrentWindow().outerSize();Returns
Section titled “Returns”The window’s outer size.
Inherited from
Section titled “Inherited from”position()
Section titled “position()”position(): Promise<PhysicalPosition>;Defined in: packages/api/src/webview.ts:469
The position of the top-left hand corner of the webview’s client area relative to the top-left hand corner of the desktop.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';const position = await getCurrentWebview().position();Returns
Section titled “Returns”The webview’s position, in physical pixels.
Remarks
Section titled “Remarks”Uses the core:webview:allow-webview-position permission, which is
part of core:webview:default.
Inherited from
Section titled “Inherited from”reparent()
Section titled “reparent()”reparent(window: string | Window | WebviewWindow): Promise<void>;Defined in: packages/api/src/webview.ts:678
Moves this webview to the window with the given label.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().reparent('other-window');Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
window |
| string | Window | WebviewWindow |
The target window, or its label. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:webview:allow-reparent permission (not included in
core:webview:default).
Inherited from
Section titled “Inherited from”requestUserAttention()
Section titled “requestUserAttention()”requestUserAttention(requestType: UserAttentionType | null): Promise<void>;Defined in: packages/api/src/window.ts:1049
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:
nullhas no effect. - Linux: Urgency levels have the same effect.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().requestUserAttention();Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
requestType |
| UserAttentionType | null |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-request-user-attention permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”scaleFactor()
Section titled “scaleFactor()”scaleFactor(): Promise<number>;Defined in: packages/api/src/window.ts:635
The scale factor that can be used to map physical pixels to logical pixels.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const factor = await getCurrentWindow().scaleFactor();Returns
Section titled “Returns”The window’s monitor scale factor.
Inherited from
Section titled “Inherited from”sceneIdentifier()
Section titled “sceneIdentifier()”sceneIdentifier(): Promise<string>;Defined in: packages/api/src/window.ts:999
The identifier of the iOS scene hosting this window.
On iOS each window is backed by a UIScene. Use this to tell windows apart
from native code, or to match a window with a scene configuration declared in
your Info.plist.
Platform-specific
- iOS: Supported.
- Windows / Linux / macOS / Android: Unsupported, the call rejects because the command is not registered.
See the mobile multiwindow guide.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const scene = await getCurrentWindow().sceneIdentifier();Returns
Section titled “Returns”The scene identifier.
Remarks
Section titled “Remarks”Uses the core:window:allow-scene-identifier permission, which is part
of core:window:default.
2.11.0
Inherited from
Section titled “Inherited from”setAlwaysOnBottom()
Section titled “setAlwaysOnBottom()”setAlwaysOnBottom(alwaysOnBottom: boolean): Promise<void>;Defined in: packages/api/src/window.ts:1554
Whether the window should always be below other windows.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setAlwaysOnBottom(true);Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
alwaysOnBottom |
boolean |
Whether the window should always be below other windows or not. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-always-on-bottom permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setAlwaysOnTop()
Section titled “setAlwaysOnTop()”setAlwaysOnTop(alwaysOnTop: boolean): Promise<void>;Defined in: packages/api/src/window.ts:1533
Whether the window should always be on top of other windows.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setAlwaysOnTop(true);Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
alwaysOnTop |
boolean |
Whether the window should always be on top of other windows or not. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-always-on-top permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setAutoResize()
Section titled “setAutoResize()”setAutoResize(autoResize: boolean): Promise<void>;Defined in: packages/api/src/webview.ts:598
Sets whether the webview should automatically grow and shrink its size and position when the parent window resizes.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().setAutoResize(true);Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
autoResize |
boolean |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:webview:allow-set-webview-auto-resize permission
(not included in core:webview:default).
Inherited from
Section titled “Inherited from”setBackgroundColor()
Section titled “setBackgroundColor()”setBackgroundColor(color: Color): Promise<void>;Defined in: packages/api/src/webviewWindow.ts:280
Set the window and webview background color.
Platform-specific
- Android / iOS: Unsupported for the window layer.
- macOS / iOS: Not implemented for the webview layer.
- Windows:
- alpha channel is ignored for the window layer.
- On Windows 7, alpha channel is ignored for the webview layer.
- On Windows 8 and newer, if alpha channel is not
0, it will be ignored.
Example
Section titled “Example”import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow';await getCurrentWebviewWindow().setBackgroundColor('#2f2f2f');Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
color |
Color |
The new background color. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires both the core:window:allow-set-background-color and
core:webview:allow-set-webview-background-color permissions, neither of which
is included in the respective default permission set.
2.1.0
Inherited from
Section titled “Inherited from”setBadgeCount()
Section titled “setBadgeCount()”setBadgeCount(count?: number): Promise<void>;Defined in: packages/api/src/window.ts:2095
Sets the badge count. It is app wide and not specific to this window.
Platform-specific
- Windows: Unsupported. Use
Window.setOverlayIconinstead.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setBadgeCount(5);Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
count? |
number |
The badge count. Use undefined to remove the badge. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-badge-count permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setBadgeLabel()
Section titled “setBadgeLabel()”setBadgeLabel(label?: string): Promise<void>;Defined in: packages/api/src/window.ts:2120
Sets the badge label shown on the app’s dock icon. macOS only
Unlike Window.setBadgeCount, which takes a number, this shows
arbitrary short text. It is app-wide and not specific to this window.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setBadgeLabel("Hello");Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
label? |
string |
The badge label. Use undefined to remove the badge. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-badge-label permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setClosable()
Section titled “setClosable()”setClosable(closable: boolean): Promise<void>;Defined in: packages/api/src/window.ts:1201
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.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setClosable(false);Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
closable |
boolean |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-closable permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setContentProtected()
Section titled “setContentProtected()”setContentProtected(protected_: boolean): Promise<void>;Defined in: packages/api/src/window.ts:1574
Prevents the window contents from being captured by other apps.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setContentProtected(true);Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
protected_ |
boolean |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-content-protected permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setCursorGrab()
Section titled “setCursorGrab()”setCursorGrab(grab: boolean): Promise<void>;Defined in: packages/api/src/window.ts:1902
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.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setCursorGrab(true);Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
grab |
boolean |
true to grab the cursor icon, false to release it. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-cursor-grab permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setCursorIcon()
Section titled “setCursorIcon()”setCursorIcon(icon: CursorIcon): Promise<void>;Defined in: packages/api/src/window.ts:1950
Modifies the cursor icon of the window.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setCursorIcon('help');Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
icon |
CursorIcon |
The new cursor icon. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-cursor-icon permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setCursorPosition()
Section titled “setCursorPosition()”setCursorPosition(position: PhysicalPosition | LogicalPosition | Position): Promise<void>;Defined in: packages/api/src/window.ts:2006
Changes the position of the cursor in window coordinates.
Example
Section titled “Example”import { getCurrentWindow, LogicalPosition } from '@tauri-apps/api/window';await getCurrentWindow().setCursorPosition(new LogicalPosition(600, 300));Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
position |
| PhysicalPosition | LogicalPosition | Position |
The new cursor position. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-cursor-position permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setCursorVisible()
Section titled “setCursorVisible()”setCursorVisible(visible: boolean): Promise<void>;Defined in: packages/api/src/window.ts:1929
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.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setCursorVisible(false);Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
visible |
boolean |
If false, this will hide the cursor. If true, this will show the cursor. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-cursor-visible permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setDecorations()
Section titled “setDecorations()”setDecorations(decorations: boolean): Promise<void>;Defined in: packages/api/src/window.ts:1416
Whether the window should have borders and bars.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setDecorations(false);Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
decorations |
boolean |
Whether the window should have borders and bars. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-decorations permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setEffects()
Section titled “setEffects()”setEffects(effects: Effects): Promise<void>;Defined in: packages/api/src/window.ts:1489
Applies platform-specific window effects such as Mica, Acrylic, Blur or the macOS vibrancy materials.
Requires the window to be transparent, so create it with transparent: true
(or set transparent in tauri.conf.json). Give the page a transparent or
translucent background as well, otherwise the effect is hidden behind your own
background color.
Conflicting effects are resolved by applying the first supported one and ignoring the rest, so you can list a Windows and a macOS effect together.
Platform-specific
- Windows: If the window uses decorations or shadows, you may need this workaround.
- Linux: Unsupported.
Example
Section titled “Example”import { getCurrentWindow, Effect, EffectState } from '@tauri-apps/api/window';
await getCurrentWindow().setEffects({ effects: [Effect.Mica, Effect.Acrylic, Effect.UnderWindowBackground], state: EffectState.Active, radius: 8});Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
effects |
Effects |
The effects to apply, see Effects. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-effects permission (not included
in core:window:default).
2.0.0
Inherited from
Section titled “Inherited from”setEnabled()
Section titled “setEnabled()”setEnabled(enabled: boolean): Promise<void>;Defined in: packages/api/src/window.ts:1102
Enable or disable the window.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setEnabled(false);Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
enabled |
boolean |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-enabled permission (not included
in core:window:default).
2.0.0
Inherited from
Section titled “Inherited from”setFocus()
Section titled “setFocus()”setFocus(): Promise<void>;Defined in: packages/api/src/webview.ts:579
Bring the webview to front and focus.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().setFocus();Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:webview:allow-set-webview-focus permission (not
included in core:webview:default).
Inherited from
Section titled “Inherited from”setFocusable()
Section titled “setFocusable()”setFocusable(focusable: boolean): Promise<void>;Defined in: packages/api/src/window.ts:1820
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.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setFocusable(true);Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
focusable |
boolean |
Whether the window can be focused. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-focusable permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setFullscreen()
Section titled “setFullscreen()”setFullscreen(fullscreen: boolean): Promise<void>;Defined in: packages/api/src/window.ts:1719
Sets the window fullscreen state.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setFullscreen(true);Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
fullscreen |
boolean |
Whether the window should go to fullscreen or not. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-fullscreen permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setFullscreenOnMonitor()
Section titled “setFullscreenOnMonitor()”setFullscreenOnMonitor(position: PhysicalPosition): Promise<void>;Defined in: packages/api/src/window.ts:1747
Sets the window as fullscreen on the monitor that contains the given physical position.
Does nothing if no monitor contains the position.
Example
Section titled “Example”import { getCurrentWindow, availableMonitors } from '@tauri-apps/api/window';const monitors = await availableMonitors();if (monitors.length > 1) { await getCurrentWindow().setFullscreenOnMonitor(monitors[1].position);}Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
position |
PhysicalPosition |
A physical position inside the target monitor, such as Monitor.position. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-fullscreen-on-monitor permission (not included
in core:window:default).
2.12.0
Inherited from
Section titled “Inherited from”setIcon()
Section titled “setIcon()”setIcon(icon: JsImage): Promise<void>;Defined in: packages/api/src/window.ts:1848
Sets the window icon.
Example
Section titled “Example”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"] }Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
icon |
JsImage |
Icon bytes or path to the icon file. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-icon permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setIgnoreCursorEvents()
Section titled “setIgnoreCursorEvents()”setIgnoreCursorEvents(ignore: boolean): Promise<void>;Defined in: packages/api/src/window.ts:2030
Changes the cursor events behavior.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setIgnoreCursorEvents(true);Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
ignore |
boolean |
true to ignore the cursor events; false to process them as usual. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-ignore-cursor-events permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setMaximizable()
Section titled “setMaximizable()”setMaximizable(maximizable: boolean): Promise<void>;Defined in: packages/api/src/window.ts:1150
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.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setMaximizable(false);Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
maximizable |
boolean |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-maximizable permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setMaxSize()
Section titled “setMaxSize()”setMaxSize(size: PhysicalSize | LogicalSize | Size | null | undefined): Promise<void>;Defined in: packages/api/src/window.ts:1639
Sets the window maximum inner size. If the size argument is undefined, the constraint is unset.
Example
Section titled “Example”import { getCurrentWindow, LogicalSize } from '@tauri-apps/api/window';await getCurrentWindow().setMaxSize(new LogicalSize(600, 500));Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
size |
| PhysicalSize | LogicalSize | Size | null | undefined |
The logical or physical inner size, or null to unset the constraint. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-max-size permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setMinimizable()
Section titled “setMinimizable()”setMinimizable(minimizable: boolean): Promise<void>;Defined in: packages/api/src/window.ts:1175
Sets whether the window’s native minimize button is enabled or not.
Platform-specific
- Linux / iOS / Android: Unsupported.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setMinimizable(false);Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
minimizable |
boolean |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-minimizable permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setMinSize()
Section titled “setMinSize()”setMinSize(size: PhysicalSize | LogicalSize | Size | null | undefined): Promise<void>;Defined in: packages/api/src/window.ts:1616
Sets the window minimum inner size. If the size argument is not provided, the constraint is unset.
Example
Section titled “Example”import { getCurrentWindow, PhysicalSize } from '@tauri-apps/api/window';await getCurrentWindow().setMinSize(new PhysicalSize(600, 500));Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
size |
| PhysicalSize | LogicalSize | Size | null | undefined |
The logical or physical inner size, or null to unset the constraint. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-min-size permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setOverlayIcon()
Section titled “setOverlayIcon()”setOverlayIcon(icon?: JsImage): Promise<void>;Defined in: packages/api/src/window.ts:2152
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"] }Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setOverlayIcon("/tauri/awesome.png");Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
icon? |
JsImage |
Icon bytes or path to the icon file. Use undefined to remove the overlay icon. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-overlay-icon permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setPosition()
Section titled “setPosition()”setPosition(position: PhysicalPosition | LogicalPosition | Position): Promise<void>;Defined in: packages/api/src/webview.ts:557
Sets the webview position.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';import { LogicalPosition } from '@tauri-apps/api/dpi';await getCurrentWebview().setPosition(new LogicalPosition(600, 500));Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
position |
| PhysicalPosition | LogicalPosition | Position |
The new position, in logical or physical pixels, relative to the top-left corner of the hosting window. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:webview:allow-set-webview-position permission (not
included in core:webview:default).
Inherited from
Section titled “Inherited from”setProgressBar()
Section titled “setProgressBar()”setProgressBar(state: ProgressBarState): Promise<void>;Defined in: packages/api/src/window.ts:2181
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).
Example
Section titled “Example”import { getCurrentWindow, ProgressBarStatus } from '@tauri-apps/api/window';await getCurrentWindow().setProgressBar({ status: ProgressBarStatus.Normal, progress: 50,});Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
state |
ProgressBarState |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-progress-bar permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setResizable()
Section titled “setResizable()”setResizable(resizable: boolean): Promise<void>;Defined in: packages/api/src/window.ts:1080
Updates the window resizable flag.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setResizable(false);Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
resizable |
boolean |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-resizable permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setShadow()
Section titled “setShadow()”setShadow(enable: boolean): Promise<void>;Defined in: packages/api/src/window.ts:1445
Whether or not the window should have shadow.
Platform-specific
- Windows:
falsehas no effect on decorated window, shadows are always ON.truewill make undecorated window have a 1px white border, and on Windows 11, it will have a rounded corners.
- Linux: Unsupported.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setShadow(false);Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
enable |
boolean |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-shadow permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setSimpleFullscreen()
Section titled “setSimpleFullscreen()”setSimpleFullscreen(fullscreen: boolean): Promise<void>;Defined in: packages/api/src/window.ts:1774
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.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setSimpleFullscreen(true);Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
fullscreen |
boolean |
Whether the window should go to simple fullscreen or not. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-simple-fullscreen permission (not included
in core:window:default).
2.8.0
Inherited from
Section titled “Inherited from”setSize()
Section titled “setSize()”setSize(size: PhysicalSize | LogicalSize | Size): Promise<void>;Defined in: packages/api/src/webview.ts:534
Resizes the webview.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';import { LogicalSize } from '@tauri-apps/api/dpi';await getCurrentWebview().setSize(new LogicalSize(600, 500));Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
size |
| PhysicalSize | LogicalSize | Size |
The logical or physical size. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:webview:allow-set-webview-size permission (not
included in core:webview:default).
Inherited from
Section titled “Inherited from”setSizeConstraints()
Section titled “setSizeConstraints()”setSizeConstraints(constraints: WindowSizeConstraints | null | undefined): Promise<void>;Defined in: packages/api/src/window.ts:1664
Sets the window inner size constraints.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setSizeConstraints({ minWidth: 300 });Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
constraints |
| WindowSizeConstraints | null | undefined |
The inner size constraints in logical pixels, or null to unset every constraint. Each field is optional and independent, so { minWidth: 300 } constrains only the width. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-size-constraints permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setSkipTaskbar()
Section titled “setSkipTaskbar()”setSkipTaskbar(skip: boolean): Promise<void>;Defined in: packages/api/src/window.ts:1873
Whether the window icon should be hidden from the taskbar or not.
Platform-specific
- macOS: Unsupported.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setSkipTaskbar(true);Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
skip |
boolean |
true to hide window icon, false to show it. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-skip-taskbar permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setTheme()
Section titled “setTheme()”setTheme(theme?: Theme | null): Promise<void>;Defined in: packages/api/src/window.ts:2272
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.
Use Window.theme to read the effective theme and Window.onThemeChanged to react to changes.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setTheme('dark');// follow the system theme againawait getCurrentWindow().setTheme(null);Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
theme? |
Theme | null |
The theme to apply, or null/undefined to follow the system theme. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-theme permission (not included
in core:window:default).
2.0.0
Inherited from
Section titled “Inherited from”setTitle()
Section titled “setTitle()”setTitle(title: string): Promise<void>;Defined in: packages/api/src/window.ts:1222
Sets the window title.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setTitle('Tauri');Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
title |
string |
The new title |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-title permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”setTitleBarStyle()
Section titled “setTitleBarStyle()”setTitleBarStyle(style: TitleBarStyle): Promise<void>;Defined in: packages/api/src/window.ts:2238
Sets the title bar style. macOS only.
Use transparent or overlay to build a custom title bar: with overlay the
page extends under the title bar and only the traffic lights remain, so leave
room for them in your layout and pair it with Window.startDragging on a
draggable region.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setTitleBarStyle('overlay');Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
style |
TitleBarStyle |
The new title bar style, see TitleBarStyle. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-title-bar-style permission (not included
in core:window:default).
2.0.0
Inherited from
Section titled “Inherited from”setVisibleOnAllWorkspaces()
Section titled “setVisibleOnAllWorkspaces()”setVisibleOnAllWorkspaces(visible: boolean): Promise<void>;Defined in: packages/api/src/window.ts:2209
Sets whether the window should be visible on all workspaces or virtual desktops.
Platform-specific
- Windows / iOS / Android: Unsupported.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setVisibleOnAllWorkspaces(true);Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
visible |
boolean |
Whether the window should follow the user across workspaces. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-set-visible-on-all-workspaces permission (not included
in core:window:default).
2.0.0
Inherited from
Section titled “Inherited from”Window.setVisibleOnAllWorkspaces
setZoom()
Section titled “setZoom()”setZoom(scaleFactor: number): Promise<void>;Defined in: packages/api/src/webview.ts:657
Set webview zoom level.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().setZoom(1.5);Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
scaleFactor |
number |
The zoom level, where 1 is 100%. |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:webview:allow-set-webview-zoom permission (not
included in core:webview:default).
Inherited from
Section titled “Inherited from”show()
Section titled “show()”show(): Promise<void>;Defined in: packages/api/src/webview.ts:637
Show the webview.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().show();Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:webview:allow-webview-show permission (not
included in core:webview:default).
Inherited from
Section titled “Inherited from”size()
Section titled “size()”size(): Promise<PhysicalSize>;Defined in: packages/api/src/webview.ts:489
The physical size of the webview’s client area. The client area is the content of the webview, excluding the title bar and borders.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';const size = await getCurrentWebview().size();Returns
Section titled “Returns”The webview’s size, in physical pixels.
Remarks
Section titled “Remarks”Uses the core:webview:allow-webview-size permission, which is part
of core:webview:default.
Inherited from
Section titled “Inherited from”startDragging()
Section titled “startDragging()”startDragging(): Promise<void>;Defined in: packages/api/src/window.ts:2050
Starts dragging the window.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().startDragging();Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-start-dragging permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”startResizeDragging()
Section titled “startResizeDragging()”startResizeDragging(direction: ResizeDirection): Promise<void>;Defined in: packages/api/src/window.ts:2069
Starts resize-dragging the window.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().startResizeDragging();Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
direction |
ResizeDirection |
Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-start-resize-dragging permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”theme()
Section titled “theme()”theme(): Promise<Theme | null>;Defined in: packages/api/src/window.ts:915
Gets the window’s current theme.
Platform-specific
- macOS: Theme was introduced on macOS 10.14. Returns
lighton macOS 10.13 and below.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const theme = await getCurrentWindow().theme();Returns
Section titled “Returns”The window theme.
Inherited from
Section titled “Inherited from”title()
Section titled “title()”title(): Promise<string>;Defined in: packages/api/src/window.ts:894
Gets the window’s current title.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const title = await getCurrentWindow().title();Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”toggleMaximize()
Section titled “toggleMaximize()”toggleMaximize(): Promise<void>;Defined in: packages/api/src/window.ts:1280
Toggles the window maximized state.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().toggleMaximize();Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-toggle-maximize permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”unmaximize()
Section titled “unmaximize()”unmaximize(): Promise<void>;Defined in: packages/api/src/window.ts:1261
Unmaximizes the window.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().unmaximize();Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-unmaximize permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”unminimize()
Section titled “unminimize()”unminimize(): Promise<void>;Defined in: packages/api/src/window.ts:1318
Unminimizes the window.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().unminimize();Returns
Section titled “Returns”A promise indicating the success or failure of the operation.
Remarks
Section titled “Remarks”Requires the core:window:allow-unminimize permission (not included
in core:window:default).
Inherited from
Section titled “Inherited from”getAll()
Section titled “getAll()”static getAll(): Promise<WebviewWindow[]>;Defined in: packages/api/src/webviewWindow.ts:172
Gets a list of instances of Webview for all available webviews.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”getByLabel()
Section titled “getByLabel()”static getByLabel(label: string): Promise< | WebviewWindow| null>;Defined in: packages/api/src/webviewWindow.ts:152
Gets the Webview for the webview associated with the given label.
Example
Section titled “Example”import { WebviewWindow } from '@tauri-apps/api/webviewWindow';const mainWebview = WebviewWindow.getByLabel('main');Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
label |
string |
The webview label. |
Returns
Section titled “Returns”Promise<
| WebviewWindow
| null>
The Webview instance to communicate with the webview or null if the webview doesn’t exist.
Inherited from
Section titled “Inherited from”getCurrent()
Section titled “getCurrent()”static getCurrent(): WebviewWindow;Defined in: packages/api/src/webviewWindow.ts:165
Get an instance of Webview for the current webview.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”References
Section titled “References”Re-exports Color
DragDropEvent
Section titled “DragDropEvent”Re-exports DragDropEvent
© 2026 Tauri Contributors. CC-BY / MIT