Skip to main content

WindowConfig

Struct WindowConfig 

Source
pub struct WindowConfig {
Show 63 fields pub label: String, pub create: bool, pub url: WebviewUrl, pub user_agent: Option<String>, pub drag_drop_enabled: bool, pub center: bool, pub x: Option<f64>, pub y: Option<f64>, pub width: f64, pub height: f64, pub min_width: Option<f64>, pub min_height: Option<f64>, pub max_width: Option<f64>, pub max_height: Option<f64>, pub prevent_overflow: Option<PreventOverflowConfig>, pub resizable: bool, pub maximizable: bool, pub minimizable: bool, pub closable: bool, pub title: String, pub fullscreen: bool, pub focus: bool, pub focusable: bool, pub transparent: bool, pub maximized: bool, pub visible: bool, pub decorations: bool, pub always_on_bottom: bool, pub always_on_top: bool, pub visible_on_all_workspaces: bool, pub content_protected: bool, pub skip_taskbar: bool, pub window_classname: Option<String>, pub no_redirection_bitmap: bool, pub theme: Option<Theme>, pub title_bar_style: TitleBarStyle, pub traffic_light_position: Option<LogicalPosition>, pub hidden_title: bool, pub accept_first_mouse: bool, pub tabbing_identifier: Option<String>, pub additional_browser_args: Option<String>, pub shadow: bool, pub window_effects: Option<WindowEffectsConfig>, pub incognito: bool, pub parent: Option<String>, pub proxy_url: Option<Url>, pub zoom_hotkeys_enabled: bool, pub browser_extensions_enabled: bool, pub use_https_scheme: bool, pub devtools: Option<bool>, pub background_color: Option<Color>, pub background_throttling: Option<BackgroundThrottlingPolicy>, pub javascript_disabled: bool, pub allow_link_preview: bool, pub disable_input_accessory_view: bool, pub data_directory: Option<PathBuf>, pub data_store_identifier: Option<[u8; 16]>, pub scroll_bar_style: ScrollBarStyle, pub limit_navigations_to_app_bound_domains: bool, pub activity_name: Option<String>, pub created_by_activity_name: Option<String>, pub requested_by_scene_identifier: Option<String>, pub general_autofill_enabled: bool,
}
Expand description

The window configuration object.

See more: https://v2.tauri.app/reference/config/#windowconfig

Fields§

§label: String

The window identifier. It must be alphanumeric.

§create: bool

Whether Tauri should create this window at app startup or not.

When this is set to false you must manually grab the config object via app.config().app.windows and create it with WebviewWindowBuilder::from_config.

§Example:

tauri::Builder::default()
  .setup(|app| {
    tauri::WebviewWindowBuilder::from_config(app.handle(), &app.config().app.windows[0])?.build()?;
    Ok(())
  });
§url: WebviewUrl

The window webview URL.

§user_agent: Option<String>

The user agent for the webview

§drag_drop_enabled: bool

Whether the drag and drop handlers used internally to generate DragDropEvents are enabled on the webview. By default it is enabled.

Disabling it is required to use HTML5 drag and drop on the frontend on Windows since we replace the drag drop handler of WebView2.

Note: this setting maps to WebviewBuilder::disable_drag_drop_handler, not WindowBuilder::drag_and_drop.

§center: bool

Whether or not the window starts centered or not.

§x: Option<f64>

The horizontal position of the window’s top left corner in logical pixels

§y: Option<f64>

The vertical position of the window’s top left corner in logical pixels

§width: f64

The window width in logical pixels.

§height: f64

The window height in logical pixels.

§min_width: Option<f64>

The min window width in logical pixels.

§min_height: Option<f64>

The min window height in logical pixels.

§max_width: Option<f64>

The max window width in logical pixels.

§max_height: Option<f64>

The max window height in logical pixels.

§prevent_overflow: Option<PreventOverflowConfig>

Whether or not to prevent the window from overflowing the workarea

§Platform-specific

  • iOS / Android: Unsupported.
§resizable: bool

Whether the window is resizable or not. When resizable is set to false, native window’s maximize button is automatically disabled.

§maximizable: bool

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.
§minimizable: bool

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

§Platform-specific

  • Linux / iOS / Android: Unsupported.
§closable: bool

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.
§title: String

The window title.

§fullscreen: bool

Whether the window starts as fullscreen or not.

§focus: bool

Whether the window will be initially focused or not.

§focusable: bool

Whether the window will be focusable or not.

§transparent: bool

Whether the window is transparent or not.

Note that on macOS this requires the macos-private-api feature flag, enabled under tauri > macOSPrivateApi. WARNING: Using private APIs on macOS prevents your application from being accepted to the App Store.

On Windows, using noRedirectionBitmap can help avoid a white flash when creating a transparent window.

§maximized: bool

Whether the window is maximized or not.

§visible: bool

Whether the window is visible or not.

§decorations: bool

Whether the window should have borders and bars.

§always_on_bottom: bool

Whether the window should always be below other windows.

§always_on_top: bool

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

§visible_on_all_workspaces: bool

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

§Platform-specific

  • Windows / iOS / Android: Unsupported.
§content_protected: bool

Prevents the window contents from being captured by other apps.

§skip_taskbar: bool

If true, hides the window icon from the taskbar on Windows and Linux.

§window_classname: Option<String>

The name of the window class created on Windows to create the window. Windows only.

§no_redirection_bitmap: bool

This sets WS_EX_NOREDIRECTIONBITMAP.

This can avoid the white flash that may appear before the webview content is rendered when using a transparent window. Windows only.

§theme: Option<Theme>

The initial window theme. Defaults to the system theme. Only implemented on Windows and macOS 10.14+.

§title_bar_style: TitleBarStyle

The style of the macOS title bar.

§traffic_light_position: Option<LogicalPosition>

The position of the window controls on macOS.

Requires titleBarStyle: Overlay and decorations: true.

§hidden_title: bool

If true, sets the window title to be hidden on macOS.

§accept_first_mouse: bool

Whether clicking an inactive window also clicks through to the webview on macOS.

§Platform-specific

  • CEF runtime: Unsupported. Chromium decides on its own whether the click that activates the window reaches the page: it is swallowed on regular windows and only clicks through on always-on-top windows or while a DevTools debugger is attached.
§tabbing_identifier: Option<String>

Defines the window tabbing identifier for macOS.

Windows with matching tabbing identifiers will be grouped together. If the tabbing identifier is not set, automatic tabbing will be disabled.

§additional_browser_args: Option<String>

Defines additional browser arguments on Windows.

§Warning

Webview instances with different browser arguments must also have different data directories.

By default wry passes --disable-features=msWebOOUI,msPdfOOUI,msSmartScreenProtection so if you set this, you also need to disable these components by yourself if you want.

§shadow: bool

Whether or not the window has shadow.

§Platform-specific

  • Windows:
    • false has no effect on decorated window, shadow 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.
§window_effects: Option<WindowEffectsConfig>

Window effects.

Requires the window to be transparent.

§Platform-specific:

§incognito: bool

Whether or not the webview should be launched in incognito mode.

§Platform-specific:

  • Android: Unsupported.
§parent: Option<String>

Sets the window associated with this label to be the parent of the window to be created.

§Platform-specific

§proxy_url: Option<Url>

The proxy URL for the WebView for all network requests.

Must be either a http:// or a socks5:// URL.

§Platform-specific

  • macOS: Requires the macos-proxy feature flag and only compiles for macOS 14+.
§zoom_hotkeys_enabled: bool

Whether page zooming by hotkeys is enabled

§Platform-specific:

  • Windows: Controls WebView2’s IsZoomControlEnabled setting.

  • MacOS / Linux: Injects a polyfill that zooms in and out with ctrl/command + -/=, 20% in each step, ranging from 20% to 1000%. Requires webview:allow-set-webview-zoom permission

  • Android / iOS: Unsupported.

§browser_extensions_enabled: bool

Whether browser extensions can be installed for the webview process

§Platform-specific:

§use_https_scheme: bool

Sets whether the custom protocols should use https://<scheme>.localhost instead of the default http://<scheme>.localhost on Windows and Android. Defaults to false.

§Note

Using a https scheme will NOT allow mixed content when trying to fetch http endpoints and therefore will not match the behavior of the <scheme>://localhost protocols used on macOS and Linux.

§Warning

Changing this value between releases will change the IndexedDB, cookies and localstorage location and your app will not be able to access the old data.

§devtools: Option<bool>

Enable web inspector which is usually called browser devtools. Enabled by default.

This API works in debug builds, but requires devtools feature flag to enable it in release builds.

§Platform-specific

  • macOS: This will call private functions on macOS.
  • Android: Open chrome://inspect/#devices in Chrome to get the devtools window. Wry’s WebView devtools API isn’t supported on Android.
  • iOS: Open Safari > Develop > [Your Device Name] > [Your WebView] to get the devtools window.
§background_color: Option<Color>

Set the window and webview background color.

§Platform-specific:

  • Windows: alpha channel is ignored for the window layer.
  • Windows: On Windows 7, alpha channel is ignored for the webview layer.
  • Windows: On Windows 8 and newer, if alpha channel is not 0, it will be ignored for the webview layer.
§background_throttling: Option<BackgroundThrottlingPolicy>

Change the default background throttling behaviour.

By default, browsers use a suspend policy that will throttle timers and even unload the whole tab (view) to free resources after roughly 5 minutes when a view became minimized or hidden. This will pause all tasks until the documents visibility state changes back from hidden to visible by bringing the view back to the foreground.

§Platform-specific

  • Linux / Windows / Android: Unsupported. Workarounds like a pending WebLock transaction might suffice.
  • iOS: Supported since version 17.0+.
  • macOS: Supported since version 14.0+.

see https://github.com/tauri-apps/tauri/issues/5250#issuecomment-2569380578

§javascript_disabled: bool

Whether we should disable JavaScript code execution on the webview or not.

§allow_link_preview: bool

on macOS and iOS there is a link preview on long pressing links, this is enabled by default. see https://docs.rs/objc2-web-kit/latest/objc2_web_kit/struct.WKWebView.html#method.allowsLinkPreview

§disable_input_accessory_view: bool

Allows disabling the input accessory view on iOS.

The accessory view is the view that appears above the keyboard when a text input element is focused. It usually displays a view with “Done”, “Next” buttons.

§data_directory: Option<PathBuf>

Set a custom path for the webview’s data directory (localStorage, cache, etc.) relative to [appDataDir()]/${label}.

To set absolute paths, use WebviewWindowBuilder::data_directory

§Platform-specific:
  • Windows: WebViews with different values for settings like additionalBrowserArgs, browserExtensionsEnabled or scrollBarStyle must have different data directories.
  • macOS / iOS: Unsupported, use dataStoreIdentifier instead.
  • Android: Unsupported.
§data_store_identifier: Option<[u8; 16]>

Initialize the WebView with a custom data store identifier. This can be seen as a replacement for dataDirectory which is unavailable in WKWebView. See https://developer.apple.com/documentation/webkit/wkwebsitedatastore/init(foridentifier:)?language=objc

The array must contain 16 u8 numbers.

§Platform-specific:
  • iOS: Supported since version 17.0+.
  • macOS: Supported since version 14.0+.
  • Windows / Linux / Android: Unsupported.
§scroll_bar_style: ScrollBarStyle

Specifies the native scrollbar style to use with the webview. CSS styles that modify the scrollbar are applied on top of the native appearance configured here.

Defaults to default, which is the browser default.

§Platform-specific

  • Windows:
    • fluentOverlay requires WebView2 Runtime version 125.0.2535.41 or higher, and does nothing on older versions.
    • This option must be given the same value for all webviews that target the same data directory.
  • Linux / Android / iOS / macOS: Unsupported. Only supports Default and performs no operation.
§limit_navigations_to_app_bound_domains: bool

Whether to limit navigations to App-Bound Domains. This is necessary to enable Service Workers on iOS according to StackOverflow.

Default is false.

Note: If you set this to true make sure to add localhost and any registrable domains used in this webview to tauri-src/Info.ios.plist:

<plist>
<dict>
    <key>WKAppBoundDomains</key>
    <array>
        <string>localhost</string>
        <string>aregistrabledomain.example</string>
    </array>
</dict>
</plist>

You must add localhost if any webview with this set to true opens a local webpage, makes any localhost calls, or uses the isolation pattern because Tauri uses the localhost domain for hosting the application webpage, the IPC protocol, and the isolation pattern’s iframe.

Requests served through custom uri schemes are allowed so long as they use a registrable domain specified in the WKAppBoundDomains array for all the requests from the app, including requests for the localhost domain.

In theory, you can whitelist an entire uri scheme by including the protocol name followed by a colon. For example, to allow all requests using a custom “stream” uri scheme (see this tauri example), you could add stream: to the AppBoundDomains array. That said, I’m not sure whether Apple would let your app through app review if you do whitelist an entire protocol because this feature is not mentioned in their blog post on App-Bound Domains.

See https://webkit.org/blog/10882/app-bound-domains/ and https://developer.apple.com/documentation/webkit/wkwebviewconfiguration/limitsnavigationstoappbounddomains for the official documentation on App-Bound Domains.

§Platform-specific

  • iOS: Supported since version 14.0+.
  • Linux / Windows / Android / MacOS: Unsupported.
§activity_name: Option<String>

The name of the Android activity to create for this window.

§created_by_activity_name: Option<String>

The name of the Android activity that is creating this webview window.

This is important to determine which stack the activity will belong to.

§requested_by_scene_identifier: Option<String>

Sets the identifier of the scene that is requesting the new scene, establishing a relationship between the two scenes.

By default the system uses the foreground scene.

§general_autofill_enabled: bool

Controls the WebView’s browser-level general autofill behavior.

This option does not disable password or credit card autofill.

When set to false, the WebView will not automatically populate general form fields using previously stored data such as addresses or contact information.

If not specified, this is true by default.

§Platform-specific

  • Windows: Supported. WebView2’s autofill feature (called “Suggestions”) may not honor autocomplete="off" on input elements in some cases.
  • Linux / Android / iOS / macOS: Unsupported and performs no operation.

Trait Implementations§

Source§

impl Clone for WindowConfig

Source§

fn clone(&self) -> WindowConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WindowConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WindowConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for WindowConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for WindowConfig

Source§

fn eq(&self, other: &WindowConfig) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for WindowConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for WindowConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.