Tables
Data table
Standard data table with sorting options.
Buttons used within these tables should stick to button--small
.
The td containing any buttons can have data-th="Actions"
to stop the buttons wrapping. The heading of the buttons column can have the class column-actions-heading
to hide the 'Actions' heading text (this text will still be available to screen readers).
Beatae rerum | Error qui | Sed quo enim modi cumque ad | Temporibusquoset Non nemo | Account status | Actions |
---|---|---|---|---|---|
Assumenda ut | Veniam libero aut | Et velit assumenda | Voluptatem ullam commodi | Unverified |
|
Laborum possimus | Dolores dolore veniam | Perferendis totam et | Est nulla | Unverified |
|
Dolorum quia | Minima pariatur culpa | Id qui quisquam | Exercitationem commodi officiis | Verified |
|
Minima odit | Dolorem voluptates impedit | Quas accusamus praesentium | Dolores eum nobis | Unregistered |
|
Consequatur itaque | Voluptatem ut harum | Pariatur provident voluptatem | Quis similique | Unregistered |
Standard sortable data table. Wrapping the table in table-responsive is optional and simply ensures wide tables don't break layout on small devices.
In general data tables should be limited to admin interfaces, which would be less likely to be accessed via mobile devices. They may also be used to display smaller amounts of tabular data where other layout methods don't exist.
The <th> of a sorted header should include aria mark-up: aria-sort="ascending|descending|none|other". You should apply aria-sort to only one header at a time. In the following code the first column header has aria-sort="ascending" and no aria code on any other <th>
<th> is used in rows to help clarify to screen-readers which row the action buttons apply to.
Note: a <th> should not remain empty. According to WAVE, "If the table cell is a header, provide text within the cell that describes the column or row. If the cell is not a header or must remain empty (such as the top-left cell in a data table), make the cell a <td> rather than a <th>."
<!-- START data table component -->
<div class="table-responsive">
<table>
<thead>
<tr>
<th class="column-sortable" aria-sort="ascending"><a href="#" class="column-sortable__link column-sortable__link--up">Ut iusto</a></th>
<th>Corporis recusandae</th>
<th class="column-sortable"><a href="#" class="column-sortable__link">Autem omnis et repellat officiis a</a></th>
<th class="column-sortable"><a href="#" class="column-sortable__link column-sortable__link--down">Temporibusquoset Rerum perferendis</a></th>
<th>Account status</th>
<th class="column-actions-heading">Actions</th>
</tr>
</thead>
<tbody>
<tr class="table-row-disabled">
<th>Quo corporis</th>
<td>Qui id et</td>
<td>Est eum cupiditate</td>
<td>Id vero et</td>
<td><p class="icon-inline--left icon--account-monza">Unverified</p></td>
<td data-th="Actions">
<div class="buttons">
<button class="button button--small" disabled>Edit</button>
<a href="#" class="button button--small disabled" role="button">Delete</a>
</div>
</td>
</tr>
<tr>
<th>Repudiandae sit</th>
<td>Velit nostrum sunt</td>
<td>Blanditiis ipsa ut</td>
<td><a href="#" title="Test link">Voluptatem perspiciatis</a></td>
<td><p class="icon-inline--left icon--account-monza">Unverified</p></td>
<td data-th="Actions">
<div class="buttons">
<button class="button button--small">Edit</button>
<a href="#" class="button button--small" role="button">Delete</a>
</div>
</td>
</tr>
<tr class="table-row-disabled">
<th>Praesentium aperiam</th>
<td>Qui reiciendis fugit</td>
<td>Voluptatem vel voluptatem</td>
<td>Eaque iste aperiam</td>
<td><p class="icon-inline--left icon--account-dark">Verified</p></td>
<td data-th="Actions">
<div class="buttons">
<button class="button button--small" disabled>Edit</button>
<a href="#" class="button button--small disabled" role="button">Delete</a>
</div>
</td>
</tr>
<tr>
<th>Officia facere</th>
<td>Corporis accusantium hic</td>
<td>Id minima nam</td>
<td>Cupiditate eaque consequatur</td>
<td><p class="icon-inline--left icon--account-monza">Unregistered</p></td>
<td data-th="Actions">
<div class="buttons">
<button class="button button--small">Edit</button>
<a href="#" class="button button--small" role="button">Delete</a>
</div>
</td>
</tr>
<tr>
<th>Perspiciatis dolores</th>
<td>Illo sit ducimus</td>
<td>Ab rerum ut</td>
<td><a href="#" title="Test link">Velit amet</a></td>
<td><p class="icon-inline--left icon--account-monza">Unregistered</p></td>
<td data-th="Actions">
<div class="buttons">
<button class="button button--small">Edit</button>
<a href="#" class="button button--small" role="button">Delete</a>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- END data table component -->
Table with fixed columns width
Adding the class table--fixed-column-width
will make the columns equal width - this can look neater.
Dolorum officia | Omnis blanditiis | Est recusandae dolore sed laboriosam ut | Temporibusquoset Quos odit | Account status | Actions |
---|---|---|---|---|---|
Exercitationem in | Eum earum omnis | Est sed nemo | Ipsam saepe cum | Unverified |
Delete |
Qui quae | Corporis vitae non | Esse cum illum | Debitis veritatis | Unverified |
Delete |
Et itaque | Qui quisquam quae | Voluptatem autem earum | Eveniet alias nam | Verified |
Delete |
Inventore laboriosam | Rerum ducimus sed | Earum amet voluptates | Nam vel maiores | Unregistered |
Delete |
Voluptatibus minima | Hic aut totam | Nam molestiae laboriosam | Sint voluptatem | Unregistered |
Delete |
Finer control of a table
There are some classes that in combination can give you a lot more control of how your table looks.
Borderless table
We can add table-borderless
to the surrounding div.
Qualification | Requirement | Notes |
---|---|---|
UCAS Tariff | 100 Tariff points | From either A level, International Baccalaureate, or Scottish Higher |
A level | BBB |
Bold text in a column
We can add a class to make text bold in a specific column. This class is added to the surrounding div.
In the following example table-col2-bold
had been added to bold the text in the second column.
Qualification | Requirement | Notes |
---|---|---|
UCAS Tariff | 100 Tariff points | From either A level, International Baccalaureate, or Scottish Higher |
A level | BBB |
Align a column's text to the right
We can add a class to align the text to the right in a specific column.
In the following example table-col1-right
had been added to right align the text in the first column.
Qualification | Requirement | Notes |
---|---|---|
UCAS Tariff | 100 Tariff points | From either A level, International Baccalaureate, or Scottish Higher |
A level | BBB |
Control column widths by %
We can state the percentage widths of the columns by attaching classes to tds.
In the following example column-width--20pc
had been added to all the tds that make up the first and second columns. The class column-width--60pc
had been added to all the tds that make up the third column.
It's a good idea for the tds in a row to add up to 100%!
Qualification | Requirement | Notes |
---|---|---|
UCAS Tariff | 100 Tariff points | From either A level, International Baccalaureate, or Scottish Higher |
A level | BBB |
Hide table head row
We can hide the top row if the columns are self-explanatory. They will still appear to screen readers.
We do this by adding the class table-hide-head-row
to the div surrounding the table.
Data table, responsive list
Adding the class table-responsive--list
will render the table as a list at smaller widths. The table headers will not be displayed, so this won't be suitable for a table that has sortable columns.
This table will break to a list view on smaller devices. If you would like it to break sooner you can add the class table-responsive--list--break-at-medium
Et tempore | Quo | Et laborum tempore | Temporibusquoset nobis similique | Actions |
---|---|---|---|---|
Harum voluptas | Atque et omnis | Doloremque sint pariatur | Delectus autem animi | |
Qui qui | Animi non velit | Doloribus ipsam minima | Accusantium dolores unde | |
Praesentium sequi | Autem odio error | Aut delectus dolores | Voluptatem accusamus et | |
Ratione deserunt | Accusantium asperiores consequatur | Maiores fuga nulla | Quia non quis | |
Amet aliquid | Facere magni dolor | Unde voluptatem voluptatem | Occaecati aut non | |
Qui qui | Et quae corrupti | Harum accusamus accusamus | Adipisci quaerat tenetur | |
Atque occaecati | Qui voluptas sapiente | Enim est nam | Facilis aut expedita | |
Excepturi voluptates | Reiciendis reiciendis suscipit | Itaque reprehenderit repudiandae | Porro beatae ipsam | |
Laborum nesciunt | Molestiae in quis | Eum nam est | Non molestiae mollitia | |
Similique odit | Sed culpa sint | Nam et necessitatibus | Facere aperiam deleniti | |
Id et | Dolores minus quas | Qui ea dolorum | Explicabo sint blanditiis | |
Beatae laudantium | Magni suscipit accusamus | Corporis odit ex | Tempore quo iusto | |
Ab perspiciatis | Dolorem aliquid dignissimos | Ut ut asperiores | Non qui voluptas | |
Repellendus laudantium | Aspernatur voluptate ad | Enim sit nemo | Ullam similique iure | |
Nihil praesentium | Aut dolorem asperiores | Eveniet deserunt natus | Nihil dolorem sit | |
Dicta et | Rem maiores et | Explicabo et saepe | Sed impedit sit | |
Doloremque tenetur | Sed corrupti repellendus | Voluptatem harum aut | Quasi eius tempore | |
Voluptate est | Quia sequi aliquid | Omnis molestias qui | Omnis repudiandae ab | |
Dolores laboriosam | Laborum commodi temporibus | Deleniti et qui | Necessitatibus sit eos | |
In accusantium | Commodi itaque vel | Repellat voluptatibus quasi | In laborum dolores |
All cells will need a data-th
attribute for the column name. This is used at small screen sizes to identify the cells when displayed as a list.
<!-- START table-data-long-responsive-list component -->
<div class="table-responsive table-responsive--list">
<table>
<thead>
<tr>
<th class="column-sortable" aria-sort="ascending"><a href="#" class="column-sortable__link column-sortable__link--up">Nihil magnam</a></th>
<th>Modi</th>
<th class="column-sortable"><a href="#" class="column-sortable__link">Illo voluptates aut</a></th>
<th class="column-sortable"><a href="#" class="column-sortable__link column-sortable__link--down">Temporibusquoset sed sit</a></th>
<th class="column-actions-heading">Actions</th>
</tr>
</thead>
<tbody>
<tr>
<!-- NB: All cells will need a data-th attribute for the column name. -->
<!-- This is used at small screen sizes to identify the cells when displayed as a list. -->
<th data-th="Nihil magnam">Consequatur voluptatibus</th>
<td data-th="Modi">Eligendi illo ut</td>
<td data-th="Illo voluptates aut">Distinctio laudantium quo</td>
<td data-th="Temporibusquoset sed sit">Ut numquam optio</td>
<td data-th="Actions">
<button class="button button--small">View</button>
<button class="button button--small">Delete</button>
</td>
</tr>
<tr>
<!-- NB: All cells will need a data-th attribute for the column name. -->
<!-- This is used at small screen sizes to identify the cells when displayed as a list. -->
<th data-th="Nihil magnam">Accusantium facere</th>
<td data-th="Modi">Est officiis nemo</td>
<td data-th="Illo voluptates aut">Voluptatem velit ullam</td>
<td data-th="Temporibusquoset sed sit">Harum non velit</td>
<td data-th="Actions">
<button class="button button--small">View</button>
<button class="button button--small">Delete</button>
</td>
</tr>
<tr>
<!-- NB: All cells will need a data-th attribute for the column name. -->
<!-- This is used at small screen sizes to identify the cells when displayed as a list. -->
<th data-th="Nihil magnam">Soluta vero</th>
<td data-th="Modi">Accusantium enim illum</td>
<td data-th="Illo voluptates aut">Vel laborum rerum</td>
<td data-th="Temporibusquoset sed sit">Voluptas exercitationem corporis</td>
<td data-th="Actions">
<button class="button button--small">View</button>
<button class="button button--small">Delete</button>
</td>
</tr>
</tbody>
</table>
</div>
<!-- END table-data-long-responsive-list component -->
Data table, column select
Voluptatem perferendis | Et al | Minima aut accusantium dolorem explicabo eos | Nisi sit | Dicta ratione | Velit quo | Quod nam | Culpa voluptatem | Temporibusquoset Non ab | Actions |
---|---|---|---|---|---|---|---|---|---|
Architecto ut | Et debitis magnam | Id consequatur voluptas | Et praesentium ipsum | Necessitatibus tempore aspernatur | Omnis eos aperiam | Soluta nisi omnis | Repudiandae nisi qui | Veniam mollitia animi | |
Consequuntur et | Amet dignissimos deserunt | Quis cumque accusantium | Est ex quibusdam | Omnis sit id | Ut sit eveniet | Dicta consequatur voluptatibus | Est autem quidem | Voluptatum expedita delectus | |
Est non | Optio libero ea | Sed sint sit | Laudantium assumenda facilis | Exercitationem occaecati culpa | Tempora ipsum nobis | Sint quod quisquam | Sed nisi et | Quas non nesciunt | |
Quibusdam voluptate | Et in optio | Fuga magnam voluptas | Corporis consequatur tempore | Harum quos consequatur | Commodi sunt qui | In blanditiis eveniet | Dolor quos debitis | Recusandae commodi saepe | |
Aut earum | Perspiciatis minima doloribus | Blanditiis ut iusto | Architecto dolor necessitatibus | Eius est fuga | Sequi id assumenda | Pariatur et ut | Voluptate quibusdam beatae | Et tenetur nisi | |
In in | Quo sed in | Est possimus soluta | Laudantium ut in | Eos aliquid debitis | Totam sequi sint | Optio iure voluptatum | Voluptate maxime quam | Sapiente non odit |
Data table with clickable row highlight
Adding the class .table-responsive--active-row
to any <tr>
will add a hover highlight to the row and change its cursor to a pointer to indicate that it is a clickable link.
The highlight colour will adopt the scheme colour if used.
Quas sed | Ea illo | Veniam et delectus et repudiandae sint | Temporibusquoset Unde dolorum | Actions |
---|---|---|---|---|
Sed voluptatem | Eligendi dolor reiciendis | Incidunt et dolorem | Rem velit sed | |
Laudantium ut | Iusto nemo ut | Id dolorem sit | Consequatur ex | |
Eum neque | Culpa adipisci sequi | Esse in distinctio | Alias cum modi | |
Odio fugit | Consectetur ea vel | Eum tempora repudiandae | Rerum neque dolorum | |
Asperiores minus | Quaerat molestiae ut | Illo pariatur aliquam | Velit aliquam laudantium |