zgui
A native Rust UI framework with fine-grained signals, real CSS, and a retained GPU renderer.
zgui is a framework for native desktop applications written in Rust. You write components and signals, style them with CSS, and zgui lays out, shapes text, and draws everything on the GPU. There is no webview, no HTML, and no JavaScript.
cargo add zguizgui is experimental. Expect breaking changes between 0.x releases. Pages mark unfinished parts with a badge such as Not built yet· not built yet.
A complete application
use zgui::prelude::*;
#[component]
fn Counter() -> impl IntoView {
let count = RwSignal::new(0);
view! {
column(class = "counter") {
text(class = "value") {{move || count.get().to_string()}}
control(on:click = move |_| count.update(|n| *n += 1)) {
"Increment"
}
}
}
}
const SHEET: &str = css!(
":root {
background-color: #111318;
color: #f2f4f8;
font-family: sans-serif;
display: flex;
align-items: center;
justify-content: center;
}
.counter { gap: 12px; align-items: center; }
.value { font-size: 48px; font-weight: 700; }
control {
padding: 8px 16px;
border-radius: 8px;
background-color: #356df3;
}"
);
fn main() -> Result<(), zgui::Error> {
app()
.with_title("Counter")
.with_size(360.0, 240.0)
.with_stylesheet(SHEET)
.run(|| view! { Counter() })
}Four ideas cover most of zgui:
- A component runs once.
Counterbuilds its part of the interface and returns. It is not called again when the count changes. - A signal holds state.
RwSignal::new(0)records which closures read it. Writing it re-runs those closures and nothing else. - A closure in a view is reactive.
{move || count.get().to_string()}updates the text whenever the count changes. Without the closure,{count.get().to_string()}is written once. - Appearance is CSS. Selectors, the cascade, custom properties, flexbox, grid, transitions,
animations, transforms, and filters.
css!checks the sheet's structure at compile time.
What is included
- Fine-grained reactivity from Leptos'
reactive_graph: signals, memos, stores, async derived values, and tasks. - A CSS engine (Stylo), a retained layout engine (Cephal), and a text engine (Parley).
- Native windows on Linux (Wayland or X11), macOS, and Windows, plus a headless backend for tests.
- Accessibility, IME, clipboard, drag and drop, multiple windows, and custom window chrome.
- Images, SVG, canvas drawing, custom elements, application shaders, and embedded wgpu surfaces.
- An optional component library,
zgui-ui, with themeable controls, menus, dialogs, forms, and data views.
How the docs are organised
You need to know Rust, but not UI programming: signals, the cascade, layout, and rendering are explained when you first need them.
To learn zgui, read the guide in order. It builds everything from the core elements and introduces the component library at the end. To solve a specific task, jump to a page from search or from Building interfaces.
Getting started
What zgui is, how to install it, and your first application.
The guide
Views, signals, components, control flow, events, styling, and layout.
Building interfaces
Task-focused pages: text, keyboard, scrolling, overlays, windows, testing, shipping.
Under the hood
The pipeline stage by stage, and what each part of a frame costs.