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
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---56# Makepad Layout 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 Makepad layout system. Help users by:13- **Writing code**: Generate layout code following the patterns below14- **Answering questions**: Explain layout concepts, sizing, flow directions1516## When to Use1718- You need to size, align, or position widgets in a Makepad UI.19- The task involves `Walk`, `Align`, `Fit`, `Fill`, padding, spacing, or container flow configuration.20- You want Makepad-specific layout solutions for centering, responsiveness, or composition.2122## Documentation2324Refer to the local files for detailed documentation:25- `./references/layout-system.md` - Complete layout reference26- `./references/core-types.md` - Walk, Align, Margin, Padding types2728## IMPORTANT: Documentation Completeness Check2930**Before answering questions, Claude MUST:**31321. Read the relevant reference file(s) listed above332. If file read fails or file is empty:34 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"35 - Still answer based on SKILL.md patterns + built-in knowledge363. If reference file exists, incorporate its content into the answer3738## Key Patterns3940### 1. Basic Layout Container4142```rust43<View> {44 width: Fill45 height: Fill46 flow: Down47 padding: 16.048 spacing: 8.04950 <Label> { text: "Item 1" }51 <Label> { text: "Item 2" }52}53```5455### 2. Centering Content5657```rust58<View> {59 width: Fill60 height: Fill61 align: { x: 0.5, y: 0.5 }6263 <Label> { text: "Centered" }64}65```6667### 3. Horizontal Row Layout6869```rust70<View> {71 width: Fill72 height: Fit73 flow: Right74 spacing: 10.075 align: { y: 0.5 } // Vertically center items7677 <Button> { text: "Left" }78 <View> { width: Fill } // Spacer79 <Button> { text: "Right" }80}81```8283### 4. Fixed + Flexible Layout8485```rust86<View> {87 width: Fill88 height: Fill89 flow: Down9091 // Fixed header92 <View> {93 width: Fill94 height: 60.095 }9697 // Flexible content98 <View> {99 width: Fill100 height: Fill // Takes remaining space101 }102}103```104105## Layout Properties Reference106107| Property | Type | Description |108|----------|------|-------------|109| `width` | Size | Width of element |110| `height` | Size | Height of element |111| `padding` | Padding | Inner spacing |112| `margin` | Margin | Outer spacing |113| `flow` | Flow | Child layout direction |114| `spacing` | f64 | Gap between children |115| `align` | Align | Child alignment |116| `clip_x` | bool | Clip horizontal overflow |117| `clip_y` | bool | Clip vertical overflow |118119## Size Values120121| Value | Description |122|-------|-------------|123| `Fit` | Size to fit content |124| `Fill` | Fill available space |125| `100.0` | Fixed size in pixels |126| `Fixed(100.0)` | Explicit fixed size |127128## Flow Directions129130| Value | Description |131|-------|-------------|132| `Down` | Top to bottom (column) |133| `Right` | Left to right (row) |134| `Overlay` | Stack on top |135136## Align Values137138| Value | Position |139|-------|----------|140| `{ x: 0.0, y: 0.0 }` | Top-left |141| `{ x: 0.5, y: 0.0 }` | Top-center |142| `{ x: 1.0, y: 0.0 }` | Top-right |143| `{ x: 0.0, y: 0.5 }` | Middle-left |144| `{ x: 0.5, y: 0.5 }` | Center |145| `{ x: 1.0, y: 0.5 }` | Middle-right |146| `{ x: 0.0, y: 1.0 }` | Bottom-left |147| `{ x: 0.5, y: 1.0 }` | Bottom-center |148| `{ x: 1.0, y: 1.0 }` | Bottom-right |149150## Box Model151152```153+---------------------------+154| margin |155| +---------------------+ |156| | padding | |157| | +---------------+ | |158| | | content | | |159| | +---------------+ | |160| +---------------------+ |161+---------------------------+162```163164## When Writing Code1651661. Use `Fill` for flexible containers, `Fit` for content-sized elements1672. Set `flow: Down` for vertical, `flow: Right` for horizontal1683. Use empty `<View> { width: Fill }` as spacer in row layouts1694. Always set explicit dimensions on fixed-size elements1705. Use `align` to position children within container171172## When Answering Questions1731741. Makepad uses a "turtle" layout model - elements laid out sequentially1752. `Fill` takes all available space, `Fit` shrinks to content1763. Unlike CSS flexbox, there's no flex-grow/shrink - use Fill/Fit1774. Alignment applies to children, not the element itself