Below is a ready-to-copy “modern data table” built with plain HTML + Tailwind CSS (no extra JS framework).
It already includes:
• Responsive horizontal scroll (so the table never breaks on mobile)
• Sticky header, zebra stripes, and row-hover highlight
• Dark-mode support (just add class="dark" on or )
• Tiny action buttons (Edit / Delete) with icons
Feel free to swap columns, colors, or add interactivity later (Alpine/React/etc.).
html Copy code
<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<title>Tailwind Data Table</title>
<script src="https://cdn.tailwindcss.com?plugins=forms,typography"></script>
</head>
<body class="h-full bg-gray-100 dark:bg-gray-900 text-gray-800 dark:text-gray-100">
<main class="min-h-full flex items-start justify-center p-6">
<!-- Card container -->
<section class="w-full max-w-5xl">
<h1 class="text-2xl font-semibold mb-4">User List</h1>
<!-- Scroll wrapper (makes table horizontally scrollable on small screens) -->
<div class="overflow-x-auto rounded-lg shadow-lg ring-1 ring-black/10 dark:ring-white/10">
<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700 text-sm text-left">
<!-- Sticky header -->
<thead class="bg-gray-50 dark:bg-gray-800 sticky top-0 z-10">
<tr>
<th scope="col" class="py-3 px-6 font-medium tracking-wider">#</th>
<th scope="col" class="py-3 px-6 font-medium tracking-wider">Avatar</th>
<th scope="col" class="py-3 px-6 font-medium tracking-wider">Name</th>
<th scope="col" class="py-3 px-6 font-medium tracking-wider">Email</th>
<th scope="col" class="py-3 px-6 font-medium tracking-wider text-center">Role</th>
<th scope="col" class="py-3 px-6 font-medium tracking-wider text-center">Actions</th>
</tr>
</thead>
<!-- Table body -->
<tbody class="divide-y divide-gray-200 dark:divide-gray-700">
<!-- Row -->
<tr class="bg-white hover:bg-gray-50 dark:bg-gray-900 dark:hover:bg-gray-800">
<td class="py-3 px-6">1</td>
<td class="py-3 px-6">
<img src="https://i.pravatar.cc/40?u=1" alt="Avatar" class="w-8 h-8 rounded-full ring-1 ring-gray-300">
</td>
<td class="py-3 px-6 font-medium">Alice Johnson</td>
<td class="py-3 px-6">alice@example.com</td>
<td class="py-3 px-6 text-center">
<span class="inline-flex items-center rounded-full bg-green-100 text-green-800 dark:bg-green-800 dark:text-green-100 px-2 py-0.5 text-xs font-medium">Admin</span>
</td>
<td class="py-3 px-6 text-center">
<button class="inline-flex items-center gap-1 text-blue-600 hover:text-blue-800 dark:text-blue-400">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M15.232 5.232l3.536 3.536-9 9H6.232v-3.536l9-9z"/><path d="M16 7l1-1c.586-.586 1.414-.586 2 0s.586 1.414 0 2l-1 1"/></svg>
Edit
</button>
<button class="inline-flex items-center gap-1 ml-3 text-red-600 hover:text-red-800 dark:text-red-400">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M3 6h18M9 6v12a2 2 0 002 2h2a2 2 0 002-2V6"/></svg>
Delete
</button>
</td>
</tr>
<!-- Duplicate the <tr> block as needed ➜ sample rows -->
<tr class="bg-white hover:bg-gray-50 dark:bg-gray-900 dark:hover:bg-gray-800">
<td class="py-3 px-6">2</td>
<td class="py-3 px-6"><img src="https://i.pravatar.cc/40?u=2" class="w-8 h-8 rounded-full ring-1 ring-gray-300" /></td>
<td class="py-3 px-6 font-medium">Bob Martin</td>
<td class="py-3 px-6">bob@example.com</td>
<td class="py-3 px-6 text-center">
<span class="inline-flex items-center rounded-full bg-indigo-100 text-indigo-800 dark:bg-indigo-800 dark:text-indigo-100 px-2 py-0.5 text-xs font-medium">Editor</span>
</td>
<td class="py-3 px-6 text-center">
<!-- same buttons -->
<button class="inline-flex items-center gap-1 text-blue-600 hover:text-blue-800 dark:text-blue-400">…</button>
<button class="inline-flex items-center gap-1 ml-3 text-red-600 hover:text-red-800 dark:text-red-400">…</button>
</td>
</tr>
<!-- More rows… -->
</tbody>
</table>
</div>
</section>
</main>
</body>
</html>
How to adapt:
Columns
Change <th> and corresponding <td> cells. Tailwind’s text-left, text-center, etc., control alignment.
Colors / themes
Swap bg-gray-*, text-green-*, etc. for your palette (or use Tailwind’s @apply in a CSS file).
Dark mode
Works out-of-the-box. Add class="dark" to the root element, or let Tailwind manage dark mode with media query.
Sorting / pagination / filters
Add Alpine.js, HTMX, or your favorite framework. With Alpine, a simple column sort looks like:
html Copy code
<th @click="sort('name')" class="cursor-pointer select-none …">Name</th>
…and in your Alpine component you’d maintain sortKey and sortDirection state.
Accessibility
– Keep <th scope="col"> in headers
– Use <caption> if your table needs a descriptive caption
– For icon-only buttons, add aria-label="Edit" etc.
Enjoy! If you need interactive sorting, search, pagination, or a fully responsive card-on-mobile layout, just let me know.