webviewWindow
References
Section titled “References”Re-exports Color
DragDropEvent
Section titled “DragDropEvent”Re-exports DragDropEvent
Classes
Section titled “Classes”WebviewWindow
Section titled “WebviewWindow”Create new webview or get a handle to an existing one.
Webviews are identified by a label a unique identifier that can be used to reference it later.
It may only contain alphanumeric characters a-zA-Z plus the following special characters -, /, : and _.
Example
Section titled “Example”import { Window } from "@tauri-apps/api/window"import { Webview } from "@tauri-apps/api/webview"
const appWindow = new Window('uniqueLabel');
appWindow.once('tauri://created', async function () { // `new Webview` Should be called after the window is successfully created, // or webview may not be attached to the window since window is not created yet.
// loading embedded asset: const webview = new Webview(appWindow, 'theUniqueLabel', { url: 'path/to/page.html',
// create a webview with specific logical position and size x: 0, y: 0, width: 800, height: 600, }); // alternatively, load a remote URL: const webview = new Webview(appWindow, 'theUniqueLabel', { url: 'https://github.com/tauri-apps/tauri',
// create a webview with specific logical position and size x: 0, y: 0, width: 800, height: 600, });
webview.once('tauri://created', function () { // webview successfully created }); webview.once('tauri://error', function (e) { // an error happened creating the webview });
// emit an event to the backend await webview.emit("some-event", "data"); // listen to an event from the backend const unlisten = await webview.listen("event-name", e => { }); unlisten();});2.0.0
Extends
Section titled “Extends”Constructors
Section titled “Constructors”new WebviewWindow()
Section titled “new WebviewWindow()”new WebviewWindow(label, options): WebviewWindowCreates a new Window hosting a Webview.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
label | string | The unique webview label. Must be alphanumeric: a-zA-Z-/:_. |
options | Omit<WebviewOptions, "x" | "y" | "width" | "height"> & WindowOptions | - |
Returns
Section titled “Returns”The WebviewWindow instance to communicate with the window and webview.
Example
Section titled “Example”import { WebviewWindow } from '@tauri-apps/api/webviewWindow'const webview = new WebviewWindow('my-label', { url: 'https://github.com/tauri-apps/tauri'});webview.once('tauri://created', function () { // webview successfully created});webview.once('tauri://error', function (e) { // an error happened creating the webview});Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webviewWindow.ts#L75
Properties
Section titled “Properties”| Property | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|
label | string | The webview label. It is a unique identifier for the webview, can be used to reference it later. | Window.label | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webviewWindow.ts#L51 |
listeners | Record<string, EventCallback<any>[]> | Local event listeners. | Window.listeners | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webviewWindow.ts#L54 |
window | Window | The window hosting this webview. | Webview.window | Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webview.ts#L157 |
Methods
Section titled “Methods”activityName()
Section titled “activityName()”activityName(): Promise<string>Returns
Section titled “Returns”Promise<string>
Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L823
center()
Section titled “center()”center(): Promise<void>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L847
clearAllBrowsingData()
Section titled “clearAllBrowsingData()”clearAllBrowsingData(): Promise<void>Clears all browsing data for this webview.
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().clearAllBrowsingData();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webview.ts#L589
clearEffects()
Section titled “clearEffects()”clearEffects(): Promise<void>Clear any applied effects if possible.
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1235
close()
Section titled “close()”close(): Promise<void>Closes the webview.
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().close();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webview.ts#L436
destroy()
Section titled “destroy()”destroy(): Promise<void>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1172
emit()
Section titled “emit()”emit<T>(event, payload?): Promise<void>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 { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().emit('webview-loaded', { loggedIn: true, token: 'authToken' });Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webview.ts#L325
emitTo()
Section titled “emitTo()”emitTo<T>( target, event,payload?): Promise<void>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 { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().emitTo('main', 'webview-loaded', { loggedIn: true, token: 'authToken' });Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webview.ts#L353
hide()
Section titled “hide()”hide(): Promise<void>Hide the webview.
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().hide();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webview.ts#L523
innerPosition()
Section titled “innerPosition()”innerPosition(): Promise<PhysicalPosition>The position of the top-left hand corner of the window’s client area relative to the top-left hand corner of the desktop.
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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L537
innerSize()
Section titled “innerSize()”innerSize(): Promise<PhysicalSize>The physical size of the window’s client area. The client area is the content of the window, excluding the title bar and borders.
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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L570
isAlwaysOnTop()
Section titled “isAlwaysOnTop()”isAlwaysOnTop(): Promise<boolean>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L817
isClosable()
Section titled “isClosable()”isClosable(): Promise<boolean>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L750
isDecorated()
Section titled “isDecorated()”isDecorated(): Promise<boolean>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L671
isEnabled()
Section titled “isEnabled()”isEnabled(): Promise<boolean>Whether the window is enabled or disabled.
Returns
Section titled “Returns”Promise<boolean>
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);2.0.0
Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L939
isFocused()
Section titled “isFocused()”isFocused(): Promise<boolean>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L655
isFullscreen()
Section titled “isFullscreen()”isFullscreen(): Promise<boolean>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L609
isMaximizable()
Section titled “isMaximizable()”isMaximizable(): Promise<boolean>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L708
isMaximized()
Section titled “isMaximized()”isMaximized(): Promise<boolean>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L639
isMinimizable()
Section titled “isMinimizable()”isMinimizable(): Promise<boolean>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L729
isMinimized()
Section titled “isMinimized()”isMinimized(): Promise<boolean>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L623
isResizable()
Section titled “isResizable()”isResizable(): Promise<boolean>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L687
isVisible()
Section titled “isVisible()”isVisible(): Promise<boolean>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L766
listen()
Section titled “listen()”listen<T>(event, handler): Promise<UnlistenFn>Listen to an emitted event on this webview 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. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
Example
Section titled “Example”import { WebviewWindow } from '@tauri-apps/api/webviewWindow';const unlisten = await WebviewWindow.getCurrent().listen<string>('state-changed', (event) => { console.log(`Got error: ${payload}`);});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmountedunlisten();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webviewWindow.ts#L155
maximize()
Section titled “maximize()”maximize(): Promise<void>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1042
minimize()
Section titled “minimize()”minimize(): Promise<void>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1090
onCloseRequested()
Section titled “onCloseRequested()”onCloseRequested(handler): Promise<UnlistenFn>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. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
Example
Section titled “Example”import { getCurrentWindow } from "@tauri-apps/api/window";import { confirm } from '@tauri-apps/api/dialog';const unlisten = await getCurrentWindow().onCloseRequested(async (event) => { const confirmed = await confirm('Are you sure?'); if (!confirmed) { // user did not confirm closing the window; let's prevent it event.preventDefault(); }});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmountedunlisten();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1897
onDragDropEvent()
Section titled “onDragDropEvent()”onDragDropEvent(handler): Promise<UnlistenFn>Listen to a file drop event. The listener is triggered when the user hovers the selected files on the webview, drops the files or cancels the operation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
handler | EventCallback<DragDropEvent> |
Returns
Section titled “Returns”A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
Example
Section titled “Example”import { getCurrentWebview } from "@tauri-apps/api/webview";const unlisten = await getCurrentWebview().onDragDropEvent((event) => { if (event.payload.type === 'over') { console.log('User hovering', event.payload.position); } else if (event.payload.type === 'drop') { console.log('User dropped', event.payload.paths); } else { console.log('File drop cancelled'); }});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmountedunlisten();When the debugger panel is open, the drop position of this event may be inaccurate due to a known limitation. To retrieve the correct drop position, please detach the debugger.
Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webview.ts#L641
onFocusChanged()
Section titled “onFocusChanged()”onFocusChanged(handler): Promise<UnlistenFn>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. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
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);});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmountedunlisten();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2013
onMoved()
Section titled “onMoved()”onMoved(handler): Promise<UnlistenFn>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. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
Example
Section titled “Example”import { getCurrentWindow } from "@tauri-apps/api/window";const unlisten = await getCurrentWindow().onMoved(({ payload: position }) => { console.log('Window moved', position);});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmountedunlisten();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1868
onResized()
Section titled “onResized()”onResized(handler): Promise<UnlistenFn>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. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
Example
Section titled “Example”import { getCurrentWindow } from "@tauri-apps/api/window";const unlisten = await getCurrentWindow().onResized(({ payload: size }) => { console.log('Window resized', size);});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmountedunlisten();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1844
onScaleChanged()
Section titled “onScaleChanged()”onScaleChanged(handler): Promise<UnlistenFn>Listen to window scale change. Emitted when the window’s scale factor has changed. The following user actions can cause DPI changes:
- Changing the display’s resolution.
- Changing the display’s scale factor (e.g. in Control Panel on Windows).
- Moving the window to a display with a different scale factor.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
handler | EventCallback<ScaleFactorChanged> |
Returns
Section titled “Returns”A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
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);});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmountedunlisten();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2053
onThemeChanged()
Section titled “onThemeChanged()”onThemeChanged(handler): Promise<UnlistenFn>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. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
Example
Section titled “Example”import { getCurrentWindow } from "@tauri-apps/api/window";const unlisten = await getCurrentWindow().onThemeChanged(({ payload: theme }) => { console.log('New theme: ' + theme);});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmountedunlisten();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L2079
once()
Section titled “once()”once<T>(event, handler): Promise<UnlistenFn>Listen to an emitted event on this webview 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. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
Example
Section titled “Example”import { WebviewWindow } from '@tauri-apps/api/webviewWindow';const unlisten = await WebviewWindow.getCurrent().once<null>('initialized', (event) => { console.log(`Webview initialized!`);});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmountedunlisten();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webviewWindow.ts#L190
outerPosition()
Section titled “outerPosition()”outerPosition(): Promise<PhysicalPosition>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L553
outerSize()
Section titled “outerSize()”outerSize(): Promise<PhysicalSize>The physical size of the entire window. These dimensions include the title bar and borders. If you don’t want that (and you usually don’t), use inner_size instead.
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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L590
position()
Section titled “position()”position(): Promise<PhysicalPosition>The position of the top-left hand corner of the webview’s client area relative to the top-left hand corner of the desktop.
Returns
Section titled “Returns”The webview’s position.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';const position = await getCurrentWebview().position();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webview.ts#L398
reparent()
Section titled “reparent()”reparent(window): Promise<void>Moves this webview to the given label.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
window | string | Window | WebviewWindow |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().reparent('other-window');Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webview.ts#L572
requestUserAttention()
Section titled “requestUserAttention()”requestUserAttention(requestType): Promise<void>Requests user attention to the window, this has no effect if the application
is already focused. How requesting for user attention manifests is platform dependent,
see UserAttentionType for details.
Providing null will unset the request for user attention. Unsetting the request for
user attention might not be done automatically by the WM when the window receives input.
Platform-specific
- macOS:
nullhas no effect. - Linux: Urgency levels have the same effect.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
requestType | null | UserAttentionType |
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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L873
scaleFactor()
Section titled “scaleFactor()”scaleFactor(): Promise<number>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L521
sceneIdentifier()
Section titled “sceneIdentifier()”sceneIdentifier(): Promise<string>Returns
Section titled “Returns”Promise<string>
Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L829
setAlwaysOnBottom()
Section titled “setAlwaysOnBottom()”setAlwaysOnBottom(alwaysOnBottom): Promise<void>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);Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1271
setAlwaysOnTop()
Section titled “setAlwaysOnTop()”setAlwaysOnTop(alwaysOnTop): Promise<void>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);Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1253
setAutoResize()
Section titled “setAutoResize()”setAutoResize(autoResize): Promise<void>Sets whether the webview should automatically grow and shrink its size and position when the parent window resizes.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
autoResize | boolean |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().setAutoResize(true);Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webview.ts#L506
setBackgroundColor()
Section titled “setBackgroundColor()”setBackgroundColor(color): Promise<void>Set the window and webview background color.
Platform-specific:
- Android / iOS: Unsupported for the window layer.
- macOS / iOS: Not implemented for the webview layer.
- Windows:
- alpha channel is ignored for the window layer.
- On Windows 7, alpha channel is ignored for the webview layer.
- On Windows 8 and newer, if alpha channel is not
0, it will be ignored.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
color | Color |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
2.1.0
Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webviewWindow.ts#L222
setBadgeCount()
Section titled “setBadgeCount()”setBadgeCount(count?): Promise<void>Sets the badge count. It is app wide and not specific to this window.
Platform-specific
- Windows: Unsupported. Use @{linkcode Window.setOverlayIcon} instead.
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);Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1697
setBadgeLabel()
Section titled “setBadgeLabel()”setBadgeLabel(label?): Promise<void>Sets the badge cont macOS only.
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");Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1716
setClosable()
Section titled “setClosable()”setClosable(closable): Promise<void>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);Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1007
setContentProtected()
Section titled “setContentProtected()”setContentProtected(protected_): Promise<void>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);Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1288
setCursorGrab()
Section titled “setCursorGrab()”setCursorGrab(grab): Promise<void>Grabs the cursor, preventing it from leaving the window.
There’s no guarantee that the cursor will be hidden. You should hide it by yourself if you want so.
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);Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1544
setCursorIcon()
Section titled “setCursorIcon()”setCursorIcon(icon): Promise<void>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');Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1586
setCursorPosition()
Section titled “setCursorPosition()”setCursorPosition(position): Promise<void>Changes the position of the cursor in window coordinates.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
position | LogicalPosition | PhysicalPosition | 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));Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1620
setCursorVisible()
Section titled “setCursorVisible()”setCursorVisible(visible): Promise<void>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);Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1568
setDecorations()
Section titled “setDecorations()”setDecorations(decorations): Promise<void>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);Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1189
setEffects()
Section titled “setEffects()”setEffects(effects): Promise<void>Set window effects.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
effects | Effects |
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1225
setEnabled()
Section titled “setEnabled()”setEnabled(enabled): Promise<void>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);2.0.0
Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L920
setFocus()
Section titled “setFocus()”setFocus(): Promise<void>Bring the webview 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 { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().setFocus();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webview.ts#L490
setFocusable()
Section titled “setFocusable()”setFocusable(focusable): Promise<void>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);Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1469
setFullscreen()
Section titled “setFullscreen()”setFullscreen(fullscreen): Promise<void>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);Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1413
setIcon()
Section titled “setIcon()”setIcon(icon): Promise<void>Sets the window icon.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
icon | | string | number[] | ArrayBuffer | Uint8Array<ArrayBufferLike> | Image | 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"] }Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1494
setIgnoreCursorEvents()
Section titled “setIgnoreCursorEvents()”setIgnoreCursorEvents(ignore): Promise<void>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);Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1641
setMaxSize()
Section titled “setMaxSize()”setMaxSize(size): Promise<void>Sets the window maximum inner size. If the size argument is undefined, the constraint is unset.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
size | | undefined | null | LogicalSize | PhysicalSize | Size | 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));Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1344
setMaximizable()
Section titled “setMaximizable()”setMaximizable(maximizable): Promise<void>Sets whether the window’s native maximize button is enabled or not. If resizable is set to false, this setting is ignored.
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);Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L962
setMinSize()
Section titled “setMinSize()”setMinSize(size): Promise<void>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 | | undefined | null | LogicalSize | PhysicalSize | Size | 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));Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1324
setMinimizable()
Section titled “setMinimizable()”setMinimizable(minimizable): Promise<void>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);Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L984
setOverlayIcon()
Section titled “setOverlayIcon()”setOverlayIcon(icon?): Promise<void>Sets the overlay icon. Windows only The overlay icon can be set for every window.
Note that you may need the image-ico or image-png Cargo features to use this API.
To enable it, change your Cargo.toml file:
[dependencies]tauri = { version = "...", features = ["...", "image-png"] }Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
icon? | | string | number[] | ArrayBuffer | Uint8Array<ArrayBufferLike> | Image | 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");Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1745
setPosition()
Section titled “setPosition()”setPosition(position): Promise<void>Sets the webview position.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
position | LogicalPosition | PhysicalPosition | 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 { getCurrent, LogicalPosition } from '@tauri-apps/api/webview';await getCurrentWebview().setPosition(new LogicalPosition(600, 500));Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webview.ts#L471
setProgressBar()
Section titled “setProgressBar()”setProgressBar(state): Promise<void>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,});Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1773
setResizable()
Section titled “setResizable()”setResizable(resizable): Promise<void>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);Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L901
setShadow()
Section titled “setShadow()”setShadow(enable): Promise<void>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);Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1215
setSimpleFullscreen()
Section titled “setSimpleFullscreen()”setSimpleFullscreen(fullscreen): Promise<void>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.
Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1429
setSize()
Section titled “setSize()”setSize(size): Promise<void>Resizes the webview.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
size | LogicalSize | PhysicalSize | Size | The logical or physical size. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrent, LogicalSize } from '@tauri-apps/api/webview';await getCurrentWebview().setSize(new LogicalSize(600, 500));Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webview.ts#L453
setSizeConstraints()
Section titled “setSizeConstraints()”setSizeConstraints(constraints): Promise<void>Sets the window inner size constraints.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
constraints | undefined | null | WindowSizeConstraints | 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 } from '@tauri-apps/api/window';await getCurrentWindow().setSizeConstraints({ minWidth: 300 });Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1364
setSkipTaskbar()
Section titled “setSkipTaskbar()”setSkipTaskbar(skip): Promise<void>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);Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1518
setTheme()
Section titled “setTheme()”setTheme(theme?): Promise<void>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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
theme? | null | Theme |
Returns
Section titled “Returns”Promise<void>
2.0.0
Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1818
setTitle()
Section titled “setTitle()”setTitle(title): Promise<void>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');Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1025
setTitleBarStyle()
Section titled “setTitleBarStyle()”setTitleBarStyle(style): Promise<void>Sets the title bar style. macOS only.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
style | TitleBarStyle |
Returns
Section titled “Returns”Promise<void>
2.0.0
Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1801
setVisibleOnAllWorkspaces()
Section titled “setVisibleOnAllWorkspaces()”setVisibleOnAllWorkspaces(visible): Promise<void>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 |
|---|---|
visible | boolean |
Returns
Section titled “Returns”Promise<void>
2.0.0
Inherited from
Section titled “Inherited from”Window.setVisibleOnAllWorkspaces
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1789
setZoom()
Section titled “setZoom()”setZoom(scaleFactor): Promise<void>Set webview zoom level.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
scaleFactor | number |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().setZoom(1.5);Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webview.ts#L555
show()
Section titled “show()”show(): Promise<void>Show the webview.
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';await getCurrentWebview().show();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webview.ts#L539
size()
Section titled “size()”size(): Promise<PhysicalSize>The physical size of the webview’s client area. The client area is the content of the webview, excluding the title bar and borders.
Returns
Section titled “Returns”The webview’s size.
Example
Section titled “Example”import { getCurrentWebview } from '@tauri-apps/api/webview';const size = await getCurrentWebview().size();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webview.ts#L415
startDragging()
Section titled “startDragging()”startDragging(): Promise<void>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1658
startResizeDragging()
Section titled “startResizeDragging()”startResizeDragging(direction): Promise<void>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1674
theme()
Section titled “theme()”theme(): Promise<null | Theme>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L801
title()
Section titled “title()”title(): Promise<string>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L780
toggleMaximize()
Section titled “toggleMaximize()”toggleMaximize(): Promise<void>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1074
unmaximize()
Section titled “unmaximize()”unmaximize(): Promise<void>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1058
unminimize()
Section titled “unminimize()”unminimize(): Promise<void>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();Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/window.ts#L1106
getAll()
Section titled “getAll()”static getAll(): Promise<WebviewWindow[]>Gets a list of instances of Webview for all available webviews.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webviewWindow.ts#L132
getByLabel()
Section titled “getByLabel()”static getByLabel(label): Promise<null | WebviewWindow>Gets the Webview for the webview associated with the given label.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
label | string | The webview label. |
Returns
Section titled “Returns”Promise<null | WebviewWindow>
The Webview instance to communicate with the webview or null if the webview doesn’t exist.
Example
Section titled “Example”import { WebviewWindow } from '@tauri-apps/api/webviewWindow';const mainWebview = WebviewWindow.getByLabel('main');Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webviewWindow.ts#L112
getCurrent()
Section titled “getCurrent()”static getCurrent(): WebviewWindowGet an instance of Webview for the current webview.
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webviewWindow.ts#L125
Functions
Section titled “Functions”getAllWebviewWindows()
Section titled “getAllWebviewWindows()”function getAllWebviewWindows(): Promise<WebviewWindow[]>Gets a list of instances of Webview for all available webview windows.
Returns
Section titled “Returns”2.0.0
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webviewWindow.ts#L34
getCurrentWebviewWindow()
Section titled “getCurrentWebviewWindow()”function getCurrentWebviewWindow(): WebviewWindowGet an instance of Webview for the current webview window.
Returns
Section titled “Returns”2.0.0
Source: https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/webviewWindow.ts#L23
© 2026 Tauri Contributors. CC-BY / MIT