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 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: Version: makepad-widgets (dev branch) | Last Updated: 2026-01-19 > > Check for updates: https://crates.io/crates/makepad-widgets4license: MIT5---67# Makepad Widgets Skill89> **Version:** makepad-widgets (dev branch) | **Last Updated:** 2026-01-1910>11> Check for updates: https://crates.io/crates/makepad-widgets1213You are an expert at Makepad widgets. Help users by:14- **Writing code**: Generate widget code following the patterns below15- **Answering questions**: Explain widget properties, variants, and usage1617## When to Use18- You need to work with core or advanced widgets in Makepad.19- The task involves widget selection, properties, variants, composition, or widget-specific behavior.20- You want examples for `View`, `Button`, labels, rich text, or other `makepad-widgets` building blocks.2122## Documentation2324Refer to the local files for detailed documentation:25- `./references/widgets-core.md` - Core widgets (View, Button, Label, etc.)26- `./references/widgets-advanced.md` - Helper and advanced widgets27- `./references/widgets-richtext.md` - Rich text widgets (Markdown, Html, TextFlow)2829## IMPORTANT: Documentation Completeness Check3031**Before answering questions, Claude MUST:**32331. Read the relevant reference file(s) listed above342. If file read fails or file is empty:35 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"36 - Still answer based on SKILL.md patterns + built-in knowledge373. If reference file exists, incorporate its content into the answer3839## Key Patterns4041### 1. View (Basic Container)4243```rust44<View> {45 width: Fill46 height: Fill47 flow: Down48 padding: 16.049 show_bg: true50 draw_bg: { color: #1A1A1A }5152 <Label> { text: "Content" }53}54```5556### 2. Button5758```rust59<Button> {60 text: "Click Me"61 draw_bg: {62 color: #0066CC63 color_hover: #0088FF64 border_radius: 4.065 }66 draw_text: {67 color: #FFFFFF68 text_style: { font_size: 14.0 }69 }70}71```7273### 3. Label with Styling7475```rust76<Label> {77 width: Fit78 height: Fit79 text: "Hello World"80 draw_text: {81 color: #FFFFFF82 text_style: {83 font_size: 16.084 line_spacing: 1.485 }86 }87}88```8990### 4. Image9192```rust93<Image> {94 width: 200.095 height: 150.096 source: dep("crate://self/resources/photo.png")97 fit: Contain98}99```100101### 5. TextInput102103```rust104<TextInput> {105 width: Fill106 height: Fit107 text: "Default value"108 draw_text: {109 text_style: { font_size: 14.0 }110 }111}112```113114## Widget Traits (from source)115116```rust117pub trait WidgetNode: LiveApply {118 fn find_widgets(&self, path: &[LiveId], cached: WidgetCache, results: &mut WidgetSet);119 fn walk(&mut self, cx: &mut Cx) -> Walk;120 fn area(&self) -> Area;121 fn redraw(&mut self, cx: &mut Cx);122}123124pub trait Widget: WidgetNode {125 fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {}126 fn draw_walk(&mut self, cx: &mut Cx2d, scope: &mut Scope, walk: Walk) -> DrawStep;127 fn draw(&mut self, cx: &mut Cx2d, scope: &mut Scope) -> DrawStep;128 fn widget(&self, path: &[LiveId]) -> WidgetRef;129}130```131132## All Built-in Widgets (84 files in widgets/src/)133134| Category | Widgets |135|----------|---------|136| **Basic** | `View`, `Label`, `Button`, `Icon`, `Image` |137| **Input** | `TextInput`, `CheckBox`, `RadioButton`, `Slider`, `DropDown`, `ColorPicker` |138| **Container** | `ScrollBars`, `PortalList`, `FlatList`, `StackNavigation`, `Dock`, `Splitter` |139| **Navigation** | `TabBar`, `Tab`, `FoldHeader`, `FoldButton`, `ExpandablePanel` |140| **Overlay** | `Modal`, `Tooltip`, `PopupMenu`, `PopupNotification` |141| **Media** | `Video`, `RotatedImage`, `ImageBlend`, `MultiImage` |142| **Layout** | `AdaptiveView`, `SlidePanel`, `PageFlip`, `SlidesView` |143| **Special** | `Markdown`, `Html`, `TextFlow`, `WebView`, `KeyboardView` |144| **Utility** | `LoadingSpinner`, `DesktopButton`, `LinkLabel`, `ScrollShadow` |145146## Core Widgets Reference147148| Widget | Purpose | Key Properties |149|--------|---------|----------------|150| `View` | Container | `flow`, `align`, `show_bg`, `draw_bg`, `optimize` |151| `Button` | Clickable | `text`, `draw_bg`, `draw_text`, `draw_icon` |152| `Label` | Text display | `text`, `draw_text` |153| `Image` | Image display | `source`, `fit` |154| `TextInput` | Text entry | `text`, `draw_text`, `draw_cursor`, `draw_selection` |155| `CheckBox` | Toggle | `text`, `selected` |156| `RadioButton` | Selection | `text`, `selected` |157| `Slider` | Value slider | `min`, `max`, `step` |158| `DropDown` | Select menu | `labels`, `selected` |159| `PortalList` | Virtual list | Efficient scrolling for large lists |160| `Modal` | Dialog | Overlay dialog boxes |161| `Tooltip` | Hint | Hover tooltips |162163## View Variants164165| Variant | Description |166|---------|-------------|167| `SolidView` | Solid background color |168| `RoundedView` | Rounded corners |169| `RoundedAllView` | Individual corner control |170| `RectView` | Rectangle with border/gradient |171| `CircleView` | Circle/ellipse shape |172| `GradientXView` | Horizontal gradient |173| `GradientYView` | Vertical gradient |174| `RoundedShadowView` | Rounded with shadow |175| `ScrollXView` | Horizontal scroll |176| `ScrollYView` | Vertical scroll |177| `ScrollXYView` | Both directions scroll |178| `CachedView` | Texture-cached |179180## Button Variants181182| Variant | Description |183|---------|-------------|184| `ButtonFlat` | Flat style |185| `ButtonFlatIcon` | Flat with icon |186| `ButtonFlatter` | No background |187| `ButtonGradientX` | Horizontal gradient |188| `ButtonGradientY` | Vertical gradient |189| `ButtonIcon` | Standard with icon |190191## ImageFit Values192193| Value | Description |194|-------|-------------|195| `Stretch` | Stretch to fill |196| `Contain` | Fit within, preserve ratio |197| `Cover` | Cover area, may crop |198| `Fill` | Fill without ratio |199200## When Writing Code2012021. Always set `width` and `height` on widgets2032. Use `show_bg: true` to enable background rendering2043. Access `draw_bg`, `draw_text`, `draw_icon` for shader uniforms2054. Use `dep("crate://self/...")` for resource paths2065. Choose appropriate View variant for visual needs207208## When Answering Questions2092101. Recommend UI Zoo example for widget exploration2112. View is the base container - most visual widgets inherit from it2123. Draw shaders (`draw_bg`, `draw_text`) control appearance2134. All widgets support animation through `animator` property214215## Limitations216- Use this skill only when the task clearly matches the scope described above.217- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.218- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.