DataTable
Styles dense tabular data and records.
See it and copy it
Framework example
Choose Astro, React, or Elements to compare native usage against the shared visual output. Each example assumes the framework-level setup is already complete.
0 selected
| Package | Target | Downloads |
|---|---|---|
@santi020k/lumen-astro | Astro | 24,800 |
@santi020k/lumen-react | React | 8,450 |
@santi020k/lumen-elements | Custom elements | 5,120 |
View DataTable code
Framework usage
Switch targets to compare the adapter code. This live preview runs the Astro example. React and Elements use their own behavior APIs; complete the matching framework setup before copying an example.---
import {
DataTable
} from '@santi020k/lumen-astro'
const columns: {
header: string
key: string
sort?: 'number' | 'string'
sortable?: boolean
}[] = [
{ header: 'Package', key: 'package', sortable: true },
{ header: 'Target', key: 'target' },
{ header: 'Downloads', key: 'downloads', sort: 'number', sortable: true }
]
const rows = [
{
downloads: { label: '24,800', sortValue: 24800 },
package: '@santi020k/lumen-astro',
rowValue: 'astro',
target: 'Astro'
},
{
downloads: { label: '8,450', sortValue: 8450 },
package: '@santi020k/lumen-react',
rowValue: 'react',
target: 'React'
},
{
downloads: { label: '5,120', sortValue: 5120 },
package: '@santi020k/lumen-elements',
rowValue: 'elements',
target: 'Custom elements'
}
]
---
<div class="docs-example-stack" data-data-table-example>
<p aria-live="polite">
<strong data-selected-count>0</strong> selected
</p>
<DataTable id="ex-datatable" columns={columns} name="packages" rows={rows} selectable />
</div>
<script>
const table = document.getElementById('ex-datatable')
const count = document.querySelector('[data-selected-count]')
table?.addEventListener('ui:data-table-selection-change', event => {
const detail = (event as CustomEvent<{ values: string[] }>).detail
if (count) count.textContent = String(detail.values.length)
})
</script>import {
DataTable
} from '@santi020k/lumen-react'
const columns: {
header: string
key: string
sort?: 'number' | 'string'
sortable?: boolean
}[] = [
{ header: 'Package', key: 'package', sortable: true },
{ header: 'Target', key: 'target' },
{ header: 'Downloads', key: 'downloads', sort: 'number', sortable: true }
]
const rows = [
{
downloads: { label: '24,800', sortValue: 24800 },
package: '@santi020k/lumen-astro',
rowValue: 'astro',
target: 'Astro'
},
{
downloads: { label: '8,450', sortValue: 8450 },
package: '@santi020k/lumen-react',
rowValue: 'react',
target: 'React'
},
{
downloads: { label: '5,120', sortValue: 5120 },
package: '@santi020k/lumen-elements',
rowValue: 'elements',
target: 'Custom elements'
}
]
export const Example = () => (
<>
<DataTable columns={columns} rows={rows} />
</>
)<script type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<div class="docs-example-stack" data-data-table-example>
<p aria-live="polite">
<strong data-selected-count>0</strong> selected
</p>
<lumen-data-table id="ex-datatable" columns={columns} name="packages" rows={rows} selectable></lumen-data-table>
</div>Framework differences
React: The React example demonstrates data rendering and sortable columns. The selection-count listener in the Astro demo is tied to Astro runtime events and is omitted from the React example.
Choose your target
Add this component
Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.
pnpm add @santi020k/lumen-astropnpm add @santi020k/lumen-astrolumen add DataTablelumen add DataTablepnpm add @santi020k/lumen-reactpnpm add @santi020k/lumen-reactlumen add DataTable --target reactlumen add DataTable --target reactpnpm add @santi020k/lumen-elementspnpm add @santi020k/lumen-elementslumen add DataTable --target elementslumen add DataTable --target elementsGlass
Add the glass prop to apply the shared blur, saturation, border, and highlight tokens. Glass reads best over vivid content, so place the surface above imagery or color.
| Package | Runtime | Glass |
|---|---|---|
| @santi020k/lumen-astro | Astro | Supported |
| @santi020k/lumen-react | React | Supported |
| @santi020k/lumen-elements | Web Components | Supported |
View DataTable code
Framework usage
Switch targets to compare the adapter code. This live preview runs the Astro example. React and Elements use their own behavior APIs; complete the matching framework setup before copying an example.---
import { DataTable } from '@santi020k/lumen-astro'
---
<div class="docs-glass-demo">
<DataTable glass>
<table>
<thead><tr><th>Package</th><th>Runtime</th><th>Glass</th></tr></thead>
<tbody>
<tr><td>@santi020k/lumen-astro</td><td>Astro</td><td>Supported</td></tr>
<tr><td>@santi020k/lumen-react</td><td>React</td><td>Supported</td></tr>
<tr><td>@santi020k/lumen-elements</td><td>Web Components</td><td>Supported</td></tr>
</tbody>
</table>
</DataTable>
</div>import { DataTable } from '@santi020k/lumen-react'
export const Example = () => (
<>
<DataTable columns={columns} rows={rows} />
</>
)<script type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<div class="docs-glass-demo">
<lumen-data-table glass>
<table>
<thead><tr><th>Package</th><th>Runtime</th><th>Glass</th></tr></thead>
<tbody>
<tr><td>@santi020k/lumen-astro</td><td>Astro</td><td>Supported</td></tr>
<tr><td>@santi020k/lumen-react</td><td>React</td><td>Supported</td></tr>
<tr><td>@santi020k/lumen-elements</td><td>Web Components</td><td>Supported</td></tr>
</tbody>
</table>
</lumen-data-table>
</div>API reference
Lumen-specific props and runtime attributes for the Astro primitive. Use the framework differences above and the copyable examples for React composition and Elements attributes; the public adapter types define their supported contracts.
| Attribute | Values | Default | Description |
|---|---|---|---|
| glass | boolean | "subtle" | "strong" | false | Applies the tokenized liquid-glass surface treatment with backdrop-filter fallbacks; "subtle" and "strong" adjust the fill intensity. |
| layout | "records" | "scroll" | "scroll" | Opt-in responsive record labels; rich authored Table children remain available. |
| sortMode | "client" | "manual" | "client" | Manual mode requests host sorting and preserves supplied server order. |
| column.render, renderDetails | React render callbacks | - | Renders rich cells and stable record details without changing sort values. |
| expandedRowIds, onExpandedRowIdsChange | controlled React expansion | - | Preserves expansion by stable record ID across pages. |
| DataTableSortControls | React component | - | Shares controlled sort state with headers for a visible mobile sort path. |
| columns | DataTableColumn[] | [] | Generates table headers and maps row cells by column key when rows are provided. |
| rows | DataTableRow[] | [] | Generates table body rows from structured data. |
| name | string | - | Scopes selectable row checkbox names for form submission and runtime selection state. |
| selectable | boolean | false | Enables selectable row behavior for the UIPrimitives runtime. |
| class, className | string | "" | Merges custom classes with the generated ui-* root classes. |
| ...native attributes | HTML attributes | - | Forwards standard attributes to the root element unless the component consumes them. |
Runtime events
CustomEvents dispatched by the Astro UIPrimitives runtime for this component.
| Event | Target | Detail | When |
|---|---|---|---|
| ui:data-table-selection-change | DataTable root ([data-ui-datatable]) | { values: string[] } | Fires after a selectable DataTable row checkbox, select-all checkbox, or form reset changes the selected row values. |