UILayouts
LazyVStack
Lazily lay out vertically arranged child views.
LazyVStack uses SwiftUI's native lazy container to lay out content vertically. It works well inside a vertical ScrollView that displays a long list.
OneScript currently resolves the complete TypeScript/TSX child-node tree before committing the view. SwiftUI creates the corresponding views on demand during layout and display.
import {
LazyVStack, PinnedScrollableViews, ScrollView, Section, Text,
} from "onescript/views"
<ScrollView>
<LazyVStack
alignment="leading"
spacing={8}
pinnedViews={[PinnedScrollableViews.sectionHeaders]}
>
<Section header={<Text>A</Text>}>
<Text>Alice</Text>
<Text>Alex</Text>
</Section>
<Section header={<Text>B</Text>}>
<Text>Bob</Text>
</Section>
</LazyVStack>
</ScrollView>| Prop | Type | Description |
|---|---|---|
alignment | "leading" | "center" | "trailing" | Horizontal child alignment. Defaults to "center". |
spacing | number | Space between children in pt. Uses the system spacing when omitted. |
pinnedViews | PinnedScrollableView[] | Section headers or footers that remain pinned while scrolling. |
children | view or view array | Child views displayed from top to bottom. |
PinnedScrollableViews.sectionHeaders pins headers and PinnedScrollableViews.sectionFooters pins footers. Pinning takes effect inside a vertical ScrollView.
How is this guide?
Last updated on