OneScript

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>
PropTypeDescription
alignment"leading" | "center" | "trailing"Horizontal child alignment. Defaults to "center".
spacingnumberSpace between children in pt. Uses the system spacing when omitted.
pinnedViewsPinnedScrollableView[]Section headers or footers that remain pinned while scrolling.
childrenview or view arrayChild 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