In this tutorial we will create simple tailwind css datatable, tailwind css datatable with icon, tailwind css datatable with divider, examples with Tailwind CSS.
Tool Use
Tailwind CSS 2.x / 3.x
Jquery 3.1
jquery.dataTables.js
jquery.dataTables.css
Heroicons Icons
Setup Project
Using CDN
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
or
The Easiest way to install Tailwind CSS with Tailwind CLI
How to Install Tailwind CSS with NPM
👉 Tailwind CSS Simple Table Example
Example 1
Simple DataTable
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DataTable</title>
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" charset="utf8"
src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.js"></script>
</head>
<body>
<div class="container mx-auto">
<div class="flex flex-col">
<div class="w-full">
<div class="p-4 border-b border-gray-200 shadow">
<!-- <table> -->
<table id="dataTable" class="p-4">
<thead class="bg-gray-50">
<tr>
<th class="p-8 text-xs text-gray-500">
ID
</th>
<th class="p-8 text-xs text-gray-500">
Name
</th>
<th class="p-8 text-xs text-gray-500">
Email
</th>
<th class="p-8 text-xs text-gray-500">
Created_at
</th>
<th class="px-6 py-2 text-xs text-gray-500">
Edit
</th>
<th class="px-6 py-2 text-xs text-gray-500">
Delete
</th>
</tr>
</thead>
<tbody class="bg-white">
<tr class="whitespace-nowrap">
<td class="px-6 py-4 text-sm text-center text-gray-500">
1
</td>
<td class="px-6 py-4 text-center">
<div class="text-sm text-gray-900">
Jon doe 1
</div>
</td>
<td class="px-6 py-4 text-center">
<div class="text-sm text-gray-500">[email protected]</div>
</td>
<td class="px-6 py-4 text-sm text-center text-gray-500">
2021-1-12
</td>
<td class="px-6 py-4 text-center">
<a href="#" class="px-4 py-1 text-sm text-white bg-blue-400 rounded">Edit</a>
</td>
<td class="px-6 py-4 text-center">
<a href="#" class="px-4 py-1 text-sm text-white bg-red-400 rounded">Delete</a>
</td>
</tr>
<tr class="whitespace-nowrap">
<td class="px-6 py-4 text-sm text-center text-gray-500">
2
</td>
<td class="px-6 py-4 text-center">
<div class="text-sm text-gray-900">
Jon doe 2
</div>
</td>
<td class="px-6 py-4 text-center">
<div class="text-sm text-gray-500">[email protected]</div>
</td>
<td class="px-6 py-4 text-sm text-center text-gray-500">
2021-1-12
</td>
<td class="px-6 py-4 text-center">
<a href="#" class="px-4 py-1 text-sm text-white bg-blue-400 rounded">Edit</a>
</td>
<td class="px-6 py-4 text-center">
<a href="#" class="px-4 py-1 text-sm text-white bg-red-400 rounded">Delete</a>
</td>
</tr>
<tr class="whitespace-nowrap">
<td class="px-6 py-4 text-sm text-center text-gray-500">
3
</td>
<td class="px-6 py-4 text-center">
<div class="text-sm text-gray-900">
Jon doe 3
</div>
</td>
<td class="px-6 py-4 text-center">
<div class="text-sm text-gray-500">[email protected]</div>
</td>
<td class="px-6 py-4 text-sm text-center text-gray-500">
2021-1-12
</td>
<td class="px-6 py-4 text-center">
<a href="#" class="px-4 py-1 text-sm text-white bg-blue-400 rounded">Edit</a>
</td>
<td class="px-6 py-4 text-center">
<a href="#" class="px-4 py-1 text-sm text-white bg-red-400 rounded">Delete</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function () {
$('#dataTable').DataTable();
});
</script>
</body>
</html>
Example 2
Small Size DataTable with border and shadow.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DataTable</title>
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" charset="utf8"
src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.js"></script>
</head>
<body>
<div class="container flex justify-center mx-auto">
<div class="flex flex-col">
<div class="w-full">
<div class="p-12 border-b border-gray-200 shadow">
<table class="divide-y divide-gray-300" id="dataTable">
<thead class="bg-gray-100">
<tr>
<th class="px-6 py-2 text-xs text-gray-500">
ID
</th>
<th class="px-6 py-2 text-xs text-gray-500">
Name
</th>
<th class="px-6 py-2 text-xs text-gray-500">
Email
</th>
<th class="px-6 py-2 text-xs text-gray-500">
Created_at
</th>
<th class="px-6 py-2 text-xs text-gray-500">
Edit
</th>
<th class="px-6 py-2 text-xs text-gray-500">
Delete
</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-500">
<tr class="whitespace-nowrap">
<td class="px-6 py-4 text-sm text-center text-gray-500">
1
</td>
<td class="px-6 py-4 text-center">
<div class="text-sm text-gray-900">
Jon doe
</div>
</td>
<td class="px-6 py-4 text-center">
<div class="text-sm text-gray-500">[email protected]</div>
</td>
<td class="px-6 py-4 text-sm text-center text-gray-500">
2021-1-12
</td>
<td class="px-6 py-4 text-center">
<a href="#"
class="px-4 py-1 text-sm text-blue-600 bg-blue-200 rounded-full">Edit</a>
</td>
<td class="px-6 py-4 text-center">
<a href="#"
class="px-4 py-1 text-sm text-red-400 bg-red-200 rounded-full">Delete</a>
</td>
</tr>
<tr class="bg-gray-50 whitespace-nowrap">
<td class="px-6 py-4 text-sm text-center text-gray-500">
2
</td>
<td class="px-6 py-4 text-center">
<div class="text-sm text-gray-900">
Jon doe 2
</div>
</td>
<td class="px-6 py-4 text-center">
<div class="text-sm text-gray-500">[email protected]</div>
</td>
<td class="px-6 py-4 text-sm text-center text-gray-500">
2021-1-12
</td>
<td class="px-6 py-4 text-center">
<a href="#"
class="px-4 py-1 text-sm text-blue-600 bg-blue-200 rounded-full">Edit</a>
</td>
<td class="px-6 py-4 text-center">
<a href="#" class="px-4 py-1 text-sm text-red-400 rounded-full">Delete</a>
</td>
</tr>
<tr class="whitespace-nowrap">
<td class="px-6 py-4 text-sm text-center text-gray-500">
3
</td>
<td class="px-6 py-4 text-center">
<div class="text-sm text-gray-900">
Jon doe 3
</div>
</td>
<td class="px-6 py-4 text-center">
<div class="text-sm text-gray-500">[email protected]</div>
</td>
<td class="px-6 py-4 text-sm text-center text-gray-500">
2021-1-12
</td>
<td class="px-6 py-4 text-center">
<a href="#"
class="px-4 py-1 text-sm text-blue-600 bg-blue-200 rounded-full">Edit</a>
</td>
<td class="px-6 py-4 text-center">
<a href="#"
class="px-4 py-1 text-sm text-red-400 bg-red-200 rounded-full">Delete</a>
</td>
</tr>
<tr class="bg-gray-50 whitespace-nowrap">
<td class="px-6 py-4 text-sm text-center text-gray-500">
4
</td>
<td class="px-6 py-4 text-center">
<div class="text-sm text-gray-900">
Jon doe 4
</div>
</td>
<td class="px-6 py-4 text-center">
<div class="text-sm text-gray-500">[email protected]</div>
</td>
<td class="px-6 py-4 text-sm text-center text-gray-500">
2021-1-12
</td>
<td class="px-6 py-4 text-center">
<a href="#"
class="px-4 py-1 text-sm text-blue-600 bg-blue-200 rounded-full">Edit</a>
</td>
<td class="px-6 py-4 text-center">
<a href="#" class="px-4 py-1 text-sm text-red-400 rounded-full">Delete</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function () {
$('#dataTable').DataTable();
});
</script>
</body>
</html>
Example 3
DataTable with Icon.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DataTable</title>
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" charset="utf8"
src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.js"></script>
</head>
<body>
<div class="container mx-auto">
<div class="flex flex-col">
<div class="w-full">
<div class="p-8 border-b border-gray-200 shadow">
<table class="divide-y divide-gray-300" id="dataTable">
<thead class="bg-black">
<tr>
<th class="px-6 py-2 text-xs text-white">
ID
</th>
<th class="px-6 py-2 text-xs text-white">
Name
</th>
<th class="px-6 py-2 text-xs text-white">
Email
</th>
<th class="px-6 py-2 text-xs text-white">
Created_at
</th>
<th class="px-6 py-2 text-xs text-white">
Edit
</th>
<th class="px-6 py-2 text-xs text-white">
Delete
</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-300">
<tr class="text-center whitespace-nowrap">
<td class="px-6 py-4 text-sm text-gray-500">
1
</td>
<td class="px-6 py-4">
<div class="text-sm text-gray-900">
Jon doe
</div>
</td>
<td class="px-6 py-4">
<div class="text-sm text-gray-500">[email protected]</div>
</td>
<td class="px-6 py-4 text-sm text-gray-500">
2021-1-12
</td>
<td class="px-6 py-4">
<a href="#" class="inline-block text-center">
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 text-blue-400"
fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
</svg>
</a>
</td>
<td class="px-6 py-4">
<a href="#" class="inline-block text-center">
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 text-red-400"
fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
</svg>
</a>
</td>
</tr>
<tr class="text-center whitespace-nowrap">
<td class="px-6 py-4 text-sm text-gray-500">
2
</td>
<td class="px-6 py-4">
<div class="text-sm text-gray-900">
Jon doe 2
</div>
</td>
<td class="px-6 py-4">
<div class="text-sm text-gray-500">[email protected]</div>
</td>
<td class="px-6 py-4 text-sm text-gray-500">
2021-1-12
</td>
<td class="px-6 py-4">
<a href="#" class="inline-block text-center">
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 text-blue-400"
fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
</svg>
</a>
</td>
<td class="px-6 py-4">
<a href="#" class="inline-block text-center">
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 text-red-400"
fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
</svg>
</a>
</td>
</tr>
<tr class="text-center whitespace-nowrap">
<td class="px-6 py-4 text-sm text-gray-500">
3
</td>
<td class="px-6 py-4">
<div class="text-sm text-gray-900">
Jon doe 3
</div>
</td>
<td class="px-6 py-4">
<div class="text-sm text-gray-500">[email protected]</div>
</td>
<td class="px-6 py-4 text-sm text-gray-500">
2021-1-12
</td>
<td class="px-6 py-4">
<a href="#" class="inline-block text-center">
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 text-blue-400"
fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
</svg>
</a>
</td>
<td class="px-6 py-4">
<a href="#" class="inline-block text-center">
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 text-red-400"
fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
</svg>
</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function () {
$('#dataTable').DataTable();
});
</script>
</body>
</html>
See Also
Tailwind CSS Free Digital Agency Landing Page
TailFood – Free Tailwind CSS Restaurant Template
Tailwind CSS Real Estate Template
Tailwind CSS Simple Responsive Landing Page Template
Tailwind CSS Simple Verification Email Template
Read Also
Tailwind CSS 3 FAQ Accordion UI Example
Tailwind CSS 3 Alert Message Example
Tailwind CSS 3 Avatars Example
Tailwind CSS 3 Breadcrumb Example
Tailwind CSS Gradient Button Example
Tailwind CSS 3D Button Example
Tailwind CSS Loading Button Example
Tailwind CSS v3 Cards Examples
Tailwind CSS Checkbox Form Examples
Tailwind CSS Dropdowns (Menu) on Hover Example
Tailwind CSS Multiselect Dropdown Example
How to use dark mode toggle switch in Tailwind CSS 3
How to use @apply directive in Tailwind CSS
Tailwind CSS sticky header & fixed navbar example
Tailwind CSS Navbar UI Example
Tailwind CSS 3 Login Page UI Example
Tailwind CSS Login Modal Example
Tailwind CSS 3 Overlay Image Example
Tailwind CSS Thank You Page Example
Tailwind CSS Timeline UI Example
Tailwind CSS Responsive Footer Section Example
Tailwind CSS Background Image Header Example