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
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
1---2name: makepad-widgets3description: CRITICAL: Use for Makepad widgets and UI components. Triggers on: makepad widget, makepad View, makepad Button, makepad Label, makepad Image, makepad TextInput, RoundedView, SolidView, ScrollView, "makepad component", makepad Markdown, makepad Html, TextFlow, rich text, 富文本, markdown渲染, makepad 组件, makepad 按钮, makepad 列表, makepad 视图, makepad 输入框4---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## Documentation
17
18Refer to the local files for detailed documentation:
19- `./references/widgets-core.md` - Core widgets (View, Button, Label, etc.)
20- `./references/widgets-advanced.md` - Helper and advanced widgets
21- `./references/widgets-richtext.md` - Rich text widgets (Markdown, Html, TextFlow)
22
23## IMPORTANT: Documentation Completeness Check
24
25**Before answering questions, Claude MUST:**
26
271. Read the relevant reference file(s) listed above
282. If file read fails or file is empty:
29 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"
30 - Still answer based on SKILL.md patterns + built-in knowledge
313. If reference file exists, incorporate its content into the answer
32
33## Key Patterns
34
35### 1. View (Basic Container)
36
37```rust
38<View> {
39 width: Fill
40 height: Fill
41 flow: Down
42 padding: 16.0
43 show_bg: true
44 draw_bg: { color: #1A1A1A }
45
46 <Label> { text: "Content" }
47}
48```
49
50### 2. Button
51
52```rust
53<Button> {
54 text: "Click Me"
55 draw_bg: {
56 color: #0066CC
57 color_hover: #0088FF
58 border_radius: 4.0
59 }
60 draw_text: {
61 color: #FFFFFF
62 text_style: { font_size: 14.0 }
63 }
64}
65```
66
67### 3. Label with Styling
68
69```rust
70<Label> {
71 width: Fit
72 height: Fit
73 text: "Hello World"
74 draw_text: {
75 color: #FFFFFF
76 text_style: {
77 font_size: 16.0
78 line_spacing: 1.4
79 }
80 }
81}
82```
83
84### 4. Image
85
86```rust
87<Image> {
88 width: 200.0
89 height: 150.0
90 source: dep("crate://self/resources/photo.png")
91 fit: Contain
92}
93```
94
95### 5. TextInput
96
97```rust
98<TextInput> {
99 width: Fill
100 height: Fit
101 text: "Default value"
102 draw_text: {
103 text_style: { font_size: 14.0 }
104 }
105}
106```
107
108## Widget Traits (from source)
109
110```rust
111pub trait WidgetNode: LiveApply {
112 fn find_widgets(&self, path: &[LiveId], cached: WidgetCache, results: &mut WidgetSet);
113 fn walk(&mut self, cx: &mut Cx) -> Walk;
114 fn area(&self) -> Area;
115 fn redraw(&mut self, cx: &mut Cx);
116}
117
118pub trait Widget: WidgetNode {
119 fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {}
120 fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep;
121 fn draw(&mut self, cx: &mut Cx2d, scope: &mut Scope) -> DrawStep;
122 fn widget(&self, path: &[LiveId]) -> WidgetRef;
123}
124```
125
126## All Built-in Widgets (84 files in widgets/src/)
127
128| Category | Widgets |
129|----------|---------|
130| **Basic** | `View`, `Label`, `Button`, `Icon`, `Image` |
131| **Input** | `TextInput`, `CheckBox`, `RadioButton`, `Slider`, `DropDown`, `ColorPicker` |
132| **Container** | `ScrollBars`, `PortalList`, `FlatList`, `StackNavigation`, `Dock`, `Splitter` |
133| **Navigation** | `TabBar`, `Tab`, `FoldHeader`, `FoldButton`, `ExpandablePanel` |
134| **Overlay** | `Modal`, `Tooltip`, `PopupMenu`, `PopupNotification` |
135| **Media** | `Video`, `RotatedImage`, `ImageBlend`, `MultiImage` |
136| **Layout** | `AdaptiveView`, `SlidePanel`, `PageFlip`, `SlidesView` |
137| **Special** | `Markdown`, `Html`, `TextFlow`, `WebView`, `KeyboardView` |
138| **Utility** | `LoadingSpinner`, `DesktopButton`, `LinkLabel`, `ScrollShadow` |
139
140## Core Widgets Reference
141
142| Widget | Purpose | Key Properties |
143|--------|---------|----------------|
144| `View` | Container | `flow`, `align`, `show_bg`, `draw_bg`, `optimize` |
145| `Button` | Clickable | `text`, `draw_bg`, `draw_text`, `draw_icon` |
146| `Label` | Text display | `text`, `draw_text` |
147| `Image` | Image display | `source`, `fit` |
148| `TextInput` | Text entry | `text`, `draw_text`, `draw_cursor`, `draw_selection` |
149| `CheckBox` | Toggle | `text`, `selected` |
150| `RadioButton` | Selection | `text`, `selected` |
151| `Slider` | Value slider | `min`, `max`, `step` |
152| `DropDown` | Select menu | `labels`, `selected` |
153| `PortalList` | Virtual list | Efficient scrolling for large lists |
154| `Modal` | Dialog | Overlay dialog boxes |
155| `Tooltip` | Hint | Hover tooltips |
156
157## View Variants
158
159| Variant | Description |
160|---------|-------------|
161| `SolidView` | Solid background color |
162| `RoundedView` | Rounded corners |
163| `RoundedAllView` | Individual corner control |
164| `RectView` | Rectangle with border/gradient |
165| `CircleView` | Circle/ellipse shape |
166| `GradientXView` | Horizontal gradient |
167| `GradientYView` | Vertical gradient |
168| `RoundedShadowView` | Rounded with shadow |
169| `ScrollXView` | Horizontal scroll |
170| `ScrollYView` | Vertical scroll |
171| `ScrollXYView` | Both directions scroll |
172| `CachedView` | Texture-cached |
173
174## Button Variants
175
176| Variant | Description |
177|---------|-------------|
178| `ButtonFlat` | Flat style |
179| `ButtonFlatIcon` | Flat with icon |
180| `ButtonFlatter` | No background |
181| `ButtonGradientX` | Horizontal gradient |
182| `ButtonGradientY` | Vertical gradient |
183| `ButtonIcon` | Standard with icon |
184
185## ImageFit Values
186
187| Value | Description |
188|-------|-------------|
189| `Stretch` | Stretch to fill |
190| `Contain` | Fit within, preserve ratio |
191| `Cover` | Cover area, may crop |
192| `Fill` | Fill without ratio |
193
194## When Writing Code
195
1961. Always set `width` and `height` on widgets
1972. Use `show_bg: true` to enable background rendering
1983. Access `draw_bg`, `draw_text`, `draw_icon` for shader uniforms
1994. Use `dep("crate://self/...")` for resource paths
2005. Choose appropriate View variant for visual needs
201
202## When Answering Questions
203
2041. Recommend UI Zoo example for widget exploration
2052. View is the base container - most visual widgets inherit from it
2063. Draw shaders (`draw_bg`, `draw_text`) control appearance
2074. All widgets support animation through `animator` property