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