data-table
Apresentação As peças pequenas de vocabulário com que se monta um ecrã: estado, identidade, progresso, tabelas de dados e gráficos, e a única forma de aviso.
Uma tabela nativa para números que as pessoas comparam. Se a tabela for mais larga do que o ecrã, o seu cartão desloca-se na horizontal, por isso um telemóvel mantém todas as colunas e os cabeçalhos de linha ficam fixos no início. Para tornar uma coluna ordenável, ligue o seu cabeçalho à lista ordenada por ela.
Cada exemplo funciona de verdade, mas as suas ligações não levam a lado nenhum. HTML mostra a marcação para copiar.
Ordenada por um número
<div rst-box-head >
<h2 id ="sales-h" >Vendas por semana</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" >Semana</th >
<th scope ="col" rst-num aria-sort ="descending" >
<a href ="/sales?sort=sold&dir=asc" >Vendidos<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&dir=desc" >Objetivo<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 >Reembolsos</th >
<th scope ="col" rst-num >Receita</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 >
Numa aplicação, isto chegaria a /sales?sort=sold&dir=asc, /sales?sort=target&dir=desc. Aqui as suas ligações e formulários não levam a lado nenhum.
Densa, com cabeçalho fixo
rst-table-scroll="bounded" limita a altura, e a linha de cabeçalho fica no lugar enquanto as linhas deslizam por baixo dela.
<div rst-box-head >
<h2 id ="sales-h" >Vendas por semana</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" >Semana</th >
<th scope ="col" rst-num >Vendidos</th >
<th scope ="col" rst-num >Objetivo</th >
<th scope ="col" rst-num >Reembolsos</th >
<th scope ="col" rst-num >Receita</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 >
Nenhuma linha corresponde
Quando nenhuma linha corresponde, a linha de cabeçalho fica no lugar e uma célula diz que nada corresponde. O estado vazio é para uma tabela que nunca teve linhas.
<div rst-box-head >
<h2 id ="sales-h" >Vendas por semana</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" >Semana</th >
<th scope ="col" rst-num >Vendidos</th >
<th scope ="col" rst-num >Objetivo</th >
<th scope ="col" rst-num >Reembolsos</th >
<th scope ="col" rst-num >Receita</th >
</tr >
</thead >
<tbody >
<tr rst-table-empty >
<td colspan ="5" >Nenhuma semana corresponde. <a href ="/sales" >Limpar filtros</a ></td >
</tr >
</tbody >
</table >
</div >
Numa aplicação, isto chegaria a /sales. Aqui as suas ligações e formulários não levam a lado nenhum.