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
When to Use
This skill is applicable to execute the workflow or actions described in the overview.
1---2name: makepad-widgets3description: 'Version: makepad-widgets (dev branch) | Last Updated: 2026-01-19 > >4 Check for updates: https://crates.io/crates/makepad-widgets'5risk: safe6source: community7license: MIT8metadata:9 source: https://skillmd.com/skills/jantoniofc/makepad-widgets10---1112# Makepad Widgets Skill1314> **Version:** makepad-widgets (dev branch) | **Last Updated:** 2026-01-1915>16> Check for updates: https://crates.io/crates/makepad-widgets1718You are an expert at Makepad widgets. Help users by:19- **Writing code**: Generate widget code following the patterns below20- **Answering questions**: Explain widget properties, variants, and usage2122## When to Use23- You need to work with core or advanced widgets in Makepad.24- The task involves widget selection, properties, variants, composition, or widget-specific behavior.25- You want examples for `View`, `Button`, labels, rich text, or other `makepad-widgets` building blocks.2627## Documentation2829Refer to the local files for detailed documentation:30- `./references/widgets-core.md` - Core widgets (View, Button, Label, etc.)31- `./references/widgets-advanced.md` - Helper and advanced widgets32- `./references/widgets-richtext.md` - Rich text widgets (Markdown, Html, TextFlow)3334## IMPORTANT: Documentation Completeness Check3536**Before answering questions, Claude MUST:**37381. Read the relevant reference file(s) listed above392. If file read fails or file is empty:40 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"41 - Still answer based on SKILL.md patterns + built-in knowledge423. If reference file exists, incorporate its content into the answer4344## Key Patterns4546### 1. View (Basic Container)4748```rust49<View> {50 width: Fill51 height: Fill52 flow: Down53 padding: 16.054 show_bg: true55 draw_bg: { color: #1A1A1A }5657 <Label> { text: "Content" }58}59```6061### 2. Button6263```rust64<Button> {65 text: "Click Me"66 draw_bg: {67 color: #0066CC68 color_hover: #0088FF69 border_radius: 4.070 }71 draw_text: {72 color: #FFFFFF73 text_style: { font_size: 14.0 }74 }75}76```7778### 3. Label with Styling7980```rust81<Label> {82 width: Fit83 height: Fit84 text: "Hello World"85 draw_text: {86 color: #FFFFFF87 text_style: {88 font_size: 16.089 line_spacing: 1.490 }91 }92}93```9495### 4. Image9697```rust98<Image> {99 width: 200.0100 height: 150.0101 source: dep("crate://self/resources/photo.png")102 fit: Contain103}104```105106### 5. TextInput107108```rust109<TextInput> {110 width: Fill111 height: Fit112 text: "Default value"113 draw_text: {114 text_style: { font_size: 14.0 }115 }116}117```118119## Widget Traits (from source)120121```rust122pub trait WidgetNode: LiveApply {123 fn find_widgets(&self, path: &[LiveId], cached: WidgetCache, results: &mut WidgetSet);124 fn walk(&mut self, cx: &mut Cx) -> Walk;125 fn area(&self) -> Area;126 fn redraw(&mut self, cx: &mut Cx);127}128129pub trait Widget: WidgetNode {130 fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {}131 fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep;132 fn draw(&mut self, cx: &mut Cx2d, scope: &mut Scope) -> DrawStep;133 fn widget(&self, path: &[LiveId]) -> WidgetRef;134}135```136137## All Built-in Widgets (84 files in widgets/src/)138139| Category | Widgets |140|----------|---------|141| **Basic** | `View`, `Label`, `Button`, `Icon`, `Image` |142| **Input** | `TextInput`, `CheckBox`, `RadioButton`, `Slider`, `DropDown`, `ColorPicker` |143| **Container** | `ScrollBars`, `PortalList`, `FlatList`, `StackNavigation`, `Dock`, `Splitter` |144| **Navigation** | `TabBar`, `Tab`, `FoldHeader`, `FoldButton`, `ExpandablePanel` |145| **Overlay** | `Modal`, `Tooltip`, `PopupMenu`, `PopupNotification` |146| **Media** | `Video`, `RotatedImage`, `ImageBlend`, `MultiImage` |147| **Layout** | `AdaptiveView`, `SlidePanel`, `PageFlip`, `SlidesView` |148| **Special** | `Markdown`, `Html`, `TextFlow`, `WebView`, `KeyboardView` |149| **Utility** | `LoadingSpinner`, `DesktopButton`, `LinkLabel`, `ScrollShadow` |150151## Core Widgets Reference152153| Widget | Purpose | Key Properties |154|--------|---------|----------------|155| `View` | Container | `flow`, `align`, `show_bg`, `draw_bg`, `optimize` |156| `Button` | Clickable | `text`, `draw_bg`, `draw_text`, `draw_icon` |157| `Label` | Text display | `text`, `draw_text` |158| `Image` | Image display | `source`, `fit` |159| `TextInput` | Text entry | `text`, `draw_text`, `draw_cursor`, `draw_selection` |160| `CheckBox` | Toggle | `text`, `selected` |161| `RadioButton` | Selection | `text`, `selected` |162| `Slider` | Value slider | `min`, `max`, `step` |163| `DropDown` | Select menu | `labels`, `selected` |164| `PortalList` | Virtual list | Efficient scrolling for large lists |165| `Modal` | Dialog | Overlay dialog boxes |166| `Tooltip` | Hint | Hover tooltips |167168## View Variants169170| Variant | Description |171|---------|-------------|172| `SolidView` | Solid background color |173| `RoundedView` | Rounded corners |174| `RoundedAllView` | Individual corner control |175| `RectView` | Rectangle with border/gradient |176| `CircleView` | Circle/ellipse shape |177| `GradientXView` | Horizontal gradient |178| `GradientYView` | Vertical gradient |179| `RoundedShadowView` | Rounded with shadow |180| `ScrollXView` | Horizontal scroll |181| `ScrollYView` | Vertical scroll |182| `ScrollXYView` | Both directions scroll |183| `CachedView` | Texture-cached |184185## Button Variants186187| Variant | Description |188|---------|-------------|189| `ButtonFlat` | Flat style |190| `ButtonFlatIcon` | Flat with icon |191| `ButtonFlatter` | No background |192| `ButtonGradientX` | Horizontal gradient |193| `ButtonGradientY` | Vertical gradient |194| `ButtonIcon` | Standard with icon |195196## ImageFit Values197198| Value | Description |199|-------|-------------|200| `Stretch` | Stretch to fill |201| `Contain` | Fit within, preserve ratio |202| `Cover` | Cover area, may crop |203| `Fill` | Fill without ratio |204205## When Writing Code2062071. Always set `width` and `height` on widgets2082. Use `show_bg: true` to enable background rendering2093. Access `draw_bg`, `draw_text`, `draw_icon` for shader uniforms2104. Use `dep("crate://self/...")` for resource paths2115. Choose appropriate View variant for visual needs212213## When Answering Questions2142151. Recommend UI Zoo example for widget exploration2162. View is the base container - most visual widgets inherit from it2173. Draw shaders (`draw_bg`, `draw_text`) control appearance2184. All widgets support animation through `animator` property219220## When to Use221This skill is applicable to execute the workflow or actions described in the overview.