跳到內容
欄目
Fiesta

data-table

展示 砌成一個畫面嘅嗰啲細塊講法:狀態、身分、進度、資料表格同圖表,同唯一嗰種提示形狀。

俾人比較數字嘅原生表格。如果表格比螢幕闊,佢張卡片會左右捲動,所以手機都保留到每一欄,而行標題會固定喺開頭。想某一欄可以排序,就將佢嘅表頭連去按嗰欄排好序嘅列表。

每個例子都真係用得,不過入面啲連結唔會帶你去邊度。 HTML 顯示可以複製嘅標記。

按數字排序

預覽
<div rst-box-head>
  <h2 id="sales-h">按週計嘅銷量</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">週</th>
        <th scope="col" rst-num aria-sort="descending">
          <a href="/sales?sort=sold&amp;dir=asc">賣出<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">目標<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>退款</th>
        <th scope="col" rst-num>收入</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">總數</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>

喺應用程式入面,呢個會去到 /sales?sort=sold&dir=asc, /sales?sort=target&dir=desc。喺呢度,佢嘅連結同表格都唔會去任何地方。

密集,表頭固定

rst-table-scroll="bounded" 限制高度,啲行喺下面捲動嘅時候,表頭行企喺原位唔郁。

預覽
<div rst-box-head>
  <h2 id="sales-h">按週計嘅銷量</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">週</th>
        <th scope="col" rst-num>賣出</th>
        <th scope="col" rst-num>目標</th>
        <th scope="col" rst-num>退款</th>
        <th scope="col" rst-num>收入</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>

冇行符合

冇行符合嘅時候,表頭行企喺原位唔郁,一格講明冇嘢符合。空狀態係俾從來都冇過行嘅表格用嘅。

預覽
<div rst-box-head>
  <h2 id="sales-h">按週計嘅銷量</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">週</th>
        <th scope="col" rst-num>賣出</th>
        <th scope="col" rst-num>目標</th>
        <th scope="col" rst-num>退款</th>
        <th scope="col" rst-num>收入</th>
      </tr>
    </thead>
    <tbody>
      <tr rst-table-empty>
        <td colspan="5">冇任何一週符合。<a href="/sales">清除篩選</a></td>
      </tr>
    </tbody>
  </table>
</div>

喺應用程式入面,呢個會去到 /sales。喺呢度,佢嘅連結同表格都唔會去任何地方。