121
GitHub
Data displayGlass surface

DataTable

Styles dense tabular data and records.

FrameworksAstro · React · Elements

Registry commandlumen add DataTable

InteractionEnhanced runtime

01

See it in context

Preview

0 selected

PackageTargetDownloads
@santi020k/lumen-astroAstro24,800
@santi020k/lumen-reactReact8,450
@santi020k/lumen-elementsCustom elements5,120
02

Copy a working example

Usage

Astro examples assume UIPrimitives is mounted once in your root layout. Do not add the runtime next to each component instance.

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:datatable-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-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:datatable-selection-change', event => {
    const detail = (event as CustomEvent<{ values: string[] }>).detail

    if (count) count.textContent = String(detail.values.length)
  })
</script>
03

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.

PackageRuntimeGlass
@santi020k/lumen-astroAstroSupported
@santi020k/lumen-reactReactSupported
@santi020k/lumen-elementsWeb ComponentsSupported
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>
---
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>

API reference

Lumen-specific props and runtime attributes for the Astro primitive. React props follow the same names; Elements use equivalent kebab-case attributes where custom elements expose them.

AttributeValuesDefaultDescription
glassboolean | "subtle" | "strong"falseApplies the tokenized liquid-glass surface treatment with backdrop-filter fallbacks; "subtle" and "strong" adjust the fill intensity.
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