Methane@methane-ui/*
CSS LayoutsComponentsSkillsTheme BuilderGitHub
← All Components

<mth-table>

@methane-ui/ui~12.3 KB brotli (cold + Lit)~4.4 KB marginal

Accessible data table reconciling <mth-column> children, .columns/.rows properties, and async DataSource<T> via TableCore, SelectionController, DataController, SlotCollectionController, and RovingFocusController.

When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.

Live Interactive Preview

Interactive StageLive Custom Element · <mth-table> (@methane-ui/ui)
Ready · interact with <mth-table>, or toggle Theme, Direction (LTR/RTL), or props above.

Multi-Framework Playground & Snippets

<script type="module" src="@methane-ui/ui/table"></script>
<mth-table selectable="none" row-key="id">Example</mth-table>

Properties & Attributes

PropertyAttributeTypeDefaultDescription
rows—ReadonlyArray<unknown>—Array of row data records.
columns—ReadonlyArray<unknown> | nullnullImperative column definitions.
dataSource—unknown | nullnullAsync DataSource backing table rows.
selectableselectable'none' | 'single' | 'multiple'"none"Row selection mode (none, single, or multiple).
selectedIds—ReadonlyArray<string>—Array of currently selected row IDs.
filterfilterstring""Global text filter applied via TableCore or DataController.
captioncaptionstring""Visible/accessible <caption> text.
labellabelstring""Accessible aria-label when caption is omitted.
rowKeyrow-keystring"id"Property key used to derive unique row IDs.
stripedstripedbooleanfalseAlternates subtle striping across body rows.
stickyHeadersticky-headerbooleanfalsePins the table header during vertical scrolling.

Events

EventDetail TypeDescription
mth-sort{ sorting: ReadonlyArray<unknown> }Emitted when sorting rules change.
mth-selection-change{ selectedIds: ReadonlyArray<string> }Emitted when selected row IDs change.
mth-row-click{ id: string; row: unknown }Emitted when a data row is clicked.
mth-data-state{ status: unknown; count: number }Emitted when DataController transitions state.

APG Keyboard Matrix

KeyDirectionWhenExpected Behavior
ArrowRightltrHeader control has focusMoves focus to next header control
ArrowLeftrtlHeader control has focus in RTLMoves focus to next header control
HomebothHeader control has focusMoves focus to first header control
EndbothHeader control has focusMoves focus to last header control
EnterbothSortable column header button has focusToggles column sort order and emits mth-sort

Accessibility Checklist

CategoryRequirementVerified By
ariaAll aria-* IDREFs resolve within the same DOM root (ADR-003).scanSameRootAria
focusFocus ownership matches focusModel="none" with host role="table".lint-plugin & spec-compiler
contrastRenders legible borders, focus outlines, and selection indicators under forced-colors: active.Playwright forced-colors matrix
keyboardImplements all 5 APG keyboard transitions across LTR/RTL.mth-table.spec.test.ts
statesExposes ElementInternals CustomStateSet flags: :state(loading), :state(empty), :state(error), :state(striped).Conformance suite
i18nRoutes 8 UI/ARIA strings through @methane-ui/core i18n catalog.Locale context test