Table
Displays a table
| 1 | <table> |
| 2 | <thead> |
| 3 | <tr> |
| 4 | <th>Name</th> |
| 5 | <th>Age</th> |
| 6 | <th>Country</th> |
| 7 | </tr> |
| 8 | </thead> |
| 9 | <tbody> |
| 10 | <tr> |
| 11 | <td>John</td> |
| 12 | <td>25</td> |
| 13 | <td>USA</td> |
| 14 | </tr> |
| 15 | <tr> |
| 16 | <td>Jane</td> |
| 17 | <td>30</td> |
| 18 | <td>Canada</td> |
| 19 | </tr> |
| 20 | </tbody> |
| 21 | <tfoot> |
| 22 | <tr> |
| 23 | <td>Joe</td> |
| 24 | <td>27.8</td> |
| 25 | <td>Lithuania for some unexplainable reason</td> |
| 26 | </tr> |
| 27 | </tfoot> |
| 28 | </table> |
| 29 |
Theme
Import
@import '@webtui/css/components/table.css';
Usage
<table>
<thead>
<tr>
<td>...</td>
<td>...</td>
</tr>
</thead>
<tbody>
<tr>
<td>...</td>
<td>...</td>
<td>...</td>
</tr>
...
</tbody>
<tfoot>
<tr>
<td>...</td>
</tr>
</tfoot>
</table>
Examples
Divide
Use the divide- attribute to change the direction of the table dividers
<table divide-="none"></table>
<table divide-="horizontal"></table>
<table divide-="vertical"></table>
<table divide-="both"></table>
<!-- Not providing `divide-` is the same as `divide-="both"` -->
<table></table>
| 1 | |
| 2 | <table divide-="both"> |
| 3 | <thead> |
| 4 | <tr> |
| 5 | <th>divide-</th> |
| 6 | <th>both</th> |
| 7 | </tr> |
| 8 | </thead> |
| 9 | <tbody> |
| 10 | <tr> |
| 11 | <td>or</td> |
| 12 | <td>also</td> |
| 13 | </tr> |
| 14 | <tr> |
| 15 | <td>divide-</td> |
| 16 | <td><not provided></td> |
| 17 | </tr> |
| 18 | </tbody> |
| 19 | </table> |
| 20 | <table divide-="horizontal"> |
| 21 | <thead> |
| 22 | <tr> |
| 23 | <th>divide-</th> |
| 24 | <th>horizontal</th> |
| 25 | </tr> |
| 26 | </thead> |
| 27 | <tbody> |
| 28 | <tr> |
| 29 | <td>hey</td> |
| 30 | <td>look</td> |
| 31 | </tr> |
| 32 | <tr> |
| 33 | <td>horizontal</td> |
| 34 | <td>lines</td> |
| 35 | </tr> |
| 36 | </tbody> |
| 37 | </table> |
| 38 | <table divide-="vertical"> |
| 39 | <thead> |
| 40 | <tr> |
| 41 | <th>divide-</th> |
| 42 | <th>vertical</th> |
| 43 | </tr> |
| 44 | </thead> |
| 45 | <tbody> |
| 46 | <tr> |
| 47 | <td>hey</td> |
| 48 | <td>look</td> |
| 49 | </tr> |
| 50 | <tr> |
| 51 | <td>vertical</td> |
| 52 | <td>lines</td> |
| 53 | </tr> |
| 54 | </tbody> |
| 55 | </table> |
| 56 | <table divide-="none"> |
| 57 | <thead> |
| 58 | <tr> |
| 59 | <th>divide-</th> |
| 60 | <th>none</th> |
| 61 | </tr> |
| 62 | </thead> |
| 63 | <tbody> |
| 64 | <tr> |
| 65 | <td>hey</td> |
| 66 | <td>look</td> |
| 67 | </tr> |
| 68 | <tr> |
| 69 | <td>no</td> |
| 70 | <td>lines</td> |
| 71 | </tr> |
| 72 | </tbody> |
| 73 | </table> |
| 74 |
Theme
ASCII Boxes
Pair the table component with the box- utility to add box borders around the table
<table box-="none" divide-="none"></table>
<table box-="square" divide-="both"></table>
<table box-="round" divide-="horizontal"></table>
<table box-="double" divide-="vertical"></table>
| 1 | |
| 2 | <table divide-="both" box-="square"> |
| 3 | <thead> |
| 4 | <tr> |
| 5 | <th>divide-</th> |
| 6 | <th>both</th> |
| 7 | </tr> |
| 8 | </thead> |
| 9 | <tbody> |
| 10 | <tr> |
| 11 | <td>box-</td> |
| 12 | <td>square</td> |
| 13 | </tr> |
| 14 | </tbody> |
| 15 | </table> |
| 16 | <table divide-="horizontal" box-="round"> |
| 17 | <thead> |
| 18 | <tr> |
| 19 | <th>divide-</th> |
| 20 | <th>horizontal</th> |
| 21 | </tr> |
| 22 | </thead> |
| 23 | <tbody> |
| 24 | <tr> |
| 25 | <td>box-</td> |
| 26 | <td>round</td> |
| 27 | </tr> |
| 28 | </tbody> |
| 29 | </table> |
| 30 | <table divide-="vertical" box-="double"> |
| 31 | <thead> |
| 32 | <tr> |
| 33 | <th>divide-</th> |
| 34 | <th>vertical</th> |
| 35 | </tr> |
| 36 | </thead> |
| 37 | <tbody> |
| 38 | <tr> |
| 39 | <td>box-</td> |
| 40 | <td>double</td> |
| 41 | </tr> |
| 42 | </tbody> |
| 43 | </table> |
| 44 | <table divide-="none" box-="none"> |
| 45 | <thead> |
| 46 | <tr> |
| 47 | <th>divide-</th> |
| 48 | <th>none</th> |
| 49 | </tr> |
| 50 | </thead> |
| 51 | <tbody> |
| 52 | <tr> |
| 53 | <td>box-</td> |
| 54 | <td>none</td> |
| 55 | </tr> |
| 56 | </tbody> |
| 57 | </table> |
| 58 |
Theme
Reference
Properties
--table-border-width: The width of the table borders--table-border-color: The color of the table borders
Note: If used with box-, --table-border-color inherits the value of --box-border-color
table {
--table-border-width: 1px;
--table-border-color: var(--foreground2);
}
Extending
To extend the Table stylesheet, define a CSS rule on the components layer
@layer components {
table {
/* ... */
}
}
Scope
- All
<table>elements - All
<tr>,<th>, and<td>elements that are children of a<table>
table {
tr {
th {
/* ... */
}
td {
/* ... */
}
}
}