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-widgets4---5
6# Makepad Widgets Skill
7
8> **Version:** makepad-widgets (dev branch) | **Last Updated:** 2026-01-19
9>
10> Check for updates: https://crates.io/crates/makepad-widgets
11
12You are an expert at Makepad widgets. Help users by:
13- **Writing code**: Generate widget code following the patterns below
14- **Answering questions**: Explain widget properties, variants, and usage
15
16## When to Use
17- You need to work with core or advanced widgets in Makepad.
18- The task involves widget selection, properties, variants, composition, or widget-specific behavior.
19- You want examples for `View`, `Button`, labels, rich text, or other `makepad-widgets` building blocks.
20
21## Documentation
22
23Refer to the local files for detailed documentation:
24- `./references/widgets-core.md` - Core widgets (View, Button, Label, etc.)
25- `./references/widgets-advanced.md` - Helper and advanced widgets
26- `./references/widgets-richtext.md` - Rich text widgets (Markdown, Html, TextFlow)
27
28## IMPORTANT: Documentation Completeness Check
29
30**Before answering questions, Claude MUST:**
31
321. Read the relevant reference file(s) listed above
332. 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 knowledge
363. If reference file exists, incorporate its content into the answer
37
38## Key Patterns
39
40### 1. View (Basic Container)
41
42```rust
43<View> {
44 width: Fill
45 height: Fill
46 flow: Down
47 padding: 16.0
48 show_bg: true
49 draw_bg: { color: #1A1A1A }
50
51 <Label> { text: "Content" }
52}
53```
54
55### 2. Button
56
57```rust
58<Button> {
59 text: "Click Me"
60 draw_bg: {
61 color: #0066CC
62 color_hover: #0088FF
63 border_radius: 4.0
64 }
65 draw_text: {
66 color: #FFFFFF
67 text_style: { font_size: 14.0 }
68 }
69}
70```
71
72### 3. Label with Styling
73
74```rust
75<Label> {
76 width: Fit
77 height: Fit
78 text: "Hello World"
79 draw_text: {
80 color: #FFFFFF
81 text_style: {
82 font_size: 16.0
83 line_spacing: 1.4
84 }
85 }
86}
87```
88
89### 4. Image
90
91```rust
92<Image> {
93 width: 200.0
94 height: 150.0
95 source: dep("crate://self/resources/photo.png")
96 fit: Contain
97}
98```
99
100### 5. TextInput
101
102```rust
103<TextInput> {
104 width: Fill
105 height: Fit
106 text: "Default value"
107 draw_text: {
108 text_style: { font_size: 14.0 }
109 }
110}
111```
112
113## Widget Traits (from source)
114
115```rust
116pub trait WidgetNode: LiveApply {
117 fn find_widgets(&self, path: &[LiveId], cached: WidgetCache, results: &mut WidgetSet);
118 fn walk(&mut self, cx: &mut Cx) -> Walk;
119 fn area(&self) -> Area;
120 fn redraw(&mut self, cx: &mut Cx);
121}
122
123pub trait Widget: WidgetNode {
124 fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {}
125 fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep;
126 fn draw(&mut self, cx: &mut Cx2d, scope: &mut Scope) -> DrawStep;
127 fn widget(&self, path: &[LiveId]) -> WidgetRef;
128}
129```
130
131## All Built-in Widgets (84 files in widgets/src/)
132
133| Category | Widgets |
134|----------|---------|
135| **Basic** | `View`, `Label`, `Button`, `Icon`, `Image` |
136| **Input** | `TextInput`, `CheckBox`, `RadioButton`, `Slider`, `DropDown`, `ColorPicker` |
137| **Container** | `ScrollBars`, `PortalList`, `FlatList`, `StackNavigation`, `Dock`, `Splitter` |
138| **Navigation** | `TabBar`, `Tab`, `FoldHeader`, `FoldButton`, `ExpandablePanel` |
139| **Overlay** | `Modal`, `Tooltip`, `PopupMenu`, `PopupNotification` |
140| **Media** | `Video`, `RotatedImage`, `ImageBlend`, `MultiImage` |
141| **Layout** | `AdaptiveView`, `SlidePanel`, `PageFlip`, `SlidesView` |
142| **Special** | `Markdown`, `Html`, `TextFlow`, `WebView`, `KeyboardView` |
143| **Utility** | `LoadingSpinner`, `DesktopButton`, `LinkLabel`, `ScrollShadow` |
144
145## Core Widgets Reference
146
147| Widget | Purpose | Key Properties |
148|--------|---------|----------------|
149| `View` | Container | `flow`, `align`, `show_bg`, `draw_bg`, `optimize` |
150| `Button` | Clickable | `text`, `draw_bg`, `draw_text`, `draw_icon` |
151| `Label` | Text display | `text`, `draw_text` |
152| `Image` | Image display | `source`, `fit` |
153| `TextInput` | Text entry | `text`, `draw_text`, `draw_cursor`, `draw_selection` |
154| `CheckBox` | Toggle | `text`, `selected` |
155| `RadioButton` | Selection | `text`, `selected` |
156| `Slider` | Value slider | `min`, `max`, `step` |
157| `DropDown` | Select menu | `labels`, `selected` |
158| `PortalList` | Virtual list | Efficient scrolling for large lists |
159| `Modal` | Dialog | Overlay dialog boxes |
160| `Tooltip` | Hint | Hover tooltips |
161
162## View Variants
163
164| Variant | Description |
165|---------|-------------|
166| `SolidView` | Solid background color |
167| `RoundedView` | Rounded corners |
168| `RoundedAllView` | Individual corner control |
169| `RectView` | Rectangle with border/gradient |
170| `CircleView` | Circle/ellipse shape |
171| `GradientXView` | Horizontal gradient |
172| `GradientYView` | Vertical gradient |
173| `RoundedShadowView` | Rounded with shadow |
174| `ScrollXView` | Horizontal scroll |
175| `ScrollYView` | Vertical scroll |
176| `ScrollXYView` | Both directions scroll |
177| `CachedView` | Texture-cached |
178
179## Button Variants
180
181| Variant | Description |
182|---------|-------------|
183| `ButtonFlat` | Flat style |
184| `ButtonFlatIcon` | Flat with icon |
185| `ButtonFlatter` | No background |
186| `ButtonGradientX` | Horizontal gradient |
187| `ButtonGradientY` | Vertical gradient |
188| `ButtonIcon` | Standard with icon |
189
190## ImageFit Values
191
192| Value | Description |
193|-------|-------------|
194| `Stretch` | Stretch to fill |
195| `Contain` | Fit within, preserve ratio |
196| `Cover` | Cover area, may crop |
197| `Fill` | Fill without ratio |
198
199## When Writing Code
200
2011. Always set `width` and `height` on widgets
2022. Use `show_bg: true` to enable background rendering
2033. Access `draw_bg`, `draw_text`, `draw_icon` for shader uniforms
2044. Use `dep("crate://self/...")` for resource paths
2055. Choose appropriate View variant for visual needs
206
207## When Answering Questions
208
2091. Recommend UI Zoo example for widget exploration
2102. View is the base container - most visual widgets inherit from it
2113. Draw shaders (`draw_bg`, `draw_text`) control appearance
2124. All widgets support animation through `animator` property
213
214## Limitations
215- Use this skill only when the task clearly matches the scope described above.
216- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
217- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.