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
When to Use
This skill is applicable to execute the workflow or actions described in the overview.
1---2name: makepad-basics3description: 'CRITICAL: Use for Makepad getting started and app structure. Triggers4 on:56 makepad, makepad getting started, makepad tutorial, live_design!, app_main!,78 makepad project setup, makepad hello world, "how to create makepad app", makepad9 入门, 创建 makepad 应用, makepad 教程, makepad 项目结构'10risk: safe11source: https://github.com/makepad/makepad12license: MIT13metadata:14 source: https://skillmd.com/skills/jantoniofc/makepad-basics15---1617# Makepad Basics Skill1819> **Version:** makepad-widgets (dev branch) | **Last Updated:** 2026-01-1920>21> Check for updates: https://crates.io/crates/makepad-widgets2223You are an expert at the Rust `makepad-widgets` crate. Help users by:24- **Writing code**: Generate Rust code following the patterns below25- **Answering questions**: Explain concepts, troubleshoot issues, reference documentation2627## When to Use28- You need to get started with Makepad or understand basic app structure and boilerplate.29- The task involves project setup, `live_design!`, `app_main!`, or first-screen application wiring.30- You want foundational Makepad guidance before moving into more specific layout, widget, or shader topics.3132## Documentation3334Refer to the local files for detailed documentation:35- `./references/app-structure.md` - Complete app boilerplate and structure36- `./references/event-handling.md` - Event handling patterns3738## IMPORTANT: Documentation Completeness Check3940**Before answering questions, Claude MUST:**41421. Read the relevant reference file(s) listed above432. If file read fails or file is empty:44 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"45 - Still answer based on SKILL.md patterns + built-in knowledge463. If reference file exists, incorporate its content into the answer4748## Key Patterns4950### 1. Basic App Structure5152```rust53use makepad_widgets::*;5455live_design! {56 use link::theme::*;57 use link::shaders::*;58 use link::widgets::*;5960 App = {{App}} {61 ui: <Root> {62 main_window = <Window> {63 body = <View> {64 width: Fill, height: Fill65 flow: Down6667 <Label> { text: "Hello Makepad!" }68 }69 }70 }71 }72}7374app_main!(App);7576#[derive(Live, LiveHook)]77pub struct App {78 #[live] ui: WidgetRef,79}8081impl LiveRegister for App {82 fn live_register(cx: &mut Cx) {83 crate::makepad_widgets::live_design(cx);84 }85}8687impl AppMain for App {88 fn handle_event(&mut self, cx: &mut Cx, event: &Event) {89 self.ui.handle_event(cx, event, &mut Scope::empty());90 }91}92```9394### 2. Cargo.toml Setup9596```toml97[package]98name = "my_app"99version = "0.1.0"100edition = "2024"101102[dependencies]103makepad-widgets = { git = "https://github.com/makepad/makepad", branch = "dev" }104```105106### 3. Handling Button Clicks107108```rust109impl AppMain for App {110 fn handle_event(&mut self, cx: &mut Cx, event: &Event) {111 let actions = self.ui.handle_event(cx, event, &mut Scope::empty());112113 if self.ui.button(id!(my_button)).clicked(&actions) {114 log!("Button clicked!");115 }116 }117}118```119120### 4. Accessing and Modifying Widgets121122```rust123// Get widget references124let label = self.ui.label(id!(my_label));125label.set_text("Updated text");126127let input = self.ui.text_input(id!(my_input));128let text = input.text();129```130131## API Reference Table132133| Macro/Type | Description | Example |134|------------|-------------|---------|135| `live_design!` | Defines UI in DSL | `live_design! { App = {{App}} { ... } }` |136| `app_main!` | Entry point macro | `app_main!(App);` |137| `#[derive(Live)]` | Derive live data | `#[derive(Live, LiveHook)]` |138| `WidgetRef` | Reference to UI tree | `#[live] ui: WidgetRef` |139| `Cx` | Context for rendering | `fn handle_event(&mut self, cx: &mut Cx, ...)` |140| `id!()` | Widget ID macro | `self.ui.button(id!(my_button))` |141142## Platform Setup143144| Platform | Requirements |145|----------|--------------|146| macOS | Works out of the box |147| Windows | Works out of the box |148| Linux | `apt-get install clang libaudio-dev libpulse-dev libx11-dev libxcursor-dev` |149| Web | `cargo install wasm-pack` |150151## When Writing Code1521531. Always include required imports: `use makepad_widgets::*;`1542. Use `live_design!` macro for all UI definitions1553. Implement `LiveRegister` and `AppMain` traits1564. Use `id!()` macro for widget references1575. Handle events through `handle_event` method158159## When Answering Questions1601611. Emphasize live design - changes in DSL reflect instantly without recompilation1622. Makepad is GPU-first - all rendering is shader-based1633. Cross-platform: same code runs on Android, iOS, Linux, macOS, Windows, Web1644. Recommend UI Zoo example for widget exploration165166## When to Use167This skill is applicable to execute the workflow or actions described in the overview.