Table Component
Axiom01 provides clean, semantic, and responsive styling for HTML tables, ensuring tabular data is presented clearly and accessibly. Our table component focuses on readability and maintainability without excessive class usage.
Live Example
Basic Table
| # | First Name | Last Name | Username |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Larry | the Bird |
Striped Table
| Product | Quantity | Price |
|---|---|---|
| Axiom T-Shirt | 2 | $29.99 |
| Axiom Mug | 1 | $14.50 |
| Axiom Sticker Pack | 3 | $7.00 |
HTML Structure
Axiom01 styles standard HTML <table> elements. No special classes are needed for basic table styling, promoting semantic HTML.
<!-- Basic Table -->
<table>
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
</tr>
<tr>
<td>2</td>
<td>Jacob</td>
<td>Thornton</td>
<td>@fat</td>
</tr>
</tbody>
</table>
<!-- Striped Table -->
<table class="striped">
<!-- ... table content ... -->
</table>
Styling
Axiom01 applies default styles to <table>, <th>, and <td> elements. For variations, a minimal class approach is used:
- Default: Basic borders, padding, and text alignment are applied to all tables.
- Striped: Add the
.stripedclass to the<table>element to apply alternating row backgrounds for improved readability. - Hover Rows: Rows automatically get a subtle hover effect.
Responsive Tables
For tables that may contain many columns and overflow on smaller screens, wrap the table in a container with overflow-x: auto; to enable horizontal scrolling.
<div style="overflow-x: auto;">
<table>
<!-- ... wide table content ... -->
</table>
</div>
Accessibility
Tables are inherently accessible when structured correctly:
- Always use
<thead>,<tbody>, and<th>elements. - Use the
scopeattribute on<th>elements (e.g.,<th scope="col">or<th scope="row">) to explicitly define header cells for screen readers. - Provide a
<caption>element for a descriptive table title.
Customization
Customize the appearance using Axiom01's CSS variables for colors (e.g., --a-color-outline for borders, --a-color-surface-variant for striped rows), spacing, and typography. You can also add custom classes for more specific table variations.