Action Table is a lightweight and fast Web Component that turns static HTML tables into interactive ones with filter and sort capabilities.
1. Download and load the Action Table web component.
# NPM $ npm install @colinaut/action-table
<!-- Stylesheet --> <link rel="stylesheet" href="/path/to/action-table.css"> <!-- Core JavaScript --> <script type="module" src="/path/to/action-table.js"></script> <!-- Enable filter menus and switches --> <script type="module" src="/path/to/action-table-filters.js"></script> <!-- Enable toggle switches --> <script type="module" src="/path/to/action-table-switch.js"></script> <!-- Enable pagination controls --> <script type="module" src="/path/to/action-table-pagination.js"></script>
2. Wrap your HTML table into the <action-table> element.
<action-table store urlparams pagination="10">
<table>
<thead>
<tr>
<th>Animal</th>
<th>Name</th>
<th>Color</th>
<th>Age</th>
<th>Actions</th>
<th>Favs</th>
<th no-sort>Switch</th>
<th>Day</th>
</tr>
</thead>
<tbody>
<tr>
<td>rabbit</td>
<td>Attila</td>
<td>white</td>
<td>N/A</td>
<td><span>jump</span><span>eat</span></td>
<td>
<action-table-switch class="star"></action-table-switch>
</td>
<td class="switch"><input type="checkbox" aria-label="switch" /></td>
<td data-filter="Mon">Mon, 10am</td>
</tr>
<tr>
<td>small dog</td>
<td>Sophia</td>
<td>black</td>
<td>4</td>
<td><span>run</span><span>eat</span><span>snuggle</span></td>
<td>
<action-table-switch checked class="star"></action-table-switch>
</td>
<td class="switch"><input type="checkbox" aria-label="switch" /></td>
<td data-filter="Tue">Tue, 11am</td>
</tr>
<tr>
<td>rabbit</td>
<td>Cindy</td>
<td>brown</td>
<td>N/A</td>
<td><span>jump</span><span>run</span></td>
<td>
<action-table-switch checked class="star"></action-table-switch>
</td>
<td class="switch"><input type="checkbox" checked aria-label="switch" /></td>
<td data-filter="Sat">Sat, 1pm</td>
</tr>
<tr>
<td>raccoon</td>
<td>Sewer</td>
<td>gray</td>
<td>2</td>
<td><span>run</span><span>eat</span><span>hide</span></td>
<td>
<action-table-switch class="star"></action-table-switch>
</td>
<td class="switch"><input type="checkbox" aria-label="switch" /></td>
<td data-filter="Sun">Sun, 2pm</td>
</tr>
<tr>
<td>dog</td>
<td>Ziggy</td>
<td>gray</td>
<td>8</td>
<td><span>run</span><span>snuggle</span></td>
<td>
<action-table-switch class="star"></action-table-switch>
</td>
<td class="switch"><input type="checkbox" aria-label="switch" /></td>
<td data-filter="Mon">Mon, 3pm</td>
</tr>
<tr>
<td>raccoon</td>
<td>Wrapper</td>
<td>brown</td>
<td>6</td>
<td><span>eat</span></td>
<td>
<action-table-switch class="star"></action-table-switch>
</td>
<td class="switch"><input type="checkbox" checked aria-label="switch" /></td>
<td data-filter="Mon">Sun, 10am</td>
</tr>
<tr>
<td>cat</td>
<td>Tommy</td>
<td>brown</td>
<td>2</td>
<td><span>run</span><span>explore</span></td>
<td>
<action-table-switch checked class="star"></action-table-switch>
</td>
<td class="switch"><input type="checkbox" aria-label="switch" /></td>
<td data-filter="Tue">Tue, 11am</td>
</tr>
<tr>
<td>cat</td>
<td>Steve</td>
<td>black</td>
<td>6</td>
<td><span>run</span><span>snuggle</span></td>
<td>
<action-table-switch class="star" checked></action-table-switch>
</td>
<td class="switch"><input type="checkbox" checked aria-label="switch" /></td>
<td data-filter="Wed">Wed, 12pm</td>
</tr>
</tbody>
</table>
</action-table> 3. Create filter controls as follows:
<action-table-filters> <!-- Filter Menu --> <action-table-filter-menu name="Animal"></action-table-filter-menu> <action-table-filter-menu name="Day" label="Day"></action-table-filter-menu> <!-- Checkbox/Radio --> <action-table-filter-menu name="Color" type="checkbox" label="Color (default inclusive)"></action-table-filter-menu> <action-table-filter-menu name="Actions" type="checkbox" exclusive label="Actions (exclusive)"></action-table-filter-menu> <action-table-filter-menu name="Age" type="radio"></action-table-filter-menu> <!-- Switch --> <action-table-filter-switch class="star" name="Favs"></action-table-filter-switch> <action-table-filter-switch class="switch" name="Switch"></action-table-filter-switch> <!-- Search Field --> <label for="name-search">Search Name</label> <input id="name-search" name="name" type="search" placeholder="Search" /></div> <label for="action-table-search">Search Whole Table</label> <input id="action-table-search" name="action-table" type="search" placeholder="Search" /> </action-table-filters>
4. Add a custom pagination component to the table.
<action-table-pagination label="Showing {rows} of {total}:"></action-table-pagination>
<action-table-pagination-options options="5,10,25,50" label="Rows per:"></action-table-pagination-options> v2.4.22 (06/25/2025)
v2.4.21 (01/13/2025)
v2.4.19 (09/04/2024)
v2.4.18 (08/26/2024)
v2.4.17 (08/20/2024)
v2.4.16 (08/05/2024)
v2.4.15 (08/04/2024)
v2.4.14 (03/01/2024)
v2.4.13 (02/26/2024)
v2.4.12 (02/26/2024)
v2.4.11 (02/18/2024)
v2.4.9 (02/08/2024)
v2.4.6 (02/07/2024)
v2.4.4 (02/04/2024)
v2.4.2 (01/31/2024)
action-table-filter-menu includes new descending attribute to reverse the order of the listed options.data-order attribute for th in the table. This is an optional comma separated string attribute for setting the sort order manually for a given column.v2.4.1 (01/19/2024)
<action-table-filter-menu> so that the All text can be modified.v2.4.0 (01/19/2024)
<action-table-no-results> that you can place anywhere and write what you want inside.<action-table-filter-menu> now use includes() by default with use of regex test() as optional by adding regex attribute.<action-table-pagination> now indicates the current rows visible and the total number of rows.<action-table-pagination> element label text is now modifiable through the label attribute<action-table-pagination-options> element for creating a user accessible select menu for changing the number of rows shown per page.v2.3.9 (12/23/2023)
v2.3.8 (12/22/2023)
v2.3.1 (12/22/2023)
v2.3.0 (12/22/2023)
v2.2.2 (12/21/2023)
v2.2.1 (12/20/2023)
v2.1.6 (12/19/2023)
v2.1.5 (12/19/2023)
v2.1.3 (12/18/2023)
v2.1.2 (12/16/2023)
v2.1.1 (12/14/2023)
v2.1.0 (12/13/2023)
v2.0.5 (12/13/2023)
v2.0.0 (12/12/2023)
The post Add Sortable and Filterable Functionalities to HTML Tables with the Action Table Web Component appeared first on CSS Script.
Emily Blunt, Cillian Murphy, Millicent Simmonds, and Noah Jupe are officially reprising their roles for…
Whether you’re after a new Apple Watch Ultra or want to add a few new…
Sony's upgraded PlayStation Spectral Super Resolution (PSSR) technology is rolling out to several titles on…
There's no better time to dive into the world of immersive VR gaming. AliExpress is…
Krafton has been ordered to reinstate the former boss of Subnautica 2 studio Unknown Worlds…
Tje GeForce RTX 5080 graphics card will allow you to run all of the latest…
This website uses cookies.