Row and Column are the fundamental layout widgets in Iced. They arrange their children in a linear fashion - Row horizontally and Column vertically.
Row Widget
Distributes children horizontally from left to right.Basic Usage
Row Methods
new()
Creates an empty row.
with_children(children: impl IntoIterator<Item = Element>)
Creates a row with the given children.
spacing(amount: impl Into<Pixels>)
Sets horizontal spacing between elements.
padding(padding: impl Into<Padding>)
Sets padding around all children.
width(width: impl Into<Length>)
Sets the row width.
height(height: impl Into<Length>)
Sets the row height.
align_y(align: alignment::Vertical)
Sets vertical alignment of children.
clip(clip: bool)
Sets whether children should be clipped on overflow.
push(child: impl Into<Element>)
Adds a child to the row.
extend(children: impl IntoIterator<Item = Element>)
Adds multiple children to the row.
Wrapping Row
Column Widget
Distributes children vertically from top to bottom.Basic Usage
Column Methods
new()
Creates an empty column.
with_children(children: impl IntoIterator<Item = Element>)
Creates a column with the given children.
spacing(amount: impl Into<Pixels>)
Sets vertical spacing between elements.
padding(padding: impl Into<Padding>)
Sets padding around all children.
width(width: impl Into<Length>)
Sets the column width.
height(height: impl Into<Length>)
Sets the column height.
max_width(max_width: impl Into<Pixels>)
Sets the maximum width.
align_x(align: alignment::Horizontal)
Sets horizontal alignment of children.
clip(clip: bool)
Sets whether children should be clipped on overflow.
push(child: impl Into<Element>)
Adds a child to the column.
Wrapping Column
Using the Macros
Both widgets have convenient macros for quick construction:Common Patterns
Navigation Bar
Form Layout
Sidebar Layout
Toolbar with Groups
Centered Content
Grid-like Layout
Tips and Best Practices
- Use macros for readability -
row![]andcolumn![]are more concise - Set consistent spacing - Use the same spacing values throughout your app
- Use Length::Fill wisely - It expands to fill available space
- Combine with containers - Add padding and styling with containers
- Mind the alignment - Use
align_xandalign_yfor proper positioning - Use wrapping for responsive layouts -
.wrap()creates flexible layouts
Related Widgets
- Container - For single child with alignment
- Scrollable - For scrollable content
- Grid - For proper grid layouts
- Stack - For layered content
