Getting Started
#Requirements
- macOS 14 or later
- Rust 1.90 or later
- Bun 1.4 or later
- Xcode Command Line Tools (
xcode-select --install)
macOS is the supported target today.
#Create a project
bunx @quickgui/cli init my-app --language rust
cd my-app
quickgui devinit writes the project and installs dependencies. Omit --language to choose Go, TypeScript, or Rust interactively.
#Your first window
The generated src/main.rs opens a window. Keep state on your View and call cx.invalidate() after you change it.
use quickgui::{
App, AppInfo, Application, Color, EventContext, IntoElement, View, ViewContext, WindowOptions,
div, text,
};
fn main() -> Result<(), quickgui::AppError> {
Application::new()
.app_info(AppInfo::new("My App", "0.1.0", "com.example.my-app").expect("valid identity"))
.on_reopen(|has_visible_windows, cx| {
if !has_visible_windows {
open_window(cx);
}
})
.run(open_window)
}
fn open_window(cx: &mut App) {
cx.open_window(WindowOptions::new("My App").size(760.0, 520.0), Counter { count: 0 });
}
struct Counter {
count: usize,
}
impl View for Counter {
fn render(&mut self, cx: &mut ViewContext<'_, Self>) -> impl IntoElement {
let increment = cx.listener("increment", |this, cx: &mut EventContext| {
this.count += 1;
cx.invalidate();
});
div()
.size_full()
.flex_col()
.items_center()
.justify_center()
.gap_3()
.child(text(format!("Count: {}", self.count)))
.child(
div()
.on_click(increment)
.px_4()
.py_2()
.rounded_lg()
.bg(Color::rgb8(37, 99, 235))
.child("Increment"),
)
}
}on_reopen opens a window again when the user clicks the Dock icon and none are visible.
#Run and build
quickgui check
quickgui test
quickgui fmt
quickgui dev
quickgui builddev rebuilds as you edit. build writes a packaged app under dist/.
#Next steps
- Write components.
- Keep them in sync with view state.
- Add styles and layout.
