Skip to content
loseta

Components / Surfaces

Table

A responsive table for tabular data.

Status stableWorks with checkbox, badge, button, dropdown-menu
A list of your recent invoices.
Invoice Status Method Amount
INV-001 Paid Credit card $250.00
INV-002 Pending PayPal $150.00
INV-003 Unpaid Bank transfer $350.00
<div class="table-container">
  <table class="table">
    <caption>A list of your recent invoices.</caption>
    <thead>
      <tr>
        <th scope="col">Invoice</th>
        <th scope="col">Status</th>
        <th scope="col">Method</th>
        <th scope="col" style="text-align: end">Amount</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>INV-001</td>
        <td>Paid</td>
        <td>Credit card</td>
        <td style="text-align: end">$250.00</td>
      </tr>
      <tr>
        <td>INV-002</td>
        <td>Pending</td>
        <td>PayPal</td>
        <td style="text-align: end">$150.00</td>
      </tr>
      <tr>
        <td>INV-003</td>
        <td>Unpaid</td>
        <td>Bank transfer</td>
        <td style="text-align: end">$350.00</td>
      </tr>
    </tbody>
  </table>
</div>

Installation

pnpm dlx loseta add table
npx loseta add table

Examples

A list of your recent invoices.
Invoice Status Method Amount
INV-001 Paid Credit card $250.00
INV-002 Pending PayPal $150.00
INV-003 Unpaid Bank transfer $350.00
INV-004 Paid Credit card $450.00
Total $1,200.00
<div class="table-container">
  <table class="table">
    <caption>A list of your recent invoices.</caption>
    <thead>
      <tr>
        <th scope="col">Invoice</th>
        <th scope="col">Status</th>
        <th scope="col">Method</th>
        <th scope="col" style="text-align: end">Amount</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>INV-001</td>
        <td>Paid</td>
        <td>Credit card</td>
        <td style="text-align: end">$250.00</td>
      </tr>
      <tr>
        <td>INV-002</td>
        <td>Pending</td>
        <td>PayPal</td>
        <td style="text-align: end">$150.00</td>
      </tr>
      <tr>
        <td>INV-003</td>
        <td>Unpaid</td>
        <td>Bank transfer</td>
        <td style="text-align: end">$350.00</td>
      </tr>
      <tr>
        <td>INV-004</td>
        <td>Paid</td>
        <td>Credit card</td>
        <td style="text-align: end">$450.00</td>
      </tr>
    </tbody>
    <tfoot>
      <tr>
        <th scope="row" colspan="3">Total</th>
        <td style="text-align: end">$1,200.00</td>
      </tr>
    </tfoot>
  </table>
</div>

Actions

Products and their current prices.
Product Price Actions
Wireless Mouse $29.99
Mechanical Keyboard $129.99
USB-C Hub $49.99
<div class="table-container">
  <table class="table">
    <caption>Products and their current prices.</caption>
    <thead>
      <tr>
        <th scope="col">Product</th>
        <th scope="col" style="text-align: end">Price</th>
        <th scope="col"><span class="sr-only">Actions</span></th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Wireless Mouse</td>
        <td style="text-align: end">$29.99</td>
        <td>
          <div class="dropdown-menu">
            <button type="button" class="btn" data-variant="ghost" data-size="icon-sm" aria-haspopup="menu" aria-expanded="false" aria-label="Open menu for Wireless Mouse"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/></svg></button>
            <div data-popover data-side="top" data-align="end" aria-hidden="true">
              <div role="menu">
                <button type="button" role="menuitem">Edit</button>
                <button type="button" role="menuitem">Duplicate</button>
                <div role="separator"></div>
                <button type="button" role="menuitem" data-variant="destructive">Delete</button>
              </div>
            </div>
          </div>
        </td>
      </tr>
      <tr>
        <td>Mechanical Keyboard</td>
        <td style="text-align: end">$129.99</td>
        <td>
          <div class="dropdown-menu">
            <button type="button" class="btn" data-variant="ghost" data-size="icon-sm" aria-haspopup="menu" aria-expanded="false" aria-label="Open menu for Mechanical Keyboard"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/></svg></button>
            <div data-popover data-side="top" data-align="end" aria-hidden="true">
              <div role="menu">
                <button type="button" role="menuitem">Edit</button>
                <button type="button" role="menuitem">Duplicate</button>
                <div role="separator"></div>
                <button type="button" role="menuitem" data-variant="destructive">Delete</button>
              </div>
            </div>
          </div>
        </td>
      </tr>
      <tr>
        <td>USB-C Hub</td>
        <td style="text-align: end">$49.99</td>
        <td>
          <div class="dropdown-menu">
            <button type="button" class="btn" data-variant="ghost" data-size="icon-sm" aria-haspopup="menu" aria-expanded="false" aria-label="Open menu for USB-C Hub"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/></svg></button>
            <div data-popover data-side="top" data-align="end" aria-hidden="true">
              <div role="menu">
                <button type="button" role="menuitem">Edit</button>
                <button type="button" role="menuitem">Duplicate</button>
                <div role="separator"></div>
                <button type="button" role="menuitem" data-variant="destructive">Delete</button>
              </div>
            </div>
          </div>
        </td>
      </tr>
    </tbody>
  </table>
</div>

Selection

Select invoices to export.
Invoice Status Amount
INV-001 Paid $250.00
INV-002 Pending $150.00
INV-003 Unpaid $350.00
<div class="table-container">
  <table class="table">
    <caption>Select invoices to export.</caption>
    <thead>
      <tr>
        <th scope="col"><input class="checkbox" type="checkbox" aria-label="Select all invoices"></th>
        <th scope="col">Invoice</th>
        <th scope="col">Status</th>
        <th scope="col" style="text-align: end">Amount</th>
      </tr>
    </thead>
    <tbody>
      <tr aria-selected="true">
        <td><input class="checkbox" type="checkbox" aria-label="Select INV-001" checked></td>
        <td>INV-001</td>
        <td><span class="badge" data-variant="outline">Paid</span></td>
        <td style="text-align: end">$250.00</td>
      </tr>
      <tr>
        <td><input class="checkbox" type="checkbox" aria-label="Select INV-002"></td>
        <td>INV-002</td>
        <td><span class="badge" data-variant="secondary">Pending</span></td>
        <td style="text-align: end">$150.00</td>
      </tr>
      <tr>
        <td><input class="checkbox" type="checkbox" aria-label="Select INV-003"></td>
        <td>INV-003</td>
        <td><span class="badge" data-variant="destructive">Unpaid</span></td>
        <td style="text-align: end">$350.00</td>
      </tr>
    </tbody>
  </table>
</div>

Right-to-left

قائمة بفواتيرك الأخيرة.
الفاتورة الحالة الطريقة المبلغ
INV-001 مدفوع بطاقة ائتمانية $250.00
INV-002 قيد الانتظار PayPal $150.00
INV-003 غير مدفوع تحويل بنكي $350.00
<div class="table-container" dir="rtl" lang="ar">
  <table class="table">
    <caption>قائمة بفواتيرك الأخيرة.</caption>
    <thead>
      <tr>
        <th scope="col">الفاتورة</th>
        <th scope="col">الحالة</th>
        <th scope="col">الطريقة</th>
        <th scope="col" style="text-align: end">المبلغ</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>INV-001</td>
        <td>مدفوع</td>
        <td>بطاقة ائتمانية</td>
        <td style="text-align: end">$250.00</td>
      </tr>
      <tr>
        <td>INV-002</td>
        <td>قيد الانتظار</td>
        <td>PayPal</td>
        <td style="text-align: end">$150.00</td>
      </tr>
      <tr>
        <td>INV-003</td>
        <td>غير مدفوع</td>
        <td>تحويل بنكي</td>
        <td style="text-align: end">$350.00</td>
      </tr>
    </tbody>
  </table>
</div>

Accessibility and behavior

  • Use aria-selected="true" on selectable rows. Checkbox cells accept a native input[type="checkbox"] or role="checkbox". A row containing an expanded trigger keeps the muted highlight.

Files

components/table.cssbase
styles/nova/table.cssstyle

Install contract

The CLI writes the base file under components/, the visual file for the selected style under styles/<name>/, and any primitive dependency underprimitives/. The generated index.css imports them in the right layer order.

← Back to components

loseta is MIT licensed. Built with native CSS, no runtime. Inspired byshadcn/ui.