← All Components
<mth-datagrid>
Enterprise virtualized data grid wrapping @tanstack/table-core and @tanstack/virtual-core with sorting, filtering, pinning, column resizing, selection, and DataSource<T> streaming.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Ready · interact with <mth-datagrid>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/datagrid/datagrid"></script>
<mth-datagrid row-height="40"></mth-datagrid>import '@methane-ui/datagrid/datagrid';
import '@methane-ui/react';
export function Example() {
return <mth-datagrid row-height="40"></mth-datagrid>;
}<script setup lang="ts">
import '@methane-ui/datagrid/datagrid';
</script>
<template>
<mth-datagrid row-height="40"></mth-datagrid>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/datagrid/datagrid';
import { MthDatagridDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthDatagridDirective],
template: `<mth-datagrid row-height="40"></mth-datagrid>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/datagrid/datagrid';
import MthDatagrid from '@methane-ui/svelte/MthDatagrid.svelte';
</script>
<MthDatagrid row-height="40"></MthDatagrid>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
rows | — | ReadonlyArray<Record<string, unknown>> | — | Array of row records displayed in the grid. |
columns | — | ReadonlyArray<unknown> | — | Column definitions with optional accessorKey, sortable, width, and pinned. |
dataSource | — | unknown | null | — | Optional async DataSource<T, string> controller source. |
selectable | selectable | boolean | false | Enables multi-row checkbox selection. |
multiSort | multi-sort | boolean | false | Allows sorting across multiple columns simultaneously. |
filter | filter | string | "" | Global search filter string applied across filterable columns. |
rowHeight | row-height | number | 40 | Estimated virtual row block size in pixels. |
label | label | string | "" | Accessible grid label. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-sort-change | { sorting: ReadonlyArray<{ id: string; desc: boolean }> } | Fired when column sorting updates. |
mth-selection-change | { selectedIds: ReadonlyArray<string> } | Fired when selected row IDs change. |
mth-column-resize | { columnId: string; width: number } | Fired when a column width is updated. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| ArrowDown | both | grid row focused | moves roving focus to next row |
| ArrowUp | both | grid row focused | moves roving focus to previous row |
| Home | both | grid row focused | moves roving focus to first row |
| End | both | grid row focused | moves roving focus to last row |
| Enter | both | column sort header focused | toggles sort order for column |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | Focus ownership matches focusModel="host". | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 5 APG keyboard transitions across LTR/RTL. | mth-datagrid.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(loading), :state(empty), :state(error), :state(selectable). | Conformance suite |
| i18n | Routes 8 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |