LazyHStack(children: Component): Component;
LazyHStack(children: Component[]): Component;
LazyHStack(props: { spacing?: number, alignment?: VerticalAlignment, pinnedViews?: PinnedScrollableViews }, children: Component[]): Component;
Parameters
The horizontal spacing between items.
The vertical alignment of items (e.g., “top”, “center”, “bottom”).
Views to pin during scrolling. Options are “sectionHeaders”, “sectionFooters”, or “all”.
The items to display in the lazy horizontal stack.
Support
Usage
Basic lazy horizontal stack
ScrollView([
LazyHStack([
RoundedRectangle({ cornerRadius: 8 })
.fill(Color("red"))
.frame({ width: 100, height: 100 }),
RoundedRectangle({ cornerRadius: 8 })
.fill(Color("blue"))
.frame({ width: 100, height: 100 }),
RoundedRectangle({ cornerRadius: 8 })
.fill(Color("green"))
.frame({ width: 100, height: 100 })
])
])
Lazy horizontal stack with spacing
ScrollView(.horizontal, [
LazyHStack({ spacing: 20 }, [
RoundedRectangle({ cornerRadius: 8 })
.fill(Color("red"))
.frame({ width: 100, height: 100 }),
RoundedRectangle({ cornerRadius: 8 })
.fill(Color("blue"))
.frame({ width: 100, height: 100 }),
RoundedRectangle({ cornerRadius: 8 })
.fill(Color("green"))
.frame({ width: 100, height: 100 })
])
])
Photo gallery with pinned views
ScrollView(.horizontal, [
LazyHStack({ pinnedViews: "all", spacing: 12 }, [
ForEach(photoGroups, (group) =>
Section({
header: Text(group.title)
.font("headline")
.rotationEffect(-90)
.frame({ width: 40 })
}, [
ForEach(group.photos, (photo) =>
Image({ url: photo.url })
.aspectRatio(1.0, contentMode: "fill")
.frame({ width: 150, height: 150 })
.cornerRadius(12)
)
])
)
])
])