This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index at /llms.txt, or add .md to any page's URL.
Views and repeated content
An element has a tag, an optional positional value, named attributes, and
indented children. A component use has a capitalized name and named arguments
inside parentheses. The compiler checks tags, attributes, leaf-node children,
and handler signatures.
text
text "Heading" role="heading"
image "/assets/photo.jpg" width=120 height=80 object-fit="cover"
Card(title="Heading", selected=selected)
Positional values depend on the tag. Prefer a corpus example when using a new
tag. The app's root view must be exactly one element: an if, for, or match
there is refused, so put a stable element around conditional or repeated content.
A child component used inside an element may return a region or several nodes.
if conditionally creates nodes:
text
column
if pending(results)
text "Loading…"
else
text `${results.length} results`
match renders an option's alternatives:
text
match selected
case some(item)
text item.title
case none
text "Nothing selected"
for repeats a subtree, with an optional index and a required stable key:
text
for item, i in items key=item.id
row gap=8
text `${i + 1}`
ItemRow(item=item, open=open)
Keys identify rows across inserts, removals, and reordering. Use a unique durable
item identifier, not an index that changes when the list is edited. A child
component's state inside a row belongs to that row's key. Keep durable data in
the data module or retained app state; a removed row is not a persistent store.
For long lists, use a bounded virtualized collection:
text
list virtualized=true height=500 estimated-item-height=64
for item in items key=item.id
column padding=12
text item.title
The children of a list whose rows go down the page are its rows, and each
platform draws a row as its own list does: UIKit's separators and the cell's
highlight on iOS, a table on the Mac, one line between rows on the web and the
Linux desktop, none on Android. Draw no separator and no press of your own.
What you do write on a row wins: a border on its top or bottom edge replaces the
separator there (border-bottom="none" for a child that is no row, a count or an
empty state), and appearance="none" on the list keeps rows that are yours, a
transcript or a feed of cards. A list laid out sideways is a carousel and gets
none of it.
A virtualized list has one direct keyed for, whose body has one flow root.
A vertical list with appearance="none" can hold fixed content before and after
it. Put a second for inside an element (all its rows mount); fixed content
cannot hold a virtualized list. Fixed roots require nonnegative margin lengths, including percentages and
font-relative units, and static or relative positioning without vertical offsets
(lower-collection-fixed-flow).
Fixed children keep their authored sibling layout and stay mounted, including
when the for is empty. They have no data-row key or cell styling; give one an
id to reach it with element scrollIntoView(id). The list's end, including
scroll-start="end", scrollFollowEnd and reachend, includes the trail.
An eager for inside a fixed element still receives the development long-list
notice at 200 rows.
A vertical list needs a real height bound (height, max-height, or growing
flex in a bounded parent). A horizontal one needs a literal display="flex" and
a positive height in points, literal or computed, takes estimated-item-width
(literal or computed) and CSS's gap between its cards, and refuses
justify-content other than flex-start. Padding along the list's
axis is room before the first child and after the last, as in CSS: a length or an
env() inset, not a percentage. On iOS a list's pull-to-refresh spinner draws
below its padding-top, so a header laid over that padding does not hide it. A
virtualized list's scroll-padding insets where scrollIntoView aligns a row,
as in CSS: scroll-padding-top the height of that header brings a row to just
below it, and the first row to the very top. On iOS the row also lands clear of
the bars UIKit draws the list under (a header, or a composer it lifts into a
bar), as scrollToItem(at:at:animated:) does: block="end" puts the newest
message just above the composer. Any other scroll container takes it too.
Virtualized lists nest one level deep (an inner vertical list needs a literal
height or max-height); deeper nesting, masonry, wrapping, reversed lists, and
RTL horizontal collections are not supported.
reachstart, reachend, and refresh bind actions, optionally with captured
arguments, for fetching data. An estimate is a layout hint, not a data limit.
Is this helpful
Last updated November 30, 2026