kui-native (0.1.0-alpha.39)

Published 2026-10-06 13:56:16 +03:00 by qxuken

Installation

[registries.forgejo]
index = "sparse+" # Sparse index
# index = "" # Git

[net]
git-fetch-with-cli = true
cargo add [email protected] --registry forgejo

About this package

Batteries-included kui runner: winit + wgpu around a Core, App trait, widgets

kui-native

The windowed kui runner: a winit window and a wgpu renderer around kui-core, with the App trait an application implements.

kui is a Rust UI library whose view is a plain data tree rebuilt every frame. kui-native is the crate most apps depend on. It re-exports all of kui-core (the model, the layout, the widgets), draws through kui-wgpu, and adds the App trait, the app(...) launcher builder, multiple windows, the clipboard, file dialogs, audio, AccessKit and a headless testing driver that runs under plain cargo test.

Install

cargo add kui-native

Default features: audio, accesskit, derive (#[derive(Message)]) and dialogs; each can be turned off with --no-default-features.

On Linux the build needs pkg-config and ALSA's headers (libasound2-dev on Debian and Ubuntu). A window loads libxkbcommon, the X11 or Wayland client libraries and Vulkan or EGL at run time. macOS and Windows need only a Rust toolchain.

Example

use kui_native::widgets;
use kui_native::{App, Message, NodeSpec, TextStyle, Ui, UiEvent};

#[derive(Message, Clone, Debug, PartialEq)]
enum Msg {
    Inc,
    Dec,
}

#[derive(Default)]
struct Counter {
    count: i64,
}

impl App for Counter {
    // Called once per frame; everything on screen is declared here.
    fn view(&mut self, ui: &mut Ui<'_>) {
        let t = ui.theme();
        ui.with(NodeSpec::column().fill().center().gap(16.0).bg(t.bg), |ui| {
            ui.text(&self.count.to_string(), TextStyle::new(56.0).color(t.fg));
            ui.with(NodeSpec::row().gap(8.0), |ui| {
                widgets::button(ui, "-1", Msg::Dec);
                widgets::button(ui, "+1", Msg::Inc);
            });
        });
    }

    // Each event the frame produced, after the frame.
    fn on_event(&mut self, ev: UiEvent) {
        match ev.message::<Msg>() {
            Some(Msg::Inc) => self.count += 1,
            Some(Msg::Dec) => self.count -= 1,
            None => {}
        }
    }
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    kui_native::app("Counter").size(360.0, 240.0).run(Counter::default())
}

Where it fits

Crate What it is
kui-native This crate: the windowed runner most apps use
kui-core The model, layout, widgets and events, no window
kui-wgpu The GPU renderer
kui-derive #[derive(Message)]
kui-lua, kui-ffi Lua and C bindings; kui-node is the Node.js binding, on npm

Documentation

License

MIT

Dependencies

ID Version
accesskit ^0.25
accesskit_winit ^0.34
arboard ^3.6
kira ^0.12
kui-core ^0.1.0-alpha.39
kui-wgpu ^0.1.0-alpha.39
pollster ^1
rfd ^0.17
winit ^0.30
x11rb ^0.13
objc2 ^0.6
objc2-app-kit ^0.3
objc2-foundation ^0.3
objc2-quartz-core ^0.3
windows-sys ^0.52

Keywords

gui ui layout wgpu
Details
Cargo
2026-10-06 13:56:16 +03:00
0
MIT
199 KiB
Assets (1)
Versions (27) View all
0.1.0-alpha.45 2026-10-08
0.1.0-alpha.44 2026-10-08
0.1.0-alpha.43 2026-10-08
0.1.0-alpha.42 2026-10-07
0.1.0-alpha.41 2026-10-07