Skip to main content
196

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Web docs
Data displayGlass surface

DataTable

Styles dense tabular data and records.

FrameworksAstro · React · Elements

Registry commandlumen add DataTable

InteractionEnhanced runtime

01

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.

AstroCode target · live preview uses Astro

0 selected

PackageTargetDownloads
@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.
astro
---
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>
Edit DataTable in browser

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.

02

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.

bash@santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
bashAstro wrapper
lumen add DataTable
lumen add DataTable

Glass

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.

AstroCode target · live preview uses Astro
PackageRuntimeGlass
@santi020k/lumen-astroAstroSupported
@santi020k/lumen-reactReactSupported
@santi020k/lumen-elementsWeb ComponentsSupported
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.
astro
---
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>
Edit DataTable in browser

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.

AttributeValuesDefaultDescription
glassboolean | "subtle" | "strong"falseApplies 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, renderDetailsReact render callbacks-Renders rich cells and stable record details without changing sort values.
expandedRowIds, onExpandedRowIdsChangecontrolled React expansion-Preserves expansion by stable record ID across pages.
DataTableSortControlsReact component-Shares controlled sort state with headers for a visible mobile sort path.
columnsDataTableColumn[][]Generates table headers and maps row cells by column key when rows are provided.
rowsDataTableRow[][]Generates table body rows from structured data.
namestring-Scopes selectable row checkbox names for form submission and runtime selection state.
selectablebooleanfalseEnables selectable row behavior for the UIPrimitives runtime.
class, classNamestring""Merges custom classes with the generated ui-* root classes.
...native attributesHTML 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.

EventTargetDetailWhen
ui:data-table-selection-changeDataTable root ([data-ui-datatable]){ values: string[] }Fires after a selectable DataTable row checkbox, select-all checkbox, or form reset changes the selected row values.

Web docsFull catalog