LazyVStack
The LazyVStack component is part of the Scripting app's UI library. It arranges its children in a vertical stack, creating and displaying items only as needed, optimizing performance for large data sets.
LazyVStack
Type: FunctionComponent<LazyVStackProps>
A LazyVStack arranges its children in a line that grows vertically. Unlike a regular vertical stack, it lazily loads and displays views only when they are about to appear on the screen. This makes it ideal for lists or large sets of dynamically generated content.
LazyVStackProps
PinnedScrollViews
The PinnedScrollViews type defines which kinds of child views can remain pinned to the scroll view's bounds as it scrolls:
'sectionHeaders': Pins only the section headers'sectionFooters': Pins only the section footers'sectionHeadersAndFooters': Pins both section headers and footers
Example Usage
Explanation:
- The stack arranges the
Sectionviews vertically with12points of spacing - The
alignmentproperty aligns the items to the leading edge of the stack - The
pinnedViewsproperty ensures that section headers remain pinned to the top of the scroll view when scrolling
Notes
- Lazy loading ensures that views are only created as they become visible, which improves performance for large content
- Use
spacingto control the vertical distance between items andalignmentto customize the horizontal alignment - The
pinnedViewsproperty is especially useful for table or list-like layouts with sticky headers or footers
This API allows you to efficiently manage vertically growing content while offering customization for layout and scrolling behavior.
