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: Version: makepad-widgets (dev branch) | Last Updated: 2026-01-19 > > Check for updates: https://crates.io/crates/makepad-widgets4---56# Makepad Widgets Skill78> **Version:** makepad-widgets (dev branch) | **Last Updated:** 2026-01-199>10> Check for updates: https://crates.io/crates/makepad-widgets1112You are an expert at Makepad widgets. Help users by:13- **Writing code**: Generate widget code following the patterns below14- **Answering questions**: Explain widget properties, variants, and usage1516## Documentation1718Refer 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 widgets21- `./references/widgets-richtext.md` - Rich text widgets (Markdown, Html, TextFlow)2223## IMPORTANT: Documentation Completeness Check2425**Before answering questions, Claude MUST:**26271. Read the relevant reference file(s) listed above282. 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 knowledge313. If reference file exists, incorporate its content into the answer3233## Key Patterns3435### 1. View (Basic Container)3637```rust38<View> {39 width: Fill40 height: Fill41 flow: Down42 padding: 16.043 show_bg: true44 draw_bg: { color: #1A1A1A }4546 <Label> { text: "Content" }47}48```4950### 2. Button5152```rust53<Button> {54 text: "Click Me"55 draw_bg: {56 color: #0066CC57 color_hover: #0088FF58 border_radius: 4.059 }60 draw_text: {61 color: #FFFFFF62 text_style: { font_size: 14.0 }63 }64}65```6667### 3. Label with Styling6869```rust70<Label> {71 width: Fit72 height: Fit73 text: "Hello World"74 draw_text: {75 color: #FFFFFF76 text_style: {77 font_size: 16.078 line_spacing: 1.479 }80 }81}82```8384### 4. Image8586```rust87<Image> {88 width: 200.089 height: 150.090 source: dep("crate://self/resources/photo.png")91 fit: Contain92}93```9495### 5. TextInput9697```rust98<TextInput> {99 width: Fill100 height: Fit101 text: "Default value"102 draw_text: {103 text_style: { font_size: 14.0 }104 }105}106```107108## Widget Traits (from source)109110```rust111pub 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}117118pub 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```125126## All Built-in Widgets (84 files in widgets/src/)127128| 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` |139140## Core Widgets Reference141142| 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 |156157## View Variants158159| 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 |173174## Button Variants175176| 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 |184185## ImageFit Values186187| 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 |193194## When Writing Code1951961. Always set `width` and `height` on widgets1972. Use `show_bg: true` to enable background rendering1983. Access `draw_bg`, `draw_text`, `draw_icon` for shader uniforms1994. Use `dep("crate://self/...")` for resource paths2005. Choose appropriate View variant for visual needs201202## When Answering Questions2032041. Recommend UI Zoo example for widget exploration2052. View is the base container - most visual widgets inherit from it2063. Draw shaders (`draw_bg`, `draw_text`) control appearance2074. All widgets support animation through `animator` property