LazyVStack ( children : Component ): Component ;
LazyVStack ( children : Component []): Component ;
LazyVStack ( props : { spacing? : number ; alignment ?: HorizontalAlignment ; pinnedViews ?: PinnedScrollableViews }, children : Component []): Component ;
children
Component | Component[]
required
A single component or array of components to arrange vertically with lazy rendering.
Configuration options for the lazy stack. The distance in points between adjacent children. When omitted, the system uses a default spacing.
The horizontal alignment of children within the stack. One of "leading", "center", or "trailing". Defaults to "center".
Which views to pin during scrolling. One of "sectionHeaders", "sectionFooters", or "all". When set, Section headers and/or footers stick to the edges of the scroll view while their content is visible.
Support
Usage
Basic lazy list
Use inside a ScrollView for efficient rendering of large datasets:
ScrollView ([
LazyVStack ({ spacing: 8 }, [
ForEach ( items , ( item ) =>
Text ( item . name ). padding ( 12 )
)
])
])
ScrollView ([
LazyVStack ({ pinnedViews: "sectionHeaders" }, [
Section ({ header: Text ( "Group A" ). font ( "headline" ) }, [
ForEach ( groupA , ( item ) => Text ( item . name ))
]),
Section ({ header: Text ( "Group B" ). font ( "headline" ) }, [
ForEach ( groupB , ( item ) => Text ( item . name ))
])
])
])
With alignment
ScrollView ([
LazyVStack ({ spacing: 12 , alignment: "leading" }, [
ForEach ( messages , ( msg ) =>
Text ( msg . text )
. padding ( 12 )
. background ( Color ( "secondarySystemBackground" ))
. cornerRadius ( 8 )
)
])
])
Notes
LazyVStack only creates views for children that are currently visible. This is critical for performance with large data sets.
Always place LazyVStack inside a ScrollView . Without a scrollable parent, there is no viewport boundary to drive lazy rendering.
For non-lazy vertical layout, use VStack .
See Also