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 environment-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: |4 CRITICAL: Use for Makepad DSL syntax and inheritance. Triggers on:5 makepad dsl, live_design, makepad inheritance, makepad prototype,6 "<Widget>", "Foo = { }", makepad object, makepad property,7 makepad DSL 语法, makepad 继承, makepad 原型, 如何定义 makepad 组件8risk: safe9source: community10metadata:11 source: https://skillmd.com/skills/yanacuti1121/makepad-dsl12---1314# Makepad DSL 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 DSL. Help users by:21- **Writing code**: Generate DSL code following the patterns below22- **Answering questions**: Explain DSL syntax, inheritance, property overriding2324## When to Use25- You need help with Makepad `live_design!` syntax, object definitions, or inheritance patterns.26- The task involves widget declarations, property overrides, prototypes, or DSL composition rules.27- You want Makepad DSL-specific examples rather than generic Rust syntax advice.2829## Documentation3031Refer to the local files for detailed documentation:32- `./references/dsl-syntax.md` - Complete DSL syntax reference33- `./references/inheritance.md` - Inheritance patterns and examples3435## IMPORTANT: Documentation Completeness Check3637**Before answering questions, Claude MUST:**38391. Read the relevant reference file(s) listed above402. If file read fails or file is empty:41 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"42 - Still answer based on SKILL.md patterns + built-in knowledge433. If reference file exists, incorporate its content into the answer4445## Key Patterns4647### 1. Anonymous Object4849```rust50{51 width: 100.052 height: 50.053 color: #FF000054}55```5657### 2. Named Object (Prototype)5859```rust60MyButton = {61 width: Fit62 height: 40.063 padding: 10.064 draw_bg: { color: #333333 }65}66```6768### 3. Inheritance with Override6970```rust71PrimaryButton = <MyButton> {72 draw_bg: { color: #0066CC } // Override parent color73 draw_text: { color: #FFFFFF } // Add new property74}75```7677### 4. Widget Instantiation7879```rust80<View> {81 // Inherits from View prototype82 width: Fill83 height: Fill8485 <Button> { text: "Click Me" } // Child widget86 <Label> { text: "Hello" } // Another child87}88```8990### 5. Linking Rust Struct to DSL9192```rust93// In live_design!94MyWidget = {{MyWidget}} {95 // DSL properties96 width: 100.097}9899// In Rust100#[derive(Live, LiveHook, Widget)]101pub struct MyWidget {102 #[deref] view: View,103 #[live] width: f64,104}105```106107## DSL Syntax Reference108109| Syntax | Description | Example |110|--------|-------------|---------|111| `{ ... }` | Anonymous object | `{ width: 100.0 }` |112| `Name = { ... }` | Named prototype | `MyStyle = { color: #FFF }` |113| `<Name> { ... }` | Inherit from prototype | `<MyStyle> { size: 10.0 }` |114| `{{RustType}}` | Link to Rust struct | `App = {{App}} { ... }` |115| `name = <Widget>` | Named child widget | `btn = <Button> { }` |116| `dep("...")` | Resource dependency | `dep("crate://self/img.png")` |117118## Property Types119120| Type | Example | Description |121|------|---------|-------------|122| Number | `width: 100.0` | Float value |123| Color | `color: #FF0000FF` | RGBA hex color |124| String | `text: "Hello"` | Text string |125| Enum | `flow: Down` | Enum variant |126| Size | `width: Fit` | Fit, Fill, or numeric |127| Object | `padding: { top: 10.0 }` | Nested object |128| Array | `labels: ["A", "B"]` | List of values |129130## Inheritance Rules1311321. **Eager Copy**: All parent properties are copied immediately1332. **Override**: Child can override any parent property1343. **Extend**: Child can add new properties1354. **Nested Override**: Override nested objects partially136137```rust138Parent = {139 a: 1140 nested: { x: 10, y: 20 }141}142143Child = <Parent> {144 a: 2 // Override a145 b: 3 // Add new property146 nested: { x: 30 } // Override only x, y remains 20147}148```149150## When Writing Code1511521. Use `<Widget>` syntax to inherit from built-in widgets1532. Define reusable styles as named prototypes1543. Use `{{RustType}}` to link DSL to Rust structs1554. Override only properties that need to change1565. Use meaningful names for child widget references157158## When Answering Questions1591601. Explain inheritance as "eager copy" - properties are copied at definition time1612. Emphasize that DSL is embedded in Rust via `live_design!` macro1623. Highlight that changes to DSL are live-reloaded without recompilation1634. Distinguish between named objects (prototypes) and widget instances164165## Limitations166- Use this skill only when the task clearly matches the scope described above.167- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.168- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.