Have you ever wanted to build a professional desktop application like VS Code or Zed Editor, but didn’t know where to start? Most modern tools are built with C++ or Electron, each with their own limitations. GPUI Kit is a new Rust solution that helps you build high-performance desktop applications with a modern development experience.
Why GPUI Kit?#
Building desktop applications isn’t simple. You need:
- High performance: Applications must be smooth, no lag when processing large amounts of data
- Beautiful UI: Buttons, menus, tables, panels need to look professional
- Extensibility: Plugins, themes, customization are common requirements
- Cross-platform: Run on macOS, Windows, Linux with the same codebase
Electron (used by VS Code, Slack) is easy to develop but heavy and RAM-intensive. Native frameworks like Qt are powerful but complex with a steep learning curve. GPUI Kit sits in the middle: native performance with a modern development experience.
What is GPUI Kit?#
Think of GPUI Kit as a LEGO kit for building desktop applications. It provides:
- 75+ pre-built UI components: Buttons, menus, tables, charts, code editors, dockable panels
- GPU-accelerated rendering: Uses GPU for smooth rendering on 120Hz displays
- WebAssembly support: Run on the web from the same codebase
- Accessibility built-in: Screen reader support, keyboard navigation
- UI testing: Automated UI testing capabilities
GPUI Kit is built on GPUI - the GPU-accelerated framework from Zed Industries (creators of Zed Editor).
Three-Layer Architecture#
GPUI Kit has three layers, each serving different purposes:
gpui-component: Use when you want speed#
gpui-component provides 75+ pre-styled UI components. This is the best choice when you want to:
- Build applications quickly with professional UI
- Not worry about detailed design decisions
- Use included themes (light, dark, and many custom themes)
Example creating a button:
use gpui_kit::component::button::*;
impl Render for HelloWorld {
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
div()
.v_flex()
.gap_2()
.items_center()
.child("Hello, World!")
.child(
Button::new("ok")
.primary()
.label("Let's Go!")
.on_click(cx.listener(Self::go)),
)
}
}rustgpui-base: Use when you want full control#
gpui-base provides zero-style primitives with behavior only. You have complete control over how each component looks. This is the choice when:
- You want to build your own design system
- Need to fine-tune every pixel of the UI
- Require consistent branding
Example creating a button with custom style:
use gpui_kit::base::*;
Button::new("save")
.on_click(cx.listener(Self::save))
.rounded_md()
.child("Save changes")rustgpui-shell: Use when you need JavaScript extensions#
gpui-shell allows your Rust application to be extended with JavaScript after shipping. This is useful when:
- Building a plugin system for users
- Hot-reload during development
- Don’t need to rebuild the entire application
Example JavaScript extension:
import { Button, text } from "gpui";
Button.new("save")
.on_click((_e, cx) => this.save(cx))
.child(text("Save changes"))javascriptInstallation and Getting Started#
Installing GPUI Kit is simple - just one dependency:
[dependencies]
gpui-kit = "0.7"tomlFull Hello World example:
use gpui_kit::*;
actions!(hello, [Quit]);
struct Hello;
impl Render for Hello {
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
div().child("Hello, World!")
}
}
fn main() {
gpui_kit::application().run(|cx| {
gpui_kit::init(cx);
gpui_kit::open_window(WindowOptions::default(), cx, |_, cx| cx.new(|_| Hello))
.expect("failed to open window");
});
}rustPowerful Features#
Virtualized Lists and Tables#
When displaying thousands of rows of data, rendering everything makes the application lag. GPUI Kit only renders what the user sees (virtualization):
use gpui_kit::component::table::*;
DataTable::new("data-table")
.items(items)
.columns(vec![
Column::new("name", "Name").width(px(200.)),
Column::new("email", "Email").width(px(300.)),
])rustIntegrated Code Editor#
GPUI Kit includes a real code editor with:
- Rope-backed text: stable at 200K lines
- Tree-sitter highlighting: accurate syntax highlighting
- LSP integration: autocomplete, hover, diagnostics
use gpui_kit::component::editor::*;
Editor::new(editor_id)
.focus(cx)
.multi_line(true)
.show_line_numbers(true)rustDockable Panels#
IDE-style layout with dockable, draggable, zoomable panels:
use gpui_kit::component::dock::*;
DockArea::new(dock_id)
.layout(DockLayout {
panels: vec![],
dock_state: DockState::new(),
})rustUI Integration Testing#
Automated UI testing:
use gpui_kit::test::*;
#[gpui::test]
async fn test_button_click(cx: &mut TestAppContext) {
let window = cx.build_window(|cx| cx.new(|_| MyView));
let button = window.view.read(cx).button;
cx.simulate_click(button, cx);
assert!(window.view.read(cx).was_clicked);
}rustComparison with Other Frameworks#
| Feature | GPUI Kit | Electron | Qt | Iced |
|---|---|---|---|---|
| Language | Rust | JavaScript/Node | C++/QML | Rust |
| Performance | High (GPU) | Low | High | High |
| Binary size | ~12MB | ~150MB+ | ~20MB | ~11MB |
| Cross-platform | ✓ | ✓ | ✓ | ✓ |
| Web support | ✓ (WASM) | ✓ | ✓ | ✓ |
| Component library | 75+ | Build yourself | Basic | Basic |
| Learning curve | Medium | Low | High | Low |
When to Use GPUI Kit?#
Use when:
- Building complex desktop applications (IDEs, data tools)
- Need high performance with large amounts of data
- Want cross-platform with one codebase
- Need complex code editors or data tables
- Team has Rust experience or wants to learn Rust
Don’t use when:
- Simple applications that don’t need high performance
- Team only knows JavaScript and doesn’t want to learn Rust
- Require absolute native look and feel on each platform
- Very limited development time
Conclusion#
GPUI Kit is a powerful framework for Rust developers who want to build high-performance desktop applications. With three flexible layers (component, base, shell), you can choose the level of control that fits your project’s needs. If you’re looking for an Electron alternative without learning C++, GPUI Kit is worth considering.