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
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for enprojectnment-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: 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## When to Use17- You need to work with core or advanced widgets in Makepad.18- The task involves widget selection, properties, variants, composition, or widget-specific behavior.19- You want examples for `View`, `Button`, labels, rich text, or other `makepad-widgets` building blocks.2021## Documentation2223Refer to the local files for detailed documentation:24- `./references/widgets-core.md` - Core widgets (View, Button, Label, etc.)25- `./references/widgets-advanced.md` - Helper and advanced widgets26- `./references/widgets-richtext.md` - Rich text widgets (Markdown, Html, TextFlow)2728## IMPORTANT: Documentation Completeness Check2930**Before answering questions, Claude MUST:**31321. Read the relevant reference file(s) listed above332. If file read fails or file is empty:34 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"35 - Still answer based on SKILL.md patterns + built-in knowledge363. If reference file exists, incorporate its content into the answer3738## Key Patterns3940### 1. View (Basic Container)4142```rust43<View> {44 width: Fill45 height: Fill46 flow: Down47 padding: 16.048 show_bg: true49 draw_bg: { color: #1A1A1A }5051 <Label> { text: "Content" }52}53```5455### 2. Button5657```rust58<Button> {59 text: "Click Me"60 draw_bg: {61 color: #0066CC62 color_hover: #0088FF63 border_radius: 4.064 }65 draw_text: {66 color: #FFFFFF67 text_style: { font_size: 14.0 }68 }69}70```7172### 3. Label with Styling7374```rust75<Label> {76 width: Fit77 height: Fit78 text: "Hello World"79 draw_text: {80 color: #FFFFFF81 text_style: {82 font_size: 16.083 line_spacing: 1.484 }85 }86}87```8889### 4. Image9091```rust92<Image> {93 width: 200.094 height: 150.095 source: dep("crate://self/resources/photo.png")96 fit: Contain97}98```99100### 5. TextInput101102```rust103<TextInput> {104 width: Fill105 height: Fit106 text: "Default value"107 draw_text: {108 text_style: { font_size: 14.0 }109 }110}111```112113## Widget Traits (from source)114115```rust116pub trait WidgetNode: LiveApply {117 fn find_widgets(&self, path: &[LiveId], cached: WidgetCache, results: &mut WidgetSet);118 fn walk(&mut self, cx: &mut Cx) -> Walk;119 fn area(&self) -> Area;120 fn redraw(&mut self, cx: &mut Cx);121}122123pub trait Widget: WidgetNode {124 fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {}125 fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep;126 fn draw(&mut self, cx: &mut Cx2d, scope: &mut Scope) -> DrawStep;127 fn widget(&self, path: &[LiveId]) -> WidgetRef;128}129```130131## All Built-in Widgets (84 files in widgets/src/)132133| Category | Widgets |134|----------|---------|135| **Basic** | `View`, `Label`, `Button`, `Icon`, `Image` |136| **Input** | `TextInput`, `CheckBox`, `RadioButton`, `Slider`, `DropDown`, `ColorPicker` |137| **Container** | `ScrollBars`, `PortalList`, `FlatList`, `StackNavigation`, `Dock`, `Splitter` |138| **Navigation** | `TabBar`, `Tab`, `FoldHeader`, `FoldButton`, `ExpandablePanel` |139| **Overlay** | `Modal`, `Tooltip`, `PopupMenu`, `PopupNotification` |140| **Media** | `Video`, `RotatedImage`, `ImageBlend`, `MultiImage` |141| **Layout** | `AdaptiveView`, `SlidePanel`, `PageFlip`, `SlidesView` |142| **Special** | `Markdown`, `Html`, `TextFlow`, `WebView`, `KeyboardView` |143| **Utility** | `LoadingSpinner`, `DesktopButton`, `LinkLabel`, `ScrollShadow` |144145## Core Widgets Reference146147| Widget | Purpose | Key Properties |148|--------|---------|----------------|149| `View` | Container | `flow`, `align`, `show_bg`, `draw_bg`, `optimize` |150| `Button` | Clickable | `text`, `draw_bg`, `draw_text`, `draw_icon` |151| `Label` | Text display | `text`, `draw_text` |152| `Image` | Image display | `source`, `fit` |153| `TextInput` | Text entry | `text`, `draw_text`, `draw_cursor`, `draw_selection` |154| `CheckBox` | Toggle | `text`, `selected` |155| `RadioButton` | Selection | `text`, `selected` |156| `Slider` | Value slider | `min`, `max`, `step` |157| `DropDown` | Select menu | `labels`, `selected` |158| `PortalList` | Virtual list | Efficient scrolling for large lists |159| `Modal` | Dialog | Overlay dialog boxes |160| `Tooltip` | Hint | Hover tooltips |161162## View Variants163164| Variant | Description |165|---------|-------------|166| `SolidView` | Solid background color |167| `RoundedView` | Rounded corners |168| `RoundedAllView` | Individual corner control |169| `RectView` | Rectangle with border/gradient |170| `CircleView` | Circle/ellipse shape |171| `GradientXView` | Horizontal gradient |172| `GradientYView` | Vertical gradient |173| `RoundedShadowView` | Rounded with shadow |174| `ScrollXView` | Horizontal scroll |175| `ScrollYView` | Vertical scroll |176| `ScrollXYView` | Both directions scroll |177| `CachedView` | Texture-cached |178179## Button Variants180181| Variant | Description |182|---------|-------------|183| `ButtonFlat` | Flat style |184| `ButtonFlatIcon` | Flat with icon |185| `ButtonFlatter` | No background |186| `ButtonGradientX` | Horizontal gradient |187| `ButtonGradientY` | Vertical gradient |188| `ButtonIcon` | Standard with icon |189190## ImageFit Values191192| Value | Description |193|-------|-------------|194| `Stretch` | Stretch to fill |195| `Contain` | Fit within, preserve ratio |196| `Cover` | Cover area, may crop |197| `Fill` | Fill without ratio |198199## When Writing Code2002011. Always set `width` and `height` on widgets2022. Use `show_bg: true` to enable background rendering2033. Access `draw_bg`, `draw_text`, `draw_icon` for shader uniforms2044. Use `dep("crate://self/...")` for resource paths2055. Choose appropriate View variant for visual needs206207## When Answering Questions2082091. Recommend UI Zoo example for widget exploration2102. View is the base container - most visual widgets inherit from it2113. Draw shaders (`draw_bg`, `draw_text`) control appearance2124. All widgets support animation through `animator` property213214## Limitations215- Use this skill only when the task clearly matches the scope described above.216- Do not treat the output as a substitute for enprojectnment-specific validation, testing, or expert review.217- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.