Web component / esm

<table-modifiable>

See the README for installation and API documentation.

Class-only import

This page loads the component class from esm.sh and registers it manually. The package root and table-modifiable.js export the class without registering it; unlike the definition-module example, this import needs customElements.define().

All columns remain readable before enhancement or if loading fails. After enhancement, open the native popover to choose columns. Focus the table region to scroll wider data with the arrow keys.

<script type="module">
import { TableModifiableElement } from
  'https://esm.sh/@aarongustafson/table-modifiable@1.1.3/table-modifiable.js?bundle&target=es2022';
if (!customElements.get('table-modifiable')) {
  customElements.define('table-modifiable', TableModifiableElement);
}
</script>

<table-modifiable removable="Name,Email,Phone"
  role="region" aria-label="Contact table" tabindex="0">
  <table>
    <caption>Contact directory</caption>
    <thead><tr>
      <th>Name</th><th>Email</th><th>Phone</th>
    </tr></thead>
    <tbody>
      <tr><td>John Doe</td><td>john@example.com</td><td>555-1234</td></tr>
      <tr><td>Jane Smith</td><td>jane@example.com</td><td>555-5678</td></tr>
      <tr><td>Bob Johnson</td><td>bob@example.com</td><td>555-9012</td></tr>
    </tbody>
  </table>
</table-modifiable>
Contact directory
Name Email Phone
John Doe john@example.com 555-1234
Jane Smith jane@example.com 555-5678
Bob Johnson bob@example.com 555-9012