Reference

VirtualList

A scrolling box that draws only the rows in view of the one keyed for inside it — for a tree, search results or a diff of thousands of rows.

VirtualList(rowHeight: Number, estimate: Number, reveal: String or Number, …) { … }

Since 5.9.0

rowHeight

label

Picked: Commit #250

Commit #1

Commit #2

Commit #3

Commit #4

Commit #5

Commit #6

Commit #7

Commit #8

Commit #9

Commit #10

Commit #11

Commit #12

Commit #13

Commit #14

Commit #15

Commit #16

Commit #17

Commit #18

Commit #19

Commit #20

Commit #21

Commit #22

Commit #23

Commit #24

Commit #25

Commit #26

Commit #27

Commit #28

Commit #29

Commit #30

Commit #31

Commit #32

Commit #33

Commit #34

Commit #35

Commit #36

Commit #37

Commit #38

Commit #39

Commit #40

Commit #41

Commit #42

Commit #43

Commit #44

Commit #45

Commit #46

Commit #47

Commit #48

Commit #49

Commit #50

Commit #51

Commit #52

Commit #53

Commit #54

Commit #55

Commit #56

Commit #57

Commit #58

Commit #59

Commit #60

Example

wf

state rows = (0..500).map(i => "Commit #{i + 1}") state picked = "Commit #250" Text("Picked: {picked}").muted VirtualList(rowHeight: 36, reveal: picked, label: "Commits") { style { height: 260px; border: 1px solid $color-border; border-radius: $radius-md } for r in rows by r { Row(justify: .between, align: .center) { style { height: 36px; padding: 0 0.75rem } Text(r) Button("Pick").sm { on click { picked = r } } } } }

Rows of different heights, measured

wf

state notes = (0..300).map(i => if i % 5 == 0 { "Note {i}: a longer line that wraps onto a second line in a narrow box." } else { "Note {i}" }) VirtualList(estimate: 40, label: "Notes") { style { max-height: 300px } for n in notes by n { Text(n) { style { padding: 0.5rem } } } }

Props

Props of VirtualList
PropTypeUnsetMeaning

rowHeight:

Number

none: rows are measured

Every row's height, in px: the fast path. Unset, each row is measured once drawn

estimate:

Number

32 (rowHeight when given)

The height a row not yet drawn stands for while there is no rowHeight, in px

reveal:

String or Number

none

A row's key, as its for … by gives it: when it changes, that row is scrolled into view — the selection, the current match

label:

String

none

The scrolling box's accessible name (aria-label): what the list is, for a screen reader

Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.

Flags and cases

A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.

No flags of its own.

Events

Every element also takes the props, the events and the attribute families listed on every element.

Slots

children

Renders with the class wf-virtual-list, stable across releases, so a stylesheet may target it.