FlowLayout
Custom SwiftUI Layout that wraps children to next line (like CSS flex-wrap).
Usage
FlowLayout(spacing: 8) {
ForEach(items) { item in
TagButton(item)
}
} Behavior
- Lays out children horizontally
- When width exceeded, wraps to next row
- Maintains consistent spacing between items
- Adapts to container width
Implementation
Implements SwiftUI Layout protocol:
sizeThatFits(): Calculates total height neededplaceSubviews(): Positions each child
Known Issues
Context menu closures evaluated once at build time (SwiftUI bug). Workaround: Use Menu with primaryAction instead of contextMenu.
Used By
- 409-tag-filter - Tag toggle buttons
- 409-tag-combo-box - Tag selector
Related
- 409-tag-filter - Primary usage
- 402-ios - UI architecture