ScrollView(children: Component): Component;
ScrollView(children: Component[]): Component;
ScrollView(props: { axis?: Axis; showsIndicators?: boolean }, children: Component[]): Component;
children
Component | Component[]
required
The scrollable content. Typically a stack or lazy stack containing the scroll content.
Configuration options for the scroll view.
The scroll direction. One of "vertical", "horizontal", or "both". See Axis. Defaults to "vertical". Whether to show scroll indicators. Defaults to true.
Support
Usage
ScrollView([
VStack({ spacing: 12 }, [
ForEach(items, (item) =>
Text(item.name).padding(8)
)
])
])
ScrollView({ axis: "horizontal", showsIndicators: false }, [
HStack({ spacing: 16 }, [
ForEach(cards, (card) =>
Image({ url: card.imageUrl })
.frame({ width: 200, height: 150 })
.cornerRadius(12)
)
])
])
With a lazy stack
For large data sets, use LazyVStack or LazyHStack inside a ScrollView for efficient rendering:
ScrollView([
LazyVStack({ spacing: 8 }, [
ForEach(allItems, (item) =>
HStack({ spacing: 12 }, [
Image({ url: item.thumbnail })
.frame({ width: 48, height: 48 }),
Text(item.title)
])
.padding(8)
)
])
])
ScrollView({ showsIndicators: false }, [
VStack({ spacing: 16 }, [
ForEach(photos, (photo) =>
Image({ url: photo.url })
.aspectRatio(1.5)
)
])
])
See Also