Makepad Widgets 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 widgets. Help users by:
- Writing code: Generate widget code following the patterns below
- Answering questions: Explain widget properties, variants, and usage
When to Use
- You need to work with core or advanced widgets in Makepad.
- The task involves widget selection, properties, variants, composition, or widget-specific behavior.
- You want examples for
View, Button, labels, rich text, or other makepad-widgets building blocks.
Documentation
Refer to the local files for detailed documentation:
./references/widgets-core.md - Core widgets (View, Button, Label, etc.)
./references/widgets-advanced.md - Helper and advanced widgets
./references/widgets-richtext.md - Rich text widgets (Markdown, Html, TextFlow)
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. View (Basic Container)
<View> {
width: Fill
height: Fill
flow: Down
padding: 16.0
show_bg: true
draw_bg: { color: #1A1A1A }
<Label> { text: "Content" }
}
2. Button
<Button> {
text: "Click Me"
draw_bg: {
color: #0066CC
color_hover: #0088FF
border_radius: 4.0
}
draw_text: {
color: #FFFFFF
text_style: { font_size: 14.0 }
}
}
3. Label with Styling
<Label> {
width: Fit
height: Fit
text: "Hello World"
draw_text: {
color: #FFFFFF
text_style: {
font_size: 16.0
line_spacing: 1.4
}
}
}
4. Image
<Image> {
width: 200.0
height: 150.0
source: dep("crate://self/resources/photo.png")
fit: Contain
}
5. TextInput
<TextInput> {
width: Fill
height: Fit
text: "Default value"
draw_text: {
text_style: { font_size: 14.0 }
}
}
Widget Traits (from source)
pub trait WidgetNode: LiveApply {
fn find_widgets(&self, path: &[LiveId], cached: WidgetCache, results: &mut WidgetSet);
fn walk(&mut self, cx: &mut Cx) -> Walk;
fn area(&self) -> Area;
fn redraw(&mut self, cx: &mut Cx);
}
pub trait Widget: WidgetNode {
fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {}
fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep;
fn draw(&mut self, cx: &mut Cx2d, scope: &mut Scope) -> DrawStep;
fn widget(&self, path: &[LiveId]) -> WidgetRef;
}
All Built-in Widgets (84 files in widgets/src/)
| Category |
Widgets |
| Basic |
View, Label, Button, Icon, Image |
| Input |
TextInput, CheckBox, RadioButton, Slider, DropDown, ColorPicker |
| Container |
ScrollBars, PortalList, FlatList, StackNavigation, Dock, Splitter |
| Navigation |
TabBar, Tab, FoldHeader, FoldButton, ExpandablePanel |
| Overlay |
Modal, Tooltip, PopupMenu, PopupNotification |
| Media |
Video, RotatedImage, ImageBlend, MultiImage |
| Layout |
AdaptiveView, SlidePanel, PageFlip, SlidesView |
| Special |
Markdown, Html, TextFlow, WebView, KeyboardView |
| Utility |
LoadingSpinner, DesktopButton, LinkLabel, ScrollShadow |
Core Widgets Reference
| Widget |
Purpose |
Key Properties |
View |
Container |
flow, align, show_bg, draw_bg, optimize |
Button |
Clickable |
text, draw_bg, draw_text, draw_icon |
Label |
Text display |
text, draw_text |
Image |
Image display |
source, fit |
TextInput |
Text entry |
text, draw_text, draw_cursor, draw_selection |
CheckBox |
Toggle |
text, selected |
RadioButton |
Selection |
text, selected |
Slider |
Value slider |
min, max, step |
DropDown |
Select menu |
labels, selected |
PortalList |
Virtual list |
Efficient scrolling for large lists |
Modal |
Dialog |
Overlay dialog boxes |
Tooltip |
Hint |
Hover tooltips |
View Variants
| Variant |
Description |
SolidView |
Solid background color |
RoundedView |
Rounded corners |
RoundedAllView |
Individual corner control |
RectView |
Rectangle with border/gradient |
CircleView |
Circle/ellipse shape |
GradientXView |
Horizontal gradient |
GradientYView |
Vertical gradient |
RoundedShadowView |
Rounded with shadow |
ScrollXView |
Horizontal scroll |
ScrollYView |
Vertical scroll |
ScrollXYView |
Both directions scroll |
CachedView |
Texture-cached |
Button Variants
| Variant |
Description |
ButtonFlat |
Flat style |
ButtonFlatIcon |
Flat with icon |
ButtonFlatter |
No background |
ButtonGradientX |
Horizontal gradient |
ButtonGradientY |
Vertical gradient |
ButtonIcon |
Standard with icon |
ImageFit Values
| Value |
Description |
Stretch |
Stretch to fill |
Contain |
Fit within, preserve ratio |
Cover |
Cover area, may crop |
Fill |
Fill without ratio |
When Writing Code
- Always set
width and height on widgets
- Use
show_bg: true to enable background rendering
- Access
draw_bg, draw_text, draw_icon for shader uniforms
- Use
dep("crate://self/...") for resource paths
- Choose appropriate View variant for visual needs
When Answering Questions
- Recommend UI Zoo example for widget exploration
- View is the base container - most visual widgets inherit from it
- Draw shaders (
draw_bg, draw_text) control appearance
- All widgets support animation through
animator property
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-widgets3description: 'Version: makepad-widgets (dev branch) | Last Updated: 2026-01-19 > > Check for updates: https://crates.io/crates/makepad-widgets'4metadata:5 source: https://skillmd.com/skills/iradoweck/makepad-widgets6 aas-risk: safe7 aas-source: community8---910# Makepad Widgets Skill1112> **Version:** makepad-widgets (dev branch) | **Last Updated:** 2026-01-1913>14> Check for updates: https://crates.io/crates/makepad-widgets1516You are an expert at Makepad widgets. Help users by:17- **Writing code**: Generate widget code following the patterns below18- **Answering questions**: Explain widget properties, variants, and usage1920## When to Use21- You need to work with core or advanced widgets in Makepad.22- The task involves widget selection, properties, variants, composition, or widget-specific behavior.23- You want examples for `View`, `Button`, labels, rich text, or other `makepad-widgets` building blocks.2425## Documentation2627Refer to the local files for detailed documentation:28- `./references/widgets-core.md` - Core widgets (View, Button, Label, etc.)29- `./references/widgets-advanced.md` - Helper and advanced widgets30- `./references/widgets-richtext.md` - Rich text widgets (Markdown, Html, TextFlow)3132## IMPORTANT: Documentation Completeness Check3334**Before answering questions, Claude MUST:**35361. Read the relevant reference file(s) listed above372. If file read fails or file is empty:38 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"39 - Still answer based on SKILL.md patterns + built-in knowledge403. If reference file exists, incorporate its content into the answer4142## Key Patterns4344### 1. View (Basic Container)4546```rust47<View> {48 width: Fill49 height: Fill50 flow: Down51 padding: 16.052 show_bg: true53 draw_bg: { color: #1A1A1A }5455 <Label> { text: "Content" }56}57```5859### 2. Button6061```rust62<Button> {63 text: "Click Me"64 draw_bg: {65 color: #0066CC66 color_hover: #0088FF67 border_radius: 4.068 }69 draw_text: {70 color: #FFFFFF71 text_style: { font_size: 14.0 }72 }73}74```7576### 3. Label with Styling7778```rust79<Label> {80 width: Fit81 height: Fit82 text: "Hello World"83 draw_text: {84 color: #FFFFFF85 text_style: {86 font_size: 16.087 line_spacing: 1.488 }89 }90}91```9293### 4. Image9495```rust96<Image> {97 width: 200.098 height: 150.099 source: dep("crate://self/resources/photo.png")100 fit: Contain101}102```103104### 5. TextInput105106```rust107<TextInput> {108 width: Fill109 height: Fit110 text: "Default value"111 draw_text: {112 text_style: { font_size: 14.0 }113 }114}115```116117## Widget Traits (from source)118119```rust120pub trait WidgetNode: LiveApply {121 fn find_widgets(&self, path: &[LiveId], cached: WidgetCache, results: &mut WidgetSet);122 fn walk(&mut self, cx: &mut Cx) -> Walk;123 fn area(&self) -> Area;124 fn redraw(&mut self, cx: &mut Cx);125}126127pub trait Widget: WidgetNode {128 fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {}129 fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep;130 fn draw(&mut self, cx: &mut Cx2d, scope: &mut Scope) -> DrawStep;131 fn widget(&self, path: &[LiveId]) -> WidgetRef;132}133```134135## All Built-in Widgets (84 files in widgets/src/)136137| Category | Widgets |138|----------|---------|139| **Basic** | `View`, `Label`, `Button`, `Icon`, `Image` |140| **Input** | `TextInput`, `CheckBox`, `RadioButton`, `Slider`, `DropDown`, `ColorPicker` |141| **Container** | `ScrollBars`, `PortalList`, `FlatList`, `StackNavigation`, `Dock`, `Splitter` |142| **Navigation** | `TabBar`, `Tab`, `FoldHeader`, `FoldButton`, `ExpandablePanel` |143| **Overlay** | `Modal`, `Tooltip`, `PopupMenu`, `PopupNotification` |144| **Media** | `Video`, `RotatedImage`, `ImageBlend`, `MultiImage` |145| **Layout** | `AdaptiveView`, `SlidePanel`, `PageFlip`, `SlidesView` |146| **Special** | `Markdown`, `Html`, `TextFlow`, `WebView`, `KeyboardView` |147| **Utility** | `LoadingSpinner`, `DesktopButton`, `LinkLabel`, `ScrollShadow` |148149## Core Widgets Reference150151| Widget | Purpose | Key Properties |152|--------|---------|----------------|153| `View` | Container | `flow`, `align`, `show_bg`, `draw_bg`, `optimize` |154| `Button` | Clickable | `text`, `draw_bg`, `draw_text`, `draw_icon` |155| `Label` | Text display | `text`, `draw_text` |156| `Image` | Image display | `source`, `fit` |157| `TextInput` | Text entry | `text`, `draw_text`, `draw_cursor`, `draw_selection` |158| `CheckBox` | Toggle | `text`, `selected` |159| `RadioButton` | Selection | `text`, `selected` |160| `Slider` | Value slider | `min`, `max`, `step` |161| `DropDown` | Select menu | `labels`, `selected` |162| `PortalList` | Virtual list | Efficient scrolling for large lists |163| `Modal` | Dialog | Overlay dialog boxes |164| `Tooltip` | Hint | Hover tooltips |165166## View Variants167168| Variant | Description |169|---------|-------------|170| `SolidView` | Solid background color |171| `RoundedView` | Rounded corners |172| `RoundedAllView` | Individual corner control |173| `RectView` | Rectangle with border/gradient |174| `CircleView` | Circle/ellipse shape |175| `GradientXView` | Horizontal gradient |176| `GradientYView` | Vertical gradient |177| `RoundedShadowView` | Rounded with shadow |178| `ScrollXView` | Horizontal scroll |179| `ScrollYView` | Vertical scroll |180| `ScrollXYView` | Both directions scroll |181| `CachedView` | Texture-cached |182183## Button Variants184185| Variant | Description |186|---------|-------------|187| `ButtonFlat` | Flat style |188| `ButtonFlatIcon` | Flat with icon |189| `ButtonFlatter` | No background |190| `ButtonGradientX` | Horizontal gradient |191| `ButtonGradientY` | Vertical gradient |192| `ButtonIcon` | Standard with icon |193194## ImageFit Values195196| Value | Description |197|-------|-------------|198| `Stretch` | Stretch to fill |199| `Contain` | Fit within, preserve ratio |200| `Cover` | Cover area, may crop |201| `Fill` | Fill without ratio |202203## When Writing Code2042051. Always set `width` and `height` on widgets2062. Use `show_bg: true` to enable background rendering2073. Access `draw_bg`, `draw_text`, `draw_icon` for shader uniforms2084. Use `dep("crate://self/...")` for resource paths2095. Choose appropriate View variant for visual needs210211## When Answering Questions2122131. Recommend UI Zoo example for widget exploration2142. View is the base container - most visual widgets inherit from it2153. Draw shaders (`draw_bg`, `draw_text`) control appearance2164. All widgets support animation through `animator` property217218## Limitations219- Use this skill only when the task clearly matches the scope described above.220- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.221- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.