Component

Expandable Table

Project management table with expandable rows. Click rows to reveal team members, dates, and budget details with animated expansion and color-coded borders.

  • Component
  • Tailwind
  • HTML
  • MIT

Preview

Live component

Interactive preview
Open preview
9:41 100%
devsnips.dev/library/tailwind/components/tables/expandable-table/
fluid · no fixed width 100%
No dependencies Production-ready

Install

Add to your project

terminal
npx devsnips add Tailwind/Components/Tables/expandable-table
registry path: Tailwind/Components/Tables/expandable-table

Source

Implementation

code.html
<div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
  <table class="w-full">
    <thead>
      <tr class="bg-gray-50 border-b border-gray-200">
        <th class="px-5 py-3.5 text-left text-xs font-bold text-gray-600 uppercase tracking-wider w-8"></th>
        <th class="px-5 py-3.5 text-left text-xs font-bold text-gray-600 uppercase tracking-wider">Project</th>
        <th class="px-5 py-3.5 text-left text-xs font-bold text-gray-600 uppercase tracking-wider">Team Lead</th>
        <th class="px-5 py-3.5 text-left text-xs font-bold text-gray-600 uppercase tracking-wider">Progress</th>
        <th class="px-5 py-3.5 text-left text-xs font-bold text-gray-600 uppercase tracking-wider">Status</th>
      </tr>
    </thead>
    <tbody class="divide-y divide-gray-100" id="expandableTable">
      <tr class="expandable-row" onclick="toggleRow(this)">
        <td class="px-5 py-4">
          <button class="expand-btn w-6 h-6 rounded-lg bg-blue-100 flex items-center justify-center text-blue-600 hover:bg-blue-200 transition-colors">
            <svg class="w-4 h-4 transition-transform" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/></svg>
          </button>
        </td>
        <td class="px-5 py-4">
          <div class="flex items-center gap-3">
            <div class="w-10 h-10 rounded-lg bg-gradient-to-br from-blue-500 to-indigo-600 flex items-center justify-center shadow-md shadow-blue-200">
              <svg class="w-5 h-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/></svg>
            </div>
            <div>
              <p class="text-sm font-semibold text-gray-900">Website Redesign</p>
              <p class="text-xs text-gray-500">12 tasks</p>
            </div>
          </div>
        </td>
        <td class="px-5 py-4">
          <img src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=40&h=40&fit=crop" alt="Sarah" class="w-8 h-8 rounded-full object-cover">
        </td>
        <td class="px-5 py-4">
          <div class="flex items-center gap-3">
            <div class="w-24 h-2 bg-gray-200 rounded-full overflow-hidden">
              <div class="h-full bg-gradient-to-r from-blue-500 to-indigo-500 rounded-full" style="width: 72%"></div>
            </div>
            <span class="text-sm font-medium text-gray-600">72%</span>
          </div>
        </td>
        <td class="px-5 py-4"><span class="px-2.5 py-1 bg-blue-100 text-blue-700 text-xs font-medium rounded-full">In Progress</span></td>
      </tr>
      <tr class="expanded-content hidden">
        <td colspan="5" class="px-5 py-4 bg-slate-50 border-b">
          <div class="pl-4 border-l-4 border-blue-500 space-y-3">
            <h4 class="text-sm font-semibold text-gray-900 mb-2">Team Members</h4>
            <div class="flex flex-wrap gap-2">
              <img src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=40&h=40&fit=crop" class="w-8 h-8 rounded-full object-cover ring-2 ring-white"><img src="https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=40&h=40&fit=crop" class="w-8 h-8 rounded-full object-cover ring-2 ring-white"><img src="https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=40&h=40&fit=crop" class="w-8 h-8 rounded-full object-cover ring-2 ring-white"><img src="https://images.unsplash.com/photo-1438761681033-6461ffad8d80?w=40&h=40&fit=crop" class="w-8 h-8 rounded-full object-cover ring-2 ring-white">
            </div>
            <div class="grid grid-cols-3 gap-4 mt-3 text-sm"><div><p class="text-gray-500">Start Date</p><p class="font-medium text-gray-900">Jan 15, 2026</p></div><div><p class="text-gray-500">End Date</p><p class="font-medium text-gray-900">Apr 30, 2026</p></div><div><p class="text-gray-500">Budget</p><p class="font-medium text-gray-900">$45,000</p></div></div>
          </div>
        </td>
      </tr>
      <tr class="expandable-row" onclick="toggleRow(this)">
        <td class="px-5 py-4">
          <button class="expand-btn w-6 h-6 rounded-lg bg-emerald-100 flex items-center justify-center text-emerald-600 hover:bg-emerald-200 transition-colors">
            <svg class="w-4 h-4 transition-transform" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/></svg>
          </button>
        </td>
        <td class="px-5 py-4">
          <div class="flex items-center gap-3">
            <div class="w-10 h-10 rounded-lg bg-gradient-to-br from-emerald-500 to-teal-600 flex items-center justify-center shadow-md shadow-emerald-200">
              <svg class="w-5 h-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 18h.01M8 21h8a2 2 0 002-2V5a2 2 0 00-2-2H8a2 2 0 00-2 2v14a2 2 0 002 2z"/></svg>
            </div>
            <div>
              <p class="text-sm font-semibold text-gray-900">Mobile App v2.0</p>
              <p class="text-xs text-gray-500">24 tasks</p>
            </div>
          </div>
        </td>
        <td class="px-5 py-4">
          <img src="https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=40&h=40&fit=crop" alt="James" class="w-8 h-8 rounded-full object-cover">
        </td>
        <td class="px-5 py-4">
          <div class="flex items-center gap-3">
            <div class="w-24 h-2 bg-gray-200 rounded-full overflow-hidden">
              <div class="h-full bg-gradient-to-r from-emerald-500 to-teal-500 rounded-full" style="width: 45%"></div>
            </div>
            <span class="text-sm font-medium text-gray-600">45%</span>
          </div>
        </td>
        <td class="px-5 py-4"><span class="px-2.5 py-1 bg-amber-100 text-amber-700 text-xs font-medium rounded-full">On Track</span></td>
      </tr>
      <tr class="expanded-content hidden">
        <td colspan="5" class="px-5 py-4 bg-slate-50 border-b">
          <div class="pl-4 border-l-4 border-emerald-500 space-y-3">
            <h4 class="text-sm font-semibold text-gray-900 mb-2">Team Members</h4>
            <div class="flex flex-wrap gap-2">
              <img src="https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=40&h=40&fit=crop" class="w-8 h-8 rounded-full object-cover ring-2 ring-white"><img src="https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=40&h=40&fit=crop" class="w-8 h-8 rounded-full object-cover ring-2 ring-white"><img src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=40&h=40&fit=crop" class="w-8 h-8 rounded-full object-cover ring-2 ring-white">
            </div>
            <div class="grid grid-cols-3 gap-4 mt-3 text-sm"><div><p class="text-gray-500">Start Date</p><p class="font-medium text-gray-900">Feb 1, 2026</p></div><div><p class="text-gray-500">End Date</p><p class="font-medium text-gray-900">Jun 15, 2026</p></div><div><p class="text-gray-500">Budget</p><p class="font-medium text-gray-900">$120,000</p></div></div>
          </div>
        </td>
      </tr>
    </tbody>
  </table>
</div>
<script>
function toggleRow(row) {
  const content = row.nextElementSibling;
  const btn = row.querySelector('.expand-btn svg');
  content.classList.toggle('hidden');
  btn.classList.toggle('rotate-90');
}
</script>
105 lines UTF-8 · LF · Spaces: 2

AI-ready

Available to your agent.

This component is reachable through the DevSnips CLI, MCP server and Skills integrations — one registry, one resource path.

Resource path

devsnips://components/tables/expandable-table

Continue browsing

View all