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: |4 CRITICAL: Use for Makepad getting started and app structure. Triggers on:5 makepad, makepad getting started, makepad tutorial, live_design!, app_main!,6 makepad project setup, makepad hello world, "how to create makepad app",7 makepad 入门, 创建 makepad 应用, makepad 教程, makepad 项目结构8risk: unknown9source: "https://github.com/makepad/makepad"10metadata:11 source: https://skillmd.com/skills/nimoqup046-collab/makepad-basics12---1314# Makepad Basics Skill1516> **Version:** makepad-widgets (dev branch) | **Last Updated:** 2026-01-1917>18> Check for updates: https://crates.io/crates/makepad-widgets1920You are an expert at the Rust `makepad-widgets` crate. Help users by:21- **Writing code**: Generate Rust code following the patterns below22- **Answering questions**: Explain concepts, troubleshoot issues, reference documentation2324## Documentation2526Refer to the local files for detailed documentation:27- `./references/app-structure.md` - Complete app boilerplate and structure28- `./references/event-handling.md` - Event handling patterns2930## IMPORTANT: Documentation Completeness Check3132**Before answering questions, Claude MUST:**33341. Read the relevant reference file(s) listed above352. If file read fails or file is empty:36 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"37 - Still answer based on SKILL.md patterns + built-in knowledge383. If reference file exists, incorporate its content into the answer3940## Key Patterns4142### 1. Basic App Structure4344```rust45use makepad_widgets::*;4647live_design! {48 use link::theme::*;49 use link::shaders::*;50 use link::widgets::*;5152 App = {{App}} {53 ui: <Root> {54 main_window = <Window> {55 body = <View> {56 width: Fill, height: Fill57 flow: Down5859 <Label> { text: "Hello Makepad!" }60 }61 }62 }63 }64}6566app_main!(App);6768#[derive(Live, LiveHook)]69pub struct App {70 #[live] ui: WidgetRef,71}7273impl LiveRegister for App {74 fn live_register(cx: &mut Cx) {75 crate::makepad_widgets::live_design(cx);76 }77}7879impl AppMain for App {80 fn handle_event(&mut self, cx: &mut Cx, event: &Event) {81 self.ui.handle_event(cx, event, &mut Scope::empty());82 }83}84```8586### 2. Cargo.toml Setup8788```toml89[package]90name = "my_app"91version = "0.1.0"92edition = "2024"9394[dependencies]95makepad-widgets = { git = "https://github.com/makepad/makepad", branch = "dev" }96```9798### 3. Handling Button Clicks99100```rust101impl AppMain for App {102 fn handle_event(&mut self, cx: &mut Cx, event: &Event) {103 let actions = self.ui.handle_event(cx, event, &mut Scope::empty());104105 if self.ui.button(id!(my_button)).clicked(&actions) {106 log!("Button clicked!");107 }108 }109}110```111112### 4. Accessing and Modifying Widgets113114```rust115// Get widget references116let label = self.ui.label(id!(my_label));117label.set_text("Updated text");118119let input = self.ui.text_input(id!(my_input));120let text = input.text();121```122123## API Reference Table124125| Macro/Type | Description | Example |126|------------|-------------|---------|127| `live_design!` | Defines UI in DSL | `live_design! { App = {{App}} { ... } }` |128| `app_main!` | Entry point macro | `app_main!(App);` |129| `#[derive(Live)]` | Derive live data | `#[derive(Live, LiveHook)]` |130| `WidgetRef` | Reference to UI tree | `#[live] ui: WidgetRef` |131| `Cx` | Context for rendering | `fn handle_event(&mut self, cx: &mut Cx, ...)` |132| `id!()` | Widget ID macro | `self.ui.button(id!(my_button))` |133134## Platform Setup135136| Platform | Requirements |137|----------|--------------|138| macOS | Works out of the box |139| Windows | Works out of the box |140| Linux | `apt-get install clang libaudio-dev libpulse-dev libx11-dev libxcursor-dev` |141| Web | `cargo install wasm-pack` |142143## When Writing Code1441451. Always include required imports: `use makepad_widgets::*;`1462. Use `live_design!` macro for all UI definitions1473. Implement `LiveRegister` and `AppMain` traits1484. Use `id!()` macro for widget references1495. Handle events through `handle_event` method150151## When Answering Questions1521531. Emphasize live design - changes in DSL reflect instantly without recompilation1542. Makepad is GPU-first - all rendering is shader-based1553. Cross-platform: same code runs on Android, iOS, Linux, macOS, Windows, Web1564. Recommend UI Zoo example for widget exploration