Installation
Enable thewebview feature in your Cargo.toml:
Basic Usage
Important Setup
You must register theWebViewPlugin when launching your app:
Features
- Modern Web Support: Full HTML5, CSS3, and JavaScript support
- Multiple WebViews: Create and manage multiple web views
- Lifecycle Control: Control when WebViews are created and destroyed
- Layout Integration: WebViews respect Freya’s layout system
- Tab System: Build browser-like interfaces with multiple tabs
Creating WebViews
Simple WebView
WebView with ID
Use IDs to manage WebView lifecycle:Control Lifecycle
By default, WebViews are closed when unmounted. To keep them alive:Building a Tab System
Create a browser-like interface with multiple tabs:Multiple WebViews
Display multiple WebViews simultaneously:Resizable WebViews
Combine WebViews withResizableContainer:
Managing WebView Lifecycle
Close WebView Programmatically
Clean Up on Exit
Key Types
WebView
The main WebView component:WebViewId
Unique identifier for WebView instances:WebViewPlugin
Plugin that must be registered:WebViewManager
Static methods for managing WebViews:WebViewManager::close(id)- Close a WebView by ID
WebViewConfig
Configuration options for WebViews (advanced usage).Layout Integration
WebViews respect all standard layout properties:Example: Complete Browser
See thefeature_webview.rs example in the repository for a complete tab-based browser implementation with:
- Multiple tabs
- Tab creation and closing
- Active tab switching
- WebView lifecycle management
- Persistent WebViews when switching tabs
Notes
- Always register
WebViewPluginbefore using WebViews - WebViews use the system’s native web rendering engine (WebKit on macOS, WebView2 on Windows, WebKitGTK on Linux)
- By default, WebViews are destroyed when unmounted unless
close_on_drop(false)is set - Use unique
WebViewIds to manage multiple WebViews - WebViews run in a separate thread and communicate asynchronously with the UI