Concept

Lazy containers create views on-demand based on visibility instead of building the entire view tree upfront.

They are used for:

efficient rendering of large scrollable content

Types

LazyVStack → vertical 1D layout
LazyHStack → horizontal 1D layout
LazyVGrid  → vertical 2D layout (columns)
LazyHGrid  → horizontal 2D layout (rows)

Core Behavior

Only visible views are created
Off-screen views do not exist in the view tree
Views are created and destroyed during scrolling

Requirement

Lazy containers behave lazily ONLY inside a ScrollView

Example:

ScrollView {
    LazyVStack {
        // lazy behavior works
    }
}

Without ScrollView:

acts like a normal stack (no laziness)

Mental Model

Lazy container = dynamic subtree generator tied to scroll position