Skip to content

Columns

A column is a plain object. Only accessor and header are required.

const columns: HeadlessColumnDef<Person>[] = [
{ accessor: 'name', header: 'Name' },
// a function accessor needs an id
{ accessor: (row) => `${row.first} ${row.last}`, id: 'full', header: 'Full name' },
{ accessor: 'age', header: 'Age', align: 'end', width: 100, footer: 'Average' },
];
OptionWhat it does
accessor, idA key of the row, or a function. Functions need an id.
header, footerThe text. The footer row shows when any column has a footer.
cellA snippet that renders the cell. It gets { value, row, rowId }.
alignstart, center or end.
width, minWidth, maxWidthPixel sizes. Columns without a width share the free space.
enableSorting, enableHiding, enableResizing, enableGlobalFilter, enableGrouping, enableColumnOrderingTurn a feature off for one column.
aggregate, aggregateFormatWhat group rows show for the column.
filterVariant, filterOptionsThe column filter. See Filtering.
sortValue, searchValueMap the value to what sorting and search compare.
{#snippet price({ value })}
<strong>{value.toLocaleString('en', { style: 'currency', currency: 'USD' })}</strong>
{/snippet}
<MaterialHeadlessTable columns={[{ accessor: 'price', header: 'Price', cell: price }]} {data} />