What zgui is
A native Rust UI framework with fine-grained signals, real CSS, and a retained GPU renderer — what it gives you and what it does not try to be.
zgui is a framework for native desktop applications written in Rust. You build the interface from components, keep state in signals, and style everything with CSS. zgui handles layout, text, input, and accessibility, and draws every pixel on the GPU.
#[component]
fn Toggle() -> impl IntoView {
let on = RwSignal::new(false);
view! {
control(
class = "toggle",
state:checked = move || on.get(),
on:click = move |_| on.update(|value| *value = !*value)
) {
{move || if on.get() { "On" } else { "Off" }}
}
}
}.toggle { padding: 8px 16px; border-radius: 8px; background-color: #232936; }
.toggle:checked { background-color: #3b6cf6; }A click writes one signal. zgui re-runs the two closures that read it, one for the label and one
for the :checked state, and redraws the button. Nothing else in the window runs again.
Fine-grained reactivity
A component runs once to build its part of the interface. After that, changes flow through signals. A signal records which closures read it, and writing it re-runs only those closures. A counter in a window with thousands of elements updates one text node.
The reactive core is Leptos' reactive_graph, so signals, memos, stores, and async derived values
work the way they do in Leptos. Signals covers the model from first
principles.
Real CSS
Appearance is CSS, resolved by Stylo, the style engine Firefox uses. Selectors, the cascade, custom
properties, flexbox, grid, and animations work as you expect. States such as :hover, :focus, and :checked match because zgui tracks the
pointer, focus, and element state itself.
Retained rendering
In an immediate-mode library, your code describes the whole interface again on every frame. That is simple to reason about, but each frame costs a full pass whether or not anything changed.
zgui is retained at every stage. The document, computed styles, layout, shaped text, paint recordings, and pixels all survive between frames, and a change redoes only the work it affects. An idle window with ten thousand elements costs about as much as one with ten.
Your state and the views that read it.
A retained tree of elements.
CSS in, computed styles out (Stylo).
Positions, sizes, and shaped glyphs (Cephal, Parley).
Retained drawing recordings.
wgpu draws into a target kept between frames.
Only changed pixels are redrawn.
Data flows one way: layout never edits the document, and the renderer knows nothing about elements. Each stage passes plain data to the next, so most of the framework can be tested without a window or a GPU.
You do not need to know these stages to write an application. They explain rules you will meet later: a component runs once, a signal write takes effect at the end of the frame, and changing a colour is cheaper than changing a width. Under the hood covers each stage in detail.
What zgui includes
| Area | What you get |
|---|---|
| State | Signals, memos, stores, and async tasks, built on Leptos' reactive_graph |
| Styling | Selectors, the cascade, custom properties, media queries, flexbox, grid, transitions, animations, transforms, filters |
| Text | Shaping, wrapping, bidirectional text, editing, IME, selection, system or bundled fonts |
| Graphics | Images, SVG, canvas drawing (including large data series), custom elements, application shaders written in WGSL, embedded wgpu surfaces |
| Platform | Linux (native Wayland or X11), macOS, Windows, and a headless backend for tests; multiple windows, clipboard, drag and drop, custom window chrome, macOS application menu |
| Accessibility | An AccessKit tree for screen readers on every desktop platform |
| Components | zgui-ui, an optional themeable library of controls, menus, dialogs, forms, and data views |
An experimental backend runs applications directly on a Linux console through DRM/KMS, with no display server. It lives in the zgui repository and is not published.
What zgui is not
- Not a browser. There is no webview, HTML parser, JavaScript engine, or DOM specification. zgui uses browser-engine libraries where they fit: Stylo for CSS, Parley for text, and Cephal, a retained incremental layout engine, for block, flex, and grid layout.
- Not a wrapper over native widgets. There is no
NSButtonor GTK widget underneath. zgui draws everything on the GPU, so an interface looks the same on every platform. - Not the web platform. CSS support targets application interfaces. Floats,
contenteditable, and HTML forms are not goals.