Active Table Web Component

1.1.8 · active · verified Tue Apr 21

Active Table is a framework-agnostic web component, currently at stable version 1.1.8, designed to provide a highly customizable and editable table experience. Built with Lit Element, it offers a robust feature set including adding, removing, moving, and editing rows/columns, text validation, sorting, pagination, filtering, and various column types (Text, Number, Currency, Select, Label, Date, Checkbox). It also provides an API for building custom column types, and capabilities for importing, exporting, pasting, and drag-and-dropping CSV, XLS, XLSX, ODS, and TXT files. The component supports programmatic cell updates, reactive dimensions, and handles overflow. Releases are frequent, addressing bugs and introducing new features like column/row dragging, indicating active development. Its key differentiator is being a standalone web component, allowing seamless integration into any JavaScript framework or vanilla HTML, and shipping with comprehensive TypeScript types.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to install, register, instantiate, and programmatically interact with the `active-table` web component in a TypeScript environment, including setting initial data and retrieving updated data.

import 'active-table'; // Registers the <active-table> custom element
import type { ActiveTable } from 'active-table'; // For TypeScript type safety

document.addEventListener('DOMContentLoaded', () => {
  const tableElement = document.createElement('active-table') as ActiveTable;
  tableElement.setAttribute('data', JSON.stringify([
    ['Product', 'Price', 'Stock'],
    ['Laptop', 1200, 50],
    ['Mouse', 25, 200],
    ['Keyboard', 75, 100],
  ]));
  // You can also set properties directly:
  tableElement.pagination = true;
  tableElement.enterKeyMoveDown = true;

  document.body.appendChild(tableElement);

  // Example of programmatic interaction after the table is rendered
  setTimeout(() => {
    const activeTableInstance = document.querySelector('active-table') as ActiveTable | null;
    if (activeTableInstance) {
      console.log('Current table data:', activeTableInstance.getData());
      // Programmatically add a row
      activeTableInstance.addRow(['Monitor', 300, 75]);
      console.log('Data after adding row:', activeTableInstance.getData());
    }
  }, 1000);
});

view raw JSON →