Tauri Core API - v2.6.0
    Preparing search index...

    Class 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 _.

    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

    Hierarchy (View Summary)

    Index

    Constructors

    • Creates a new Window hosting a Webview.

      Parameters

      • label: string

        The unique webview label. Must be alphanumeric: a-zA-Z-/:_.

      • options: Omit<WebviewOptions, "width" | "height" | "x" | "y"> & WindowOptions = {}

      Returns WebviewWindow

      The WebviewWindow instance to communicate with the window and webview.

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

    Properties

    window: Window

    The window hosting this webview.

    label: string

    The webview label. It is a unique identifier for the webview, can be used to reference it later.

    listeners: Record<string, EventCallback<any>[]>

    Local event listeners.

    Methods

    • Emits an event to all targets.

      Type Parameters

      • T

      Parameters

      • event: string

        Event name. Must include only alphanumeric characters, -, /, : and _.

      • Optionalpayload: T

        Event payload.

      Returns Promise<void>

      import { getCurrentWebview } from '@tauri-apps/api/webview';
      await getCurrentWebview().emit('webview-loaded', { loggedIn: true, token: 'authToken' });
    • Emits an event to all targets matching the given target.

      Type Parameters

      • T

      Parameters

      • target: string | EventTarget

        Label of the target Window/Webview/WebviewWindow or raw EventTarget object.

      • event: string

        Event name. Must include only alphanumeric characters, -, /, : and _.

      • Optionalpayload: T

        Event payload.

      Returns Promise<void>

      import { getCurrentWebview } from '@tauri-apps/api/webview';
      await getCurrentWebview().emitTo('main', 'webview-loaded', { loggedIn: true, token: 'authToken' });
    • 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 Promise<dpi.PhysicalPosition>

      The webview's position.

      import { getCurrentWebview } from '@tauri-apps/api/webview';
      const position = await getCurrentWebview().position();
    • 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 Promise<dpi.PhysicalSize>

      The webview's size.

      import { getCurrentWebview } from '@tauri-apps/api/webview';
      const size = await getCurrentWebview().size();
    • Closes the webview.

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWebview } from '@tauri-apps/api/webview';
      await getCurrentWebview().close();
    • Bring the webview to front and focus.

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWebview } from '@tauri-apps/api/webview';
      await getCurrentWebview().setFocus();
    • Sets whether the webview should automatically grow and shrink its size and position when the parent window resizes.

      Parameters

      • autoResize: boolean

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWebview } from '@tauri-apps/api/webview';
      await getCurrentWebview().setAutoResize(true);
    • Hide the webview.

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWebview } from '@tauri-apps/api/webview';
      await getCurrentWebview().hide();
    • Show the webview.

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWebview } from '@tauri-apps/api/webview';
      await getCurrentWebview().show();
    • Set webview zoom level.

      Parameters

      • scaleFactor: number

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWebview } from '@tauri-apps/api/webview';
      await getCurrentWebview().setZoom(1.5);
    • Moves this webview to the given label.

      Parameters

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWebview } from '@tauri-apps/api/webview';
      await getCurrentWebview().reparent('other-window');
    • Clears all browsing data for this webview.

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWebview } from '@tauri-apps/api/webview';
      await getCurrentWebview().clearAllBrowsingData();
    • 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

      Returns Promise<UnlistenFn>

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

      import { 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 unmounted
      unlisten();

      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.

    • Gets the Webview for the webview associated with the given label.

      Parameters

      • label: string

        The webview label.

      Returns Promise<null | WebviewWindow>

      The Webview instance to communicate with the webview or null if the webview doesn't exist.

      import { Webview } from '@tauri-apps/api/webviewWindow';
      const mainWebview = Webview.getByLabel('main');
    • Listen to an emitted event on this webivew window.

      Type Parameters

      • T

      Parameters

      • event: EventName

        Event name. Must include only alphanumeric characters, -, /, : and _.

      • handler: EventCallback<T>

        Event handler.

      Returns Promise<UnlistenFn>

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

      import { 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 unmounted
      unlisten();
    • Listen to an emitted event on this webview window only once.

      Type Parameters

      • T

      Parameters

      • event: EventName

        Event name. Must include only alphanumeric characters, -, /, : and _.

      • handler: EventCallback<T>

        Event handler.

      Returns Promise<UnlistenFn>

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

      import { 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 unmounted
      unlisten();
    • Set the window and webview background color.

      • 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

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      2.1.0

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

      Returns Promise<number>

      The window's monitor scale factor.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      const factor = await getCurrentWindow().scaleFactor();
    • 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 Promise<dpi.PhysicalPosition>

      The window's inner position.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      const position = await getCurrentWindow().innerPosition();
    • 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 Promise<dpi.PhysicalSize>

      The window's inner size.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      const size = await getCurrentWindow().innerSize();
    • 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 Promise<dpi.PhysicalSize>

      The window's outer size.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      const size = await getCurrentWindow().outerSize();
    • Gets the window's current fullscreen state.

      Returns Promise<boolean>

      Whether the window is in fullscreen mode or not.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      const fullscreen = await getCurrentWindow().isFullscreen();
    • Gets the window's current minimized state.

      Returns Promise<boolean>

      import { getCurrentWindow } from '@tauri-apps/api/window';
      const minimized = await getCurrentWindow().isMinimized();
    • Gets the window's current maximized state.

      Returns Promise<boolean>

      Whether the window is maximized or not.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      const maximized = await getCurrentWindow().isMaximized();
    • Gets the window's current focus state.

      Returns Promise<boolean>

      Whether the window is focused or not.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      const focused = await getCurrentWindow().isFocused();
    • Gets the window's current decorated state.

      Returns Promise<boolean>

      Whether the window is decorated or not.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      const decorated = await getCurrentWindow().isDecorated();
    • Gets the window's current resizable state.

      Returns Promise<boolean>

      Whether the window is resizable or not.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      const resizable = await getCurrentWindow().isResizable();
    • Gets the window's native maximize button state.

      • Linux / iOS / Android: Unsupported.

      Returns Promise<boolean>

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

      import { getCurrentWindow } from '@tauri-apps/api/window';
      const maximizable = await getCurrentWindow().isMaximizable();
    • Gets the window's native minimize button state.

      • Linux / iOS / Android: Unsupported.

      Returns Promise<boolean>

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

      import { getCurrentWindow } from '@tauri-apps/api/window';
      const minimizable = await getCurrentWindow().isMinimizable();
    • Gets the window's native close button state.

      • iOS / Android: Unsupported.

      Returns Promise<boolean>

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

      import { getCurrentWindow } from '@tauri-apps/api/window';
      const closable = await getCurrentWindow().isClosable();
    • Gets the window's current visible state.

      Returns Promise<boolean>

      Whether the window is visible or not.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      const visible = await getCurrentWindow().isVisible();
    • Gets the window's current title.

      Returns Promise<string>

      import { getCurrentWindow } from '@tauri-apps/api/window';
      const title = await getCurrentWindow().title();
    • Gets the window's current theme.

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

      Returns Promise<null | Theme>

      The window theme.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      const theme = await getCurrentWindow().theme();
    • Whether the window is configured to be always on top of other windows or not.

      Returns Promise<boolean>

      Whether the window is visible or not.

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

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().center();
    • Requests user attention to the window, this has no effect if the application is already focused. How requesting for user attention manifests is platform dependent, see UserAttentionType for details.

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

      • macOS: null has no effect.
      • Linux: Urgency levels have the same effect.

      Parameters

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().requestUserAttention();
    • Updates the window resizable flag.

      Parameters

      • resizable: boolean

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

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

      Parameters

      • enabled: boolean

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

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

      2.0.0

    • Whether the window is enabled or disabled.

      Returns Promise<boolean>

      A promise indicating the success or failure of the operation.

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

      2.0.0

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

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

      Parameters

      • maximizable: boolean

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().setMaximizable(false);
    • Sets whether the window's native minimize button is enabled or not.

      • Linux / iOS / Android: Unsupported.

      Parameters

      • minimizable: boolean

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().setMinimizable(false);
    • Sets whether the window's native close button is enabled or not.

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

      Parameters

      • closable: boolean

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

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

      Parameters

      • title: string

        The new title

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

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

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

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

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().unmaximize();
    • Toggles the window maximized state.

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

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

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

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

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().unminimize();
    • Destroys the window. Behaves like Window.close but forces the window close instead of emitting a closeRequested event.

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().destroy();
    • Whether the window should have borders and bars.

      Parameters

      • decorations: boolean

        Whether the window should have borders and bars.

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().setDecorations(false);
    • Whether or not the window should have shadow.

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

      Parameters

      • enable: boolean

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().setShadow(false);
    • Whether the window should always be on top of other windows.

      Parameters

      • alwaysOnTop: boolean

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

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().setAlwaysOnTop(true);
    • Whether the window should always be below other windows.

      Parameters

      • alwaysOnBottom: boolean

        Whether the window should always be below other windows or not.

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().setAlwaysOnBottom(true);
    • Prevents the window contents from being captured by other apps.

      Parameters

      • protected_: boolean

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().setContentProtected(true);
    • Sets the window minimum inner size. If the size argument is not provided, the constraint is unset.

      Parameters

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow, PhysicalSize } from '@tauri-apps/api/window';
      await getCurrentWindow().setMinSize(new PhysicalSize(600, 500));
    • Sets the window maximum inner size. If the size argument is undefined, the constraint is unset.

      Parameters

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

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

      Parameters

      • constraints: undefined | null | WindowSizeConstraints

        The logical or physical inner size, or null to unset the constraint.

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

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

      Parameters

      • fullscreen: boolean

        Whether the window should go to fullscreen or not.

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

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

      Parameters

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

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

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

      [dependencies]
      tauri = { version = "...", features = ["...", "image-png"] }
    • Whether the window icon should be hidden from the taskbar or not.

      • macOS: Unsupported.

      Parameters

      • skip: boolean

        true to hide window icon, false to show it.

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().setSkipTaskbar(true);
    • Grabs the cursor, preventing it from leaving the window.

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

      • Linux: Unsupported.
      • macOS: This locks the cursor in a fixed location, which looks visually awkward.

      Parameters

      • grab: boolean

        true to grab the cursor icon, false to release it.

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().setCursorGrab(true);
    • Modifies the cursor's visibility.

      • Windows: The cursor is only hidden within the confines of the window.
      • macOS: The cursor is hidden as long as the window has input focus, even if the cursor is outside of the window.

      Parameters

      • visible: boolean

        If false, this will hide the cursor. If true, this will show the cursor.

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().setCursorVisible(false);
    • Modifies the cursor icon of the window.

      Parameters

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().setCursorIcon('help');
    • Changes the cursor events behavior.

      Parameters

      • ignore: boolean

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

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

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

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().startDragging();
    • Starts resize-dragging the window.

      Parameters

      • direction: ResizeDirection

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().startResizeDragging();
    • Sets the badge count. It is app wide and not specific to this window.

      • Windows: Unsupported. Use @{linkcode Window.setOverlayIcon} instead.

      Parameters

      • Optionalcount: number

        The badge count. Use undefined to remove the badge.

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().setBadgeCount(5);
    • Sets the badge cont macOS only.

      Parameters

      • Optionallabel: string

        The badge label. Use undefined to remove the badge.

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().setBadgeLabel("Hello");
    • 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

      • Optionalicon: string | number[] | ArrayBuffer | Uint8Array<ArrayBufferLike> | Image

        Icon bytes or path to the icon file. Use undefined to remove the overlay icon.

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow } from '@tauri-apps/api/window';
      await getCurrentWindow().setOverlayIcon("/tauri/awesome.png");
    • Sets the taskbar progress state.

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

      Parameters

      Returns Promise<void>

      A promise indicating the success or failure of the operation.

      import { getCurrentWindow, ProgressBarStatus } from '@tauri-apps/api/window';
      await getCurrentWindow().setProgressBar({
      status: ProgressBarStatus.Normal,
      progress: 50,
      });
    • Sets whether the window should be visible on all workspaces or virtual desktops.

      • Windows / iOS / Android: Unsupported.

      Parameters

      • visible: boolean

      Returns Promise<void>

      2.0.0

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

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

      Parameters

      • Optionaltheme: null | Theme

      Returns Promise<void>

      2.0.0

    • Listen to window resize.

      Parameters

      Returns Promise<UnlistenFn>

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

      import { getCurrentWindow } from "@tauri-apps/api/window";
      const unlisten = await getCurrentWindow().onResized(({ payload: size }) => {
      console.log('Window resized', size);
      });

      // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
      unlisten();
    • Listen to window move.

      Parameters

      Returns Promise<UnlistenFn>

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

      import { getCurrentWindow } from "@tauri-apps/api/window";
      const unlisten = await getCurrentWindow().onMoved(({ payload: position }) => {
      console.log('Window moved', position);
      });

      // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
      unlisten();
    • Listen to window close requested. Emitted when the user requests to closes the window.

      Parameters

      Returns Promise<UnlistenFn>

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

      import { getCurrentWindow } from "@tauri-apps/api/window";
      import { confirm } from '@tauri-apps/api/dialog';
      const unlisten = await getCurrentWindow().onCloseRequested(async (event) => {
      const confirmed = await confirm('Are you sure?');
      if (!confirmed) {
      // user did not confirm closing the window; let's prevent it
      event.preventDefault();
      }
      });

      // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
      unlisten();
    • Listen to window focus change.

      Parameters

      Returns Promise<UnlistenFn>

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

      import { getCurrentWindow } from "@tauri-apps/api/window";
      const unlisten = await getCurrentWindow().onFocusChanged(({ payload: focused }) => {
      console.log('Focus changed, window is focused? ' + focused);
      });

      // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
      unlisten();
    • 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

      Returns Promise<UnlistenFn>

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

      import { getCurrentWindow } from "@tauri-apps/api/window";
      const unlisten = await getCurrentWindow().onScaleChanged(({ payload }) => {
      console.log('Scale changed', payload.scaleFactor, payload.size);
      });

      // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
      unlisten();
    • Listen to the system theme change.

      Parameters

      Returns Promise<UnlistenFn>

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

      import { getCurrentWindow } from "@tauri-apps/api/window";
      const unlisten = await getCurrentWindow().onThemeChanged(({ payload: theme }) => {
      console.log('New theme: ' + theme);
      });

      // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
      unlisten();