Reference

Table

Data table. Cells inside Table.Head render as <th scope="col">; caption is the table's accessible name, visually hidden.

Table(caption: String) { … }

Before 5.0

caption

Regions
Region Latency Status
fra1 42 ms Healthy
iad1 88 ms Healthy
sin1 190 ms Degraded

Example

wf

state regions = [{ name: "fra1", latency: 42, status: "Healthy" }, { name: "iad1", latency: 88, status: "Healthy" }, { name: "sin1", latency: 190, status: "Degraded" }] Table(caption: "Regions") { Table.Head { Table.Row { Table.Cell("Region") Table.Cell("Latency") Table.Cell("Status") } } Table.Body { for r in regions by r.name { Table.Row { Table.Cell(r.name).header Table.Cell("{r.latency} ms") Table.Cell { Badge(r.status, tone: if r.status == "Healthy" { .success } else { .warning }) } } } } }

Written out by hand

wf

Table(caption: "Plans") { Table.Head { Table.Row { Table.Cell("Plan") Table.Cell("Price") } } Table.Body { Table.Row { Table.Cell("Free") Table.Cell("$0") } Table.Row { Table.Cell("Pro") Table.Cell("$12 a month") } } }

Props

Props of Table
PropTypeUnsetMeaning

caption:

String

none

The table's accessible name, drawn as a <caption> that is visually hidden

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

Parts

The parts of Table are written under its name, inside it. Each is described here, with what it takes.

Table.Head

Header section; its cells become <th scope="col">.

Table.Head { … }

Table.Body

The body of a table: its rows of data.

Table.Body { … }

Table.Row

A row of cells.

Table.Row { … }

Table.Cell

A cell. header makes it a <th> anywhere, as Table.Head does for its cells.

Table.Cell(_ content: String or Number or Bool, header: Bool) { … }
Props of Table.Cell
PropTypeUnsetMeaning

content

String or Number or Bool (positional)

none

The cell's text: a string, number or boolean; unset, its block

header:

Bool

false

Drawn as a header cell, <th scope="col">, outside a Table.Head too (a cell a component draws). Written as a flag, .header, or header: true.

.header

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