← Interface components

UI.List

luastra/ui
UI.List(input: Input): Node

Creates a semantic collection whose direct children are ListItem nodes. Optional windowed mode realizes a bounded vertical viewport without introducing a feed-specific component.

Mental model

This is a declarative node: app.render describes it again from current state, while the host matches its stable id to the existing view.

Before you use it

Add luastra/ui to this module's dependencies in luastra.json, then import it with require("luastra/ui"). The project must declare the ui.render capability. app.render must return one UI.Screen root; place this node inside that tree rather than invoking it for a hidden side effect.

How it fits

The constructor validates its fields immediately and returns a UI.Node. After app.render returns, the host reconciles that node by stable id with the current semantic DOM-based interface. Current desktop and mobile hosts package the same web artifact; native adapters are used at capability boundaries.

When to use it

Use UI.List when sibling items form one meaningful sequence or set. Add mode=windowed for a bounded retained collection; use Column for unrelated blocks and Table for row-and-column relationships.

Shared parameter groups

labellayoutsemantic

Parameters

ParameterType / valuesDescription
idlowercase path, requiredUnique ID.
modewindowed?Enables host-owned vertical windowing; omit it for an ordinary complete list.
estimatedItemSizeinteger 16…4096?Estimated vertical block advance; defaults to 72 in windowed mode.
overscaninteger 1…64?Extra items realized before and after the viewport; defaults to 6.
itemCountnon-negative integer?Optional known logical total.
itemOffsetnon-negative integer?Zero-based logical position of the first retained child.
startBusy / endBusyboolean?Independent edge backpressure.
onStartReached / onEndReachedaction string?Deduplicated edge actions; provider cursors stay in application state.
childrenUI.ListItem[]Bounded retained list items with stable IDs.
gapnone | xs | sm | md | lg | xlSpace between children. Group: Layout and surfaces.
paddingnone | xs | sm | md | lg | xl | responsiveAll-side inner spacing; responsive is supported only by padding. Group: Layout and surfaces.
marginnone | xs | sm | md | lg | xlAll-side outer spacing. Group: Layout and surfaces.
paddingX / paddingYnone | xs | sm | md | lg | xlAxis-specific inner spacing. Group: Layout and surfaces.
paddingTop / paddingBottom / paddingStart / paddingEndnone | xs | sm | md | lg | xlLogical side-specific inner spacing. Group: Layout and surfaces.
marginX / marginYnone | xs | sm | md | lg | xlAxis-specific outer spacing. Group: Layout and surfaces.
marginTop / marginBottom / marginStart / marginEndnone | xs | sm | md | lg | xlLogical side-specific outer spacing. Group: Layout and surfaces.
surfaceplain | card | elevated | accentBackground, border, and elevation. Group: Layout and surfaces.
widthfull | content | wideAvailable width, 720 px maximum, or 1180 px maximum. Group: Layout and surfaces.
alignstart | center | end | stretch | betweenCross-axis alignment. Group: Layout and surfaces.
justifystart | center | end | betweenMain-axis alignment. Group: Layout and surfaces.
flowwrap | nowrapFlex wrapping. Group: Layout and surfaces.
responsivebooleanNarrow-screen adaptation. Group: Layout and surfaces.
classNamesafe string ≤ 256 bytesAdditional admitted class tokens. Group: Layout and surfaces.
tonemuted | error | successSemantic text tone. Group: State and semantics.
appearanceprimary | secondary | danger | ghostAction appearance. Group: State and semantics.
variantbody | subheading | heading | titleBody text or h3, h2, and h1 heading semantics. Group: State and semantics.
rolealert | group | statusSupported ARIA role. Group: State and semantics.
labelstringAccessible name. Group: State and semantics.
hiddenbooleanVisibility state. Group: State and semantics.
disabledbooleanDisabled state. Group: State and semantics.
busybooleanaria-busy state. Group: State and semantics.
requiredbooleanRequired input state. Group: State and semantics.
errorIdcomponent idAssociates a visible role=alert. Group: State and semantics.
textColortoken | #RRGGBBLocal or inherited foreground. Group: Text and local colors.
backgroundColortoken | #RRGGBBComponent-box background. Group: Text and local colors.
Color tokensaccent | danger | muted | surface | success | text | transparent | warningCurrent Screen theme colors. Group: Text and local colors.

Children and layout

Bounded retained list items with stable IDs.

Accessibility and keyboard

Creates a real list; provide label when a nearby heading does not make the list purpose clear. Windowed mode preserves logical positions and keeps a focused item realized.

Common mistakes

  • Rendering an unbounded provider result instead of a bounded retained page.
  • Changing ListItem IDs when the same logical item is re-rendered.

Returns

Node — a validated declarative UI node that becomes part of the next host-neutral render tree.

What happens next

A validated declarative node appears after it is returned as part of the current render tree.

Failures and fixes

Invalid fields, duplicate IDs, unsupported child combinations, or a missing ui.render capability fail during check, render-tree validation, or host startup.

Availability

Source API in 0.5.0-alpha; the public installer targets 0.5.0-alpha. Verify host-specific behavior against the selected SDK.

Focused example

UI.List {
    id = "results",
    label = "Search results",
    mode = "windowed",
    estimatedItemSize = 72,
    overscan = 6,
    itemCount = 1000,
    itemOffset = 200,
    endBusy = loadingNext,
    onEndReached = "results.next",
    table.unpack(retainedItems),
}

Continue learning

Prerequisites

UI.Table

Companions

UI.TableRowUI.TableCell

Complete inventory

View all pages in Interface components
← Previous: UI.TextInputNext: UI.ListItem →