Makepad Widgets Skill
Selective Reading Rule
Start with:
references/senior-master-standard.md
references/usage-routing.md
references/quality-checklist.md
Then load only the inherited docs, scripts, assets, or examples that match the user's actual task.
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: ALWAYS use this when the request matches Makepad Widgets: Version: makepad-widgets (dev branch) | Last Updated: 2026-01-19 > > Check for updates: https://crates.io/crates/makepad-widgets4---56# Makepad Widgets Skill78## Selective Reading Rule910Start with:1112- `references/senior-master-standard.md`13- `references/usage-routing.md`14- `references/quality-checklist.md`1516Then load only the inherited docs, scripts, assets, or examples that match the user's actual task.1718> **Version:** makepad-widgets (dev branch) | **Last Updated:** 2026-01-1919>20> Check for updates: https://crates.io/crates/makepad-widgets2122You are an expert at Makepad widgets. Help users by:23- **Writing code**: Generate widget code following the patterns below24- **Answering questions**: Explain widget properties, variants, and usage2526## When to Use27- You need to work with core or advanced widgets in Makepad.28- The task involves widget selection, properties, variants, composition, or widget-specific behavior.29- You want examples for `View`, `Button`, labels, rich text, or other `makepad-widgets` building blocks.3031## Documentation3233Refer to the local files for detailed documentation:34- `./references/widgets-core.md` - Core widgets (View, Button, Label, etc.)35- `./references/widgets-advanced.md` - Helper and advanced widgets36- `./references/widgets-richtext.md` - Rich text widgets (Markdown, Html, TextFlow)3738## IMPORTANT: Documentation Completeness Check3940**Before answering questions, Claude MUST:**41421. Read the relevant reference file(s) listed above432. If file read fails or file is empty:44 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"45 - Still answer based on SKILL.md patterns + built-in knowledge463. If reference file exists, incorporate its content into the answer4748## Key Patterns4950### 1. View (Basic Container)5152```rust53<View> {54 width: Fill55 height: Fill56 flow: Down57 padding: 16.058 show_bg: true59 draw_bg: { color: #1A1A1A }6061 <Label> { text: "Content" }62}63```6465### 2. Button6667```rust68<Button> {69 text: "Click Me"70 draw_bg: {71 color: #0066CC72 color_hover: #0088FF73 border_radius: 4.074 }75 draw_text: {76 color: #FFFFFF77 text_style: { font_size: 14.0 }78 }79}80```8182### 3. Label with Styling8384```rust85<Label> {86 width: Fit87 height: Fit88 text: "Hello World"89 draw_text: {90 color: #FFFFFF91 text_style: {92 font_size: 16.093 line_spacing: 1.494 }95 }96}97```9899### 4. Image100101```rust102<Image> {103 width: 200.0104 height: 150.0105 source: dep("crate://self/resources/photo.png")106 fit: Contain107}108```109110### 5. TextInput111112```rust113<TextInput> {114 width: Fill115 height: Fit116 text: "Default value"117 draw_text: {118 text_style: { font_size: 14.0 }119 }120}121```122123## Widget Traits (from source)124125```rust126pub trait WidgetNode: LiveApply {127 fn find_widgets(&self, path: &[LiveId], cached: WidgetCache, results: &mut WidgetSet);128 fn walk(&mut self, cx: &mut Cx) -> Walk;129 fn area(&self) -> Area;130 fn redraw(&mut self, cx: &mut Cx);131}132133pub trait Widget: WidgetNode {134 fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {}135 fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep;136 fn draw(&mut self, cx: &mut Cx2d, scope: &mut Scope) -> DrawStep;137 fn widget(&self, path: &[LiveId]) -> WidgetRef;138}139```140141## All Built-in Widgets (84 files in widgets/src/)142143| Category | Widgets |144|----------|---------|145| **Basic** | `View`, `Label`, `Button`, `Icon`, `Image` |146| **Input** | `TextInput`, `CheckBox`, `RadioButton`, `Slider`, `DropDown`, `ColorPicker` |147| **Container** | `ScrollBars`, `PortalList`, `FlatList`, `StackNavigation`, `Dock`, `Splitter` |148| **Navigation** | `TabBar`, `Tab`, `FoldHeader`, `FoldButton`, `ExpandablePanel` |149| **Overlay** | `Modal`, `Tooltip`, `PopupMenu`, `PopupNotification` |150| **Media** | `Video`, `RotatedImage`, `ImageBlend`, `MultiImage` |151| **Layout** | `AdaptiveView`, `SlidePanel`, `PageFlip`, `SlidesView` |152| **Special** | `Markdown`, `Html`, `TextFlow`, `WebView`, `KeyboardView` |153| **Utility** | `LoadingSpinner`, `DesktopButton`, `LinkLabel`, `ScrollShadow` |154155## Core Widgets Reference156157| Widget | Purpose | Key Properties |158|--------|---------|----------------|159| `View` | Container | `flow`, `align`, `show_bg`, `draw_bg`, `optimize` |160| `Button` | Clickable | `text`, `draw_bg`, `draw_text`, `draw_icon` |161| `Label` | Text display | `text`, `draw_text` |162| `Image` | Image display | `source`, `fit` |163| `TextInput` | Text entry | `text`, `draw_text`, `draw_cursor`, `draw_selection` |164| `CheckBox` | Toggle | `text`, `selected` |165| `RadioButton` | Selection | `text`, `selected` |166| `Slider` | Value slider | `min`, `max`, `step` |167| `DropDown` | Select menu | `labels`, `selected` |168| `PortalList` | Virtual list | Efficient scrolling for large lists |169| `Modal` | Dialog | Overlay dialog boxes |170| `Tooltip` | Hint | Hover tooltips |171172## View Variants173174| Variant | Description |175|---------|-------------|176| `SolidView` | Solid background color |177| `RoundedView` | Rounded corners |178| `RoundedAllView` | Individual corner control |179| `RectView` | Rectangle with border/gradient |180| `CircleView` | Circle/ellipse shape |181| `GradientXView` | Horizontal gradient |182| `GradientYView` | Vertical gradient |183| `RoundedShadowView` | Rounded with shadow |184| `ScrollXView` | Horizontal scroll |185| `ScrollYView` | Vertical scroll |186| `ScrollXYView` | Both directions scroll |187| `CachedView` | Texture-cached |188189## Button Variants190191| Variant | Description |192|---------|-------------|193| `ButtonFlat` | Flat style |194| `ButtonFlatIcon` | Flat with icon |195| `ButtonFlatter` | No background |196| `ButtonGradientX` | Horizontal gradient |197| `ButtonGradientY` | Vertical gradient |198| `ButtonIcon` | Standard with icon |199200## ImageFit Values201202| Value | Description |203|-------|-------------|204| `Stretch` | Stretch to fill |205| `Contain` | Fit within, preserve ratio |206| `Cover` | Cover area, may crop |207| `Fill` | Fill without ratio |208209## When Writing Code2102111. Always set `width` and `height` on widgets2122. Use `show_bg: true` to enable background rendering2133. Access `draw_bg`, `draw_text`, `draw_icon` for shader uniforms2144. Use `dep("crate://self/...")` for resource paths2155. Choose appropriate View variant for visual needs216217## When Answering Questions2182191. Recommend UI Zoo example for widget exploration2202. View is the base container - most visual widgets inherit from it2213. Draw shaders (`draw_bg`, `draw_text`) control appearance2224. All widgets support animation through `animator` property223224## Limitations225- Use this skill only when the task clearly matches the scope described above.226- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.227- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.