简体中文 · English
A lightweight, cross-platform desktop GUI framework — build memory-friendly tools in Rust.
Native platform windows · tiny-skia vector rendering · Native text shaping · No runtime · No GC.
| Platform | Window / Present | Text |
|---|---|---|
| Windows | Win32 + GDI (DIB blit) | DirectWrite |
| macOS | Cocoa/AppKit + CoreGraphics (CGImage blit) | Core Text |
| Linux | X11 (x11rb, a pure-Rust protocol implementation) + PutImage; native Wayland (wl_shm, opt in with WINDUI_BACKEND=wayland; by default Wayland sessions go through XWayland) |
fontconfig font matching + built-in rasterizer |
The rendering layer (tiny-skia) and all widget/layout/event logic are platform-agnostic; each platform only implements two seams: the "window + event loop" and the "text engine".
For small tools, Electron easily costs hundreds of MB, and Go GUIs need 15–40MB due to runtime/GC. windui has no runtime and no garbage collector. Measured on Windows:
| Metric | Measured |
|---|---|
| Binary size (release, LTO+strip) | minimal window app 0.64 MB; comprehensive demo (full widget set + SVG) 1.38 MB |
| Private memory (PrivateBytes, 100% scaling) | minimal window 480×320 2.7 MB; about window 620×556 5.5 MB |
| Same, at 200% scaling | 4.6 MB / 14.2 MB |
| Cross-platform direct deps | tiny-skia (render) · resvg (SVG, on by default, stripped by LTO if unused) · serde + toml (theming); platform system bindings pulled in by target |
A memory number means nothing without its DPI. The bulk of it is the ~2.5 full-window RGBA buffers the software rasterizer keeps, and those are allocated in physical pixels — at 200% scaling the same window covers 4× the physical area, and the memory scales with it. The two rows above are the same binaries measured at two scaling factors, not two different builds.
The working set additionally covers shared system DLL mappings (gdi32/dwrite, etc. — about 22MB for the about window at 100%); the only memory the process truly owns is the private figure above.
Every number is measured by
scripts/measure_footprint.ps1and reproducible by running it.
- Imperative Builder API — pure-Rust method chaining, type-safe, zero parsing overhead.
- Copy-handle state — state is a
Signal<T>: closuresmove-capture it directly, noclone()ceremony;set()schedules a repaint automatically. Data changes drive subtree rebuilds (list_signal), so dynamic lists need no hand-written diffing. - Runtime theme switching — grab a handle with
App::theme_handle()and callset(Theme::dark())inside any callback to reskin the whole tree; colors expressed as aRole(fg_role/bg_role) follow along. - One codebase, three platforms — widget tree, layout, events, animation, theming are all platform-agnostic; switching platforms requires zero changes.
- Retained mode + dirty triggering — no redraw when idle, blocks on the event loop, zero CPU usage.
- High-quality text — native shaping (DirectWrite / Core Text; on Linux, fontconfig font matching + a built-in layout rasterizer) + grayscale anti-aliasing, crisp CJK; auto line-wrapping labels; color emoji (incl. ZWJ sequences and skin-tone modifiers), text fields accept emoji input.
- DPI / Retina aware — widget tree in logical coordinates, paint layer uniformly scales to physical pixels, text rendered at physical font size (measure and draw share one path), staying sharp at high DPI (1.5x/2x/Retina).
- Clean focus ring — the focus ring shows only during keyboard Tab navigation, never on mouse-only interaction.
- Complete widget set — layout, text, buttons, form inputs, container navigation, lists, images, tray.
- Platform-native menu feel — the right-click menu opens on release on Windows and on press on macOS / Linux by default (
App::context_menu_triggeroverrides it); menu items fire on release and can be backed out of by moving away; dropdowns and menu bars support press-drag-release to pick an item directly. - Internationalization —
Localesswitch languages at runtime; the framework's own strings (context menus, window system menu) ship in Chinese and English and can be overridden by the app. - Touch / trackpad — pan scrolling + fling inertia + edge bounce.
- Optional GPU acceleration (both platforms) — large windows can opt in with
App::renderer(Renderer::Auto): Direct2D on Windows, wgpu/Metal on macOS (compiled in by default, no feature flag needed). Geometry, gradients and shadows run on the GPU while text is still rasterized by the platform stack (DirectWrite / Core Text), so fonts and metrics are unchanged. Software rendering stays the default; RDP sessions, machines without a GPU and off-screen screenshots fall back automatically, and a device loss at runtime is recovered by rebuilding — or, failing that, by switching that window back to software rendering. It never panics. - Automatic screenshots —
--screenshotrenders one frame off-screen to PNG (--scale 1.5for high-DPI), ideal for automated regression.
Every screenshot below is captured automatically via off-screen rendering (--screenshot, see scripts/readme_shots.ps1) with no retouching.
The main examples all use frameless windows with a self-drawn title bar — the title bar is part of the widget tree, laid out and themed exactly like the rest of the window.
use windui::prelude::*;
fn main() {
// State is a Signal<T>: a Copy handle, captured directly by closures;
// writing to it schedules a repaint automatically.
let on = signal(true);
let ui = Element::col()
.fill()
.padding(20)
.spacing(12)
.bg(Color::hex(0xF5F6FA))
.child(Element::label("Hello, windui!").font_size(22.0).width_match())
.child(Element::checkbox("Enable feature", on))
.child(Element::button("OK").on_click(move |ctx| {
println!("checkbox = {}", on.get());
ctx.request_close();
}));
App::new("Demo", 360, 240).content(ui).run();
}| Category | Widgets |
|---|---|
| Layout | col / row (LinearLayout, with weight), stack (FrameLayout), grid (equal-width grid), split (draggable split pane), flex_spacer |
| Text | label (auto-wrap), label_signal (signal-bound), link (clickable), rich (rich text: styled spans / collapsible sections) |
| Button | button (hover/press/focus states + click/Enter/Space activation), icon_button |
| Form | checkbox / switch / radio (exclusive group) / slider (drag+keyboard) / text_input (CJK editing + password + multiline) / dropdown / combo_box (editable dropdown) / check_menu / stepper / chip / tag_field / color_picker |
| Feedback | progress (determinate/indeterminate) / tooltip / toast (centered transient overlay) / badge |
| Container | scroll (vertical / horizontal / both; wheel/touch + clip + scrollbar) / tabs / tabs_pill / divider / dialog (modal) / dialog_panel (titled) / visible_when |
| Navigation | menu_bar (native-feel menu bar: slide between menus, ←→ across menus, F10 / Alt activation, mnemonics) / segmented / nav_row (drill-in) / collapsible / accordion · accordion_multi; the selection highlight slides between rows (slide_highlight, used by list_pill) |
| List | list / list_pill (sidebar style) / list_icons (single-select / scroll / highlight / icons / disabled state) / list_signal (data-driven dynamic list) / reorder_list (drag to reorder) |
| Table | table (read-only) / table_custom / table_editable / table_sortable / table_sortable_server (server-side sort + paging) / table_selectable (multi-select); drag header boundaries to resize columns (weights persistable) |
| Image | image / image_svg / image_view (PNG/SVG, state modulation/tinting/rounding) |
| System | System tray (icon + left/double click + native context menu; StatusNotifierItem on Linux) and desktop notifications, global hotkeys, multi-window (ctx.open_window, incl. singleton windows), start hidden, close-to-hide, frameless window (custom title bar), file drop, clipboard |
Widget state binds uniformly to Signal<T> — a Copy handle created by signal(initial):
checkbox / switch take Signal<bool>, dropdown / list / tabs take Signal<usize>,
text_input takes Signal<String>. Writing via set() schedules a repaint automatically, with
no manual dirty marking. See docs/API_GUIDE.md §3.2.
cargo run --release --example fullshowcase # run the comprehensive demo window
cargo run --release --example ime -- --renderer gpu # enable the GPU backend (Win: D2D / macOS: Metal)
cargo run --example fullshowcase -- --screenshot out.png # render off-screen to PNG
cargo test # run unit tests
cargo clippy --all-targets # lintExamples fall into four groups:
| Group | Examples |
|---|---|
| Complete apps | settings (settings window: title bar + icon sidebar + content + action bar + two dialogs), about (about page), ime_settings (IME settings scenario), light_titlebar (installer-style light title bar) |
| Widgets & capabilities | fullshowcase (widget tour, seven tabs), theming (TOML themes + runtime reskin), font_switch (runtime UI font switch + font queries), image (images/SVG), animation, emoji (color emoji), caret (four caret styles), menubar (menu bar), i18n (multi-language), color_picker, palette (keyboard-only command palette) |
| Data display | virtual_list (virtual list + table), virtual_table_server (server-side paging), table_pager (pager bar), dyn_list (data-driven dynamic list), chat_scroll (chat-style scrolling: stick to bottom / anchor on prepend), list, dropdown, tabs_pill, toast, progress, multiline |
| System integration | tray (system tray), hotkey (global hotkeys + start hidden), multi_window (child windows + shared state), file_drop, frameless (custom title bar + system menu), background_task (cross-thread updates), ime |
Plus phase0–phase5 staged demos and the perfprobe performance probe, used for development and regression comparison.
See docs/DESIGN.md (design) and docs/ROADMAP.md (roadmap).
App layer App / UiHost (interactive host, implements AppHandler)
Widget layer Element Builder · Widget trait · layout algorithm
Core layer Arena + Node tree · Measure/Arrange/Paint phases · event dispatch
Render layer Canvas trait → tiny-skia backend (pure Rust, cross-platform)
Text layer TextEngine trait → DirectWrite (Windows) / Core Text (macOS) / fontconfig + ttf-parser (Linux)
Platform layer AppHandler trait → win32 (window/WndProc/DIB) / macos (NSWindow/NSView/CGImage) / linux (X11/PutImage or Wayland/wl_shm)
Key design: nodes live in a generational arena (not Rc<RefCell>); the Widget trait degenerates to pure content, and layout recursion is driven by Tree holding &mut self exclusively — sidestepping Rust borrow conflicts at the root. Text is composited onto the tiny-skia premultiplied buffer with anti-aliasing by the native engine. The platform seam mapping is documented in docs/MACOS_PORTING.md and docs/LINUX_PORTING.md.
Windows and macOS are supported. Linux is usable: the X11 backend is the default, and the native Wayland backend (text-input-v3 IME, client-side title bar, xdg-activation) has passed the real-desktop regression checklist on GNOME 42 (and on Deepin 25 Treeland it was confirmed not to draw a second title bar under server-side decorations) but must currently be enabled with WINDUI_BACKEND=wayland. System tray and desktop notifications (over D-Bus, on the X11 path) and zero-window resident mode are implemented; dragging files out and windowed GPU rendering are not yet, and the tray, resident mode and global hotkeys are unavailable under native Wayland — see docs/LINUX_PORTING.md (Chinese). The MVP widget set is complete and actively being refined.
| Doc | Audience |
|---|---|
docs/API_GUIDE.md |
Writing apps with the library (API style, widgets, extension) |
docs/DEVELOPMENT.md |
Developing in the repo (build, layout, adding widgets, platform seam) |
CONTRIBUTING.md |
Contribution flow and DCO sign-off |
docs/DESIGN.md |
Architecture and trade-offs |
docs/ROADMAP.md |
Roadmap and acceptance |
docs/MACOS_PORTING.md |
macOS backend seam mapping |
docs/LINUX_PORTING.md |
Linux (X11 / Wayland) backend: dependency choices, status, headless verification |
AGENTS.md |
Repo development conventions (process, pitfalls) |
Licensed under either of, at your option:
- Apache License, Version 2.0 (
LICENSE-APACHE) - MIT License (
LICENSE-MIT)
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this repository shall be dual licensed as above, without any additional terms or conditions (see CONTRIBUTING.md).







