window
Esta página aún no está disponible en tu idioma.
Provides APIs to create windows, communicate with other windows and manipulate the current window.
Window events
Section titled “Window events”Events can be listened to using Window.listen:
import { getCurrentWindow } from "@tauri-apps/api/window";getCurrentWindow().listen("my-window-event", ({ event, payload }) => { });This package is also accessible with window.__TAURI__.window when app.withGlobalTauri in tauri.conf.json is set to true.
Remarks
Section titled “Remarks”core:window:default only enables the getters (sizes, positions,
monitors, title, theme and the is* queries). Creating a window and every
method that changes one needs its own permission, which each member documents,
added to a capability in your app.
Enumerations
Section titled “Enumerations”BackgroundThrottlingPolicy
Section titled “BackgroundThrottlingPolicy”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2586
Background throttling policy
2.0.0
Enumeration Members
Section titled “Enumeration Members”Disabled
Section titled “Disabled”Disabled: "disabled";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2587
Suspend
Section titled “Suspend”Suspend: "suspend";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2589
Throttle
Section titled “Throttle”Throttle: "throttle";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2588
Effect
Section titled “Effect”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2620
Platform-specific window effects
2.0.0
Enumeration Members
Section titled “Enumeration Members”Acrylic
Section titled “Acrylic”Acrylic: "acrylic";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2734
Windows 10/11
This effect has bad performance when resizing/dragging the window on Windows 10 v1903+ and Windows 11 build 22000.
AppearanceBased
Section titled “AppearanceBased”AppearanceBased: "appearanceBased";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2626
A default material appropriate for the view’s effectiveAppearance. macOS 10.14-
Deprecated
Section titled “Deprecated”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#L2726
Windows 7/10/11(22H1) Only
This effect has bad performance when resizing/dragging the window on Windows 11 build 22621.
ContentBackground
Section titled “ContentBackground”ContentBackground: "contentBackground";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2698
macOS 10.14+
Dark: "dark";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2638
macOS 10.14-
Deprecated
Section titled “Deprecated”since macOS 10.14. Use a semantic material instead.
FullScreenUI
Section titled “FullScreenUI”FullScreenUI: "fullScreenUI";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2690
macOS 10.14+
HeaderView
Section titled “HeaderView”HeaderView: "headerView";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2674
macOS 10.14+
HudWindow
Section titled “HudWindow”HudWindow: "hudWindow";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2686
macOS 10.14+
Light: "light";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2632
macOS 10.14-
Deprecated
Section titled “Deprecated”since macOS 10.14. Use a semantic material instead.
LiquidGlassClear
Section titled “LiquidGlassClear”LiquidGlassClear: "liquidGlassClear";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2714
macOS 26.0+
LiquidGlassRegular
Section titled “LiquidGlassRegular”LiquidGlassRegular: "liquidGlassRegular";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2710
macOS 26.0+
MediumLight
Section titled “MediumLight”MediumLight: "mediumLight";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2644
macOS 10.14-
Deprecated
Section titled “Deprecated”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#L2662
macOS 10.11+
Mica: "mica";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2718
Windows 11 Only
Popover
Section titled “Popover”Popover: "popover";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2666
macOS 10.11+
Selection
Section titled “Selection”Selection: "selection";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2658
macOS 10.10+
Sheet: "sheet";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2678
macOS 10.14+
Sidebar
Section titled “Sidebar”Sidebar: "sidebar";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2670
macOS 10.11+
Tabbed
Section titled “Tabbed”Tabbed: "tabbed";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2738
Tabbed effect that matches the system dark preference Windows 11 Only
TabbedDark
Section titled “TabbedDark”TabbedDark: "tabbedDark";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2742
Tabbed effect with dark mode but only if dark mode is enabled on the system Windows 11 Only
TabbedLight
Section titled “TabbedLight”TabbedLight: "tabbedLight";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2746
Tabbed effect with light mode Windows 11 Only
Titlebar
Section titled “Titlebar”Titlebar: "titlebar";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2654
macOS 10.10+
Tooltip
Section titled “Tooltip”Tooltip: "tooltip";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2694
macOS 10.14+
UltraDark
Section titled “UltraDark”UltraDark: "ultraDark";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2650
macOS 10.14-
Deprecated
Section titled “Deprecated”since macOS 10.14. Use a semantic material instead.
UnderPageBackground
Section titled “UnderPageBackground”UnderPageBackground: "underPageBackground";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2706
macOS 10.14+
UnderWindowBackground
Section titled “UnderWindowBackground”UnderWindowBackground: "underWindowBackground";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2702
macOS 10.14+
WindowBackground
Section titled “WindowBackground”WindowBackground: "windowBackground";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2682
macOS 10.14+
EffectState
Section titled “EffectState”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2756
Window effect state macOS only
https://developer.apple.com/documentation/appkit/nsvisualeffectview/state
2.0.0
Enumeration Members
Section titled “Enumeration Members”Active
Section titled “Active”Active: "active";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2764
Make window effect state always active macOS only
FollowsWindowActiveState
Section titled “FollowsWindowActiveState”FollowsWindowActiveState: "followsWindowActiveState";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2760
Make window effect state follow the window’s active state macOS only
Inactive
Section titled “Inactive”Inactive: "inactive";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2768
Make window effect state always inactive macOS only
ProgressBarStatus
Section titled “ProgressBarStatus”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L243
The state of the taskbar/dock progress bar, see Window.setProgressBar.
2.0.0
Enumeration Members
Section titled “Enumeration Members”Error: "error";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L263
Error state. Treated as Normal on linux
Indeterminate
Section titled “Indeterminate”Indeterminate: "indeterminate";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L255
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#L247
Hide progress bar.
Normal
Section titled “Normal”Normal: "normal";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L251
Normal state.
Paused
Section titled “Paused”Paused: "paused";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L259
Paused state. Treated as Normal on Linux
ScrollBarStyle
Section titled “ScrollBarStyle”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2601
The scrollbar style to use in the webview.
Platform-specific
Section titled “Platform-specific”Windows: This option must be given the same value for all webviews.
2.8.0
Enumeration Members
Section titled “Enumeration Members”Default
Section titled “Default”Default: "default";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2605
The default scrollbar style for the webview.
FluentOverlay
Section titled “FluentOverlay”FluentOverlay: "fluentOverlay";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2612
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
UserAttentionType
Section titled “UserAttentionType”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L141
Attention type to request on a window.
1.0.0
Enumeration Members
Section titled “Enumeration Members”Critical
Section titled “Critical”Critical: 1;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L147
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
Section titled “Informational”Informational: 2;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L153
Platform-specific
- macOS: Bounces the dock icon once.
- Windows: Flashes the taskbar button until the application is in focus.
Classes
Section titled “Classes”CloseRequestedEvent
Section titled “CloseRequestedEvent”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L162
The event passed to a Window.onCloseRequested handler.
Call CloseRequestedEvent.preventDefault to keep the window open, for example to ask the user to save their work first.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CloseRequestedEvent(event): CloseRequestedEvent;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L169
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
event |
Event<unknown> |
Returns
Section titled “Returns”Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
event |
EventName |
Event name | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L164 |
id |
number |
Event identifier used to unlisten | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L166 |
Methods
Section titled “Methods”isPreventDefault()
Section titled “isPreventDefault()”isPreventDefault(): boolean;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L185
Whether CloseRequestedEvent.preventDefault was called on this event.
Returns
Section titled “Returns”boolean
preventDefault()
Section titled “preventDefault()”preventDefault(): void;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L180
Prevents the window from being closed.
Must be called before the handler returns (await anything you need first), otherwise the window is destroyed as usual.
Returns
Section titled “Returns”void
Window
Section titled “Window”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L377
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 _.
Example
Section titled “Example”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 backendawait appWindow.emit("some-event", "data");// listen to an event from the backendconst unlisten = await appWindow.listen("event-name", e => {});unlisten();2.0.0
Extended by
Section titled “Extended by”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Window(label, options?): Window;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L405
Creates a new Window.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
label |
string |
The unique window label. Must be alphanumeric: a-zA-Z-/:_. |
options |
WindowOptions |
The window configuration, see WindowOptions. |
Returns
Section titled “Returns”The Window instance to communicate with the window.
Example
Section titled “Example”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});Remarks
Section titled “Remarks”Requires the core:window:allow-create permission (not included in
core:window:default).
Properties
Section titled “Properties”| 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#L379 |
listeners |
Record<string, EventCallback<any>[]> |
Local event listeners. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L382 |
Methods
Section titled “Methods”activityName()
Section titled “activityName()”activityName(): Promise<string>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L965
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.
Returns
Section titled “Returns”Promise<string>
The activity name.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const activity = await getCurrentWindow().activityName();Remarks
Section titled “Remarks”Uses the core:window:allow-activity-name permission, which is part
of core:window:default.
2.11.0
center()
Section titled “center()”center(): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1020
Centers the window.
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().center();Remarks
Section titled “Remarks”Requires the core:window:allow-center permission (not included
in core:window:default).
clearEffects()
Section titled “clearEffects()”clearEffects(): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1512
Clear any applied effects if possible.
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().clearEffects();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
close()
Section titled “close()”close(): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1377
Closes the window.
Note this emits a closeRequested event so you can intercept it. To force window close, use Window.destroy.
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().close();Remarks
Section titled “Remarks”Requires the core:window:allow-close permission (not included
in core:window:default).
destroy()
Section titled “destroy()”destroy(): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1396
Destroys the window. Behaves like Window.close but forces the window close instead of emitting a closeRequested event.
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().destroy();Remarks
Section titled “Remarks”Requires the core:window:allow-destroy permission (not included
in core:window:default).
emit()
Section titled “emit()”emit<T>(event, payload?): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L563
Emits an event to all targets.
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”Promise<void>
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().emit('window-loaded', { loggedIn: true, token: 'authToken' });emitTo()
Section titled “emitTo()”emitTo<T>( target, event, payload?): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L590
Emits an event to all targets matching the given target.
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”Promise<void>
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().emitTo('main', 'window-loaded', { loggedIn: true, token: 'authToken' });hide()
Section titled “hide()”hide(): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1356
Sets the window visibility to false.
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().hide();Remarks
Section titled “Remarks”Requires the core:window:allow-hide permission (not included
in core:window:default).
innerPosition()
Section titled “innerPosition()”innerPosition(): Promise<PhysicalPosition>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L651
The position of the top-left hand corner of the window’s client area relative to the top-left hand corner of the desktop.
Returns
Section titled “Returns”The window’s inner position.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const position = await getCurrentWindow().innerPosition();innerSize()
Section titled “innerSize()”innerSize(): Promise<PhysicalSize>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L684
The physical size of the window’s client area. The client area is the content of the window, excluding the title bar and borders.
Returns
Section titled “Returns”The window’s inner size.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const size = await getCurrentWindow().innerSize();isAlwaysOnTop()
Section titled “isAlwaysOnTop()”isAlwaysOnTop(): Promise<boolean>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L931
Whether the window is configured to be always on top of other windows or not.
Returns
Section titled “Returns”Promise<boolean>
Whether the window is visible or not.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const alwaysOnTop = await getCurrentWindow().isAlwaysOnTop();isClosable()
Section titled “isClosable()”isClosable(): Promise<boolean>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L864
Gets the window’s native close button state.
Platform-specific
- iOS / Android: Unsupported.
Returns
Section titled “Returns”Promise<boolean>
Whether the window’s native close button is enabled or not.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const closable = await getCurrentWindow().isClosable();isDecorated()
Section titled “isDecorated()”isDecorated(): Promise<boolean>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L785
Gets the window’s current decorated state.
Returns
Section titled “Returns”Promise<boolean>
Whether the window is decorated or not.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const decorated = await getCurrentWindow().isDecorated();isEnabled()
Section titled “isEnabled()”isEnabled(): Promise<boolean>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1124
Whether the window is enabled or disabled.
A disabled window ignores all user input; see Window.setEnabled.
Returns
Section titled “Returns”Promise<boolean>
true when the window accepts user input, false when it is disabled.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const enabled = await getCurrentWindow().isEnabled();2.0.0
isFocused()
Section titled “isFocused()”isFocused(): Promise<boolean>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L769
Gets the window’s current focus state.
Returns
Section titled “Returns”Promise<boolean>
Whether the window is focused or not.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const focused = await getCurrentWindow().isFocused();isFullscreen()
Section titled “isFullscreen()”isFullscreen(): Promise<boolean>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L723
Gets the window’s current fullscreen state.
Returns
Section titled “Returns”Promise<boolean>
Whether the window is in fullscreen mode or not.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const fullscreen = await getCurrentWindow().isFullscreen();isMaximizable()
Section titled “isMaximizable()”isMaximizable(): Promise<boolean>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L822
Gets the window’s native maximize button state.
Platform-specific
- Linux / iOS / Android: Unsupported.
Returns
Section titled “Returns”Promise<boolean>
Whether the window’s native maximize button is enabled or not.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const maximizable = await getCurrentWindow().isMaximizable();isMaximized()
Section titled “isMaximized()”isMaximized(): Promise<boolean>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L753
Gets the window’s current maximized state.
Returns
Section titled “Returns”Promise<boolean>
Whether the window is maximized or not.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const maximized = await getCurrentWindow().isMaximized();isMinimizable()
Section titled “isMinimizable()”isMinimizable(): Promise<boolean>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L843
Gets the window’s native minimize button state.
Platform-specific
- Linux / iOS / Android: Unsupported.
Returns
Section titled “Returns”Promise<boolean>
Whether the window’s native minimize button is enabled or not.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const minimizable = await getCurrentWindow().isMinimizable();isMinimized()
Section titled “isMinimized()”isMinimized(): Promise<boolean>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L737
Gets the window’s current minimized state.
Returns
Section titled “Returns”Promise<boolean>
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const minimized = await getCurrentWindow().isMinimized();isResizable()
Section titled “isResizable()”isResizable(): Promise<boolean>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L801
Gets the window’s current resizable state.
Returns
Section titled “Returns”Promise<boolean>
Whether the window is resizable or not.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const resizable = await getCurrentWindow().isResizable();isVisible()
Section titled “isVisible()”isVisible(): Promise<boolean>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L880
Gets the window’s current visible state.
Returns
Section titled “Returns”Promise<boolean>
Whether the window is visible or not.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const visible = await getCurrentWindow().isVisible();listen()
Section titled “listen()”listen<T>(event, handler): Promise<UnlistenFn>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L498
Listen to an emitted event on this window.
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.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const unlisten = await getCurrentWindow().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();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.
maximize()
Section titled “maximize()”maximize(): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1242
Maximizes the window.
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().maximize();Remarks
Section titled “Remarks”Requires the core:window:allow-maximize permission (not included
in core:window:default).
minimize()
Section titled “minimize()”minimize(): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1299
Minimizes the window.
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().minimize();Remarks
Section titled “Remarks”Requires the core:window:allow-minimize permission (not included
in core:window:default).
once()
Section titled “once()”once<T>(event, handler): Promise<UnlistenFn>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L536
Listen to an emitted event on this window only once.
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.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const unlisten = await getCurrentWindow().once<null>('initialized', (event) => { console.log(`Window initialized!`);});
// call unlisten when your handler goes out of scope e.g. the component is unmountedunlisten();Remarks
Section titled “Remarks”The listener removes itself after the first event and is also removed automatically when this window is destroyed. Do call the returned function if the listener’s own scope ends before the event arrives.
onCloseRequested()
Section titled “onCloseRequested()”onCloseRequested(handler): Promise<UnlistenFn>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2365
Listen to window close requested. Emitted when the user requests to closes the window.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
handler |
(event) => | void | Promise<void> |
Returns
Section titled “Returns”A promise resolving to a function to unlisten to the event.
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();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.
onDragDropEvent()
Section titled “onDragDropEvent()”onDragDropEvent(handler): Promise<UnlistenFn>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2407
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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
handler |
EventCallback<DragDropEvent> |
Returns
Section titled “Returns”A promise resolving to a function to unlisten to the event.
Example
Section titled “Example”import { getCurrentWindow } from "@tauri-apps/api/window";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'); }});
// call unlisten when your handler goes out of scope e.g. the component is unmountedunlisten();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.
onFocusChanged()
Section titled “onFocusChanged()”onFocusChanged(handler): Promise<UnlistenFn>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2489
Listen to window focus change.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
handler |
EventCallback<boolean> |
Returns
Section titled “Returns”A promise resolving to a function to unlisten to the event.
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();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.
onMoved()
Section titled “onMoved()”onMoved(handler): Promise<UnlistenFn>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2330
Listen to window move.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
handler |
EventCallback<PhysicalPosition> |
Returns
Section titled “Returns”A promise resolving to a function to unlisten to the event.
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();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.
onResized()
Section titled “onResized()”onResized(handler): Promise<UnlistenFn>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2302
Listen to window resize.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
handler |
EventCallback<PhysicalSize> |
Returns
Section titled “Returns”A promise resolving to a function to unlisten to the event.
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();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.
onScaleChanged()
Section titled “onScaleChanged()”onScaleChanged(handler): Promise<UnlistenFn>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2533
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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
handler |
EventCallback<ScaleFactorChanged> |
Returns
Section titled “Returns”A promise resolving to a function to unlisten to the event.
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();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.
onThemeChanged()
Section titled “onThemeChanged()”onThemeChanged(handler): Promise<UnlistenFn>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2563
Listen to the system theme change.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
handler |
EventCallback<Theme> |
Returns
Section titled “Returns”A promise resolving to a function to unlisten to the event.
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();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.
outerPosition()
Section titled “outerPosition()”outerPosition(): Promise<PhysicalPosition>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L667
The position of the top-left hand corner of the window relative to the top-left hand corner of the desktop.
Returns
Section titled “Returns”The window’s outer position.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const position = await getCurrentWindow().outerPosition();outerSize()
Section titled “outerSize()”outerSize(): Promise<PhysicalSize>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L704
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.
Returns
Section titled “Returns”The window’s outer size.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const size = await getCurrentWindow().outerSize();requestUserAttention()
Section titled “requestUserAttention()”requestUserAttention(requestType): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1049
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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
requestType |
| UserAttentionType | null |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().requestUserAttention();Remarks
Section titled “Remarks”Requires the core:window:allow-request-user-attention permission (not included
in core:window:default).
scaleFactor()
Section titled “scaleFactor()”scaleFactor(): Promise<number>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L635
The scale factor that can be used to map physical pixels to logical pixels.
Returns
Section titled “Returns”Promise<number>
The window’s monitor scale factor.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const factor = await getCurrentWindow().scaleFactor();sceneIdentifier()
Section titled “sceneIdentifier()”sceneIdentifier(): Promise<string>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L999
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.
Returns
Section titled “Returns”Promise<string>
The scene identifier.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const scene = await getCurrentWindow().sceneIdentifier();Remarks
Section titled “Remarks”Uses the core:window:allow-scene-identifier permission, which is part
of core:window:default.
2.11.0
setAlwaysOnBottom()
Section titled “setAlwaysOnBottom()”setAlwaysOnBottom(alwaysOnBottom): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1554
Whether the window should always be below other windows.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
alwaysOnBottom |
boolean |
Whether the window should always be below other windows or not. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setAlwaysOnBottom(true);Remarks
Section titled “Remarks”Requires the core:window:allow-set-always-on-bottom permission (not included
in core:window:default).
setAlwaysOnTop()
Section titled “setAlwaysOnTop()”setAlwaysOnTop(alwaysOnTop): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1533
Whether the window should always be on top of other windows.
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”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setAlwaysOnTop(true);Remarks
Section titled “Remarks”Requires the core:window:allow-set-always-on-top permission (not included
in core:window:default).
setBackgroundColor()
Section titled “setBackgroundColor()”setBackgroundColor(color): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1985
Sets the window background color.
Platform-specific:
- Windows: alpha channel is ignored.
- iOS / Android: Unsupported.
This sets the color of the window itself, which is what you see while the webview is still loading or behind a transparent page. To also change the webview background use WebviewWindow.setBackgroundColor.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
color |
Color |
The new background color, see Color. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setBackgroundColor('#2f2f2f');// also accepts an RGB/RGBA tuple or an objectawait getCurrentWindow().setBackgroundColor([47, 47, 47, 255]);Remarks
Section titled “Remarks”Requires the core:window:allow-set-background-color permission (not included
in core:window:default).
2.1.0
setBadgeCount()
Section titled “setBadgeCount()”setBadgeCount(count?): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2095
Sets the badge count. It is app wide and not specific to this window.
Platform-specific
- Windows: Unsupported. Use
Window.setOverlayIconinstead.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
count? |
number |
The badge count. Use undefined to remove the badge. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setBadgeCount(5);Remarks
Section titled “Remarks”Requires the core:window:allow-set-badge-count permission (not included
in core:window:default).
setBadgeLabel()
Section titled “setBadgeLabel()”setBadgeLabel(label?): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2120
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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
label? |
string |
The badge label. Use undefined to remove the badge. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setBadgeLabel("Hello");Remarks
Section titled “Remarks”Requires the core:window:allow-set-badge-label permission (not included
in core:window:default).
setClosable()
Section titled “setClosable()”setClosable(closable): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1201
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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
closable |
boolean |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setClosable(false);Remarks
Section titled “Remarks”Requires the core:window:allow-set-closable permission (not included
in core:window:default).
setContentProtected()
Section titled “setContentProtected()”setContentProtected(protected_): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1574
Prevents the window contents from being captured by other apps.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
protected_ |
boolean |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setContentProtected(true);Remarks
Section titled “Remarks”Requires the core:window:allow-set-content-protected permission (not included
in core:window:default).
setCursorGrab()
Section titled “setCursorGrab()”setCursorGrab(grab): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1902
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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
grab |
boolean |
true to grab the cursor icon, false to release it. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setCursorGrab(true);Remarks
Section titled “Remarks”Requires the core:window:allow-set-cursor-grab permission (not included
in core:window:default).
setCursorIcon()
Section titled “setCursorIcon()”setCursorIcon(icon): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1950
Modifies the cursor icon of the window.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
icon |
CursorIcon |
The new cursor icon. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setCursorIcon('help');Remarks
Section titled “Remarks”Requires the core:window:allow-set-cursor-icon permission (not included
in core:window:default).
setCursorPosition()
Section titled “setCursorPosition()”setCursorPosition(position): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2006
Changes the position of the cursor in window coordinates.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
position |
| PhysicalPosition | LogicalPosition | Position |
The new cursor position. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow, LogicalPosition } from '@tauri-apps/api/window';await getCurrentWindow().setCursorPosition(new LogicalPosition(600, 300));Remarks
Section titled “Remarks”Requires the core:window:allow-set-cursor-position permission (not included
in core:window:default).
setCursorVisible()
Section titled “setCursorVisible()”setCursorVisible(visible): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1929
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.
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”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setCursorVisible(false);Remarks
Section titled “Remarks”Requires the core:window:allow-set-cursor-visible permission (not included
in core:window:default).
setDecorations()
Section titled “setDecorations()”setDecorations(decorations): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1416
Whether the window should have borders and bars.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
decorations |
boolean |
Whether the window should have borders and bars. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setDecorations(false);Remarks
Section titled “Remarks”Requires the core:window:allow-set-decorations permission (not included
in core:window:default).
setEffects()
Section titled “setEffects()”setEffects(effects): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1489
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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
effects |
Effects |
The effects to apply, see Effects. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
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});Remarks
Section titled “Remarks”Requires the core:window:allow-set-effects permission (not included
in core:window:default).
2.0.0
setEnabled()
Section titled “setEnabled()”setEnabled(enabled): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1102
Enable or disable the window.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
enabled |
boolean |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setEnabled(false);Remarks
Section titled “Remarks”Requires the core:window:allow-set-enabled permission (not included
in core:window:default).
2.0.0
setFocus()
Section titled “setFocus()”setFocus(): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1794
Bring the window to front and focus.
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setFocus();Remarks
Section titled “Remarks”Requires the core:window:allow-set-focus permission (not included
in core:window:default).
setFocusable()
Section titled “setFocusable()”setFocusable(focusable): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1820
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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
focusable |
boolean |
Whether the window can be focused. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setFocusable(true);Remarks
Section titled “Remarks”Requires the core:window:allow-set-focusable permission (not included
in core:window:default).
setFullscreen()
Section titled “setFullscreen()”setFullscreen(fullscreen): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1719
Sets the window fullscreen state.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
fullscreen |
boolean |
Whether the window should go to fullscreen or not. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setFullscreen(true);Remarks
Section titled “Remarks”Requires the core:window:allow-set-fullscreen permission (not included
in core:window:default).
setFullscreenOnMonitor()
Section titled “setFullscreenOnMonitor()”setFullscreenOnMonitor(position): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1747
Sets the window as fullscreen on the monitor that contains the given physical position.
Does nothing if no monitor contains the 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”Promise<void>
A promise indicating the success or failure of the operation.
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);}Remarks
Section titled “Remarks”Requires the core:window:allow-set-fullscreen-on-monitor permission (not included
in core:window:default).
2.12.0
setIcon()
Section titled “setIcon()”setIcon(icon): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1848
Sets the window icon.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
icon |
JsImage |
Icon bytes or path to the icon file. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
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"] }Remarks
Section titled “Remarks”Requires the core:window:allow-set-icon permission (not included
in core:window:default).
setIgnoreCursorEvents()
Section titled “setIgnoreCursorEvents()”setIgnoreCursorEvents(ignore): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2030
Changes the cursor events behavior.
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”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setIgnoreCursorEvents(true);Remarks
Section titled “Remarks”Requires the core:window:allow-set-ignore-cursor-events permission (not included
in core:window:default).
setMaximizable()
Section titled “setMaximizable()”setMaximizable(maximizable): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1150
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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
maximizable |
boolean |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setMaximizable(false);Remarks
Section titled “Remarks”Requires the core:window:allow-set-maximizable permission (not included
in core:window:default).
setMaxSize()
Section titled “setMaxSize()”setMaxSize(size): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1639
Sets the window maximum inner size. If the size argument is undefined, the constraint is unset.
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”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow, LogicalSize } from '@tauri-apps/api/window';await getCurrentWindow().setMaxSize(new LogicalSize(600, 500));Remarks
Section titled “Remarks”Requires the core:window:allow-set-max-size permission (not included
in core:window:default).
setMinimizable()
Section titled “setMinimizable()”setMinimizable(minimizable): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1175
Sets whether the window’s native minimize button is enabled or not.
Platform-specific
- Linux / iOS / Android: Unsupported.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
minimizable |
boolean |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setMinimizable(false);Remarks
Section titled “Remarks”Requires the core:window:allow-set-minimizable permission (not included
in core:window:default).
setMinSize()
Section titled “setMinSize()”setMinSize(size): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1616
Sets the window minimum inner size. If the size argument is not provided, the constraint is unset.
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”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow, PhysicalSize } from '@tauri-apps/api/window';await getCurrentWindow().setMinSize(new PhysicalSize(600, 500));Remarks
Section titled “Remarks”Requires the core:window:allow-set-min-size permission (not included
in core:window:default).
setOverlayIcon()
Section titled “setOverlayIcon()”setOverlayIcon(icon?): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2152
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"] }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”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setOverlayIcon("/tauri/awesome.png");Remarks
Section titled “Remarks”Requires the core:window:allow-set-overlay-icon permission (not included
in core:window:default).
setPosition()
Section titled “setPosition()”setPosition(position): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1696
Sets the window outer position.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
position |
| PhysicalPosition | LogicalPosition | Position |
The new position, in logical or physical pixels. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow, LogicalPosition } from '@tauri-apps/api/window';await getCurrentWindow().setPosition(new LogicalPosition(600, 500));Remarks
Section titled “Remarks”Requires the core:window:allow-set-position permission (not included
in core:window:default).
setProgressBar()
Section titled “setProgressBar()”setProgressBar(state): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2181
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).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
state |
ProgressBarState |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow, ProgressBarStatus } from '@tauri-apps/api/window';await getCurrentWindow().setProgressBar({ status: ProgressBarStatus.Normal, progress: 50,});Remarks
Section titled “Remarks”Requires the core:window:allow-set-progress-bar permission (not included
in core:window:default).
setResizable()
Section titled “setResizable()”setResizable(resizable): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1080
Updates the window resizable flag.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
resizable |
boolean |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setResizable(false);Remarks
Section titled “Remarks”Requires the core:window:allow-set-resizable permission (not included
in core:window:default).
setShadow()
Section titled “setShadow()”setShadow(enable): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1445
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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
enable |
boolean |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setShadow(false);Remarks
Section titled “Remarks”Requires the core:window:allow-set-shadow permission (not included
in core:window:default).
setSimpleFullscreen()
Section titled “setSimpleFullscreen()”setSimpleFullscreen(fullscreen): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1774
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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
fullscreen |
boolean |
Whether the window should go to simple fullscreen or not. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setSimpleFullscreen(true);Remarks
Section titled “Remarks”Requires the core:window:allow-set-simple-fullscreen permission (not included
in core:window:default).
2.8.0
setSize()
Section titled “setSize()”setSize(size): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1595
Resizes the window with a new inner size.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
size |
| PhysicalSize | LogicalSize | Size |
The logical or physical inner size. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow, LogicalSize } from '@tauri-apps/api/window';await getCurrentWindow().setSize(new LogicalSize(600, 500));Remarks
Section titled “Remarks”Requires the core:window:allow-set-size permission (not included
in core:window:default).
setSizeConstraints()
Section titled “setSizeConstraints()”setSizeConstraints(constraints): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1664
Sets the window inner size constraints.
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”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setSizeConstraints({ minWidth: 300 });Remarks
Section titled “Remarks”Requires the core:window:allow-set-size-constraints permission (not included
in core:window:default).
setSkipTaskbar()
Section titled “setSkipTaskbar()”setSkipTaskbar(skip): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1873
Whether the window icon should be hidden from the taskbar or not.
Platform-specific
- macOS: Unsupported.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
skip |
boolean |
true to hide window icon, false to show it. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setSkipTaskbar(true);Remarks
Section titled “Remarks”Requires the core:window:allow-set-skip-taskbar permission (not included
in core:window:default).
setTheme()
Section titled “setTheme()”setTheme(theme?): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2272
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.
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”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setTheme('dark');// follow the system theme againawait getCurrentWindow().setTheme(null);Remarks
Section titled “Remarks”Requires the core:window:allow-set-theme permission (not included
in core:window:default).
2.0.0
setTitle()
Section titled “setTitle()”setTitle(title): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1222
Sets the window title.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
title |
string |
The new title |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setTitle('Tauri');Remarks
Section titled “Remarks”Requires the core:window:allow-set-title permission (not included
in core:window:default).
setTitleBarStyle()
Section titled “setTitleBarStyle()”setTitleBarStyle(style): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2238
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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
style |
TitleBarStyle |
The new title bar style, see TitleBarStyle. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setTitleBarStyle('overlay');Remarks
Section titled “Remarks”Requires the core:window:allow-set-title-bar-style permission (not included
in core:window:default).
2.0.0
setVisibleOnAllWorkspaces()
Section titled “setVisibleOnAllWorkspaces()”setVisibleOnAllWorkspaces(visible): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2209
Sets whether the window should be visible on all workspaces or virtual desktops.
Platform-specific
- Windows / iOS / Android: Unsupported.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
visible |
boolean |
Whether the window should follow the user across workspaces. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().setVisibleOnAllWorkspaces(true);Remarks
Section titled “Remarks”Requires the core:window:allow-set-visible-on-all-workspaces permission (not included
in core:window:default).
2.0.0
show()
Section titled “show()”show(): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1337
Sets the window visibility to true.
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().show();Remarks
Section titled “Remarks”Requires the core:window:allow-show permission (not included
in core:window:default).
startDragging()
Section titled “startDragging()”startDragging(): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2050
Starts dragging the window.
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().startDragging();Remarks
Section titled “Remarks”Requires the core:window:allow-start-dragging permission (not included
in core:window:default).
startResizeDragging()
Section titled “startResizeDragging()”startResizeDragging(direction): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2069
Starts resize-dragging the window.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
direction |
ResizeDirection |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().startResizeDragging();Remarks
Section titled “Remarks”Requires the core:window:allow-start-resize-dragging permission (not included
in core:window:default).
theme()
Section titled “theme()”theme(): Promise<Theme | null>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L915
Gets the window’s current theme.
Platform-specific
- macOS: Theme was introduced on macOS 10.14. Returns
lighton macOS 10.13 and below.
Returns
Section titled “Returns”The window theme.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const theme = await getCurrentWindow().theme();title()
Section titled “title()”title(): Promise<string>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L894
Gets the window’s current title.
Returns
Section titled “Returns”Promise<string>
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';const title = await getCurrentWindow().title();toggleMaximize()
Section titled “toggleMaximize()”toggleMaximize(): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1280
Toggles the window maximized state.
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().toggleMaximize();Remarks
Section titled “Remarks”Requires the core:window:allow-toggle-maximize permission (not included
in core:window:default).
unmaximize()
Section titled “unmaximize()”unmaximize(): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1261
Unmaximizes the window.
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().unmaximize();Remarks
Section titled “Remarks”Requires the core:window:allow-unmaximize permission (not included
in core:window:default).
unminimize()
Section titled “unminimize()”unminimize(): Promise<void>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1318
Unminimizes the window.
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';await getCurrentWindow().unminimize();Remarks
Section titled “Remarks”Requires the core:window:allow-unminimize permission (not included
in core:window:default).
getAll()
Section titled “getAll()”static getAll(): Promise<Window[]>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L452
Gets a list of instances of Window for all available windows.
Returns
Section titled “Returns”getByLabel()
Section titled “getByLabel()”static getByLabel(label): Promise<Window | null>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L438
Gets the Window associated with the given label.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
label |
string |
The window label. |
Returns
Section titled “Returns”The Window instance to communicate with the window or null if the window doesn’t exist.
Example
Section titled “Example”import { Window } from '@tauri-apps/api/window';const mainWindow = Window.getByLabel('main');getCurrent()
Section titled “getCurrent()”static getCurrent(): Window;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L445
Get an instance of Window for the current window.
Returns
Section titled “Returns”getFocusedWindow()
Section titled “getFocusedWindow()”static getFocusedWindow(): Promise<Window | null>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L466
Gets the focused window.
Returns
Section titled “Returns”The Window instance or undefined if there is not any focused window.
Example
Section titled “Example”import { Window } from '@tauri-apps/api/window';const focusedWindow = Window.getFocusedWindow();Interfaces
Section titled “Interfaces”Effects
Section titled “Effects”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2775
The window effects configuration object
2.0.0
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
color? |
Color |
Window effect color. Platform-specific - Windows: Affects Effect.Blur and Effect.Acrylic only on Windows 10 v1903+. Doesn’t have any effect on Windows 7 or Windows 11. - macOS: Only affects Liquid Glass effects. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2801 |
effects |
Effect[] |
List of Window effects to apply to the Window. Generally, conflicting effects will apply the first one and ignore the rest but on macOS you can specify one Liquid Glass style and one Visual Effect material at the same time to make Tauri fallback to the latter on macOS 15 and below. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2783 |
interactive? |
boolean |
Enables interactive glass behavior, which adds a visual response to user interactions. macOS 27.0+. Only affects Liquid Glass effects. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2807 |
radius? |
number |
Window effect corner radius macOS Only | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2791 |
state? |
EffectState |
Window effect state macOS Only. Ignored for Liquid Glass Effects. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2787 |
Monitor
Section titled “Monitor”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L54
Allows you to retrieve information about a given monitor.
1.0.0
Properties
Section titled “Properties”| 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#L56 |
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#L82 |
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#L97 |
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#L65 |
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#L89 |
workArea.position |
PhysicalPosition |
- | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L90 |
workArea.size |
PhysicalSize |
- | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L91 |
PreventOverflowMargin
Section titled “PreventOverflowMargin”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2818
An extra margin kept free around a window when WindowOptions.preventOverflow limits it to the working area.
Values are in logical pixels.
2.5.0
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
height |
number |
The vertical margin, in logical pixels. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2822 |
width |
number |
The horizontal margin, in logical pixels. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2820 |
ProgressBarState
Section titled “ProgressBarState”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L300
The taskbar/dock progress indicator state, see Window.setProgressBar.
2.0.0
Properties
Section titled “Properties”| 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#L308 |
status? |
ProgressBarStatus |
The progress bar status. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L304 |
ScaleFactorChanged
Section titled “ScaleFactorChanged”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L129
The payload for the scaleChange event.
1.0.2
Properties
Section titled “Properties”| 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#L131 |
size |
PhysicalSize |
The new window size | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L133 |
WindowOptions
Section titled “WindowOptions”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2830
Configuration for the window to create.
1.0.0
Properties
Section titled “Properties”| 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#L3057 |
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#L3031 |
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#L2897 |
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#L2895 |
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#L3008 |
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#L3022 |
center? |
boolean |
Show window in the center of the screen.. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2832 |
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#L2963 |
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#L2899 |
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#L3063 |
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#L2893 |
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#L3038 |
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#L2877 |
focusable? |
boolean |
Whether the window can be focused or not. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2879 |
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#L2875 |
height? |
number |
The initial height in logical pixels. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2846 |
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#L2944 |
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#L3026 |
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#L2854 |
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#L2955 |
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#L2889 |
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#L2852 |
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#L2850 |
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#L2959 |
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#L2848 |
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#L2908 |
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#L2977 |
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#L2869 |
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#L3070 |
resizable? |
boolean |
Whether the window is resizable or not. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2871 |
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#L3053 |
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#L2922 |
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#L2901 |
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#L2951 |
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#L2928 |
title? |
string |
Window title. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2873 |
titleBarStyle? |
TitleBarStyle |
The style of the macOS title bar. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2932 |
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#L2940 |
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#L2887 |
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#L2891 |
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#L2986 |
width? |
number |
The initial width in logical pixels. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2844 |
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#L2997 |
x? |
number |
The initial horizontal position in logical pixels, measured from the left edge of the screen. Only applies if y is also set. |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2837 |
y? |
number |
The initial vertical position in logical pixels, measured from the top edge of the screen. Only applies if x is also set. |
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2842 |
WindowSizeConstraints
Section titled “WindowSizeConstraints”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L284
Inner size constraints for a window, see Window.setSizeConstraints.
Unlike Window.setMinSize and Window.setMaxSize, each dimension is independent: you can constrain only the width and leave the height free.
All values are in logical pixels. Leave a field out (or set it to
undefined) to remove that constraint.
Example
Section titled “Example”import { getCurrentWindow } from '@tauri-apps/api/window';// at least 300 logical pixels wide, height unconstrainedawait getCurrentWindow().setSizeConstraints({ minWidth: 300 });2.0.0
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
maxHeight? |
number |
The maximum height, in logical pixels. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L292 |
maxWidth? |
number |
The maximum width, in logical pixels. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L290 |
minHeight? |
number |
The minimum height, in logical pixels. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L288 |
minWidth? |
number |
The minimum width, in logical pixels. | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L286 |
Type Aliases
Section titled “Type Aliases”CursorIcon
Section titled “CursorIcon”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#L197
The cursor shape to display over a window, see Window.setCursorIcon.
The names mirror the CSS cursor keywords in camelCase (e.g. notAllowed for
not-allowed, eResize for e-resize). Support varies per platform and window
manager; unsupported values fall back to the default arrow.
type Theme = "light" | "dark";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L101
The light or dark appearance of a window or of the system.
TitleBarStyle
Section titled “TitleBarStyle”type TitleBarStyle = "visible" | "transparent" | "overlay";Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L111
The style of the window title bar. macOS only
visible: the standard title bar.transparent: the title bar is transparent but the traffic lights stay in place.overlay: the content extends under a transparent title bar, leaving only the traffic lights visible.
Functions
Section titled “Functions”availableMonitors()
Section titled “availableMonitors()”function availableMonitors(): Promise<Monitor[]>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L3149
Returns the list of all the monitors available on the system.
Returns
Section titled “Returns”Example
Section titled “Example”import { availableMonitors } from '@tauri-apps/api/window';const monitors = await availableMonitors();1.0.0
currentMonitor()
Section titled “currentMonitor()”function currentMonitor(): Promise<Monitor | null>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L3099
Returns the monitor on which the window currently resides.
Returns null if current monitor can’t be detected.
Returns
Section titled “Returns”Example
Section titled “Example”import { currentMonitor } from '@tauri-apps/api/window';const monitor = await currentMonitor();1.0.0
cursorPosition()
Section titled “cursorPosition()”function cursorPosition(): Promise<PhysicalPosition>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L3179
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.
Returns
Section titled “Returns”The cursor position, in physical pixels.
Example
Section titled “Example”import { cursorPosition } from '@tauri-apps/api/window';const position = await cursorPosition();console.log(position.x, position.y);Remarks
Section titled “Remarks”Uses the core:window:allow-cursor-position permission, which is part
of core:window:default.
2.0.0
getAllWindows()
Section titled “getAllWindows()”function getAllWindows(): Promise<Window[]>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L331
Gets a list of instances of Window for all available 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.
1.0.0
getCurrentWindow()
Section titled “getCurrentWindow()”function getCurrentWindow(): Window;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L316
Get an instance of Window for the current window.
Returns
Section titled “Returns”1.0.0
monitorFromPoint()
Section titled “monitorFromPoint()”function monitorFromPoint(x, y): Promise<Monitor | null>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L3132
Returns the monitor that contains the given point. Returns null if can’t find any.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
x |
number |
y |
number |
Returns
Section titled “Returns”Example
Section titled “Example”import { monitorFromPoint } from '@tauri-apps/api/window';const monitor = await monitorFromPoint(100.0, 200.0);1.0.0
primaryMonitor()
Section titled “primaryMonitor()”function primaryMonitor(): Promise<Monitor | null>;Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L3116
Returns the primary monitor of the system.
Returns null if it can’t identify any monitor as a primary one.
Returns
Section titled “Returns”Example
Section titled “Example”import { primaryMonitor } from '@tauri-apps/api/window';const monitor = await primaryMonitor();1.0.0
References
Section titled “References”Re-exports Color
DragDropEvent
Section titled “DragDropEvent”Re-exports DragDropEvent
LogicalPosition
Section titled “LogicalPosition”Re-exports LogicalPosition
LogicalSize
Section titled “LogicalSize”Re-exports LogicalSize
PhysicalPosition
Section titled “PhysicalPosition”Re-exports PhysicalPosition
PhysicalSize
Section titled “PhysicalSize”Re-exports PhysicalSize
© 2026 Tauri Contributors. CC-BY / MIT