Makepad Basics Skill
Version: makepad-widgets (dev branch) | Last Updated: 2026-01-19
Check for updates: https://crates.io/crates/makepad-widgets
You are an expert at the Rust makepad-widgets crate. Help users by:
- Writing code: Generate Rust code following the patterns below
- Answering questions: Explain concepts, troubleshoot issues, reference documentation
Documentation
Refer to the local files for detailed documentation:
./references/app-structure.md - Complete app boilerplate and structure
./references/event-handling.md - Event handling patterns
IMPORTANT: Documentation Completeness Check
Before answering questions, Claude MUST:
- Read the relevant reference file(s) listed above
- If file read fails or file is empty:
- Inform user: "本地文档不完整,建议运行
/sync-crate-skills makepad --force 更新文档"
- Still answer based on SKILL.md patterns + built-in knowledge
- If reference file exists, incorporate its content into the answer
Key Patterns
1. Basic App Structure
use makepad_widgets::*;
live_design! {
use link::theme::*;
use link::shaders::*;
use link::widgets::*;
App = {{App}} {
ui: <Root> {
main_window = <Window> {
body = <View> {
width: Fill, height: Fill
flow: Down
<Label> { text: "Hello Makepad!" }
}
}
}
}
}
app_main!(App);
#[derive(Live, LiveHook)]
pub struct App {
#[live] ui: WidgetRef,
}
impl LiveRegister for App {
fn live_register(cx: &mut Cx) {
crate::makepad_widgets::live_design(cx);
}
}
impl AppMain for App {
fn handle_event(&mut self, cx: &mut Cx, event: &Event) {
self.ui.handle_event(cx, event, &mut Scope::empty());
}
}
2. Cargo.toml Setup
[package]
name = "my_app"
version = "0.1.0"
edition = "2024"
[dependencies]
makepad-widgets = { git = "https://github.com/makepad/makepad", branch = "dev" }
3. Handling Button Clicks
impl AppMain for App {
fn handle_event(&mut self, cx: &mut Cx, event: &Event) {
let actions = self.ui.handle_event(cx, event, &mut Scope::empty());
if self.ui.button(id!(my_button)).clicked(&actions) {
log!("Button clicked!");
}
}
}
4. Accessing and Modifying Widgets
// Get widget references
let label = self.ui.label(id!(my_label));
label.set_text("Updated text");
let input = self.ui.text_input(id!(my_input));
let text = input.text();
API Reference Table
| Macro/Type |
Description |
Example |
live_design! |
Defines UI in DSL |
live_design! { App = {{App}} { ... } } |
app_main! |
Entry point macro |
app_main!(App); |
#[derive(Live)] |
Derive live data |
#[derive(Live, LiveHook)] |
WidgetRef |
Reference to UI tree |
#[live] ui: WidgetRef |
Cx |
Context for rendering |
fn handle_event(&mut self, cx: &mut Cx, ...) |
id!() |
Widget ID macro |
self.ui.button(id!(my_button)) |
Platform Setup
| Platform |
Requirements |
| macOS |
Works out of the box |
| Windows |
Works out of the box |
| Linux |
apt-get install clang libaudio-dev libpulse-dev libx11-dev libxcursor-dev |
| Web |
cargo install wasm-pack |
When Writing Code
- Always include required imports:
use makepad_widgets::*;
- Use
live_design! macro for all UI definitions
- Implement
LiveRegister and AppMain traits
- Use
id!() macro for widget references
- Handle events through
handle_event method
When Answering Questions
- Emphasize live design - changes in DSL reflect instantly without recompilation
- Makepad is GPU-first - all rendering is shader-based
- Cross-platform: same code runs on Android, iOS, Linux, macOS, Windows, Web
- Recommend UI Zoo example for widget exploration
1---2name: makepad-basics3description: CRITICAL: Use for Makepad getting started and app structure. Triggers on: makepad, makepad getting started, makepad tutorial, live_design!, app_main!, makepad project setup, makepad hello world, "how to create makepad app", makepad 入门, 创建 makepad 应用, makepad 教程, makepad 项目结构4---5
6# Makepad Basics Skill
7
8> **Version:** makepad-widgets (dev branch) | **Last Updated:** 2026-01-19
9>
10> Check for updates: https://crates.io/crates/makepad-widgets
11
12You are an expert at the Rust `makepad-widgets` crate. Help users by:
13- **Writing code**: Generate Rust code following the patterns below
14- **Answering questions**: Explain concepts, troubleshoot issues, reference documentation
15
16## Documentation
17
18Refer to the local files for detailed documentation:
19- `./references/app-structure.md` - Complete app boilerplate and structure
20- `./references/event-handling.md` - Event handling patterns
21
22## IMPORTANT: Documentation Completeness Check
23
24**Before answering questions, Claude MUST:**
25
261. Read the relevant reference file(s) listed above
272. If file read fails or file is empty:
28 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"
29 - Still answer based on SKILL.md patterns + built-in knowledge
303. If reference file exists, incorporate its content into the answer
31
32## Key Patterns
33
34### 1. Basic App Structure
35
36```rust
37use makepad_widgets::*;
38
39live_design! {
40 use link::theme::*;
41 use link::shaders::*;
42 use link::widgets::*;
43
44 App = {{App}} {
45 ui: <Root> {
46 main_window = <Window> {
47 body = <View> {
48 width: Fill, height: Fill
49 flow: Down
50
51 <Label> { text: "Hello Makepad!" }
52 }
53 }
54 }
55 }
56}
57
58app_main!(App);
59
60#[derive(Live, LiveHook)]
61pub struct App {
62 #[live] ui: WidgetRef,
63}
64
65impl LiveRegister for App {
66 fn live_register(cx: &mut Cx) {
67 crate::makepad_widgets::live_design(cx);
68 }
69}
70
71impl AppMain for App {
72 fn handle_event(&mut self, cx: &mut Cx, event: &Event) {
73 self.ui.handle_event(cx, event, &mut Scope::empty());
74 }
75}
76```
77
78### 2. Cargo.toml Setup
79
80```toml
81[package]
82name = "my_app"
83version = "0.1.0"
84edition = "2024"
85
86[dependencies]
87makepad-widgets = { git = "https://github.com/makepad/makepad", branch = "dev" }
88```
89
90### 3. Handling Button Clicks
91
92```rust
93impl AppMain for App {
94 fn handle_event(&mut self, cx: &mut Cx, event: &Event) {
95 let actions = self.ui.handle_event(cx, event, &mut Scope::empty());
96
97 if self.ui.button(id!(my_button)).clicked(&actions) {
98 log!("Button clicked!");
99 }
100 }
101}
102```
103
104### 4. Accessing and Modifying Widgets
105
106```rust
107// Get widget references
108let label = self.ui.label(id!(my_label));
109label.set_text("Updated text");
110
111let input = self.ui.text_input(id!(my_input));
112let text = input.text();
113```
114
115## API Reference Table
116
117| Macro/Type | Description | Example |
118|------------|-------------|---------|
119| `live_design!` | Defines UI in DSL | `live_design! { App = {{App}} { ... } }` |
120| `app_main!` | Entry point macro | `app_main!(App);` |
121| `#[derive(Live)]` | Derive live data | `#[derive(Live, LiveHook)]` |
122| `WidgetRef` | Reference to UI tree | `#[live] ui: WidgetRef` |
123| `Cx` | Context for rendering | `fn handle_event(&mut self, cx: &mut Cx, ...)` |
124| `id!()` | Widget ID macro | `self.ui.button(id!(my_button))` |
125
126## Platform Setup
127
128| Platform | Requirements |
129|----------|--------------|
130| macOS | Works out of the box |
131| Windows | Works out of the box |
132| Linux | `apt-get install clang libaudio-dev libpulse-dev libx11-dev libxcursor-dev` |
133| Web | `cargo install wasm-pack` |
134
135## When Writing Code
136
1371. Always include required imports: `use makepad_widgets::*;`
1382. Use `live_design!` macro for all UI definitions
1393. Implement `LiveRegister` and `AppMain` traits
1404. Use `id!()` macro for widget references
1415. Handle events through `handle_event` method
142
143## When Answering Questions
144
1451. Emphasize live design - changes in DSL reflect instantly without recompilation
1462. Makepad is GPU-first - all rendering is shader-based
1473. Cross-platform: same code runs on Android, iOS, Linux, macOS, Windows, Web
1484. Recommend UI Zoo example for widget exploration