Makepad DSL 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 DSL. Help users by:
- Writing code: Generate DSL code following the patterns below
- Answering questions: Explain DSL syntax, inheritance, property overriding
When to Use
- You need help with Makepad
live_design! syntax, object definitions, or inheritance patterns.
- The task involves widget declarations, property overrides, prototypes, or DSL composition rules.
- You want Makepad DSL-specific examples rather than generic Rust syntax advice.
Documentation
Refer to the local files for detailed documentation:
./references/dsl-syntax.md - Complete DSL syntax reference
./references/inheritance.md - Inheritance patterns and examples
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. Anonymous Object
{
width: 100.0
height: 50.0
color: #FF0000
}
2. Named Object (Prototype)
MyButton = {
width: Fit
height: 40.0
padding: 10.0
draw_bg: { color: #333333 }
}
3. Inheritance with Override
PrimaryButton = <MyButton> {
draw_bg: { color: #0066CC } // Override parent color
draw_text: { color: #FFFFFF } // Add new property
}
4. Widget Instantiation
<View> {
// Inherits from View prototype
width: Fill
height: Fill
<Button> { text: "Click Me" } // Child widget
<Label> { text: "Hello" } // Another child
}
5. Linking Rust Struct to DSL
// In live_design!
MyWidget = {{MyWidget}} {
// DSL properties
width: 100.0
}
// In Rust
#[derive(Live, LiveHook, Widget)]
pub struct MyWidget {
#[deref] view: View,
#[live] width: f64,
}
DSL Syntax Reference
| Syntax |
Description |
Example |
{ ... } |
Anonymous object |
{ width: 100.0 } |
Name = { ... } |
Named prototype |
MyStyle = { color: #FFF } |
<Name> { ... } |
Inherit from prototype |
<MyStyle> { size: 10.0 } |
{{RustType}} |
Link to Rust struct |
App = {{App}} { ... } |
name = <Widget> |
Named child widget |
btn = <Button> { } |
dep("...") |
Resource dependency |
dep("crate://self/img.png") |
Property Types
| Type |
Example |
Description |
| Number |
width: 100.0 |
Float value |
| Color |
color: #FF0000FF |
RGBA hex color |
| String |
text: "Hello" |
Text string |
| Enum |
flow: Down |
Enum variant |
| Size |
width: Fit |
Fit, Fill, or numeric |
| Object |
padding: { top: 10.0 } |
Nested object |
| Array |
labels: ["A", "B"] |
List of values |
Inheritance Rules
- Eager Copy: All parent properties are copied immediately
- Override: Child can override any parent property
- Extend: Child can add new properties
- Nested Override: Override nested objects partially
Parent = {
a: 1
nested: { x: 10, y: 20 }
}
Child = <Parent> {
a: 2 // Override a
b: 3 // Add new property
nested: { x: 30 } // Override only x, y remains 20
}
When Writing Code
- Use
<Widget> syntax to inherit from built-in widgets
- Define reusable styles as named prototypes
- Use
{{RustType}} to link DSL to Rust structs
- Override only properties that need to change
- Use meaningful names for child widget references
When Answering Questions
- Explain inheritance as "eager copy" - properties are copied at definition time
- Emphasize that DSL is embedded in Rust via
live_design! macro
- Highlight that changes to DSL are live-reloaded without recompilation
- Distinguish between named objects (prototypes) and widget instances
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-dsl3description: CRITICAL: Use for Makepad DSL syntax and inheritance. Triggers on: makepad dsl, live_design, makepad inheritance, makepad prototype, "<Widget>", "Foo = { }", makepad object, makepad property, makepad DSL 语法, makepad 继承, makepad 原型, 如何定义 makepad 组件4---56# Makepad DSL 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 DSL. Help users by:13- **Writing code**: Generate DSL code following the patterns below14- **Answering questions**: Explain DSL syntax, inheritance, property overriding1516## When to Use17- You need help with Makepad `live_design!` syntax, object definitions, or inheritance patterns.18- The task involves widget declarations, property overrides, prototypes, or DSL composition rules.19- You want Makepad DSL-specific examples rather than generic Rust syntax advice.2021## Documentation2223Refer to the local files for detailed documentation:24- `./references/dsl-syntax.md` - Complete DSL syntax reference25- `./references/inheritance.md` - Inheritance patterns and examples2627## 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. Anonymous Object4041```rust42{43 width: 100.044 height: 50.045 color: #FF000046}47```4849### 2. Named Object (Prototype)5051```rust52MyButton = {53 width: Fit54 height: 40.055 padding: 10.056 draw_bg: { color: #333333 }57}58```5960### 3. Inheritance with Override6162```rust63PrimaryButton = <MyButton> {64 draw_bg: { color: #0066CC } // Override parent color65 draw_text: { color: #FFFFFF } // Add new property66}67```6869### 4. Widget Instantiation7071```rust72<View> {73 // Inherits from View prototype74 width: Fill75 height: Fill7677 <Button> { text: "Click Me" } // Child widget78 <Label> { text: "Hello" } // Another child79}80```8182### 5. Linking Rust Struct to DSL8384```rust85// In live_design!86MyWidget = {{MyWidget}} {87 // DSL properties88 width: 100.089}9091// In Rust92#[derive(Live, LiveHook, Widget)]93pub struct MyWidget {94 #[deref] view: View,95 #[live] width: f64,96}97```9899## DSL Syntax Reference100101| Syntax | Description | Example |102|--------|-------------|---------|103| `{ ... }` | Anonymous object | `{ width: 100.0 }` |104| `Name = { ... }` | Named prototype | `MyStyle = { color: #FFF }` |105| `<Name> { ... }` | Inherit from prototype | `<MyStyle> { size: 10.0 }` |106| `{{RustType}}` | Link to Rust struct | `App = {{App}} { ... }` |107| `name = <Widget>` | Named child widget | `btn = <Button> { }` |108| `dep("...")` | Resource dependency | `dep("crate://self/img.png")` |109110## Property Types111112| Type | Example | Description |113|------|---------|-------------|114| Number | `width: 100.0` | Float value |115| Color | `color: #FF0000FF` | RGBA hex color |116| String | `text: "Hello"` | Text string |117| Enum | `flow: Down` | Enum variant |118| Size | `width: Fit` | Fit, Fill, or numeric |119| Object | `padding: { top: 10.0 }` | Nested object |120| Array | `labels: ["A", "B"]` | List of values |121122## Inheritance Rules1231241. **Eager Copy**: All parent properties are copied immediately1252. **Override**: Child can override any parent property1263. **Extend**: Child can add new properties1274. **Nested Override**: Override nested objects partially128129```rust130Parent = {131 a: 1132 nested: { x: 10, y: 20 }133}134135Child = <Parent> {136 a: 2 // Override a137 b: 3 // Add new property138 nested: { x: 30 } // Override only x, y remains 20139}140```141142## When Writing Code1431441. Use `<Widget>` syntax to inherit from built-in widgets1452. Define reusable styles as named prototypes1463. Use `{{RustType}}` to link DSL to Rust structs1474. Override only properties that need to change1485. Use meaningful names for child widget references149150## When Answering Questions1511521. Explain inheritance as "eager copy" - properties are copied at definition time1532. Emphasize that DSL is embedded in Rust via `live_design!` macro1543. Highlight that changes to DSL are live-reloaded without recompilation1554. Distinguish between named objects (prototypes) and widget instances156157## Limitations158- Use this skill only when the task clearly matches the scope described above.159- Do not treat the output as a substitute for enprojectnment-specific validation, testing, or expert review.160- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.