makepad-layout

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 居中

31,392 stars
Complexity: easy

About this skill

This skill empowers AI agents to act as an expert resource for the Makepad UI layout system, specifically tailored for the `makepad-widgets` development branch. It provides comprehensive assistance by generating accurate Makepad layout code snippets and offering clear explanations of complex layout concepts. Developers working with Makepad can leverage this skill to efficiently build intricate UI designs, understand unique sizing and positioning paradigms like `Fit`, `Fill`, `Size`, and `Walk`, and troubleshoot common layout challenges, such as centering elements or configuring flexible arrangements. The skill covers a wide array of layout properties including `width`, `height`, `flex`, `padding`, `margin`, `flow`, and `align`, offering both practical coding solutions and educational insights into the Makepad framework.

Best use case

Developers needing to generate Makepad UI layout code, understand Makepad's layout concepts, or troubleshoot layout issues within their Makepad applications. It's ideal for accelerating UI development and learning best practices for Makepad layout.

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 居中

Accurate and efficient Makepad layout code snippets, clear explanations of Makepad layout properties and best practices, and effective solutions to specific UI positioning or sizing challenges, leading to faster and more robust Makepad UI development.

Practical example

Example input

How do I center a component horizontally and vertically using Makepad layout?

Example output

To center a component horizontally and vertically in Makepad, you typically use a combination of `flow` and `align` properties on the parent container, often augmented with `Spacer` widgets for main-axis centering. 

1.  **Horizontal Centering (Cross-axis):** Set `align: Center` on the parent container. If the parent's `flow` is `Down`, its cross-axis is horizontal, so `align: Center` will horizontally center its children.

2.  **Vertical Centering (Main-axis):** When `flow: Down`, the main axis is vertical. To vertically center children along this axis, a common Makepad pattern involves using `Spacer` widgets with `height: Fill` (or `width: Fill` for `flow: Right`) before and after the content you wish to center. These spacers consume available space, pushing the content to the middle.

Here's an example code snippet that centers `MyCenteredComponent` within a parent `View`:

```rust
View { // Parent container
    width: Fill,
    height: Fill,
    flow: Down, // Items flow vertically
    align: Center, // Centers children horizontally (cross-axis for flow: Down)

    <Spacer> { height: Fill } // Pushes content down
    <MyCenteredComponent> {
        width: Size(100),
        height: Size(50),
        draw_bg: { color: #f00; }, // For visualization
    }
    <Spacer> { height: Fill } // Pushes content up
}
```

In this setup:
- The parent `View` occupies all available space (`width: Fill`, `height: Fill`).
- `flow: Down` arranges children vertically.
- `align: Center` on the parent ensures `MyCenteredComponent` (and the Spacers) are centered horizontally.
- The `<Spacer>` elements with `height: Fill` take up all remaining vertical space above and below `MyCenteredComponent`, effectively positioning it in the vertical center. This technique ensures robust centering across different screen sizes.

When to use this skill

  • When actively developing user interfaces with Makepad and requiring assistance with component sizing, positioning, alignment, or responsive design. Ideal for both new Makepad users seeking guidance and experienced developers looking for quick code generation or concept clarification.

When not to use this skill

  • For UI development outside of the Makepad framework, for general Rust programming tasks unrelated to UI, or for design tasks that do not involve code implementation in Makepad. This skill is highly specialized for Makepad layout.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/makepad-layout/SKILL.md --create-dirs "https://raw.githubusercontent.com/sickn33/antigravity-awesome-skills/main/plugins/antigravity-awesome-skills-claude/skills/makepad-layout/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/makepad-layout/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How makepad-layout Compares

Feature / Agentmakepad-layoutStandard Approach
Platform SupportClaudeLimited / Varies
Context Awareness High Baseline
Installation ComplexityeasyN/A

Frequently Asked Questions

What does this skill do?

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 居中

Which AI agents support this skill?

This skill is designed for Claude.

How difficult is it to install?

The installation complexity is rated as easy. You can find the installation instructions above.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# 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:**

1. Read the relevant reference file(s) listed above
2. 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
3. If reference file exists, incorporate its content into the answer

## Key Patterns

### 1. Basic Layout Container

```rust
<View> {
    width: Fill
    height: Fill
    flow: Down
    padding: 16.0
    spacing: 8.0

    <Label> { text: "Item 1" }
    <Label> { text: "Item 2" }
}
```

### 2. Centering Content

```rust
<View> {
    width: Fill
    height: Fill
    align: { x: 0.5, y: 0.5 }

    <Label> { text: "Centered" }
}
```

### 3. Horizontal Row Layout

```rust
<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

```rust
<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

1. Use `Fill` for flexible containers, `Fit` for content-sized elements
2. Set `flow: Down` for vertical, `flow: Right` for horizontal
3. Use empty `<View> { width: Fill }` as spacer in row layouts
4. Always set explicit dimensions on fixed-size elements
5. Use `align` to position children within container

## When Answering Questions

1. Makepad uses a "turtle" layout model - elements laid out sequentially
2. `Fill` takes all available space, `Fit` shrinks to content
3. Unlike CSS flexbox, there's no flex-grow/shrink - use Fill/Fit
4. Alignment applies to children, not the element itself

Related Skills

makepad-platform

31392
from sickn33/antigravity-awesome-skills

CRITICAL: Use for Makepad cross-platform support. Triggers on: makepad platform, makepad os, makepad macos, makepad windows, makepad linux, makepad android, makepad ios, makepad web, makepad wasm, makepad metal, makepad d3d11, makepad opengl, makepad webgl, OsType, CxOs, makepad 跨平台, makepad 平台支持

Development ToolsClaude

makepad-font

31392
from sickn33/antigravity-awesome-skills

CRITICAL: Use for Makepad font and text rendering. Triggers on: makepad font, makepad text, makepad glyph, makepad typography, font atlas, text layout, font family, font size, text shaping, makepad 字体, makepad 文字, makepad 排版, makepad 字形

Development ToolsClaude

makepad-animation

31355
from sickn33/antigravity-awesome-skills

CRITICAL: Use for Makepad animation system. Triggers on: makepad animation, makepad animator, makepad hover, makepad state, makepad transition, "from: { all: Forward", makepad pressed, makepad 动画, makepad 状态, makepad 过渡, makepad 悬停效果

Development ToolsClaude

moodle-external-api-development

31392
from sickn33/antigravity-awesome-skills

This skill guides you through creating custom external web service APIs for Moodle LMS, following Moodle's external API framework and coding standards.

Development ToolsClaude

mobile-developer

31392
from sickn33/antigravity-awesome-skills

Develop React Native, Flutter, or native mobile apps with modern architecture patterns. Masters cross-platform development, native integrations, offline sync, and app store optimization.

Development ToolsClaude

graphql-architect

31392
from sickn33/antigravity-awesome-skills

Master modern GraphQL with federation, performance optimization, and enterprise security. Build scalable schemas, implement advanced caching, and design real-time systems.

Development ToolsClaude

git-pr-workflows-pr-enhance

31392
from sickn33/antigravity-awesome-skills

You are a PR optimization expert specializing in creating high-quality pull requests that facilitate efficient code reviews. Generate comprehensive PR descriptions, automate review processes, and ensu

Development ToolsClaude

git-advanced-workflows

31392
from sickn33/antigravity-awesome-skills

Master advanced Git techniques to maintain clean history, collaborate effectively, and recover from any situation with confidence.

Development ToolsClaude

debugging-toolkit-smart-debug

31392
from sickn33/antigravity-awesome-skills

Use when working with debugging toolkit smart debug

Development ToolsClaude

debugger

31392
from sickn33/antigravity-awesome-skills

Debugging specialist for errors, test failures, and unexpected behavior. Use proactively when encountering any issues.

Development ToolsClaude

conductor-setup

31392
from sickn33/antigravity-awesome-skills

Configure a Rails project to work with Conductor (parallel coding agents)

Development ToolsClaudeGitHub CopilotDeepSeek

comprehensive-review-pr-enhance

31392
from sickn33/antigravity-awesome-skills

Generate structured PR descriptions from diffs, add review checklists, risk assessments, and test coverage summaries. Use when the user says "write a PR description", "improve this PR", "summarize my changes", "PR review", "pull request", or asks to document a diff for reviewers.

Development ToolsClaude