Bootstrap 5 data tables display and interact with large datasets. This page covers 4 data table patterns — search filter, sortable, action buttons and pagination — each built with vanilla JavaScript and Bootstrap.

Quick Setup

Data tables need Bootstrap 5 CSS and JS:

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>

Key Classes Reference

ClassWhat It Does
.tableBase table class
.table-hoverRow highlight on hover
.table-stripedAlternating row colors
.align-middleVertically centers cell content
.table-responsiveHorizontal scroll on mobile
.paginationPagination nav component
.page-item.activeHighlights current page
.page-item.disabledDisables prev/next at boundaries

2. Bootstrap 5 Sortable Table

Click column headers to sort the table ascending or descending. Pure JavaScript sorting.

3. Bootstrap 5 Table with Action Buttons

Data table with edit, view and delete action buttons per row. Common in admin dashboards.

Frequently Asked Questions

Get all tbody rows as an array, sort them by the clicked column's cell text content, then re-append them to tbody. For numbers parse as float before comparing. Track sort direction in an object keyed by column index and toggle on each click.
Split rows into pages of N items. Show only the current page's rows using row.style.display. Update Bootstrap's pagination component active state and disable prev/next at boundaries. Recalculate on page change and rows-per-page change.
Loop through table rows building a CSV string: rows.forEach(row => csv += [...row.cells].map(c => c.textContent).join(',') + ' '). Create a Blob with type text/csv and trigger download: const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = 'data.csv'; a.click().
For basic search, sort and pagination vanilla JavaScript is fine. For advanced features like server-side pagination, column reordering, export to Excel, and complex filtering consider DataTables.js which has Bootstrap 5 styling support. Tabulator is another good option with no jQuery dependency.
Toggle a class on row click: row.addEventListener('click', function() { this.classList.toggle('table-primary'); }). For single selection remove the class from all rows first: rows.forEach(r => r.classList.remove('table-primary')); then add to the clicked row.

Need a Full Bootstrap 5 Admin Dashboard?

Get a complete Angular 21 + Bootstrap 5 dashboard with 50+ components — built by the same team behind BootstrapPlanet.

Browse Templates →

Use code FIRST30 for 30% off your first purchase.

Related Components