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
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## Documentation1718Refer to the local files for detailed documentation:19- `./references/layout-system.md` - Complete layout reference20- `./references/core-types.md` - Walk, Align, Margin, Padding types2122## IMPORTANT: Documentation Completeness Check2324**Before answering questions, Claude MUST:**25261. Read the relevant reference file(s) listed above272. If file read fails or file is empty:28 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"29 - Still answer based on SKILL.md patterns + built-in knowledge303. If reference file exists, incorporate its content into the answer3132## Key Patterns3334### 1. Basic Layout Container3536```rust37<View> {38 width: Fill39 height: Fill40 flow: Down41 padding: 16.042 spacing: 8.04344 <Label> { text: "Item 1" }45 <Label> { text: "Item 2" }46}47```4849### 2. Centering Content5051```rust52<View> {53 width: Fill54 height: Fill55 align: { x: 0.5, y: 0.5 }5657 <Label> { text: "Centered" }58}59```6061### 3. Horizontal Row Layout6263```rust64<View> {65 width: Fill66 height: Fit67 flow: Right68 spacing: 10.069 align: { y: 0.5 } // Vertically center items7071 <Button> { text: "Left" }72 <View> { width: Fill } // Spacer73 <Button> { text: "Right" }74}75```7677### 4. Fixed + Flexible Layout7879```rust80<View> {81 width: Fill82 height: Fill83 flow: Down8485 // Fixed header86 <View> {87 width: Fill88 height: 60.089 }9091 // Flexible content92 <View> {93 width: Fill94 height: Fill // Takes remaining space95 }96}97```9899## Layout Properties Reference100101| Property | Type | Description |102|----------|------|-------------|103| `width` | Size | Width of element |104| `height` | Size | Height of element |105| `padding` | Padding | Inner spacing |106| `margin` | Margin | Outer spacing |107| `flow` | Flow | Child layout direction |108| `spacing` | f64 | Gap between children |109| `align` | Align | Child alignment |110| `clip_x` | bool | Clip horizontal overflow |111| `clip_y` | bool | Clip vertical overflow |112113## Size Values114115| Value | Description |116|-------|-------------|117| `Fit` | Size to fit content |118| `Fill` | Fill available space |119| `100.0` | Fixed size in pixels |120| `Fixed(100.0)` | Explicit fixed size |121122## Flow Directions123124| Value | Description |125|-------|-------------|126| `Down` | Top to bottom (column) |127| `Right` | Left to right (row) |128| `Overlay` | Stack on top |129130## Align Values131132| Value | Position |133|-------|----------|134| `{ x: 0.0, y: 0.0 }` | Top-left |135| `{ x: 0.5, y: 0.0 }` | Top-center |136| `{ x: 1.0, y: 0.0 }` | Top-right |137| `{ x: 0.0, y: 0.5 }` | Middle-left |138| `{ x: 0.5, y: 0.5 }` | Center |139| `{ x: 1.0, y: 0.5 }` | Middle-right |140| `{ x: 0.0, y: 1.0 }` | Bottom-left |141| `{ x: 0.5, y: 1.0 }` | Bottom-center |142| `{ x: 1.0, y: 1.0 }` | Bottom-right |143144## Box Model145146```147+---------------------------+148| margin |149| +---------------------+ |150| | padding | |151| | +---------------+ | |152| | | content | | |153| | +---------------+ | |154| +---------------------+ |155+---------------------------+156```157158## When Writing Code1591601. Use `Fill` for flexible containers, `Fit` for content-sized elements1612. Set `flow: Down` for vertical, `flow: Right` for horizontal1623. Use empty `<View> { width: Fill }` as spacer in row layouts1634. Always set explicit dimensions on fixed-size elements1645. Use `align` to position children within container165166## When Answering Questions1671681. Makepad uses a "turtle" layout model - elements laid out sequentially1692. `Fill` takes all available space, `Fit` shrinks to content1703. Unlike CSS flexbox, there's no flex-grow/shrink - use Fill/Fit1714. Alignment applies to children, not the element itself