Component

Searchable Table

Article library table with real-time search functionality. Filters by title, excerpt, author, and category with smooth animations and a no-results empty state.

  • Component
  • Tailwind
  • HTML
  • MIT

Preview

Live component

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

Install

Add to your project

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

Source

Implementation

code.html
<div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
  <div class="p-4 border-b border-gray-200">
    <div class="relative">
      <svg class="absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
      </svg>
      <input type="text" id="searchInput" onkeyup="filterTable()" placeholder="Search articles by title, author, or category..." class="w-full pl-10 pr-4 py-3 border border-gray-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-rose-500 focus:border-transparent">
    </div>
  </div>
  <div class="overflow-x-auto">
    <table class="w-full" id="articleTable">
      <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">Article</th>
          <th class="px-5 py-3.5 text-left text-xs font-bold text-gray-600 uppercase tracking-wider">Author</th>
          <th class="px-5 py-3.5 text-left text-xs font-bold text-gray-600 uppercase tracking-wider">Category</th>
          <th class="px-5 py-3.5 text-left text-xs font-bold text-gray-600 uppercase tracking-wider">Views</th>
          <th class="px-5 py-3.5 text-left text-xs font-bold text-gray-600 uppercase tracking-wider">Published</th>
          <th class="px-5 py-3.5 text-left text-xs font-bold text-gray-600 uppercase tracking-wider">Read Time</th>
        </tr>
      </thead>
      <tbody class="divide-y divide-gray-100" id="tableBody">
        <tr class="article-row hover:bg-gray-50 transition-colors">
          <td class="px-5 py-4">
            <div class="flex items-center gap-3">
              <img src="https://images.unsplash.com/photo-1555066931-4365d14bab8c?w=80&h=80&fit=crop" alt="Article thumbnail" class="w-12 h-12 rounded-lg object-cover">
              <div>
                <p class="text-sm font-medium text-gray-900 article-title">Building Scalable Microservices with Kubernetes</p>
                <p class="text-xs text-gray-500 article-excerpt">A comprehensive guide to designing and deploying microservices architecture</p>
              </div>
            </div>
          </td>
          <td class="px-5 py-4">
            <div class="flex items-center gap-2">
              <img src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=40&h=40&fit=crop" alt="Alex Rivera" class="w-8 h-8 rounded-full object-cover">
              <span class="text-sm text-gray-700">Alex Rivera</span>
            </div>
          </td>
          <td class="px-5 py-4">
            <span class="px-2.5 py-1 bg-violet-100 text-violet-700 text-xs font-medium rounded-full">DevOps</span>
          </td>
          <td class="px-5 py-4 text-sm text-gray-600">24,892</td>
          <td class="px-5 py-4 text-sm text-gray-600">Mar 10, 2026</td>
          <td class="px-5 py-4 text-sm text-gray-600">12 min</td>
        </tr>
        <tr class="article-row hover:bg-gray-50 transition-colors">
          <td class="px-5 py-4">
            <div class="flex items-center gap-3">
              <img src="https://images.unsplash.com/photo-1551288049-bebda4e38f71?w=80&h=80&fit=crop" alt="Article thumbnail" class="w-12 h-12 rounded-lg object-cover">
              <div>
                <p class="text-sm font-medium text-gray-900 article-title">Advanced React Patterns for Enterprise Apps</p>
                <p class="text-xs text-gray-500 article-excerpt">Master compound components, render props, and hooks patterns</p>
              </div>
            </div>
          </td>
          <td class="px-5 py-4">
            <div class="flex items-center gap-2">
              <img src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=40&h=40&fit=crop" alt="Sarah Chen" class="w-8 h-8 rounded-full object-cover">
              <span class="text-sm text-gray-700">Sarah Chen</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">Frontend</span>
          </td>
          <td class="px-5 py-4 text-sm text-gray-600">18,456</td>
          <td class="px-5 py-4 text-sm text-gray-600">Mar 8, 2026</td>
          <td class="px-5 py-4 text-sm text-gray-600">8 min</td>
        </tr>
        <tr class="article-row hover:bg-gray-50 transition-colors">
          <td class="px-5 py-4">
            <div class="flex items-center gap-3">
              <img src="https://images.unsplash.com/photo-1558494949-ef010cbdcc31?w=80&h=80&fit=crop" alt="Article thumbnail" class="w-12 h-12 rounded-lg object-cover">
              <div>
                <p class="text-sm font-medium text-gray-900 article-title">PostgreSQL Performance Tuning Deep Dive</p>
                <p class="text-xs text-gray-500 article-excerpt">Optimization techniques for high-traffic databases</p>
              </div>
            </div>
          </td>
          <td class="px-5 py-4">
            <div class="flex items-center gap-2">
              <img src="https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=40&h=40&fit=crop" alt="James Park" class="w-8 h-8 rounded-full object-cover">
              <span class="text-sm text-gray-700">James Park</span>
            </div>
          </td>
          <td class="px-5 py-4">
            <span class="px-2.5 py-1 bg-emerald-100 text-emerald-700 text-xs font-medium rounded-full">Database</span>
          </td>
          <td class="px-5 py-4 text-sm text-gray-600">15,234</td>
          <td class="px-5 py-4 text-sm text-gray-600">Mar 5, 2026</td>
          <td class="px-5 py-4 text-sm text-gray-600">15 min</td>
        </tr>
        <tr class="article-row hover:bg-gray-50 transition-colors">
          <td class="px-5 py-4">
            <div class="flex items-center gap-3">
              <img src="https://images.unsplash.com/photo-1526374965328-7f61d4dc18c5?w=80&h=80&fit=crop" alt="Article thumbnail" class="w-12 h-12 rounded-lg object-cover">
              <div>
                <p class="text-sm font-medium text-gray-900 article-title">Securing Cloud Infrastructure Best Practices</p>
                <p class="text-xs text-gray-500 article-excerpt">Essential security measures for AWS, GCP, and Azure</p>
              </div>
            </div>
          </td>
          <td class="px-5 py-4">
            <div class="flex items-center gap-2">
              <img src="https://images.unsplash.com/photo-1438761681033-6461ffad8d80?w=40&h=40&fit=crop" alt="Emma Liu" class="w-8 h-8 rounded-full object-cover">
              <span class="text-sm text-gray-700">Emma Liu</span>
            </div>
          </td>
          <td class="px-5 py-4">
            <span class="px-2.5 py-1 bg-rose-100 text-rose-700 text-xs font-medium rounded-full">Security</span>
          </td>
          <td class="px-5 py-4 text-sm text-gray-600">12,890</td>
          <td class="px-5 py-4 text-sm text-gray-600">Mar 3, 2026</td>
          <td class="px-5 py-4 text-sm text-gray-600">10 min</td>
        </tr>
        <tr class="article-row hover:bg-gray-50 transition-colors">
          <td class="px-5 py-4">
            <div class="flex items-center gap-3">
              <img src="https://images.unsplash.com/photo-1558655146-9f40138edfeb?w=80&h=80&fit=crop" alt="Article thumbnail" class="w-12 h-12 rounded-lg object-cover">
              <div>
                <p class="text-sm font-medium text-gray-900 article-title">TypeScript 5.0: New Features and Migration</p>
                <p class="text-xs text-gray-500 article-excerpt">Everything you need to know about the latest TypeScript release</p>
              </div>
            </div>
          </td>
          <td class="px-5 py-4">
            <div class="flex items-center gap-2">
              <img src="https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=40&h=40&fit=crop" alt="Michael Zhang" class="w-8 h-8 rounded-full object-cover">
              <span class="text-sm text-gray-700">Michael Zhang</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">Frontend</span>
          </td>
          <td class="px-5 py-4 text-sm text-gray-600">21,567</td>
          <td class="px-5 py-4 text-sm text-gray-600">Mar 1, 2026</td>
          <td class="px-5 py-4 text-sm text-gray-600">6 min</td>
        </tr>
      </tbody>
    </table>
  </div>
  <div id="noResults" class="hidden py-12 text-center">
    <svg class="w-16 h-16 mx-auto text-gray-300 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
      <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9.172 16.172a4 4 0 015.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
    </svg>
    <p class="text-gray-500 font-medium">No articles found</p>
    <p class="text-gray-400 text-sm mt-1">Try adjusting your search terms</p>
  </div>
</div>

<script>
function filterTable() {
  const input = document.getElementById('searchInput');
  const filter = input.value.toLowerCase();
  const rows = document.querySelectorAll('.article-row');
  let visibleCount = 0;
  
  rows.forEach(row => {
    const title = row.querySelector('.article-title')?.textContent.toLowerCase() || '';
    const excerpt = row.querySelector('.article-excerpt')?.textContent.toLowerCase() || '';
    const author = row.cells[1]?.textContent.toLowerCase() || '';
    const category = row.cells[2]?.textContent.toLowerCase() || '';
    
    if (title.includes(filter) || excerpt.includes(filter) || author.includes(filter) || category.includes(filter)) {
      row.style.display = '';
      visibleCount++;
    } else {
      row.style.display = 'none';
    }
  });
  
  document.getElementById('noResults').classList.toggle('hidden', visibleCount > 0);
}
</script>
173 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/searchable-table

Continue browsing

View all