Introduction
Widgets are the building blocks of Iced applications. They provide interactive components that users can see and interact with. Each widget is generic over aMessage type, allowing it to produce application-specific messages when interacted with.
Core Widget Concepts
Message Production
Widgets communicate with your application through messages. When a user interacts with a widget (clicking a button, typing in a text input, etc.), the widget produces a message that your application’supdate function can handle.
Widget Lifecycle
Every widget implements theWidget trait, which provides methods for:
- Layout: Computing the size and position of the widget
- Event handling: Responding to user interactions
- Drawing: Rendering the widget on screen
- Styling: Customizing the visual appearance
Available Widgets
Interactive Widgets
Button
A clickable button that produces messages when pressed
Checkbox
A toggleable checkbox for binary choices
Text Input
A field for entering text with support for passwords and validation
Slider
A horizontal bar for selecting values from a range
Layout Widgets
Container
A widget that aligns and decorates its contents
Scrollable
A scrollable container for displaying large amounts of content
Common Patterns
Disabled States
Many widgets can be disabled by not providing an event handler:Styling
All widgets support custom styling through thestyle method:
Builder Pattern
Widgets use a fluent builder pattern for configuration:Next Steps
Button
Learn about button widgets and interactions
Layout Guide
Understand how to arrange widgets
