Skip to content
Sections
Fiesta

data-table

Display The small pieces of vocabulary a screen is assembled from: status, identity, progress, data tables and charts, and the one alert shape.

A native table for numbers people compare. If the table is wider than the screen, its card scrolls sideways, so a phone keeps every column and the row headers stay pinned at the start. To make a column sortable, link its header to the list sorted by it.

Each example is live, but its links go nowhere. HTML shows the markup to copy.

Sorted by a number

Preview
<div rst-box-head>
  <h2 id="sales-h">Sales by week</h2>
</div>
<div rst-card rst-table-scroll tabindex="0" role="region" aria-labelledby="sales-h">
  <table rst-table aria-labelledby="sales-h">
    <thead>
      <tr>
        <th scope="col">Week</th>
        <th scope="col" rst-num aria-sort="descending">
          <a href="/sales?sort=sold&amp;dir=asc">Sold<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg></a>
        </th>
        <th scope="col" rst-num>
          <a href="/sales?sort=target&amp;dir=desc">Target<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg></a>
        </th>
        <th scope="col" rst-num>Refunds</th>
        <th scope="col" rst-num>Revenue</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th scope="row">3</th>
        <td rst-num>260</td>
        <td rst-num>600</td>
        <td rst-num>5</td>
        <td rst-num>€6,240</td>
      </tr>
      <tr>
        <th scope="row">4</th>
        <td rst-num>240</td>
        <td rst-num>600</td>
        <td rst-num>1</td>
        <td rst-num>€5,760</td>
      </tr>
      <tr>
        <th scope="row">2</th>
        <td rst-num>180</td>
        <td rst-num>600</td>
        <td rst-num>0</td>
        <td rst-num>€4,320</td>
      </tr>
      <tr>
        <th scope="row">1</th>
        <td rst-num>120</td>
        <td rst-num>600</td>
        <td rst-num>2</td>
        <td rst-num>€2,880</td>
      </tr>
    </tbody>
    <tfoot>
      <tr>
        <th scope="row">Total</th>
        <td rst-num>800</td>
        <td rst-num>2,400</td>
        <td rst-num>8</td>
        <td rst-num>€19,200</td>
      </tr>
    </tfoot>
  </table>
</div>

In an app this would reach /sales?sort=sold&dir=asc, /sales?sort=target&dir=desc. Here its links and forms go nowhere.

Dense, with a fixed header

rst-table-scroll="bounded" caps the height, and the header row stays in place while the rows scroll beneath it.

Preview
<div rst-box-head>
  <h2 id="sales-h">Sales by week</h2>
</div>
<div rst-card rst-table-scroll="bounded" tabindex="0" role="region" aria-labelledby="sales-h">
  <table rst-table="dense" aria-labelledby="sales-h">
    <thead>
      <tr>
        <th scope="col">Week</th>
        <th scope="col" rst-num>Sold</th>
        <th scope="col" rst-num>Target</th>
        <th scope="col" rst-num>Refunds</th>
        <th scope="col" rst-num>Revenue</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th scope="row">1</th>
        <td rst-num>120</td>
        <td rst-num>600</td>
        <td rst-num>2</td>
        <td rst-num>€2,880</td>
      </tr>
      <tr>
        <th scope="row">2</th>
        <td rst-num>180</td>
        <td rst-num>600</td>
        <td rst-num>0</td>
        <td rst-num>€4,320</td>
      </tr>
      <tr>
        <th scope="row">3</th>
        <td rst-num>260</td>
        <td rst-num>600</td>
        <td rst-num>5</td>
        <td rst-num>€6,240</td>
      </tr>
      <tr>
        <th scope="row">4</th>
        <td rst-num>240</td>
        <td rst-num>600</td>
        <td rst-num>1</td>
        <td rst-num>€5,760</td>
      </tr>
      <tr>
        <th scope="row">5</th>
        <td rst-num>390</td>
        <td rst-num>600</td>
        <td rst-num>3</td>
        <td rst-num>€9,360</td>
      </tr>
      <tr>
        <th scope="row">6</th>
        <td rst-num>610</td>
        <td rst-num>600</td>
        <td rst-num>4</td>
        <td rst-num>€14,640</td>
      </tr>
      <tr>
        <th scope="row">7</th>
        <td rst-num>650</td>
        <td rst-num>600</td>
        <td rst-num>0</td>
        <td rst-num>€15,600</td>
      </tr>
      <tr>
        <th scope="row">8</th>
        <td rst-num>690</td>
        <td rst-num>600</td>
        <td rst-num>2</td>
        <td rst-num>€16,560</td>
      </tr>
    </tbody>
  </table>
</div>

No rows match

When no rows match, the header row stays in place and one cell says that nothing matches. The empty state is for a table that has never had rows.

Preview
<div rst-box-head>
  <h2 id="sales-h">Sales by week</h2>
</div>
<div rst-card rst-table-scroll tabindex="0" role="region" aria-labelledby="sales-h">
  <table rst-table aria-labelledby="sales-h">
    <thead>
      <tr>
        <th scope="col">Week</th>
        <th scope="col" rst-num>Sold</th>
        <th scope="col" rst-num>Target</th>
        <th scope="col" rst-num>Refunds</th>
        <th scope="col" rst-num>Revenue</th>
      </tr>
    </thead>
    <tbody>
      <tr rst-table-empty>
        <td colspan="5">No weeks match. <a href="/sales">Clear filters</a></td>
      </tr>
    </tbody>
  </table>
</div>

In an app this would reach /sales. Here its links and forms go nowhere.