Lazy grid for large collections with stable identifiers and generic cells.
Content
iOS 26 · iPadOS 26 · macOS 26
Version 1.1.0
glass-data-grid
Content on an opaque, readable surface. Glass is kept for controls.
Capture
Capture of the component running in SP Glass Studio on the iOS 26.5 simulator. Liquid Glass is rendered by the system; this is an image, not a live preview.
Installation
$spglass add glass-data-grid
Copies the sources and their dependencies into your project. Set up the CLI.
As many tracks as fit the width; the default is .adaptive(minimum: 140).
layout: .fixed(n)
Exactly n tracks of equal size.
axis: .vertical
LazyVGrid in a vertical scroll view (default).
axis: .horizontal
LazyHGrid in a horizontal scroll view; give the grid a bounded height.
With selection
Every cell becomes a toggle button; the cell closure receives isSelected.
Parameters
Parameter
Type
Default
Meaning
data
RandomAccessCollection of Identifiable
—
The elements. Identifiers must be stable and unique.
layout
GlassGridLayout
.adaptive(minimum: 140)
Track sizing.
axis
Axis
.vertical
Scrolling direction.
spacing
GlassSpacingStep
.sm
Gap between cells and around the grid, from the theme's scale.
selection
Binding<Set<Element.ID>>?
nil
Selected identifiers.
emptyTitle
LocalizedStringKey?
nil
Text of the empty state; defaults to "No data".
cell
@ViewBuilder (Element) -> Cell or (Element, Bool) -> Cell
—
Content of one cell.
States
Empty: a ContentUnavailableView with emptyTitle.
Selected (with a selection binding): a checkmark badge in the top trailing corner and the .isSelected trait; the cell can also change its own appearance from isSelected.
Pressed and focused states of selectable cells are those of a plain system button.
Advanced example
Swift
/// A collection that produces its elements on demand: nothing is allocated for 30 000 samples.structSamples: RandomAccessCollection {
let count: Intvar startIndex: Int { 0 }
var endIndex: Int { count }
subscript(position: Int) -> Sample { Sample(id: position) }
}
@Stateprivatevar selection: Set<Int> = []
GlassDataGrid(Samples(count: 30_000), layout: .fixed(4), spacing: .xs, selection: $selection) { sample, isSelected inSampleCell(sample: sample)
.opacity(isSelected ? 1 : 0.85)
}
Accessibility
Cells keep the accessibility of the host's content. Selectable cells are buttons with the .isSelected trait.
Selection is shown by a checkmark symbol, not by colour alone.
An adaptive layout reflows with the window width and with Dynamic Type if the host's minimum leaves room for larger text; prefer adaptive layouts.
Limits
Laziness depends on the collection: indexing and count must be constant-time, and identifiers stable. The grid performs no per-element work in body and never copies the collection into an array.
The grid owns its scroll view; do not nest it in another scroll view of the same axis.
No prefetching, sections, reordering or drag and drop.
Do not put a glass surface in each cell: glass is for controls and navigation layers, and one glass effect per cell is costly.
Scrolling performance with tens of thousands of elements was not measured with Instruments in this phase; only the absence of eager work at construction is covered by a test.