Quick Start
Create a Rust binary, add HeroGPUI, and put a button on a themed window.
You need a Rust toolchain that supports Rust 1.98. GPUI must be the pinned Zed revision below — a crates.io GPUI release will not compile against this library.
1. Create the app
1cargo new hello-herogpui --bin
2cd hello-herogpui2. Add the crates
Paste this into Cargo.toml. If you cloned HeroGPUI next to the app, you can swap the git line for herogpui = { path = "../HeroGPUI/crates/herogpui" }.
1[dependencies]
2gpui = { git = "https://github.com/zed-industries/zed", rev = "ee3b5558c581429633937e458fad8d109f29e9ee" }
3gpui_platform = { git = "https://github.com/zed-industries/zed", rev = "ee3b5558c581429633937e458fad8d109f29e9ee", features = ["font-kit", "wayland", "x11", "runtime_shaders"] }
4herogpui = { git = "https://github.com/Porabuild/HeroGPUI" }3. Open a window
Replace src/main.rs. ThemeProvider::init must run before the first window, and app_focus_root turns on Tab and focus rings.
1use gpui::*;
2use herogpui::prelude::*;
3
4struct MyRoot;
5
6impl Render for MyRoot {
7 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
8 app_focus_root(
9 div()
10 .size_full()
11 .flex()
12 .items_center()
13 .justify_center()
14 .bg(cx.colors().background)
15 .text_color(cx.colors().foreground)
16 .child(Button::new("hello").label("Click me")),
17 window,
18 cx,
19 )
20 }
21}
22
23fn main() {
24 gpui_platform::application()
25 .with_assets(HeroGpuiAssets)
26 .run(|cx: &mut App| {
27 ThemeProvider::init(cx);
28 let bounds = Bounds::centered(None, size(px(480.), px(320.)), cx);
29 cx.open_window(
30 WindowOptions {
31 window_bounds: Some(WindowBounds::Windowed(bounds)),
32 ..Default::default()
33 },
34 |_, cx| cx.new(|_| MyRoot),
35 )
36 .unwrap();
37 });
38}4. Run it
1cargo runYou should get a small window with a primary button. From here, open the Button page or the desktop gallery.
What the other guide is for
Installation covers assets, custom themes, platform packages, and the gallery CLI. Use it after this window works.