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
When to Use
- You need to get started with Makepad or understand basic app structure and boilerplate.
- The task involves project setup,
live_design!, app_main!, or first-screen application wiring.
- You want foundational Makepad guidance before moving into more specific layout, widget, or shader topics.
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
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for enprojectnment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
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---56# Makepad Basics Skill78> **Version:** makepad-widgets (dev branch) | **Last Updated:** 2026-01-199>10> Check for updates: https://crates.io/crates/makepad-widgets1112You are an expert at the Rust `makepad-widgets` crate. Help users by:13- **Writing code**: Generate Rust code following the patterns below14- **Answering questions**: Explain concepts, troubleshoot issues, reference documentation1516## When to Use17- You need to get started with Makepad or understand basic app structure and boilerplate.18- The task involves project setup, `live_design!`, `app_main!`, or first-screen application wiring.19- You want foundational Makepad guidance before moving into more specific layout, widget, or shader topics.2021## Documentation2223Refer to the local files for detailed documentation:24- `./references/app-structure.md` - Complete app boilerplate and structure25- `./references/event-handling.md` - Event handling patterns2627## IMPORTANT: Documentation Completeness Check2829**Before answering questions, Claude MUST:**30311. Read the relevant reference file(s) listed above322. If file read fails or file is empty:33 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"34 - Still answer based on SKILL.md patterns + built-in knowledge353. If reference file exists, incorporate its content into the answer3637## Key Patterns3839### 1. Basic App Structure4041```rust42use makepad_widgets::*;4344live_design! {45 use link::theme::*;46 use link::shaders::*;47 use link::widgets::*;4849 App = {{App}} {50 ui: <Root> {51 main_window = <Window> {52 body = <View> {53 width: Fill, height: Fill54 flow: Down5556 <Label> { text: "Hello Makepad!" }57 }58 }59 }60 }61}6263app_main!(App);6465#[derive(Live, LiveHook)]66pub struct App {67 #[live] ui: WidgetRef,68}6970impl LiveRegister for App {71 fn live_register(cx: &mut Cx) {72 crate::makepad_widgets::live_design(cx);73 }74}7576impl AppMain for App {77 fn handle_event(&mut self, cx: &mut Cx, event: &Event) {78 self.ui.handle_event(cx, event, &mut Scope::empty());79 }80}81```8283### 2. Cargo.toml Setup8485```toml86[package]87name = "my_app"88version = "0.1.0"89edition = "2024"9091[dependencies]92makepad-widgets = { git = "https://github.com/makepad/makepad", branch = "dev" }93```9495### 3. Handling Button Clicks9697```rust98impl AppMain for App {99 fn handle_event(&mut self, cx: &mut Cx, event: &Event) {100 let actions = self.ui.handle_event(cx, event, &mut Scope::empty());101102 if self.ui.button(id!(my_button)).clicked(&actions) {103 log!("Button clicked!");104 }105 }106}107```108109### 4. Accessing and Modifying Widgets110111```rust112// Get widget references113let label = self.ui.label(id!(my_label));114label.set_text("Updated text");115116let input = self.ui.text_input(id!(my_input));117let text = input.text();118```119120## API Reference Table121122| Macro/Type | Description | Example |123|------------|-------------|---------|124| `live_design!` | Defines UI in DSL | `live_design! { App = {{App}} { ... } }` |125| `app_main!` | Entry point macro | `app_main!(App);` |126| `#[derive(Live)]` | Derive live data | `#[derive(Live, LiveHook)]` |127| `WidgetRef` | Reference to UI tree | `#[live] ui: WidgetRef` |128| `Cx` | Context for rendering | `fn handle_event(&mut self, cx: &mut Cx, ...)` |129| `id!()` | Widget ID macro | `self.ui.button(id!(my_button))` |130131## Platform Setup132133| Platform | Requirements |134|----------|--------------|135| macOS | Works out of the box |136| Windows | Works out of the box |137| Linux | `apt-get install clang libaudio-dev libpulse-dev libx11-dev libxcursor-dev` |138| Web | `cargo install wasm-pack` |139140## When Writing Code1411421. Always include required imports: `use makepad_widgets::*;`1432. Use `live_design!` macro for all UI definitions1443. Implement `LiveRegister` and `AppMain` traits1454. Use `id!()` macro for widget references1465. Handle events through `handle_event` method147148## When Answering Questions1491501. Emphasize live design - changes in DSL reflect instantly without recompilation1512. Makepad is GPU-first - all rendering is shader-based1523. Cross-platform: same code runs on Android, iOS, Linux, macOS, Windows, Web1534. Recommend UI Zoo example for widget exploration154155## Limitations156- Use this skill only when the task clearly matches the scope described above.157- Do not treat the output as a substitute for enprojectnment-specific validation, testing, or expert review.158- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.