0.2.1 โข Published 5 months ago
lit-material-datatable-demo v0.2.1
MD Data Table
A Material Design v3 data table component built with Lit and TypeScript, providing a modern, performant, and type-safe implementation of complex data tables.
Features
- ๐ Virtual scrolling for efficient rendering of large datasets
- ๐ Sortable columns with customizable sort logic
- โ๏ธ Resizable columns with drag handles
- โจ Material Design v3 theming and styling
- ๐ฏ TypeScript type safety
- ๐ฑ Responsive design with different size variants
- โ Row selection with checkboxes
- ๐ Loading states and progress indicators
Technical Stack
- Lit 3.2+
- TypeScript 5.7+
- Material Web Components 2.2
- Lit Labs Virtualizer for efficient scrolling
Architecture
The component uses a controller-based architecture for clean separation of concerns:
DataTableStateController
: Manages table state and dataEventsController
: Handles event dispatchingUiStateController
: Manages UI state and classesVirtualScrollController
: Handles virtual scrolling logic
Usage
import '@material/web/checkbox/checkbox.js';
import './components/data-table/md-data-table';
const columns = [{
label: 'ID',
id: 'id',
order: 1,
sortable: true
}, {
label: 'Name',
id: 'name',
order: 2
}];
@customElement('my-app')
export class MyApp extends LitElement {
render() {
return html`
<md-data-table
.columns=${columns}
.totalItems=${1000}
.dataProvider=${this.loadData}
sortable
resizable
selectable>
</md-data-table>
`;
}
}
Styling
The component uses Material Design v3 tokens for consistent theming:
- Follows MD3 color system
- Supports light/dark themes
- Uses MD3 typography scale
- Customizable via CSS custom properties
Events
sort-changed
: Emitted when column sort changesselection-changed
: Emitted when row selection changesvisibility-changed
: Emitted when visible rows changecolumn-resize
: Emitted when column width changescolumn-reorder
: Emitted when columns are reordered
License
MIT License - Copyright (c) 2025 Marek Bednรกล, Digitalworks Slovakia
Dependencies
{
"@lit-labs/virtualizer": "^2.0.15",
"@material/web": "^2.2.0",
"lit": "^3.2.1"
}
```-
0.2.1
5 months ago