Expand description
§tauri-plugin-gpui
Render GPUI views inside ordinary Tauri windows.
Tauri/TAO stays authoritative for the application lifecycle, the event
loop and native windows. This plugin permanently attaches GPUI as the
content renderer of an existing Tauri window; all attached windows share
one GPUI App running on Tauri’s event-loop thread.
use tauri_plugin_gpui::{GpuiWindowExt, gpui::{self, prelude::*}};
struct Hello;
impl gpui::Render for Hello {
fn render(&mut self, _: &mut gpui::Window, _: &mut gpui::Context<Self>) -> impl IntoElement {
gpui::div().size_full().child("Hello from GPUI")
}
}
// In an app, `context` is `tauri::generate_context!()`.
fn run(context: tauri::Context) {
tauri::Builder::default()
.setup(|app| {
tauri_plugin_gpui::init(app)?;
let window = tauri::WindowBuilder::new(app, "main").title("Example").build()?;
window.attach_gpui(|cx| cx.new(|_| Hello))?;
Ok(())
})
.run(context)
.expect("error while running tauri application");
}§Platforms and features
Linux, macOS and Windows work with default features. Android and iOS
need the mobile feature; without it, init returns
GpuiError::UnsupportedOperation on those targets. Embedding Tauri
child webviews (webview_frame) is desktop-only.
Re-exports§
pub use gpui;
Structs§
- Gpui
Config - Application-wide configuration for the shared GPUI runtime.
- Gpui
Options - Per-window attachment options.
- Webview
Frame Neither Android nor iOS - The element returned by
webview_frame.
Enums§
- Gpui
Error - Errors returned by the plugin’s public API.
Traits§
- Gpui
Window Ext - Attaches GPUI as the content renderer of a Tauri window.
Functions§
- focus_
webview Neither Android nor iOS - Gives keyboard focus to
webview, a child webview placed withwebview_frame, as clicking it would. Use it when a GPUI control opens something in the webview that expects typing, such as a search box. - init
- Initializes the shared GPUI runtime and hooks it into Tauri’s event loop.
- init_
with initwith explicit configuration.- on_back
- Sets the handler for the system back action (the Android back button
or gesture). It only runs while
set_back_enabledistrue; otherwise back leaves the app as usual. Never called on desktop. - set_
back_ enabled - Declares whether the app currently handles the back action, typically whether its navigation stack is deeper than its root. No-op on desktop.
- webview_
frame Neither Android nor iOS - Creates a GPUI element that hosts
webview, a child webview of the GPUI-backed Tauri window this element renders in. - with_
app - Runs
fwith the shared GPUIApp.