Semantic table
The comparison uses a real caption, column headers, table rows, and native buttons inside sortable headers.
Option demo
This product comparison table keeps all sortable-table options in markup, which is useful when a server-rendered page should initialize without a custom JavaScript configuration object.
Scenario
Sort laptops by fit score, price, launch date, and warranty coverage. The table starts with the highest fit score first and allows a third activation to restore the original order.
Try it
Example
Scroll horizontally to view all product details.
| Atlas 14 Rugged | 94 | $1,899 | 15 Mar 2026 | 36 months |
| HelioBook Air | 88 | $1,299 | 20 Jan 2026 | Not listed |
| Northstar Pro | 91 | $1,649 | 8 Nov 2025 | 24 months |
| FieldPad Max | 79 | $999 | 12 Sep 2025 | 12 months |
| Vector Studio 16 | 86 | $2,199 | 2 Apr 2026 | Not listed |
Developer notes
<table
data-a11y-sortable-table
data-a11y-sortable-table-default-sort="score"
data-a11y-sortable-table-default-direction="descending"
data-a11y-sortable-table-allow-unsort="true"
data-a11y-sortable-table-descending-first-types="number,date,rating"
data-a11y-sortable-table-empty-values-last="false"
>
...
</table>
import {
enhanceScrollableTableWrapper,
initSortableTables
} from "../../dist/index.js";
initSortableTables();
enhanceScrollableTableWrapper(document.getElementById("products-wrapper"));
Accessibility notes
The comparison uses a real caption, column headers, table rows, and native buttons inside sortable headers.
Sorting preserves focus on the activated header button and updates
aria-sort on the active header cell.
Data attributes cover safe scalar options. Use JavaScript options for functions such as custom parsers or custom sorters.