The LazyVGrid
component is part of the Scripting app's UI library. It arranges its children in a grid layout with columns defined by customizable sizing and alignment options. Items are created and displayed only as needed, optimizing performance for large or dynamic data sets.
FunctionComponent<LazyVGridProps>
A LazyVGrid
arranges its children in a grid that grows vertically. Unlike a regular grid, it loads and displays items lazily, creating them only when they are about to appear on the screen. This makes it ideal for grids with large or dynamic content.
Property | Type | Default | Description |
---|---|---|---|
columns |
GridItem[] |
Required | Defines the configuration for the columns in the grid, including their size and alignment. |
alignment |
HorizontalAlignment |
undefined |
Controls how the grid is aligned horizontally within its parent view. |
spacing |
number |
undefined (default spacing) |
The distance between adjacent grid items. If undefined , the grid uses a default spacing value. |
pinnedViews |
'sectionHeaders' | 'sectionFooters' | 'sectionHeadersAndFooters' |
undefined |
Specifies which child views remain pinned to the bounds of the parent scroll view. |
children |
(VirtualNode | undefined | null | (VirtualNode | undefined | null)[])[] | VirtualNode |
undefined |
The content to be displayed in the grid. Accepts one or multiple VirtualNode elements, including arrays and optional null or undefined values. |
Defines the properties for a single column in the grid.
Property | Type | Default | Description |
---|---|---|---|
alignment |
Alignment |
undefined |
Specifies the alignment to use when placing each child view in this column. |
spacing |
number |
undefined (default spacing) |
The spacing between items in this column and the next. |
size |
GridSize |
Required | Defines the size of the column. Can be a fixed size or a flexible/adaptive size based on the content. |
Defines the size of a row or column in the grid layout.
Type | Properties | Description |
---|---|---|
number |
N/A | A fixed size for the row or column. |
adaptive |
min: number , max?: number | 'infinity' |
Specifies a flexible size that adapts to the content, with a minimum and optional maximum constraint. |
flexible |
min?: number , max?: number | 'infinity' |
Specifies a single flexible size that adjusts dynamically, constrained by optional min and max values. |
Defines which views in the grid remain pinned to the parent 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 footersLazyVGrid
is ideal for vertically growing grid layouts with large or dynamic contentGridSize
to define flexible or adaptive layouts based on the available spacepinnedViews
property ensures critical views like headers or footers remain visible during scrollingThis API provides flexibility and performance optimizations for grid-based vertical layouts.