NUI / Components / Scroll, Lists & Data

ForEach

ImplementedScroll, Lists & Data

ForEach repeats entries from inline item data or a named data source.

Supported as a data repetition helper.

Overview

ForEach repeats entries from inline item data or a named data source.

When to use

  • Use ForEach when the source should read as a declarative repetition surface rather than a list-view control.

Children

Uses data/template fields instead of normal children.

Basic syntax

nui
ForEach RewardEntries {
    items: "gold|Gold|100;xp|XP|50"
}

Supported properties

PropertyTypeRequiredDefaultDescription
itemsstringNoEmptyInline item data.
dataSourcestringNoEmptyNamed external data source.
itemKeystringNoEmptyField or static key binding.
itemTextstringNoEmptyField or static display text binding.
itemValuestringNoEmptyField or static value binding.
itemCommandstringNoEmptyCommand when an entry is used.
layoutenumNoverticalEntry layout mode.
entryWidthnumberNoDefaultEntry width.
entryHeightnumberNoDefaultEntry height.
entrySpacingnumberNo0Space between entries.
gapnumberNo0Space between generated entries.
widthnumberNoAutoDesired width.
heightnumberNoAutoDesired height.
visibleboolNotrueVisibility flag.

Contextual properties

Contextual property rules

ForEach may receive stack, canvas, grid, wrap, or ExpandableArea slot properties only when it is authored as a direct child of the matching parent. It does not support normal authored child nodes.

Full syntax example

nui
ForEach RewardEntries {
    items: "gold|Gold|100;xp|XP|50"
    itemKey: "id"
    itemText: "label"
    itemValue: "amount"
    itemCommand: "ClaimReward"
    layout: vertical
    entryWidth: 180
    entryHeight: 32
    entrySpacing: 6
    gap: 6
    width: 320
    height: 160
    visible: true
}

Limitations

  • Normal children { ... } blocks are not public syntax for this component.
  • Use ListView or TileView when selection, scrolling, or list behavior is required.