Tables
- Data table
- Table with striped rows
- Table with fixed columns width
- Borderless table
- Auto width table
- Table with row underlining
- Snug table
- Small table
- Bold text in a column
- Align a column's text to the right
- Control column widths by %
- Hide table head row
- No table row highlight
- Data table, responsive list
- Data table, column select
- Table with sticky header
- Data table with clickable row highlight
- Data table with selected row
- Data table with clickable row highlight and selected row
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).
Maiores maiores | Alias natus
|
Sed quisquam
|
Temporibusquoset | Account status | Actions |
---|---|---|---|---|---|
Odit eligendi | Consectetur eos deleniti | Nulla vitae doloribus | Inventore officia autem | Unverified |
|
Libero beatae | Dolorem sed laudantium | Soluta sint et | Veritatis qui | Unverified |
|
Quaerat voluptatibus | Voluptatem dignissimos aperiam | Qui explicabo cupiditate | Sequi voluptas qui | Verified |
|
Est quia | Adipisci magni labore | Modi maxime reiciendis | Ad dolorem earum | Unregistered |
|
Non velit | Quo rem voluptas | Maxime vero molestiae | Quasi ut | Unregistered |
|
Recusandae nihil | Ut eius id | Reprehenderit optio necessitatibus | Temporibus voluptatem | 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">Qui sit</a></th>
<th>Fugit consectetur
<!-- START form-item-text_field component -->
<div class="form-item">
<label for="text_field_01" class="hide-element">Search column</label>
<input type="text" id="text_field_01">
</div>
<!-- END form-item-text_field component -->
</th>
<th class="column-sortable"><a href="#" class="column-sortable__link">Tenetur inventore</a>
<!-- START form-item-text_field component -->
<div class="form-item">
<label for="text_field_02" class="hide-element">Search column</label>
<input type="text" id="text_field_02">
</div>
<!-- END form-item-text_field component -->
</th>
<th class="column-sortable"><a href="#" class="column-sortable__link column-sortable__link--down">Temporibusquoset</a></th>
<th>Account status</th>
<th class="column-actions-heading">Actions</th>
</tr>
</thead>
<tbody>
<tr class="table-row-disabled">
<th>Maiores sed</th>
<td>Nesciunt sunt soluta</td>
<td>Velit quia doloribus</td>
<td>Et voluptate laboriosam</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>A ad</th>
<td>Illum aut ea</td>
<td>Sequi aut amet</td>
<td><a href="#" title="Test link">Et officiis</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>Deleniti voluptatem</th>
<td>Explicabo blanditiis sunt</td>
<td>Vel quia est</td>
<td>Commodi unde quo</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>Sequi corrupti</th>
<td>Enim libero perferendis</td>
<td>Aut alias voluptatem</td>
<td>Ab repellat sit</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>Qui debitis</th>
<td>Magnam magni accusantium</td>
<td>Dolor repellendus assumenda</td>
<td><a href="#" title="Test link">Provident alias</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>
<tr>
<th>Amet voluptatem</th>
<td>Est nisi dolores</td>
<td>Est consequatur nesciunt</td>
<td><a href="#" title="Test link">Non tempora</a></td>
<td><p class="icon-inline--left icon--account-monza">Unregistered</p></td>
<td class="items-inline-center" data-th="Actions">
<p class="icon--check-dark icon-inline--larger icon-hide-text margin-reset">Selected</p>
</td>
</tr>
</tbody>
</table>
</div>
<!-- END data table component -->
Table with striped rows
Adding the class table--striped-rows
will make the rows striped.
Earum nulla consequuntur | Corporis qui occaecati | A qui voluptate | Unverified |
Delete |
Ut eum quod | Suscipit consequatur quae | Voluptas sed | Unverified |
Delete |
Voluptatibus aut iste | Quo dolor rerum | Aliquid aperiam et | Verified |
Delete |
Corrupti ipsa aut | Non consequatur praesentium | Quos voluptas atque | Unregistered |
Delete |
Tenetur vitae deleniti | Vero est vitae | Est eos | Unregistered |
Delete |
Table with fixed columns width
Adding the class table--fixed-column-width
will make the columns equal width - this can look neater.
Reiciendis explicabo | Dolores nesciunt | Voluptates ea repellendus molestiae tempora temporibus | Temporibusquoset Commodi provident | Account status | Actions |
---|---|---|---|---|---|
Odit ut | Nobis et placeat | Voluptas et sequi | Enim sed et | Unverified |
Delete |
Eius commodi | Qui natus voluptas | Ut deleniti nisi | Quis ullam | Unverified |
Delete |
Voluptas deserunt | Molestias et sed | Id qui recusandae | Quia nihil officia | Verified |
Delete |
Possimus ut | Cum iste fuga | Repellat suscipit quia | Unde saepe consectetur | Unregistered |
Delete |
A repellat | Ut voluptatem velit | Sit ut veritatis | Minima officia | 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 | |
Auto width table
We can add table-auto-width
to the surrounding div, so the table sizes itself and is no longer 100% of the page width
Qualification | Requirement | Notes |
---|---|---|
UCAS Tariff | 100 Tariff points | None |
A level | BBB |
Table with row underlining
We can add row-underlining
to the table
Qualification | Requirement | Notes |
---|---|---|
UCAS Tariff | 100 Tariff points | None |
A level | BBB | |
HNC | DD |
Snug table
We can add table-snug
to the surrounding div to reduce the vertical padding in cells.
Qualification | Requirement | Notes |
---|---|---|
UCAS Tariff | 100 Tariff points | From either A level, International Baccalaureate, or Scottish Higher |
A level | BBB |
Small table
We can add table--small
to the surrounding div so the table mimics the dl.list--inline.
Modules
Unit title | Credit value | Result | Date |
---|---|---|---|
accounting | 1 Cred | Dist | January 2020 |
physics | 3 Creds | Merit | January 2020 |
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 |
Align a column's text to the centre
We can add a class to align the text to the centre in a specific column.
In the following example table-col2-centre
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.
Available widths are: 10, 20, 25, 30, 33, 40, 50, 60, 66, 70, 75, 80, 90.
It's a good idea for the tds in a row to add up to 100%!
On small screens the widths will revert to auto
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.
No table row highlight on hover
We can remove the row highlight on hover for small tables, usually when used in conjunction with table-borderless
and table-clear
.
A true data table (with lots of numbers, statuses, rows, etc.) needs highlighting.
Add the class table-no-row-hover-highlight
to the div surrounding the table.
Qualification | Requirement | Notes |
---|---|---|
UCAS Tariff | 100 Tariff points | From either A level, International Baccalaureate, or Scottish Higher |
A level | BBB |
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
Delectus assumenda | Ut | Perspiciatis ad id | Temporibusquoset quia totam | Actions |
---|---|---|---|---|
Et hic | Saepe quasi quam | Perferendis possimus inventore | Magnam porro dolores | |
Minus neque | Voluptas rerum reprehenderit | Dolorum qui tempore | Quia aut corrupti | |
Dolores eos | Iusto quo illo | Quia totam reiciendis | Quo et et | |
Sequi excepturi | Beatae sunt at | Recusandae quam earum | Sed sunt sit | |
Quia qui | Assumenda quaerat deleniti | Omnis sint laudantium | Impedit quaerat pariatur | |
Dicta rerum | Cupiditate voluptate amet | Fugiat aut molestias | Et et commodi | |
Dolorum repudiandae | Vel minima molestiae | Reprehenderit sit velit | Provident non laborum | |
Et ut | Veniam ducimus labore | Laudantium nemo sunt | Eos vel numquam | |
Vitae accusantium | Mollitia at vitae | Voluptatem provident id | Voluptas corporis accusantium | |
Fuga facilis | Ullam quidem voluptas | Non voluptas et | Fuga totam tempore | |
Qui vitae | Veritatis molestiae natus | Perspiciatis a eius | Autem ut cumque | |
Maxime repellendus | Id quos eum | Veritatis sunt sit | Laborum aut ducimus | |
Est voluptas | Fugit nobis aut | Distinctio voluptatibus deleniti | Sapiente est rerum | |
Omnis eveniet | Eius harum inventore | Minus laboriosam sequi | Recusandae incidunt sunt | |
Voluptas sequi | Voluptatibus debitis ea | Et maxime commodi | Ut nam sit | |
Nostrum quo | Totam beatae voluptatibus | Sunt ut enim | Quam in molestiae | |
Ut quidem | Ex exercitationem similique | Voluptas et sapiente | Ab quidem soluta | |
Non voluptas | Cupiditate sunt tempora | Qui nesciunt minima | Est magni cumque | |
Ut dolorum | Voluptatem dolorum officia | Quae amet quas | Qui dolores voluptas | |
Sed dolorum | Et iste earum | Voluptas illum ut | Reiciendis quo et |
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">Et cum</a></th>
<th>Dolor</th>
<th class="column-sortable"><a href="#" class="column-sortable__link">Nisi possimus voluptatum</a></th>
<th class="column-sortable"><a href="#" class="column-sortable__link column-sortable__link--down">Temporibusquoset saepe est</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="Et cum">Vel laudantium</th>
<td data-th="Dolor">Ratione iste eos</td>
<td data-th="Nisi possimus voluptatum"><a href="#">Omnis non magni</a></td>
<td data-th="Temporibusquoset saepe est">Quos odit qui</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="Et cum">Quia aut</th>
<td data-th="Dolor">Deserunt suscipit sapiente</td>
<td data-th="Nisi possimus voluptatum"><a href="#">Eaque sequi recusandae</a></td>
<td data-th="Temporibusquoset saepe est">Non suscipit voluptas</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="Et cum">Illo velit</th>
<td data-th="Dolor">Numquam nemo corrupti</td>
<td data-th="Nisi possimus voluptatum"><a href="#">Aut in et</a></td>
<td data-th="Temporibusquoset saepe est">Sit iusto nisi</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 | Voluptatibus a | Temporibusquoset Non ab | Actions |
---|---|---|---|---|---|---|---|---|---|
Earum dolores | Facere dolores quidem | Deleniti dolore dolores | Quo excepturi laboriosam | Aliquam repellendus eos | Inventore odit alias | Quos commodi quia | Consequuntur qui molestiae | Quasi voluptatibus omnis | |
Sed vel | Omnis aspernatur eius | Architecto et pariatur | In in occaecati | Sit voluptatem voluptas | Dolores debitis ex | Quia quasi magni | Eaque non ratione | Eum quasi est | |
Totam tempora | Consequatur perferendis et | Pariatur beatae quam | Mollitia exercitationem et | Voluptatem quasi molestiae | Eveniet consectetur id | Aperiam incidunt adipisci | Ea ullam vitae | Minima qui ducimus | |
Quidem consequuntur | Qui et ut | Sint a a | Sit qui ut | Omnis similique recusandae | Voluptates et delectus | Tempora modi eos | Est eveniet sit | Neque voluptate aliquid | |
Voluptatibus consectetur | Voluptas quo consequatur | Neque recusandae iusto | Error consequatur nemo | Totam vitae deserunt | Rem asperiores non | Illo sequi et | Consequatur ratione cupiditate | Modi voluptate nulla | |
Et minus | Aut assumenda nam | Beatae velit quae | Et laborum ut | Optio rerum assumenda | Qui quia quidem | Et modi consequatur | A est ab | Quis incidunt et |
Table with sticky header
This is a progressive enhancement and will not work on all browsers, including IE.
Id culpa | Sed | Non est repudiandae | Temporibusquoset aut et | Actions | Checkbox | Non est repudiandae |
---|---|---|---|---|---|---|
Voluptatem amet | Magni odit voluptatem | Et voluptatem velit | Eum et minima |
|
Rerum et fugit | |
Non recusandae | Culpa harum laudantium | Ut consequatur ipsum | Sunt quas et |
|
At sint quos | |
Et sit | Quis laboriosam voluptas | Qui doloremque est | Qui amet pariatur |
|
Optio rerum qui | |
Nulla ipsa | Totam quam harum | Illo ad voluptate | Dolores praesentium voluptatum |
|
Provident illum corrupti | |
Deleniti est | Laudantium veritatis sed | Occaecati adipisci tenetur | Molestias fuga sit |
|
Qui dolore quidem | |
Aut nesciunt | Exercitationem dignissimos corrupti | Natus occaecati et | Voluptas perferendis architecto |
|
Voluptates consequatur nam | |
Reprehenderit delectus | Dicta eaque voluptas | Et culpa eos | Illo velit corrupti |
|
Officiis veritatis atque | |
Atque itaque | Nemo pariatur repellat | Nisi dolorum et | Incidunt qui velit |
|
Dignissimos ullam necessitatibus | |
Illo ipsam | Delectus sed impedit | Recusandae iusto fugiat | Blanditiis ab dolorem |
|
Sit non repellendus | |
Sit eum | Necessitatibus tempora voluptatum | Voluptatibus sit quasi | Aut voluptatem in |
|
Sapiente cumque quasi |
Data table with clickable row highlight
Adding the class .table__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.
Laboriosam et | Non nostrum | Ut saepe magni et quo error | Temporibusquoset Eaque ut | Actions |
---|---|---|---|---|
Ex nostrum | Maxime suscipit ut | Non laudantium consequuntur | Quia qui nobis | Delete |
Mollitia quos | Ut iusto |
Laboriosam ex et | Dicta laudantium | Delete |
Quas possimus | Et et |
Consequuntur cumque hic | Occaecati odio illo | Delete |
Error blanditiis | Neque voluptas consequuntur | Quos sit nostrum | Earum quia magni | Delete |
Consectetur cupiditate | Rerum temporibus quis | Exercitationem voluptatem eligendi | Placeat qui cumque | Delete |
Data table responsive list with clickable row highlight
Qualification | Start date | Study mode | Duration | Location | Actions |
---|---|---|---|---|---|
Doctor of Philosophy - PhD | 10/2018 | Laudantium ipsam |
48 Months | Main Site | |
Doctor of Philosophy - PhD | 11/2018 | Aut aut |
48 Months | Main Site | |
Doctor of Philosophy - PhD | 12/2018 | Full-time | 48 Months | Main Site |
Data table with selected row
Adding the class .table__selected-row
to any <tr>
will highlight the row.
Tempore neque | Ut voluptatem | A aut perspiciatis maiores ut ea | Temporibusquoset Optio a | Actions |
---|---|---|---|---|
Sapiente ut | Occaecati alias non | Tempore officiis dolores | Voluptatem eum aliquam | Delete |
Qui nemo | Illo officia |
Quos explicabo officia | Est ut | Delete |
Qui repellendus | Qui sapiente |
Tempore cum omnis | Iusto facilis inventore | Delete |
Voluptatem quaerat | Cumque et distinctio | Sint quod molestiae | Voluptatem ut aut | Delete |
Aspernatur odit | Omnis distinctio quasi | Quo quia sit | Harum qui nulla | Delete |
Data table with clickable row highlight and selected row
Adding the class .table__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.
Adding the class .table__selected-row
to any <tr>
will highlight the row.
Sunt consectetur | Sit facilis | Est sint ullam in iusto et | Temporibusquoset Sit dolorum | Actions |
---|---|---|---|---|
Accusantium voluptatem | Molestiae magni quidem | Facere asperiores nesciunt | Assumenda amet fugit | Delete |
Ex sit | Aut ratione |
Ut fugit natus | Voluptates dicta | Delete |
Qui occaecati | Et officia |
Quam aut tempore | Laborum dignissimos facilis | Delete |
Ut dolor | Aliquid temporibus dolor | Maxime quia ullam | Placeat consequatur ut | Delete |
Odio quibusdam | Consequuntur esse quia | Nulla laudantium nostrum | Esse tempore et | Delete |