xengui 0.2.7

a retained-mode gui library in rust
Documentation

xengui

Latest version Downloads Rust Documentation Apache-2.0

The core, retained-mode GUI library at the heart of the XenGui ecosystem.

xengui provides the widget tree, hooks-based state model, Flexbox/Grid layout engine (via taffy), style system, text handling, and interruptible reconciler. It has no GPU or windowing dependencies of its own - rendering is delegated to a [RenderBackend] implementation (such as xengui-wgpu), and window/event integration is handled by a platform crate (such as xenframe), so xengui stays fully portable across native and WebAssembly targets.

Features

  • Retained-mode state - React-style hooks (use_state, component) drive re-renders without a virtual-DOM diffing framework bolted on top.
  • Interruptible reconciler - tree diffing runs as explicit, resumable work units instead of a single blocking pass.
  • Flexbox & Grid layout - layout system via taffy, including flex direction, wrapping, alignment, gaps, and grid tracks.
  • Declarative styling - Style/StyleBuilder API covering colors (including OKLCH), borders, typography, spacing, transitions, and more.
  • Built-in widgets - View, Label, Button, Link, TextBox, Image, Svg, and ContextMenu, each with hover/pressed/focus/disabled style variants.
  • Interaction system - unified handling of hover, click, focus, and keyboard events across widgets.
  • Backend-agnostic rendering - implement [RenderBackend] to target any graphics API.
  • Cross-platform - native targets (Windows, macOS, Linux) and WebAssembly from a single codebase.

For a full application quick start (rendering, event loop, and GPU backend together), see the workspace README.

Example

View::new()
    .display(Display::Flex)
    .flex_direction(FlexDirection::Column)
    .align_items(AlignItems::Center)
    .justify_content(JustifyContent::Center)
    .width(Length::Percent(100.0))
    .height(Length::Percent(100.0))
    .background(Color::WHITE)
    .child(
        Label::new()
            .label(format!("Count: {counter}"))
            .font_size(20)
            .color(Color::NEUTRAL_700)
        )
    .child(
        Button::new()
            .label("Increment")
            .padding(Edges::symmetric(12, 8))
            .background(Color::NEUTRAL_200)
            .on_click(move |_ctx| set_counter.update(|v| *v += 1))
    );

Installation

Cargo.toml

[dependencies]

xengui = "0.2.7"

Most applications should also pull in a platform runtime crate (e.g. xenframe) and a render backend (e.g. xengui-wgpu) - see the workspace README for a full quick-start example.

Documentation

Docs are available at: https://xengui.vercel.app/docs/xengui

License

Apache License 2.0 © 2026 randseas. See LICENSE for details.