pub struct WindowConfig {Show 57 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 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,
}Expand description
The window configuration object.
See more: https://v2.tauri.app/reference/config/#windowconfig
Fields§
§label: StringThe window identifier. It must be alphanumeric.
create: boolWhether 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: WebviewUrlThe window webview URL.
user_agent: Option<String>The user agent for the webview
drag_drop_enabled: boolWhether the drag and drop is enabled or not on the webview. By default it is enabled.
Disabling it is required to use HTML5 drag and drop on the frontend on Windows.
center: boolWhether or not the window starts centered or not.
x: Option<f64>The horizontal position of the window’s top left corner
y: Option<f64>The vertical position of the window’s top left corner
width: f64The window width.
height: f64The window height.
min_width: Option<f64>The min window width.
min_height: Option<f64>The min window height.
max_width: Option<f64>The max window width.
max_height: Option<f64>The max window height.
prevent_overflow: Option<PreventOverflowConfig>Whether or not to prevent the window from overflowing the workarea
§Platform-specific
- iOS / Android: Unsupported.
resizable: boolWhether the window is resizable or not. When resizable is set to false, native window’s maximize button is automatically disabled.
maximizable: boolWhether 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: boolWhether the window’s native minimize button is enabled or not.
§Platform-specific
- Linux / iOS / Android: Unsupported.
closable: boolWhether 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: StringThe window title.
fullscreen: boolWhether the window starts as fullscreen or not.
focus: boolWhether the window will be initially focused or not.
focusable: boolWhether the window will be focusable or not.
transparent: boolWhether 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.
maximized: boolWhether the window is maximized or not.
visible: boolWhether the window is visible or not.
decorations: boolWhether the window should have borders and bars.
always_on_bottom: boolWhether the window should always be below other windows.
always_on_top: boolWhether the window should always be on top of other windows.
visible_on_all_workspaces: boolWhether the window should be visible on all workspaces or virtual desktops.
§Platform-specific
- Windows / iOS / Android: Unsupported.
content_protected: boolPrevents the window contents from being captured by other apps.
skip_taskbar: boolIf 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.
theme: Option<Theme>The initial window theme. Defaults to the system theme. Only implemented on Windows and macOS 10.14+.
title_bar_style: TitleBarStyleThe 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.
If true, sets the window title to be hidden on macOS.
accept_first_mouse: boolWhether clicking an inactive window also clicks through to the webview on macOS.
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. By default wry passes --disable-features=msWebOOUI,msPdfOOUI,msSmartScreenProtection
so if you use this method, you also need to disable these components by yourself if you want.
shadow: boolWhether or not the window has shadow.
§Platform-specific
- Windows:
falsehas no effect on decorated window, shadow are always ON.truewill 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:
- Windows: If using decorations or shadows, you may want to try this workaround https://github.com/tauri-apps/tao/issues/72#issuecomment-975607891
- Linux: Unsupported
incognito: boolWhether 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
- Windows: This sets the passed parent as an owner window to the window to be created.
From MSDN owned windows docs:
- An owned window is always above its owner in the z-order.
- The system automatically destroys an owned window when its owner is destroyed.
- An owned window is hidden when its owner is minimized.
- Linux: This makes the new window transient for parent, see https://docs.gtk.org/gtk3/method.Window.set_transient_for.html
- macOS: This adds the window as a child of parent, see https://developer.apple.com/documentation/appkit/nswindow/1419152-addchildwindow?language=objc
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-proxyfeature flag and only compiles for macOS 14+.
zoom_hotkeys_enabled: boolWhether page zooming by hotkeys is enabled
§Platform-specific:
-
Windows: Controls WebView2’s
IsZoomControlEnabledsetting. -
MacOS / Linux: Injects a polyfill that zooms in and out with
ctrl/command+-/=, 20% in each step, ranging from 20% to 1000%. Requireswebview:allow-set-webview-zoompermission -
Android / iOS: Unsupported.
browser_extensions_enabled: boolWhether browser extensions can be installed for the webview process
§Platform-specific:
- Windows: Enables the WebView2 environment’s
AreBrowserExtensionsEnabled - MacOS / Linux / iOS / Android - Unsupported.
use_https_scheme: boolSets 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/#devicesin Chrome to get the devtools window. Wry’sWebViewdevtools 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: boolWhether we should disable JavaScript code execution on the webview or not.
allow_link_preview: boolon 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: boolAllows 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,browserExtensionsEnabledorscrollBarStylemust have different data directories. - macOS / iOS: Unsupported, use
dataStoreIdentifierinstead. - 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: ScrollBarStyleSpecifies 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:
fluentOverlayrequires 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
Defaultand performs no operation.
Trait Implementations§
Source§impl Clone for WindowConfig
impl Clone for WindowConfig
Source§fn clone(&self) -> WindowConfig
fn clone(&self) -> WindowConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more