Makepad Layout Skill
Selective Reading Rule
Start with:
references/senior-master-standard.md
references/usage-routing.md
references/quality-checklist.md
Then load only the inherited docs, scripts, assets, or examples that match the user's actual task.
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: ALWAYS use this when the request matches Makepad Layout: CRITICAL: Use for Makepad layout system.4---56# Makepad Layout Skill78## Selective Reading Rule910Start with:1112- `references/senior-master-standard.md`13- `references/usage-routing.md`14- `references/quality-checklist.md`1516Then load only the inherited docs, scripts, assets, or examples that match the user's actual task.1718> **Version:** makepad-widgets (dev branch) | **Last Updated:** 2026-01-1919>20> Check for updates: https://crates.io/crates/makepad-widgets2122You are an expert at Makepad layout system. Help users by:23- **Writing code**: Generate layout code following the patterns below24- **Answering questions**: Explain layout concepts, sizing, flow directions2526## When to Use27- You need to size, align, or position widgets in a Makepad UI.28- The task involves `Walk`, `Align`, `Fit`, `Fill`, padding, spacing, or container flow configuration.29- You want Makepad-specific layout solutions for centering, responsiveness, or composition.3031## Documentation3233Refer to the local files for detailed documentation:34- `./references/layout-system.md` - Complete layout reference35- `./references/core-types.md` - Walk, Align, Margin, Padding types3637## IMPORTANT: Documentation Completeness Check3839**Before answering questions, Claude MUST:**40411. Read the relevant reference file(s) listed above422. If file read fails or file is empty:43 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"44 - Still answer based on SKILL.md patterns + built-in knowledge453. If reference file exists, incorporate its content into the answer4647## Key Patterns4849### 1. Basic Layout Container5051```rust52<View> {53 width: Fill54 height: Fill55 flow: Down56 padding: 16.057 spacing: 8.05859 <Label> { text: "Item 1" }60 <Label> { text: "Item 2" }61}62```6364### 2. Centering Content6566```rust67<View> {68 width: Fill69 height: Fill70 align: { x: 0.5, y: 0.5 }7172 <Label> { text: "Centered" }73}74```7576### 3. Horizontal Row Layout7778```rust79<View> {80 width: Fill81 height: Fit82 flow: Right83 spacing: 10.084 align: { y: 0.5 } // Vertically center items8586 <Button> { text: "Left" }87 <View> { width: Fill } // Spacer88 <Button> { text: "Right" }89}90```9192### 4. Fixed + Flexible Layout9394```rust95<View> {96 width: Fill97 height: Fill98 flow: Down99100 // Fixed header101 <View> {102 width: Fill103 height: 60.0104 }105106 // Flexible content107 <View> {108 width: Fill109 height: Fill // Takes remaining space110 }111}112```113114## Layout Properties Reference115116| Property | Type | Description |117|----------|------|-------------|118| `width` | Size | Width of element |119| `height` | Size | Height of element |120| `padding` | Padding | Inner spacing |121| `margin` | Margin | Outer spacing |122| `flow` | Flow | Child layout direction |123| `spacing` | f64 | Gap between children |124| `align` | Align | Child alignment |125| `clip_x` | bool | Clip horizontal overflow |126| `clip_y` | bool | Clip vertical overflow |127128## Size Values129130| Value | Description |131|-------|-------------|132| `Fit` | Size to fit content |133| `Fill` | Fill available space |134| `100.0` | Fixed size in pixels |135| `Fixed(100.0)` | Explicit fixed size |136137## Flow Directions138139| Value | Description |140|-------|-------------|141| `Down` | Top to bottom (column) |142| `Right` | Left to right (row) |143| `Overlay` | Stack on top |144145## Align Values146147| Value | Position |148|-------|----------|149| `{ x: 0.0, y: 0.0 }` | Top-left |150| `{ x: 0.5, y: 0.0 }` | Top-center |151| `{ x: 1.0, y: 0.0 }` | Top-right |152| `{ x: 0.0, y: 0.5 }` | Middle-left |153| `{ x: 0.5, y: 0.5 }` | Center |154| `{ x: 1.0, y: 0.5 }` | Middle-right |155| `{ x: 0.0, y: 1.0 }` | Bottom-left |156| `{ x: 0.5, y: 1.0 }` | Bottom-center |157| `{ x: 1.0, y: 1.0 }` | Bottom-right |158159## Box Model160161```162+---------------------------+163| margin |164| +---------------------+ |165| | padding | |166| | +---------------+ | |167| | | content | | |168| | +---------------+ | |169| +---------------------+ |170+---------------------------+171```172173## When Writing Code1741751. Use `Fill` for flexible containers, `Fit` for content-sized elements1762. Set `flow: Down` for vertical, `flow: Right` for horizontal1773. Use empty `<View> { width: Fill }` as spacer in row layouts1784. Always set explicit dimensions on fixed-size elements1795. Use `align` to position children within container180181## When Answering Questions1821831. Makepad uses a "turtle" layout model - elements laid out sequentially1842. `Fill` takes all available space, `Fit` shrinks to content1853. Unlike CSS flexbox, there's no flex-grow/shrink - use Fill/Fit1864. Alignment applies to children, not the element itself187188## Limitations189- Use this skill only when the task clearly matches the scope described above.190- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.191- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.