Data Table
A Brutalist data table with stable sorting, global and column filtering, column visibility, pagination, and row selection.
Brutalist Data Table layers stable sorting, global and per-column filtering, column visibility, pagination, and row or page selection onto semantic table structure with 5px rounded-base corners, 2px black borders, zero-blur 4px offset shadows, and DM Sans typography.
Preview
Section titled “Preview” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<div class="grid w-full max-w-2xl gap-4">
<div class="flex flex-wrap items-center justify-between gap-2">
<proto-ui-brutalist-input-root
id="email-filter"
class="w-full max-w-xs"
></proto-ui-brutalist-input-root>
<div class="flex gap-2">
<proto-ui-brutalist-button id="toggle-status">
Toggle Status
</proto-ui-brutalist-button>
<proto-ui-brutalist-button id="select-page">
Select page
</proto-ui-brutalist-button>
</div>
</div>
<proto-ui-brutalist-data-table-root id="payments-table">
<proto-ui-brutalist-data-table-caption>
Recent payments.
</proto-ui-brutalist-data-table-caption>
<proto-ui-brutalist-data-table-header-row>
<proto-ui-brutalist-data-table-header data-key="status">
Status
</proto-ui-brutalist-data-table-header>
<proto-ui-brutalist-data-table-header data-key="email">
Email
</proto-ui-brutalist-data-table-header>
<proto-ui-brutalist-data-table-header
data-key="amount"
class="text-right"
>
Amount
</proto-ui-brutalist-data-table-header>
</proto-ui-brutalist-data-table-header-row>
<proto-ui-brutalist-data-table-row data-index="0">
<proto-ui-brutalist-data-table-cell
data-col="status"
></proto-ui-brutalist-data-table-cell>
<proto-ui-brutalist-data-table-cell
data-col="email"
></proto-ui-brutalist-data-table-cell>
<proto-ui-brutalist-data-table-cell
data-col="amount"
class="text-right font-medium"
></proto-ui-brutalist-data-table-cell>
</proto-ui-brutalist-data-table-row>
<div class="table-caption caption-bottom">
<div class="flex items-center justify-between pt-3">
<span id="summary" class="text-sm text-muted-foreground">
0 of 5 row(s) selected.
</span>
<div class="flex gap-2">
<proto-ui-brutalist-data-table-previous>
Previous
</proto-ui-brutalist-data-table-previous>
<proto-ui-brutalist-data-table-next>
Next
</proto-ui-brutalist-data-table-next>
</div>
</div>
</div>
</proto-ui-brutalist-data-table-root>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const rows = [
{
id: 'm5gr84i9',
status: 'Success',
email: 'ken99@example.com',
amount: 316,
},
{
id: '3u1reuv4',
status: 'Success',
email: 'abe45@example.com',
amount: 242,
},
{
id: 'derv1ws0',
status: 'Processing',
email: 'monserrat44@example.com',
amount: 837,
},
{
id: '5kma53ae',
status: 'Success',
email: 'silas22@example.com',
amount: 874,
},
{
id: 'bhqecj4p',
status: 'Failed',
email: 'carmella@example.com',
amount: 721,
},
];
const table = document.querySelector('#payments-table');
setElementProps(table, { rows, pageSize: 4 });
setElementProps(document.querySelector('#email-filter'), {
placeholder: 'Filter emails...',
onValueChange: ({ value }) =>
setElementProps(table, { columnFilters: { email: value } }),
});
</script>Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases.
import { BrutalistDataTableCaption, BrutalistDataTableCell, BrutalistDataTableHeader, BrutalistDataTableHeaderRow, BrutalistDataTableNext, BrutalistDataTablePrevious, BrutalistDataTableRoot, BrutalistDataTableRow,} from '../proto-ui/components/react';
const rows = [ { id: 'm5gr84i9', status: 'Success', email: 'ken99@example.com', amount: 316 }, { id: '3u1reuv4', status: 'Success', email: 'abe45@example.com', amount: 242 },];
export function Example() { return ( <BrutalistDataTableRoot rows={rows} pageSize={4}> <BrutalistDataTableCaption>Recent payments.</BrutalistDataTableCaption> <BrutalistDataTableHeaderRow> <BrutalistDataTableHeader headerKey="status">Status</BrutalistDataTableHeader> <BrutalistDataTableHeader headerKey="email">Email</BrutalistDataTableHeader> <BrutalistDataTableHeader headerKey="amount" className="text-right"> Amount </BrutalistDataTableHeader> </BrutalistDataTableHeaderRow> {[0, 1].map((index) => ( <BrutalistDataTableRow key={index} index={index}> <BrutalistDataTableCell columnKey="status" headers={['status']} /> <BrutalistDataTableCell columnKey="email" headers={['email']} /> <BrutalistDataTableCell columnKey="amount" headers={['amount']} className="text-right" /> </BrutalistDataTableRow> ))} <div className="table-caption caption-bottom"> <div className="flex justify-end gap-2 pt-3"> <BrutalistDataTablePrevious>Previous</BrutalistDataTablePrevious> <BrutalistDataTableNext>Next</BrutalistDataTableNext> </div> </div> </BrutalistDataTableRoot> );}Structure & Visual Grammar
Section titled “Structure & Visual Grammar”- Rows and cells: Every item in
rowsrequires a uniqueid. Place sortable column triggers inDataTableHeaderRow, map active page slots withDataTableRow, and bind fields withDataTableCellcolumnKey. - Brutalist contract: Headers use
font-heading font-bold, cells usefont-sans font-medium, selected rows highlight withbg-main text-main-foreground, andPrevious/Nextuse raised 4px hard shadows that settle+4px, +4pxon press.
Examples
Section titled “Examples”Basic Table & Sorting
Section titled “Basic Table & Sorting” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-brutalist-data-table-root id="basic-table">
<proto-ui-brutalist-data-table-caption>
A list of your recent invoices.
</proto-ui-brutalist-data-table-caption>
<proto-ui-brutalist-data-table-header-row>
<proto-ui-brutalist-data-table-header>
Invoice
</proto-ui-brutalist-data-table-header>
<proto-ui-brutalist-data-table-header>
Status
</proto-ui-brutalist-data-table-header>
<proto-ui-brutalist-data-table-header>
Method
</proto-ui-brutalist-data-table-header>
<proto-ui-brutalist-data-table-header class="text-right">
Amount (USD)
</proto-ui-brutalist-data-table-header>
</proto-ui-brutalist-data-table-header-row>
<proto-ui-brutalist-data-table-row>
<proto-ui-brutalist-data-table-cell></proto-ui-brutalist-data-table-cell>
<proto-ui-brutalist-data-table-cell></proto-ui-brutalist-data-table-cell>
<proto-ui-brutalist-data-table-cell></proto-ui-brutalist-data-table-cell>
<proto-ui-brutalist-data-table-cell
class="text-right font-medium"
></proto-ui-brutalist-data-table-cell>
</proto-ui-brutalist-data-table-row>
</proto-ui-brutalist-data-table-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#basic-table'), {
defaultSortKey: 'invoice',
defaultSortDirection: 'ascending',
pageSize: 4,
rows: [
{
id: 'inv-001',
invoice: 'INV001',
status: 'Paid',
method: 'Credit Card',
amount: 250,
},
{
id: 'inv-002',
invoice: 'INV002',
status: 'Pending',
method: 'PayPal',
amount: 150,
},
],
});
</script>Filtering & Column Visibility
Section titled “Filtering & Column Visibility” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<div class="grid gap-3">
<div class="flex flex-wrap gap-2">
<proto-ui-brutalist-input-root
id="global-filter"
></proto-ui-brutalist-input-root>
<proto-ui-brutalist-input-root
id="status-filter"
></proto-ui-brutalist-input-root>
<proto-ui-brutalist-button id="toggle-method">
Toggle Method
</proto-ui-brutalist-button>
</div>
<proto-ui-brutalist-data-table-root id="filter-table">
<proto-ui-brutalist-data-table-header-row>
<proto-ui-brutalist-data-table-header>
Invoice
</proto-ui-brutalist-data-table-header>
<proto-ui-brutalist-data-table-header>
Status
</proto-ui-brutalist-data-table-header>
<proto-ui-brutalist-data-table-header>
Method
</proto-ui-brutalist-data-table-header>
</proto-ui-brutalist-data-table-header-row>
</proto-ui-brutalist-data-table-root>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const table = document.querySelector('#filter-table');
let showMethod = true;
setElementProps(document.querySelector('#global-filter'), {
placeholder: 'Search all...',
onValueChange: ({ value }) =>
setElementProps(table, { filter: value }),
});
setElementProps(document.querySelector('#status-filter'), {
placeholder: 'Status...',
onValueChange: ({ value }) =>
setElementProps(table, { columnFilters: { status: value } }),
});
setElementProps(document.querySelector('#toggle-method'), {
onClick: () => {
showMethod = !showMethod;
setElementProps(table, {
columnVisibility: { method: showMethod },
});
},
});
</script>Pagination & Row Selection
Section titled “Pagination & Row Selection” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-brutalist-data-table-root id="paged-table">
<proto-ui-brutalist-data-table-header-row>
<proto-ui-brutalist-data-table-header>
Invoice
</proto-ui-brutalist-data-table-header>
<proto-ui-brutalist-data-table-header>
Status
</proto-ui-brutalist-data-table-header>
<proto-ui-brutalist-data-table-header>
Method
</proto-ui-brutalist-data-table-header>
</proto-ui-brutalist-data-table-header-row>
<div class="table-caption caption-bottom">
<div class="flex items-center justify-end gap-2 pt-3">
<proto-ui-brutalist-data-table-previous>
Previous
</proto-ui-brutalist-data-table-previous>
<proto-ui-brutalist-data-table-next>
Next
</proto-ui-brutalist-data-table-next>
</div>
</div>
</proto-ui-brutalist-data-table-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#paged-table'), {
pageSize: 3,
defaultSelectedKeys: ['inv-001'],
rows: [
{
id: 'inv-001',
invoice: 'INV001',
status: 'Paid',
method: 'Credit Card',
},
{
id: 'inv-002',
invoice: 'INV002',
status: 'Pending',
method: 'PayPal',
},
{
id: 'inv-003',
invoice: 'INV003',
status: 'Unpaid',
method: 'Bank Transfer',
},
{
id: 'inv-004',
invoice: 'INV004',
status: 'Paid',
method: 'Credit Card',
},
],
});
</script>Read-Only & Disabled States
Section titled “Read-Only & Disabled States” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-brutalist-data-table-root
id="readonly-table"
></proto-ui-brutalist-data-table-root>
<proto-ui-brutalist-data-table-root
id="disabled-table"
></proto-ui-brutalist-data-table-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const rows = [
{
id: 'm5gr84i9',
status: 'Success',
email: 'ken99@example.com',
},
{
id: '3u1reuv4',
status: 'Success',
email: 'abe45@example.com',
},
];
setElementProps(document.querySelector('#readonly-table'), {
rows,
readOnly: true,
});
setElementProps(document.querySelector('#disabled-table'), {
rows,
disabled: true,
});
</script>Custom Cell Formatting Recipe
Section titled “Custom Cell Formatting Recipe” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<div class="grid w-full max-w-xl gap-3">
<proto-ui-brutalist-input-root
id="service-filter"
></proto-ui-brutalist-input-root>
<div class="flex flex-wrap gap-2">
<proto-ui-brutalist-button id="toggle-col">
Show / hide status
</proto-ui-brutalist-button>
<proto-ui-brutalist-button id="select-current-page">
Select / clear current page
</proto-ui-brutalist-button>
</div>
<proto-ui-brutalist-data-table-root id="recipes-table">
<proto-ui-brutalist-data-table-caption>
Service inventory
</proto-ui-brutalist-data-table-caption>
<proto-ui-brutalist-data-table-header-row>
<proto-ui-brutalist-data-table-header>
Service
</proto-ui-brutalist-data-table-header>
<proto-ui-brutalist-data-table-header>
Status
</proto-ui-brutalist-data-table-header>
</proto-ui-brutalist-data-table-header-row>
<proto-ui-brutalist-data-table-row>
<proto-ui-brutalist-data-table-cell></proto-ui-brutalist-data-table-cell>
<proto-ui-brutalist-data-table-cell id="custom-cell-0">
<span></span>
</proto-ui-brutalist-data-table-cell>
</proto-ui-brutalist-data-table-row>
<div class="flex gap-2">
<proto-ui-brutalist-data-table-previous>
Previous
</proto-ui-brutalist-data-table-previous>
<proto-ui-brutalist-data-table-next>
Next
</proto-ui-brutalist-data-table-next>
</div>
</proto-ui-brutalist-data-table-root>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
setElementProps(document.querySelector('#custom-cell-0'), {
columnKey: 'state',
headers: ['state'],
renderValue: false,
});
</script>Pass sortKey, sortDirection, page, or selectedKeys to control each state independently.
| Prop | Type | Default |
|---|---|---|
rows | readonly DataRecord[] | [] |
sortKey | string | — (controlled) |
defaultSortKey | string | '' |
sortDirection | 'none' 'ascending' 'descending' | — (controlled) |
defaultSortDirection | 'none' 'ascending' 'descending' | 'none' |
filter | string | '' |
columnFilters | Readonly<Record<string, string>> | {} |
columnVisibility | Readonly<Record<string, boolean>> | {} |
page | number | — (controlled) |
defaultPage | number | 0 |
pageSize | number | 10 |
selectedKeys | readonly string[] | — (controlled) |
defaultSelectedKeys | readonly string[] | [] |
disabled | boolean | false |
readOnly | boolean | false |
Part Props
Section titled “Part Props”| Part / Prop | Type | Default |
|---|---|---|
Row.index | number | 0 |
Row.header | boolean | false |
Header.headerKey | string | '' |
Header.headerKind | 'column' 'row' | 'column' |
Header.sortable | boolean | true |
Cell.columnKey | string | '' |
Cell.headers | readonly string[] | [] |
Cell.renderValue | boolean | true |
Previous / Next | ButtonProps | raised hard-shadow control |
Events, Methods & Exposed States
Section titled “Events, Methods & Exposed States”- Events (Root):
sortChange,pageChange,selectionChange. - Methods (Root):
getRows(),getRecord(id),getSelectedKeys(),requestSort(key),requestPage(next),requestSelection(id),requestPageSelection(selected?). - Exposed States: Root exposes
filteredCountandpageSelection; Row exposesrowKey,selected,focused, andfocusVisible; Header exposessort; Cell exposesdisplayValue.