A cross-platform GUI library for Rust.
- Simple, renderer-neutral API.
- Retained UI tree with flexible layout.
- Built-in widgets and editor controls.
- Type-safe actions and commands.
- Accessibility and input handling.
- WGPU renderer support.
- Custom drawing surfaces.
- Headless testing utilities.
The shortest path to a native window is run:
use operad::{root_style, widgets, LayoutStyle, NativeWindowResult, UiDocument, UiSize};
fn main() -> NativeWindowResult {
operad::run("app", view)
}
fn view(viewport: UiSize) -> UiDocument {
let mut ui = UiDocument::new(root_style(viewport.width, viewport.height));
let root = ui.root;
widgets::button(
&mut ui,
root,
"run",
"Run",
widgets::ButtonOptions::new(LayoutStyle::size(140.0, 36.0)),
);
ui
}The runner opens the window, creates the renderer, lays out the document, and
routes input. Use run_app when widget actions should update application state;
the showcase example is a compact app built that way.
Web apps use the same retained document contract through the web-runtime
feature:
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen::prelude::wasm_bindgen]
pub async fn start() -> Result<(), wasm_bindgen::JsValue> {
operad::web::run("app", view).await
}For custom WGPU drawing, add a GPU canvas to the document and register a canvas renderer:
let mut canvases = operad::NativeWgpuCanvasRenderRegistry::new();
canvases.register("viewport", |state: &mut AppState, context| {
state.renderer.render(&context.surface)?;
Ok(operad::CanvasRenderOutput::new())
});
operad::run_app_with_canvas_renderers(options, state, update, view, canvases)?;The renderer callback gets the canvas texture context, so it can record normal WGPU command buffers and render passes before Operad composites the UI.
cargo add operadwidgets: widget helpers.native-window: native winit/WGPU windows.web-runtime: WASM/WebGPU runtime entry points with cosmic-text layout measurement.web-showcase: web runtime plus showcase widgets.wgpu: WGPU rendering.accesskit-winit: AccessKit support for winit hosts.text-cosmic: cosmic-text measurement and shaping.egui: egui host/input compatibility.egui-renderer-compat: egui renderer compatibility.audit: audit helpers.
Open a native window:
cargo run --example showcaseStarter templates are checked as ordinary examples:
cargo run --example minimal_native
cargo run --example simple_form
cargo run --example docked_workspaceFor the web template, build minimal_web for wasm32-unknown-unknown, run
wasm-bindgen, and serve web/minimal.
Use the fast gate while iterating:
scripts/test-fast.shThat runs formatting, locked all-target/all-feature compilation, all-feature library tests, and the locked no-default compile gate without running perf smoke or WGPU snapshot integration tests.
Focused cargo aliases are available for common loops:
cargo test-native
cargo test-matrix
cargo test-wgpu-snap
cargo test-perfRun the full local gate before release-level handoff:
scripts/test-full.shThat adds the full all-feature test suite and the supported WASM showcase check
for wasm32-unknown-unknown.
The release flow lives in docs/release_process.md.