Explore this collection of versatile table components built with Tailwind CSS. These examples provide clean, responsive designs suitable for various data presentation needs in modern web applications.
Each table comes with a preview and readily copyable HTML code. Simply integrate them into your Tailwind project and customize as needed.
Basic Table
Preview
HTML
Product name
Color
Category
Price
Apple MacBook Pro 17"
Silver
Laptop
$2999
Microsoft Surface Pro
White
Laptop PC
$1999
Magic Mouse 2
Black
Accessories
$99
Copy
<!-- Basic Table -->
<div class="overflow-x-auto relative">
<table class="min-w-full text-sm text-left text-gray-700">
<thead class="text-xs text-gray-700 uppercase bg-gray-100">
<tr>
<th scope="col" class="px-6 py-3">
Product name
</th>
<th scope="col" class="px-6 py-3">
Color
</th>
<th scope="col" class="px-6 py-3">
Category
</th>
<th scope="col" class="px-6 py-3">
Price
</th>
</tr>
</thead>
<tbody>
<tr class="bg-white border-b border-gray-100">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
Apple MacBook Pro 17"
</th>
<td class="px-6 py-4">
Silver
</td>
<td class="px-6 py-4">
Laptop
</td>
<td class="px-6 py-4">
$2999
</td>
</tr>
<tr class="bg-white border-b border-gray-100">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
Microsoft Surface Pro
</th>
<td class="px-6 py-4">
White
</td>
<td class="px-6 py-4">
Laptop PC
</td>
<td class="px-6 py-4">
$1999
</td>
</tr>
<tr class="bg-white">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
Magic Mouse 2
</th>
<td class="px-6 py-4">
Black
</td>
<td class="px-6 py-4">
Accessories
</td>
<td class="px-6 py-4">
$99
</td>
</tr>
</tbody>
</table>
</div>
Striped Table
Uses the odd:bg-white even:bg-gray-50 utility classes on table rows within <tbody>.
Preview
HTML
User
Email
Role
Status
Alice Johnson
alice.j@example.com
Admin
Active
Bob Williams
bob.w@example.com
Developer
Active
Charlie Brown
charlie.b@example.com
Designer
Pending
Diana Davis
diana.d@example.com
Support
Inactive
Copy
<!-- Striped Table -->
<div class="overflow-x-auto relative">
<table class="min-w-full text-sm text-left text-gray-700">
<thead class="text-xs text-gray-700 uppercase bg-gray-100">
<tr>
<th scope="col" class="px-6 py-3">User</th>
<th scope="col" class="px-6 py-3">Email</th>
<th scope="col" class="px-6 py-3">Role</th>
<th scope="col" class="px-6 py-3">Status</th>
</tr>
</thead>
<tbody>
<tr class="odd:bg-white even:bg-gray-50 border-b border-gray-100">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">Alice Johnson</th>
<td class="px-6 py-4">alice.j@example.com</td>
<td class="px-6 py-4">Admin</td>
<td class="px-6 py-4"><span class="bg-green-100 text-green-800 text-xs font-medium mr-2 px-2.5 py-0.5 rounded">Active</span></td>
</tr>
<tr class="odd:bg-white even:bg-gray-50 border-b border-gray-100">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">Bob Williams</th>
<td class="px-6 py-4">bob.w@example.com</td>
<td class="px-6 py-4">Developer</td>
<td class="px-6 py-4"><span class="bg-green-100 text-green-800 text-xs font-medium mr-2 px-2.5 py-0.5 rounded">Active</span></td>
</tr>
<tr class="odd:bg-white even:bg-gray-50 border-b border-gray-100">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">Charlie Brown</th>
<td class="px-6 py-4">charlie.b@example.com</td>
<td class="px-6 py-4">Designer</td>
<td class="px-6 py-4"><span class="bg-yellow-100 text-yellow-800 text-xs font-medium mr-2 px-2.5 py-0.5 rounded">Pending</span></td>
</tr>
<tr class="odd:bg-white even:bg-gray-50">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">Diana Davis</th>
<td class="px-6 py-4">diana.d@example.com</td>
<td class="px-6 py-4">Support</td>
<td class="px-6 py-4"><span class="bg-red-100 text-red-800 text-xs font-medium mr-2 px-2.5 py-0.5 rounded">Inactive</span></td>
</tr>
</tbody>
</table>
</div>
Bordered Table
Adds borders to the table and cells using border border-collapse border-gray-300 on the table and border border-gray-300 on cells.
Preview
HTML
Invoice ID
Customer
Amount
Date
INV-001
Ethan Hunt
$150.00
2023-10-26
INV-002
Ilsa Faust
$275.50
2023-10-27
INV-003
Benji Dunn
$99.99
2023-10-28
Copy
<!-- Bordered Table -->
<div class="overflow-x-auto relative">
<table class="min-w-full text-sm text-left text-gray-700 border border-collapse border-gray-300">
<thead class="text-xs text-gray-700 uppercase bg-gray-100">
<tr>
<th scope="col" class="px-4 py-2 border border-gray-300">Invoice ID</th>
<th scope="col" class="px-4 py-2 border border-gray-300">Customer</th>
<th scope="col" class="px-4 py-2 border border-gray-300">Amount</th>
<th scope="col" class="px-4 py-2 border border-gray-300">Date</th>
</tr>
</thead>
<tbody>
<tr class="bg-white">
<td class="px-4 py-2 border border-gray-300 font-medium text-gray-900">INV-001</td>
<td class="px-4 py-2 border border-gray-300">Ethan Hunt</td>
<td class="px-4 py-2 border border-gray-300">$150.00</td>
<td class="px-4 py-2 border border-gray-300">2023-10-26</td>
</tr>
<tr class="bg-white">
<td class="px-4 py-2 border border-gray-300 font-medium text-gray-900">INV-002</td>
<td class="px-4 py-2 border border-gray-300">Ilsa Faust</td>
<td class="px-4 py-2 border border-gray-300">$275.50</td>
<td class="px-4 py-2 border border-gray-300">2023-10-27</td>
</tr>
<tr class="bg-white">
<td class="px-4 py-2 border border-gray-300 font-medium text-gray-900">INV-003</td>
<td class="px-4 py-2 border border-gray-300">Benji Dunn</td>
<td class="px-4 py-2 border border-gray-300">$99.99</td>
<td class="px-4 py-2 border border-gray-300">2023-10-28</td>
</tr>
</tbody>
</table>
</div>
Hoverable Row Table
Adds a hover effect to table rows using hover:bg-gray-100 and optionally cursor-pointer on rows within <tbody>.
Preview
HTML
Task
Assigned To
Due Date
Priority
Design Homepage Mockup
Sarah Lee
2023-11-10
High
Develop API Endpoint
Mike Chen
2023-11-15
High
Write Documentation
Lisa Green
2023-11-20
Medium
User Testing
Team
2023-11-25
Low
Copy
<!-- Hoverable Row Table -->
<div class="overflow-x-auto relative">
<table class="min-w-full text-sm text-left text-gray-700">
<thead class="text-xs text-gray-700 uppercase bg-gray-100">
<tr>
<th scope="col" class="px-6 py-3">Task</th>
<th scope="col" class="px-6 py-3">Assigned To</th>
<th scope="col" class="px-6 py-3">Due Date</th>
<th scope="col" class="px-6 py-3">Priority</th>
</tr>
</thead>
<tbody>
<tr class="bg-white border-b border-gray-100 hover:bg-gray-100 cursor-pointer">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">Design Homepage Mockup</th>
<td class="px-6 py-4">Sarah Lee</td>
<td class="px-6 py-4">2023-11-10</td>
<td class="px-6 py-4"><span class="text-red-600">High</span></td>
</tr>
<tr class="bg-white border-b border-gray-100 hover:bg-gray-100 cursor-pointer">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">Develop API Endpoint</th>
<td class="px-6 py-4">Mike Chen</td>
<td class="px-6 py-4">2023-11-15</td>
<td class="px-6 py-4"><span class="text-red-600">High</span></td>
</tr>
<tr class="bg-white border-b border-gray-100 hover:bg-gray-100 cursor-pointer">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">Write Documentation</th>
<td class="px-6 py-4">Lisa Green</td>
<td class="px-6 py-4">2023-11-20</td>
<td class="px-6 py-4"><span class="text-yellow-600">Medium</span></td>
</tr>
<tr class="bg-white hover:bg-gray-100 cursor-pointer">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">User Testing</th>
<td class="px-6 py-4">Team</td>
<td class="px-6 py-4">2023-11-25</td>
<td class="px-6 py-4"><span class="text-green-600">Low</span></td>
</tr>
</tbody>
</table>
</div>
Selectable Row Table
Includes checkboxes for row selection. Basic hover styles are included. You'll need JavaScript to handle the actual selection logic (checking boxes, toggling background colors like .bg-blue-50).
Preview
HTML
Copy
<!-- Selectable Row Table -->
<!-- Requires JavaScript to handle checkbox state and row background toggling (e.g., adding/removing 'bg-blue-50') -->
<div class="overflow-x-auto relative">
<table class="min-w-full text-sm text-left text-gray-700">
<thead class="text-xs text-gray-700 uppercase bg-gray-100">
<tr>
<th scope="col" class="p-4">
<div class="flex items-center">
<input id="checkbox-all-search" type="checkbox" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 focus:ring-2">
<label for="checkbox-all-search" class="sr-only">checkbox</label>
</div>
</th>
<th scope="col" class="px-6 py-3">File Name</th>
<th scope="col" class="px-6 py-3">Type</th>
<th scope="col" class="px-6 py-3">Size</th>
<th scope="col" class="px-6 py-3">Last Modified</th>
</tr>
</thead>
<tbody>
<tr class="bg-white border-b border-gray-100 hover:bg-gray-50">
<td class="w-4 p-4">
<div class="flex items-center">
<input id="checkbox-table-search-1" type="checkbox" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 focus:ring-2">
<label for="checkbox-table-search-1" class="sr-only">checkbox</label>
</div>
</td>
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">report-q3.pdf</th>
<td class="px-6 py-4">PDF Document</td>
<td class="px-6 py-4">1.2 MB</td>
<td class="px-6 py-4">2023-10-25</td>
</tr>
<tr class="bg-white border-b border-gray-100 hover:bg-gray-50"> <!-- Add 'bg-blue-50' class via JS when selected -->
<td class="w-4 p-4">
<div class="flex items-center">
<input id="checkbox-table-search-2" type="checkbox" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 focus:ring-2">
<label for="checkbox-table-search-2" class="sr-only">checkbox</label>
</div>
</td>
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">logo-final.png</th>
<td class="px-6 py-4">PNG Image</td>
<td class="px-6 py-4">350 KB</td>
<td class="px-6 py-4">2023-10-20</td>
</tr>
<tr class="bg-white border-b border-gray-100 hover:bg-gray-50">
<td class="w-4 p-4">
<div class="flex items-center">
<input id="checkbox-table-search-3" type="checkbox" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 focus:ring-2">
<label for="checkbox-table-search-3" class="sr-only">checkbox</label>
</div>
</td>
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">presentation.pptx</th>
<td class="px-6 py-4">PowerPoint Presentation</td>
<td class="px-6 py-4">5.8 MB</td>
<td class="px-6 py-4">2023-10-15</td>
</tr>
<tr class="bg-white hover:bg-gray-50">
<td class="w-4 p-4">
<div class="flex items-center">
<input id="checkbox-table-search-4" type="checkbox" class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 focus:ring-2">
<label for="checkbox-table-search-4" class="sr-only">checkbox</label>
</div>
</td>
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">budget.xlsx</th>
<td class="px-6 py-4">Excel Spreadsheet</td>
<td class="px-6 py-4">75 KB</td>
<td class="px-6 py-4">2023-09-30</td>
</tr>
</tbody>
</table>
</div>
Responsive Table (Stacked Mobile)
This table transforms into a stacked layout on smaller screens (below 768px). It uses custom CSS (included in the <style> tag of this page) and data-label attributes on table cells.
Preview
HTML
Name
Title
Email
Role
Actions
Jane Doe
CEO
jane.doe@company.com
Admin
Edit
Delete
John Smith
Marketing Head
john.smith@company.com
Editor
Edit
Delete
Peter Jones
Lead Developer
peter.jones@company.com
Member
Edit
Delete
Copy
<!-- Responsive Table (Stacked Mobile) -->
<!-- Requires custom CSS for stacking (see <style> block in head or your CSS file) -->
<!-- Add the class 'responsive-table-stacked' to the <table> element -->
<!-- Add 'data-label' attributes to each <td> corresponding to the column header -->
<div class="overflow-x-auto relative">
<table class="w-full text-sm text-left text-gray-700 responsive-table-stacked">
<thead class="text-xs text-gray-700 uppercase bg-gray-100">
<tr>
<th scope="col" class="px-6 py-3">Name</th>
<th scope="col" class="px-6 py-3">Title</th>
<th scope="col" class="px-6 py-3">Email</th>
<th scope="col" class="px-6 py-3">Role</th>
<th scope="col" class="px-6 py-3">Actions</th>
</tr>
</thead>
<tbody>
<tr class="bg-white border-b border-gray-100">
<td data-label="Name" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">Jane Doe</td>
<td data-label="Title" class="px-6 py-4">CEO</td>
<td data-label="Email" class="px-6 py-4">jane.doe@company.com</td>
<td data-label="Role" class="px-6 py-4">Admin</td>
<td data-label="Actions" class="px-6 py-4 space-x-2 whitespace-nowrap">
<a href="#" class="font-medium text-blue-600 hover:underline">Edit</a>
<a href="#" class="font-medium text-red-600 hover:underline">Delete</a>
</td>
</tr>
<tr class="bg-white border-b border-gray-100">
<td data-label="Name" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">John Smith</td>
<td data-label="Title" class="px-6 py-4">Marketing Head</td>
<td data-label="Email" class="px-6 py-4">john.smith@company.com</td>
<td data-label="Role" class="px-6 py-4">Editor</td>
<td data-label="Actions" class="px-6 py-4 space-x-2 whitespace-nowrap">
<a href="#" class="font-medium text-blue-600 hover:underline">Edit</a>
<a href="#" class="font-medium text-red-600 hover:underline">Delete</a>
</td>
</tr>
<tr class="bg-white">
<td data-label="Name" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">Peter Jones</td>
<td data-label="Title" class="px-6 py-4">Lead Developer</td>
<td data-label="Email" class="px-6 py-4">peter.jones@company.com</td>
<td data-label="Role" class="px-6 py-4">Member</td>
<td data-label="Actions" class="px-6 py-4 space-x-2 whitespace-nowrap">
<a href="#" class="font-medium text-blue-600 hover:underline">Edit</a>
<a href="#" class="font-medium text-red-600 hover:underline">Delete</a>
</td>
</tr>
</tbody>
</table>
</div>
Expandable Row Table
Rows can be clicked to reveal more details in a secondary row. Requires minimal JavaScript (included in the <script> block at the end of this page) to toggle the visibility of the detail row.
Preview
HTML
Order ID
Customer
Date
Total
ORD-101
Michael Scott
2023-10-28
$125.50
Shipping Address: 123 Paper St, Scranton, PA
Items: 1x Premium Paper Bundle, 2x Ballpoint Pens
ORD-102
Dwight Schrute
2023-10-29
$75.00
Shipping Address: Schrute Farms, Honesdale, PA
Items: 3x Beets
ORD-103
Pam Beesly
2023-10-30
$50.25
Shipping Address: 456 Art Ave, Scranton, PA
Items: 1x Watercolor Set
Copy
<!-- Expandable Row Table -->
<!-- Requires JavaScript to toggle the 'hidden' class on the '.expandable-content' row -->
<!-- Add the 'expandable-row-trigger' class to the clickable row -->
<!-- Add the 'expandable-content' class to the initially hidden row -->
<!-- Optional: Add JS to rotate the arrow icon (e.g., adding a 'rotate-90' class) -->
<div class="overflow-x-auto relative">
<table class="min-w-full text-sm text-left text-gray-700">
<thead class="text-xs text-gray-700 uppercase bg-gray-100">
<tr>
<th scope="col" class="px-6 py-3 w-10"><!-- Expand icon column --></th>
<th scope="col" class="px-6 py-3">Order ID</th>
<th scope="col" class="px-6 py-3">Customer</th>
<th scope="col" class="px-6 py-3">Date</th>
<th scope="col" class="px-6 py-3">Total</th>
</tr>
</thead>
<tbody> <!-- Add a unique ID here if needed for JS scoping, e.g., id="my-expandable-table" -->
<!-- Row 1 -->
<tr class="bg-white border-b border-gray-100 hover:bg-gray-50 cursor-pointer expandable-row-trigger">
<td class="px-6 py-4">
<svg class="w-4 h-4 text-gray-500 transform transition-transform duration-200" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path></svg>
</td>
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">ORD-101</th>
<td class="px-6 py-4">Michael Scott</td>
<td class="px-6 py-4">2023-10-28</td>
<td class="px-6 py-4">$125.50</td>
</tr>
<tr class="hidden expandable-content bg-gray-50">
<td colspan="5" class="p-4 text-sm text-gray-600">
<p><strong>Shipping Address:</strong> 123 Paper St, Scranton, PA</p>
<p><strong>Items:</strong> 1x Premium Paper Bundle, 2x Ballpoint Pens</p>
</td>
</tr>
<!-- Row 2 -->
<tr class="bg-white border-b border-gray-100 hover:bg-gray-50 cursor-pointer expandable-row-trigger">
<td class="px-6 py-4">
<svg class="w-4 h-4 text-gray-500 transform transition-transform duration-200" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path></svg>
</td>
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">ORD-102</th>
<td class="px-6 py-4">Dwight Schrute</td>
<td class="px-6 py-4">2023-10-29</td>
<td class="px-6 py-4">$75.00</td>
</tr>
<tr class="hidden expandable-content bg-gray-50">
<td colspan="5" class="p-4 text-sm text-gray-600">
<p><strong>Shipping Address:</strong> Schrute Farms, Honesdale, PA</p>
<p><strong>Items:</strong> 3x Beets</p>
</td>
</tr>
<!-- Row 3 -->
<tr class="bg-white hover:bg-gray-50 cursor-pointer expandable-row-trigger">
<td class="px-6 py-4">
<svg class="w-4 h-4 text-gray-500 transform transition-transform duration-200" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path></svg>
</td>
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">ORD-103</th>
<td class="px-6 py-4">Pam Beesly</td>
<td class="px-6 py-4">2023-10-30</td>
<td class="px-6 py-4">$50.25</td>
</tr>
<tr class="hidden expandable-content bg-gray-50">
<td colspan="5" class="p-4 text-sm text-gray-600">
<p><strong>Shipping Address:</strong> 456 Art Ave, Scranton, PA</p>
<p><strong>Items:</strong> 1x Watercolor Set</p>
</td>
</tr>
</tbody>
</table>
</div>
Grouped Row Table
Uses multiple <tbody> elements or styled rows to visually group related data.
Preview
HTML
Employee
Department
Status
Sales Department
Andy Bernard
Sales
Active
Phyllis Lapin-Vance
Sales
Active
Accounting Department
Angela Martin
Accounting
Active
Kevin Malone
Accounting
Active
Oscar Martinez
Accounting
On Leave
Human Resources
Toby Flenderson
HR
Active
Copy
<!-- Grouped Row Table -->
<!-- Uses multiple <tbody> elements and styled header rows for grouping -->
<div class="overflow-x-auto relative">
<table class="min-w-full text-sm text-left text-gray-700">
<thead class="text-xs text-gray-700 uppercase bg-gray-100">
<tr>
<th scope="col" class="px-6 py-3">Employee</th>
<th scope="col" class="px-6 py-3">Department</th>
<th scope="col" class="px-6 py-3">Status</th>
</tr>
</thead>
<!-- Group 1: Sales -->
<tbody class="bg-white">
<tr class="bg-gray-200 font-semibold text-gray-700">
<td colspan="3" class="px-6 py-2">Sales Department</td>
</tr>
<tr class="border-b border-gray-100">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">Andy Bernard</th>
<td class="px-6 py-4">Sales</td>
<td class="px-6 py-4">Active</td>
</tr>
<tr class="border-b border-gray-100">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">Phyllis Lapin-Vance</th>
<td class="px-6 py-4">Sales</td>
<td class="px-6 py-4">Active</td>
</tr>
</tbody>
<!-- Group 2: Accounting -->
<tbody class="bg-white">
<tr class="bg-gray-200 font-semibold text-gray-700">
<td colspan="3" class="px-6 py-2">Accounting Department</td>
</tr>
<tr class="border-b border-gray-100">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">Angela Martin</th>
<td class="px-6 py-4">Accounting</td>
<td class="px-6 py-4">Active</td>
</tr>
<tr class="border-b border-gray-100">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">Kevin Malone</th>
<td class="px-6 py-4">Accounting</td>
<td class="px-6 py-4">Active</td>
</tr>
<tr class=""> <!-- Last row in group, no bottom border needed -->
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">Oscar Martinez</th>
<td class="px-6 py-4">Accounting</td>
<td class="px-6 py-4">On Leave</td>
</tr>
</tbody>
<!-- Group 3: HR -->
<tbody class="bg-white">
<tr class="bg-gray-200 font-semibold text-gray-700">
<td colspan="3" class="px-6 py-2">Human Resources</td>
</tr>
<tr class=""> <!-- Last row in group, no bottom border needed -->
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">Toby Flenderson</th>
<td class="px-6 py-4">HR</td>
<td class="px-6 py-4">Active</td>
</tr>
</tbody>
</table>
</div>
FAQ on Tailwind CSS Tables
How do I create a basic table using Tailwind CSS?
Creating a basic table requires HTML table markup combined with Tailwind utility classes. Start with standard <table>, <thead>, <tbody>, <tr>, <th>, and <td> elements. Apply classes like w-full for full width, border for borders, and p-4 for cell padding. Responsive tables often need an overflow-x-auto wrapper for horizontal scrolling on mobile devices.
What's the difference between table-auto and table-fixed layout utilities?
Table-auto automatically sizes columns based on cell content, adjusting dynamically as text length changes. Table-fixed ignores content length and divides space equally (or according to set widths). Choose table-auto for dynamic data where column width should match content or table-fixed when you need consistent column widths regardless of content.
How can I make Tailwind CSS tables responsive?
Wrap your table in a container with overflow-x-auto to enable horizontal scrolling on small screens. For complex data presentation , consider responsive design patterns like column hiding, stacking rows as cards, or collapsible sections. Many component libraries offer responsive table variants with built-in mobile-friendly features for optimal data visualization across devices.
Can I create striped tables with Tailwind?
Yes! Use the odd:bg-gray-50 or even:bg-gray-50 utilities on table rows to create zebra striping . For example:
<tr class="even:bg-gray-50">
This simple pattern enhances readability in data-heavy tables by alternating row backgrounds, improving the user interface without custom CSS.
How do I add hover effects to table rows?
Apply the hover: variant to your row styling. For example, hover:bg-slate-50 highlights rows when users mouse over them. This interactive table pattern improves user experience by providing visual feedback. You can combine hover effects with other conditional formatting for sophisticated table interactions.
What are the best Tailwind component libraries for advanced tables?
Several high-quality libraries offer pre-built table components:
Tailwind UI (official premium components)
Flowbite (comprehensive free tables)
DaisyUI (simple, customizable tables)
Material Tailwind (Material Design styled tables)
HyperUI (modern, accessible tables)
These provide sortable tables , filtering options, pagination, and other advanced features beyond basic styling.
How do I create table headers that stick when scrolling?
Create sticky headers with the sticky and top-0 utilities on your <thead> or <tr> elements. Add z-10 to ensure proper layering and a background color to prevent content showing through. This table structure pattern improves usability for long data tables, keeping column headers visible during vertical scrolling.
How can I customize table borders in Tailwind CSS?
Control borders using utilities like border, border-collapse, border-separate, and color variants like border-gray-200. Apply to specific elements (table, rows, cells) for different effects:
Full borders: border border-gray-200
Horizontal dividers: border-b
No borders: Remove border classes
Rounded corners: Add rounded to cells (with border-separate)
Can I create sortable tables with pure Tailwind?
Tailwind provides styling only. For sortable table functionality, you'll need JavaScript. Common approaches: Use table components from libraries (Tailwind UI, Flowbite), integrate with frameworks like React Table, add sorting icons with Tailwind classes (rotate, transition), or implement custom sorting with Alpine.js for lightweight applications. The styling/functionality separation follows Tailwind's utility-first CSS approach.
How do I handle tables with lots of data in Tailwind?
For large datasets, implement:
Table pagination with page navigation
Infinite scrolling within fixed height containers
Data filtering to show relevant information
Collapsible rows for hierarchical data
Column toggles to hide/show columns
Combine these data display techniques with table-fixed layout and overflow handling for optimal performance and usability in admin dashboards and web applications .