Tables

Clean, responsive tables for displaying data with various styling options.

Basic Table

Standard table with clean styling using .focus-table.

Name Email Role Status
John Doe john.doe@example.com Developer Active
Jane Smith jane.smith@example.com Designer Active
Bob Johnson bob.johnson@example.com Manager Inactive
HTML
<table class="focus-table">
  <thead>
    <tr>
      <th>Name</th>
      <th>Email</th>
      <th>Role</th>
      <th>Status</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>John Doe</td>
      <td>john.doe@example.com</td>
      <td>Developer</td>
      <td>Active</td>
    </tr>
  </tbody>
</table>

Striped Table

Alternate row backgrounds with .focus-table-striped.

Product Price Quantity Total
Product A $25.00 2 $50.00
Product B $15.00 3 $45.00
Product C $30.00 1 $30.00
Product D $20.00 2 $40.00
HTML
<table class="focus-table focus-table-striped">
  <thead>
    <tr>
      <th>Product</th>
      <th>Price</th>
      <th>Quantity</th>
      <th>Total</th>
    </tr>
  </thead>
  <tbody>
    <!-- rows here -->
  </tbody>
</table>

Bordered Table

Add borders to all cells with .focus-table-bordered.

ID Task Priority Due Date
1 Update documentation High 2026-01-15
2 Fix bug in login Critical 2026-01-10
3 Review pull requests Medium 2026-01-20
HTML
<table class="focus-table focus-table-bordered">
  <thead>
    <tr>
      <th>ID</th>
      <th>Task</th>
      <th>Priority</th>
      <th>Due Date</th>
    </tr>
  </thead>
  <tbody>
    <!-- rows here -->
  </tbody>
</table>

Compact Table

Reduce padding for more compact display with .focus-table-compact.

Server Status CPU Memory
web-01 Online 45% 2.1 GB
web-02 Online 32% 1.8 GB
db-01 Online 68% 4.5 GB
cache-01 Offline 0% 0 GB
HTML
<table class="focus-table focus-table-compact">
  <thead>
    <tr>
      <th>Server</th>
      <th>Status</th>
      <th>CPU</th>
      <th>Memory</th>
    </tr>
  </thead>
  <tbody>
    <!-- rows here -->
  </tbody>
</table>

Responsive Table

Enable horizontal scrolling on small screens with .focus-table-responsive wrapper.

Column 1 Column 2 Column 3 Column 4 Column 5 Column 6 Column 7 Column 8
Data 1 Data 2 Data 3 Data 4 Data 5 Data 6 Data 7 Data 8
Data 1 Data 2 Data 3 Data 4 Data 5 Data 6 Data 7 Data 8
HTML
<div class="focus-table-responsive">
  <table class="focus-table">
    <!-- table content -->
  </table>
</div>

Text Alignment

Align cell content with .text-center and .text-right classes.

Item Quantity Price Total
Widget A 5 $12.99 $64.95
Widget B 3 $8.50 $25.50
Widget C 7 $15.00 $105.00
HTML
<table class="focus-table">
  <thead>
    <tr>
      <th>Item</th>
      <th class="text-center">Quantity</th>
      <th class="text-right">Price</th>
      <th class="text-right">Total</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Widget A</td>
      <td class="text-center">5</td>
      <td class="text-right">$12.99</td>
      <td class="text-right">$64.95</td>
    </tr>
  </tbody>
</table>

Interactive Table Builder

Customize table appearance with the interactive builder.

Builder Options

Preview

Column 1 Column 2 Column 3
Data 1-1 Data 1-2 Data 1-3
Data 2-1 Data 2-2 Data 2-3
Data 3-1 Data 3-2 Data 3-3

Generated Code

HTML

JavaScript Table Sorting Example

Add interactive sorting to table columns with JavaScript.

Name Age City
Alice Johnson 28 New York
Bob Smith 34 Los Angeles
Charlie Brown 22 Chicago
Diana Prince 31 Boston
JavaScript
const table = document.getElementById('sortableTable');
const headers = table.querySelectorAll('th[data-sort]');
const tbody = document.getElementById('sortableTableBody');

let sortDirection = {};

headers.forEach(header => {
  header.addEventListener('click', () => {
    const column = header.dataset.sort;
    const columnIndex = Array.from(headers).indexOf(header);
    
    // Toggle sort direction
    sortDirection[column] = sortDirection[column] === 'asc' ? 'desc' : 'asc';
    
    // Get rows and sort
    const rows = Array.from(tbody.querySelectorAll('tr'));
    rows.sort((a, b) => {
      const aValue = a.children[columnIndex].textContent;
      const bValue = b.children[columnIndex].textContent;
      
      // Try to parse as number
      const aNum = parseFloat(aValue);
      const bNum = parseFloat(bValue);
      
      if (!isNaN(aNum) && !isNaN(bNum)) {
        return sortDirection[column] === 'asc' ? aNum - bNum : bNum - aNum;
      }
      
      // String comparison
      return sortDirection[column] === 'asc' 
        ? aValue.localeCompare(bValue)
        : bValue.localeCompare(aValue);
    });
    
    // Re-append sorted rows
    rows.forEach(row => tbody.appendChild(row));
  });
});

CSS Classes Reference

Class Description
.focus-table Base table styling with shadow and hover effects
.focus-table-striped Alternating row background colors
.focus-table-bordered Add borders to all table cells
.focus-table-compact Reduced padding for more compact display
.focus-table-responsive Wrapper div enabling horizontal scroll on small screens
.text-center Center-align cell content (on th/td)
.text-right Right-align cell content (on th/td)