Pass columns and rows and the table builds itself, header included. It is wrapped in a horizontal scroll container, so a table with more columns than a phone can show scrolls on its own rather than stretching the page. Exported as both table and dataTable.
striped bands alternate rows, hover highlights the row under the pointer, and dense tightens the padding for a table with many rows.
striped
Name
Value
pages
169
assets
208
total
9.5 MB
hover and dense
Name
Value
pages
169
assets
208
total
9.5 MB
stack({gap:'lg'},table({striped:true,caption:'striped',columns:[{key:'name',header:'Name'},{key:'value',header:'Value',align:'end'}],rows:[{name:'pages',value:'169'},{name:'assets',value:'208'},{name:'total',value:'9.5 MB'}],}),table({hover:true,dense:true,caption:'hover and dense',columns:[{key:'name',header:'Name'},{key:'value',header:'Value',align:'end'}],rows:[{name:'pages',value:'169'},{name:'assets',value:'208'},{name:'total',value:'9.5 MB'}],}),)
Caption
A caption names the table for anyone who arrives at it without the surrounding text — worth adding whenever the table is not directly under a heading that already says what it is.
Omit columns and the table renders its children instead, so a table with a footer row or grouped headers can be hand-built and still get the styling and the scroll container.
Props
Prop
Type
Default
Description
columns
TableColumn[]
—
{ key, header, align, render } per column. Omit to hand-write the rows.
rows
object[]
[]
One object per row.
caption
Child
—
A caption above the table.
striped
boolean
false
Band alternate rows.
hover
boolean
false
Highlight the row under the pointer.
dense
boolean
false
Tighter cell padding.
This site uses Google Analytics cookies to count visits. Nothing is stored unless you accept.