26/Forms and data
Data table
Table with column sorting, search, filter, pagination and row selection. Without JS it looks like a normal table.
Full
Try sorting by amount or date, searching, filtering by status and selecting rows.
| Nombre | Área | Estado | Monto | Última compra | |
|---|---|---|---|---|---|
| María Ramírez | Ventas | activo | Q 48.210 | 2026-09-14 | |
| José López | Soporte | activo | Q 12.900 | 2026-08-02 | |
| Ana Pérez | Operaciones | pausado | Q 30.500 | 2026-07-21 | |
| Luis Gómez | Ventas | activo | Q 8700 | 2026-10-01 | |
| Carla Méndez | Finanzas | inactivo | Q 0 | 2026-03-11 | |
| Pedro Castillo | Soporte | activo | Q 15.420 | 2026-09-30 | |
| Sofía Herrera | Operaciones | activo | Q 22.100 | 2026-06-18 | |
| Diego Morales | Ventas | pausado | Q 5300 | 2026-05-05 |
HTML
<div class="cb-table-wrap rounded-none border-0" data-cb-table data-cb-page-size="5">
<div class="cb-table-toolbar">
<div class="cb-table-toolbar__filters">
<input class="cb-input cb-input--sm" type="search" placeholder="Buscar..." aria-label="Buscar en la tabla" data-cb-table-search>
<div class="cb-select"><select class="cb-input cb-input--sm" aria-label="Filtrar por estado" data-cb-table-filter="estado"><option value="">Todos los estados</option><option value="activo">Activo</option><option value="pausado">Pausado</option><option value="inactivo">Inactivo</option></select></div>
</div>
<button class="cb-btn cb-btn--outline cb-btn--sm" type="button">Exportar</button>
</div>
<div class="cb-table-scroll">
<table class="cb-table">
<thead>
<tr>
<th class="cb-table__check"><input class="cb-checkbox" type="checkbox" data-cb-table-select-all aria-label="Seleccionar todo"></th>
<th scope="col" data-cb-sort>Nombre</th>
<th scope="col" data-cb-sort>Área</th>
<th scope="col">Estado</th>
<th scope="col" class="cb-table__num" data-cb-sort="number">Monto</th>
<th scope="col" data-cb-sort="date">Última compra</th>
</tr>
</thead>
<tbody>
<tr data-estado="activo">
<td><input class="cb-checkbox" type="checkbox" data-cb-table-select aria-label="Seleccionar a María Ramírez"></td>
<td class="cb-table__strong">María Ramírez</td>
<td>Ventas</td>
<td><span class="cb-tag cb-tag--success">activo</span></td>
<td class="cb-table__num" data-value="48210">Q 48.210</td>
<td data-value="2026-09-14">2026-09-14</td>
</tr>
<tr data-estado="activo">
<td><input class="cb-checkbox" type="checkbox" data-cb-table-select aria-label="Seleccionar a José López"></td>
<td class="cb-table__strong">José López</td>
<td>Soporte</td>
<td><span class="cb-tag cb-tag--success">activo</span></td>
<td class="cb-table__num" data-value="12900">Q 12.900</td>
<td data-value="2026-08-02">2026-08-02</td>
</tr>
<tr data-estado="pausado">
<td><input class="cb-checkbox" type="checkbox" data-cb-table-select aria-label="Seleccionar a Ana Pérez"></td>
<td class="cb-table__strong">Ana Pérez</td>
<td>Operaciones</td>
<td><span class="cb-tag cb-tag--warning">pausado</span></td>
<td class="cb-table__num" data-value="30500">Q 30.500</td>
<td data-value="2026-07-21">2026-07-21</td>
</tr>
<tr data-estado="activo">
<td><input class="cb-checkbox" type="checkbox" data-cb-table-select aria-label="Seleccionar a Luis Gómez"></td>
<td class="cb-table__strong">Luis Gómez</td>
<td>Ventas</td>
<td><span class="cb-tag cb-tag--success">activo</span></td>
<td class="cb-table__num" data-value="8700">Q 8700</td>
<td data-value="2026-10-01">2026-10-01</td>
</tr>
<tr data-estado="inactivo">
<td><input class="cb-checkbox" type="checkbox" data-cb-table-select aria-label="Seleccionar a Carla Méndez"></td>
<td class="cb-table__strong">Carla Méndez</td>
<td>Finanzas</td>
<td><span class="cb-tag ">inactivo</span></td>
<td class="cb-table__num" data-value="0">Q 0</td>
<td data-value="2026-03-11">2026-03-11</td>
</tr>
<tr data-estado="activo">
<td><input class="cb-checkbox" type="checkbox" data-cb-table-select aria-label="Seleccionar a Pedro Castillo"></td>
<td class="cb-table__strong">Pedro Castillo</td>
<td>Soporte</td>
<td><span class="cb-tag cb-tag--success">activo</span></td>
<td class="cb-table__num" data-value="15420">Q 15.420</td>
<td data-value="2026-09-30">2026-09-30</td>
</tr>
<tr data-estado="activo">
<td><input class="cb-checkbox" type="checkbox" data-cb-table-select aria-label="Seleccionar a Sofía Herrera"></td>
<td class="cb-table__strong">Sofía Herrera</td>
<td>Operaciones</td>
<td><span class="cb-tag cb-tag--success">activo</span></td>
<td class="cb-table__num" data-value="22100">Q 22.100</td>
<td data-value="2026-06-18">2026-06-18</td>
</tr>
<tr data-estado="pausado">
<td><input class="cb-checkbox" type="checkbox" data-cb-table-select aria-label="Seleccionar a Diego Morales"></td>
<td class="cb-table__strong">Diego Morales</td>
<td>Ventas</td>
<td><span class="cb-tag cb-tag--warning">pausado</span></td>
<td class="cb-table__num" data-value="5300">Q 5300</td>
<td data-value="2026-05-05">2026-05-05</td>
</tr>
</tbody>
</table>
</div>
<div class="cb-table-footer">
<span data-cb-table-status aria-live="polite"></span>
<nav data-cb-table-pagination aria-label="Paginación de la tabla"></nav>
</div>
</div>
Simple
Without data-cb-table it is style only. cb-table--compact reduces the padding.
| Plan | Usuarios | Precio |
|---|---|---|
| Básico | 1 | $9 |
| Pro | 10 | $29 |
HTML
<div class="cb-table-wrap">
<table class="cb-table cb-table--compact">
<thead><tr><th scope="col">Plan</th><th scope="col" class="cb-table__num">Usuarios</th><th scope="col" class="cb-table__num">Precio</th></tr></thead>
<tbody>
<tr><td class="cb-table__strong">Básico</td><td class="cb-table__num">1</td><td class="cb-table__num">$9</td></tr>
<tr><td class="cb-table__strong">Pro</td><td class="cb-table__num">10</td><td class="cb-table__num">$29</td></tr>
</tbody>
</table>
</div>
Classes and modifiers
| Class | Description |
|---|---|
.cb-table-wrap | Box with a border. |
.cb-table-toolbar, .cb-table-toolbar__filters | Top bar with search and filters. |
.cb-table-scroll | Horizontal scroll on small screens. |
.cb-table | Table. --compact reduces the spacing. |
.cb-table__strong, .cb-table__num, .cb-table__check | Highlighted cell, numeric cell (right aligned) and selection cell. |
.cb-table__sort | Sort button that JS creates inside the th. |
.cb-table-footer | Footer with status and pagination. |
data-cb-* attributes
| Attribute | Description |
|---|---|
data-cb-table | Enables the behavior. |
data-cb-page-size="n" | Rows per page. Without it there is no pagination. |
data-cb-sort / data-cb-sort="number|date" | On a th, makes that column sortable. |
data-value | On a cell, value used for sorting instead of the text. |
data-cb-table-search | Input that searches all columns (ignores accents). |
data-cb-table-filter="clave" | Select that compares its value with the data-clave of each row. |
data-cb-table-select / data-cb-table-select-all | Row and header checkboxes. |
data-cb-table-status, data-cb-table-pagination | Where to write the status and the pagination. |
data-cb-table-empty | Text shown when there are no results. Default: "No results". |
data-cb-table-status-text | Status template, with {start}, {end} and {total}. |
data-cb-table-selected-text | Selection template, with {count}. |
data-cb-pagination-prev / data-cb-pagination-next | aria-label of the pagination arrows. |
data-cb-pagination-page | aria-label of each page, with {page}. |
JavaScript
| Event | When it fires |
|---|---|
cb:sort | On sort (detail.column, detail.direction). |
cb:filter | On search or filter. |
cb:page | On page change (detail.page). |
cb:select | On selection change (detail.rows). |
Read the selected rows:
JS
const table = document.querySelector('[data-cb-table]');
table.addEventListener('cb:select', (event) => {
const ids = event.detail.rows.map((row) => row.dataset.id);
});
Accessibility
- Sortable headers get
aria-sortand a button so they can be used with the keyboard. - Selected rows carry
aria-selected="true". - The status ("Showing 1–5 of 8") lives in an
aria-liveregion. - Each row checkbox needs an
aria-labelwith the record's name.