Makepad Layout 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 Makepad layout system. Help users by:
- Writing code: Generate layout code following the patterns below
- Answering questions: Explain layout concepts, sizing, flow directions
When to Use
- You need to size, align, or position widgets in a Makepad UI.
- The task involves
Walk, Align, Fit, Fill, padding, spacing, or container flow configuration.
- You want Makepad-specific layout solutions for centering, responsiveness, or composition.
Documentation
Refer to the local files for detailed documentation:
./references/layout-system.md - Complete layout reference
./references/core-types.md - Walk, Align, Margin, Padding types
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 Layout Container
<View> {
width: Fill
height: Fill
flow: Down
padding: 16.0
spacing: 8.0
<Label> { text: "Item 1" }
<Label> { text: "Item 2" }
}
2. Centering Content
<View> {
width: Fill
height: Fill
align: { x: 0.5, y: 0.5 }
<Label> { text: "Centered" }
}
3. Horizontal Row Layout
<View> {
width: Fill
height: Fit
flow: Right
spacing: 10.0
align: { y: 0.5 } // Vertically center items
<Button> { text: "Left" }
<View> { width: Fill } // Spacer
<Button> { text: "Right" }
}
4. Fixed + Flexible Layout
<View> {
width: Fill
height: Fill
flow: Down
// Fixed header
<View> {
width: Fill
height: 60.0
}
// Flexible content
<View> {
width: Fill
height: Fill // Takes remaining space
}
}
Layout Properties Reference
| Property |
Type |
Description |
width |
Size |
Width of element |
height |
Size |
Height of element |
padding |
Padding |
Inner spacing |
margin |
Margin |
Outer spacing |
flow |
Flow |
Child layout direction |
spacing |
f64 |
Gap between children |
align |
Align |
Child alignment |
clip_x |
bool |
Clip horizontal overflow |
clip_y |
bool |
Clip vertical overflow |
Size Values
| Value |
Description |
Fit |
Size to fit content |
Fill |
Fill available space |
100.0 |
Fixed size in pixels |
Fixed(100.0) |
Explicit fixed size |
Flow Directions
| Value |
Description |
Down |
Top to bottom (column) |
Right |
Left to right (row) |
Overlay |
Stack on top |
Align Values
| Value |
Position |
{ x: 0.0, y: 0.0 } |
Top-left |
{ x: 0.5, y: 0.0 } |
Top-center |
{ x: 1.0, y: 0.0 } |
Top-right |
{ x: 0.0, y: 0.5 } |
Middle-left |
{ x: 0.5, y: 0.5 } |
Center |
{ x: 1.0, y: 0.5 } |
Middle-right |
{ x: 0.0, y: 1.0 } |
Bottom-left |
{ x: 0.5, y: 1.0 } |
Bottom-center |
{ x: 1.0, y: 1.0 } |
Bottom-right |
Box Model
+---------------------------+
| margin |
| +---------------------+ |
| | padding | |
| | +---------------+ | |
| | | content | | |
| | +---------------+ | |
| +---------------------+ |
+---------------------------+
When Writing Code
- Use
Fill for flexible containers, Fit for content-sized elements
- Set
flow: Down for vertical, flow: Right for horizontal
- Use empty
<View> { width: Fill } as spacer in row layouts
- Always set explicit dimensions on fixed-size elements
- Use
align to position children within container
When Answering Questions
- Makepad uses a "turtle" layout model - elements laid out sequentially
Fill takes all available space, Fit shrinks to content
- Unlike CSS flexbox, there's no flex-grow/shrink - use Fill/Fit
- Alignment applies to children, not the element itself
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-layout3description: CRITICAL: Use for Makepad layout system. Triggers on: makepad layout, makepad width, makepad height, makepad flex, makepad padding, makepad margin, makepad flow, makepad align, Fit, Fill, Size, Walk, "how to center in makepad", makepad 布局, makepad 宽度, makepad 对齐, makepad 居中4---5
6# Makepad Layout Skill
7
8> **Version:** makepad-widgets (dev branch) | **Last Updated:** 2026-01-19
9>
10> Check for updates: https://crates.io/crates/makepad-widgets
11
12You are an expert at Makepad layout system. Help users by:
13- **Writing code**: Generate layout code following the patterns below
14- **Answering questions**: Explain layout concepts, sizing, flow directions
15
16## When to Use
17- You need to size, align, or position widgets in a Makepad UI.
18- The task involves `Walk`, `Align`, `Fit`, `Fill`, padding, spacing, or container flow configuration.
19- You want Makepad-specific layout solutions for centering, responsiveness, or composition.
20
21## Documentation
22
23Refer to the local files for detailed documentation:
24- `./references/layout-system.md` - Complete layout reference
25- `./references/core-types.md` - Walk, Align, Margin, Padding types
26
27## IMPORTANT: Documentation Completeness Check
28
29**Before answering questions, Claude MUST:**
30
311. Read the relevant reference file(s) listed above
322. 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 knowledge
353. If reference file exists, incorporate its content into the answer
36
37## Key Patterns
38
39### 1. Basic Layout Container
40
41```rust
42<View> {
43 width: Fill
44 height: Fill
45 flow: Down
46 padding: 16.0
47 spacing: 8.0
48
49 <Label> { text: "Item 1" }
50 <Label> { text: "Item 2" }
51}
52```
53
54### 2. Centering Content
55
56```rust
57<View> {
58 width: Fill
59 height: Fill
60 align: { x: 0.5, y: 0.5 }
61
62 <Label> { text: "Centered" }
63}
64```
65
66### 3. Horizontal Row Layout
67
68```rust
69<View> {
70 width: Fill
71 height: Fit
72 flow: Right
73 spacing: 10.0
74 align: { y: 0.5 } // Vertically center items
75
76 <Button> { text: "Left" }
77 <View> { width: Fill } // Spacer
78 <Button> { text: "Right" }
79}
80```
81
82### 4. Fixed + Flexible Layout
83
84```rust
85<View> {
86 width: Fill
87 height: Fill
88 flow: Down
89
90 // Fixed header
91 <View> {
92 width: Fill
93 height: 60.0
94 }
95
96 // Flexible content
97 <View> {
98 width: Fill
99 height: Fill // Takes remaining space
100 }
101}
102```
103
104## Layout Properties Reference
105
106| Property | Type | Description |
107|----------|------|-------------|
108| `width` | Size | Width of element |
109| `height` | Size | Height of element |
110| `padding` | Padding | Inner spacing |
111| `margin` | Margin | Outer spacing |
112| `flow` | Flow | Child layout direction |
113| `spacing` | f64 | Gap between children |
114| `align` | Align | Child alignment |
115| `clip_x` | bool | Clip horizontal overflow |
116| `clip_y` | bool | Clip vertical overflow |
117
118## Size Values
119
120| Value | Description |
121|-------|-------------|
122| `Fit` | Size to fit content |
123| `Fill` | Fill available space |
124| `100.0` | Fixed size in pixels |
125| `Fixed(100.0)` | Explicit fixed size |
126
127## Flow Directions
128
129| Value | Description |
130|-------|-------------|
131| `Down` | Top to bottom (column) |
132| `Right` | Left to right (row) |
133| `Overlay` | Stack on top |
134
135## Align Values
136
137| Value | Position |
138|-------|----------|
139| `{ x: 0.0, y: 0.0 }` | Top-left |
140| `{ x: 0.5, y: 0.0 }` | Top-center |
141| `{ x: 1.0, y: 0.0 }` | Top-right |
142| `{ x: 0.0, y: 0.5 }` | Middle-left |
143| `{ x: 0.5, y: 0.5 }` | Center |
144| `{ x: 1.0, y: 0.5 }` | Middle-right |
145| `{ x: 0.0, y: 1.0 }` | Bottom-left |
146| `{ x: 0.5, y: 1.0 }` | Bottom-center |
147| `{ x: 1.0, y: 1.0 }` | Bottom-right |
148
149## Box Model
150
151```
152+---------------------------+
153| margin |
154| +---------------------+ |
155| | padding | |
156| | +---------------+ | |
157| | | content | | |
158| | +---------------+ | |
159| +---------------------+ |
160+---------------------------+
161```
162
163## When Writing Code
164
1651. Use `Fill` for flexible containers, `Fit` for content-sized elements
1662. Set `flow: Down` for vertical, `flow: Right` for horizontal
1673. Use empty `<View> { width: Fill }` as spacer in row layouts
1684. Always set explicit dimensions on fixed-size elements
1695. Use `align` to position children within container
170
171## When Answering Questions
172
1731. Makepad uses a "turtle" layout model - elements laid out sequentially
1742. `Fill` takes all available space, `Fit` shrinks to content
1753. Unlike CSS flexbox, there's no flex-grow/shrink - use Fill/Fit
1764. Alignment applies to children, not the element itself
177
178## Limitations
179- Use this skill only when the task clearly matches the scope described above.
180- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
181- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.