12k
All articles

Building Desktop Apps in Rust with GPUI Kit

Explore GPUI Kit for Rust desktop apps: see its components, a minimal app example, how it compares with Electron and Tauri, and its pre-1.0 trade-offs.

OpenReplay Team
OpenReplay Team
Building Desktop Apps in Rust with GPUI Kit

GPUI Kit is an open-source, Apache-2.0-licensed Rust framework from Longbridge for building desktop apps on GPUI, the GPU-rendered UI framework that Zed Industries wrote for the Zed editor.

If you have shipped an Electron app and winced at the installer size, or tried Tauri and still had to maintain a web frontend next to your Rust backend, GPUI Kit offers a third model. This first look covers what the kit contains, what a minimal app looks like, how it compares with webview-based frameworks, and whether it is mature enough to try.

Key Takeaways

  • A GPUI Kit app is written in Rust and drawn on the GPU by GPUI. The UI is not rendered in a webview and does not use operating-system controls.
  • Applications depend on a single gpui-kit crate, which pins a matching set of GPUI snapshot crates and re-exports GPUI, gpui-base, gpui-component and the default icon assets.
  • The kit ships more than 75 documented components and primitives, and targets macOS, Windows, Linux and the web through WebAssembly.
  • GPUI Kit is pre-1.0 and releases often. Even its minimal window setup changed between version 0.6 and the 0.9 line.

What Is GPUI Kit?

GPUI Kit is a component library and application layer built on top of GPUI. GPUI provides rendering, layout and the element model. The kit adds styled components, window hosting and a single dependency that keeps every layer on compatible versions.

GPUI started inside Zed. In Zed is 1.0, the Zed team writes that they “built it like a video game, organizing the entire application around feeding data to shaders running on the GPU. That meant writing our own UI framework, GPUI, from scratch in Rust.” Our overview of the Zed editor covers the editor that this approach produced.

GPUI on its own is a low-level foundation. Longbridge built the kit on it, and the GPUI Kit repository says the kit has powered Longbridge’s commercial desktop app, Longbridge Pro, from day one. The project was previously called GPUI Component, and the old repository URL now redirects to the new name. The releases page lists 0.9.1 as the latest version in the 0.9 line.

What’s in the GPUI Kit Packages?

GPUI Kit is split into four packages so you can choose how much of the stack to adopt:

  • gpui-kit: the umbrella crate and the only one an application lists.
  • gpui-base: unstyled behaviour, state and infrastructure.
  • gpui-component: the styled, themeable component set built on gpui-base.
  • gpui-shell: a Rust-hosted JavaScript runtime for loading extensions.

According to the gpui-kit crate docs, “GPUI itself is published as a family of gpui-pre-* crates that move together. This crate depends on the matching set for you, so an application lists gpui-kit alone.” gpui-shell is not part of the umbrella. Apps that host JavaScript extensions add it as a separate dependency. If you know the web ecosystem, the split works like shadcn/ui sitting on an unstyled primitive library: use gpui-component for a ready-made look, or build on gpui-base if you want to own the design system.

The gpui-component README states that “GPUI Kit ships 75+ documented components and primitives, WebAssembly support, AccessKit accessibility, UI integration testing, and an optional JavaScript extension runtime.” The range includes form controls, data tables and lists with virtual scrolling, overlays such as dialogs, sheets and notifications, a dock layout, a code editor and theming. The styling takes cues from macOS and Windows controls and from shadcn/ui. The kit also has components that display Markdown and HTML content, but you never write the UI itself in HTML.

A Minimal GPUI Kit App

A GPUI Kit app is a Rust struct that implements Render, plus a main function that initialises the kit and opens a window. Start a project with cargo new gpui-hello and add the dependency:

[dependencies]
gpui-kit = "0.9"

The following example comes from the GPUI Kit Getting Started guide for the 0.9 release line. It opens a window with a label and one button:

use gpui_kit::component::button::{Button, ButtonVariants};
use gpui_kit::*;

struct HelloWorld;

impl Render for HelloWorld {
    fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
        div()
            .flex()
            .flex_col()
            .size_full()
            .items_center()
            .justify_center()
            .gap_2()
            .child("Hello, World!")
            .child(
                Button::new("hello")
                    .primary()
                    .label("Click me")
                    .on_click(|_, _, _| println!("Clicked!")),
            )
    }
}

fn main() {
    application()
        .with_assets(assets::Assets)
        .run(|cx| {
            init(cx);
            open_window(WindowOptions::default(), cx, |_, cx| {
                cx.new(|_| HelloWorld)
            })
            .expect("Failed to open window");
        });
}

The render method returns an element tree, here a centred column div holding a text label and a primary Button that prints to the terminal when clicked. In main, .with_assets(...) registers the default icon source, and the Getting Started guide explains that gpui_kit::init(cx) initializes the enabled Kit layers, including component themes, so it has to run before any window opens. Then gpui_kit::open_window(...) creates an Entity<HelloWorld> from the closure and wraps it in a Root, which hosts the window’s dialogs, sheets and notifications. Run it with cargo run. The guide points to a separate Installation page that lists the system libraries each OS needs.

How Does GPUI Kit Compare With Electron and Tauri?

GPUI Kit differs from Electron and Tauri in what renders the UI. Electron ships its own copy of Chromium and renders a web UI. Tauri renders a web UI in the operating system’s webview behind a Rust backend. GPUI Kit drops the web layer entirely and draws Rust components with GPUI.

Electron embeds Chromium and Node.js in its binary. Tauri relies on the system webview through WRY: WKWebView on macOS, WebView2 on Windows and WebKitGTK on Linux. The Electron vs Tauri comparison goes into how those two differ.

ElectronTauriGPUI Kit
UI written inHTML, CSS, JavaScriptHTML, CSS, JavaScript (any web framework)Rust
App logicJavaScript (Node.js)Rust backend plus web frontendRust
What renders the UIChromium bundled with the appThe OS webviewGPUI, on the GPU
OS controlsNo (web elements)No (web elements)No (GPUI-drawn components)
Reuses existing web UI codeYesYesNo

The trade-off between GPUI Kit and webview frameworks works in both directions. Webview frameworks let a team reuse its HTML, CSS and component libraries. GPUI Kit gives that up in exchange for one language and one type system from the event handler down to the pixels, with no IPC bridge between a frontend and a backend.

Who Should Use GPUI Kit?

GPUI Kit suits teams that already write Rust and want a desktop UI without maintaining a web frontend alongside it.

Try it if:

  • your team is comfortable with Rust and its ownership model
  • you are building data-heavy tools such as editors, dashboards or trading terminals
  • you want the whole app in one language

Look elsewhere if:

  • you have an existing React or Vue UI you want to reuse
  • your team mostly writes JavaScript
  • you need a long-term stable API right now

If you are weighing other Rust options, the kit’s documentation site includes its own comparison with Iced, egui, Qt 6 and Slint.

Is GPUI Kit Mature Enough to Use?

GPUI Kit works for real products, but it is young, and you should expect upgrades to cost some effort.

  • Pre-1.0 and fast-moving. Minor releases change setup code. In 0.6, the hello world opened windows directly with cx.open_window and wrapped the view in Root by hand. Version 0.7.0 added a single window entry point: gpui_kit::open_window(options, cx, build) returns (AnyWindowHandle, Entity<V>) and always wraps application content in gpui_base::Root.
  • Tied to GPUI snapshots. The kit depends on the gpui-pre crates, which are published snapshots of GPUI rather than a stable release, so GPUI changes reach you through kit upgrades.
  • No HTML or CSS. Layout and styling are Rust method chains, so web skills only partly carry over.
  • A small ecosystem. There are far fewer third-party components, tutorials and answered questions than Electron or Tauri have.

Conclusion

GPUI Kit offers a coherent way to build a desktop app entirely in Rust: one dependency, a substantial set of components, and a UI drawn on the GPU rather than in a browser engine. Its pace of change makes it a better fit for a prototype or an internal tool than for a long-lived product you can’t revisit. Clone the repository, run the examples, and decide from there.

FAQs

Can a GPUI Kit app run in a web browser?

Yes. GPUI Kit supports the wasm32-unknown-unknown target, so the same Rust views and components can render in a browser. Rust compiles the app to a WebAssembly module, wasm-bindgen generates its JavaScript bindings, and a web page loads and starts it. A desktop main function is not a web entry point, so the browser build needs its own launch code. The WebAssembly guide on gpui-kit.com covers toolchain setup.

Can I use gpui-base without the styled gpui-component layer?

Yes. Declare gpui-kit with default-features = false. The crate always brings in GPUI and gpui-base, while gpui-component and the default icon set are default features you can drop. Initialise the unstyled layer with gpui_kit::base::init(cx) instead of gpui_kit::init(cx), which also covers base initialisation. This setup suits apps that own their component source and visual design but reuse shared interaction behaviour.

Do GPUI Kit apps work with screen readers?

GPUI Kit builds AccessKit support into its interaction layer, exposing roles, names, states, relationships and actions for its controls. AccessKit is a cross-platform Rust library that passes this information to each operating system's accessibility API, which screen readers rely on. Because GPUI draws its own controls instead of using OS widgets, components built from scratch must declare their own accessibility semantics, while gpui-base primitives already provide them.

Can I use GPUI Kit in a commercial or closed-source app?

Yes. GPUI Kit's source code and documentation code examples are licensed under Apache-2.0, and GPUI, from Zed Industries, uses Apache-2.0 too. Apache-2.0 is a permissive licence that allows commercial use and distribution inside proprietary software. When you distribute the app, include a copy of the licence and keep any copyright and NOTICE attributions that the projects ship with.

DevTools for the frontend

Gain Debugging Superpowers

Unleash the power of session replay to reproduce bugs, track slowdowns and uncover frustrations in your app. Get complete visibility into your frontend with OpenReplay — the most advanced open-source session replay tool for developers.

Star on GitHub12k

We use cookies to improve your experience. By using our site, you accept cookies.