{{ aspExample({ code: "", nunjucks: "", json: "", title: "", example: "default", id: "65a92fd59d3c8" }) }}

WIP – Column widths are calculated by the browser based on the available space and the content within each column. The exact distribution of widths is determined by the browser’s table layout algorithm and is therefore not directly controllable.

The only way to enforce consistent column widths is to assign fixed or equal widths to the columns. However, this can still result in wrapping where the available width is insufficient and, in many cases, may increase the amount of wrapping rather than reduce it. For this reason, fixed column widths are generally only used where the content is predictable and of a consistent length, or where a specific column is known to contain short, uniform values that can reliably fit on a single line.

When designing tables, aim to minimise the amount of data displayed in a single view. Where practical, consider splitting large datasets across multiple tables, pages, or views. This improves readability, reduces the likelihood of excessive wrapping, and allows the browser greater flexibility in allocating column widths.

When to use this component

Use the table component to let users compare information in rows and columns.

Use tables to present data or information that can be organised in a structured way. This could consist of numbers, text or statistics.

A table should make it easy to:

When not to use this component

Do not use tables for cosmetic reasons or when you can use normal page structure to present the information, for example headers or lists.

Never use the table component to layout content on a page. Instead, use the grid system.

Table with equal columns

{{ aspExample({ code: "", nunjucks: "", json: "", title: "", example: "equal-columns", id: "6659cfaa4c7cd" }) }}

Table with links

{{ aspExample({ code: "", nunjucks: "", json: "", title: "", example: "linked-rows", id: "6659cfaa4c83c" }) }}

Unread Table

{{ aspExample({ code: "", nunjucks: "", json: "", title: "", example: "blue", id: "65a92fd59d469" }) }}

Read Table

{{ aspExample({ code: "", nunjucks: "", json: "", title: "", example: "amber", id: "65a92fd59d4d3" }) }}

Processed Table

{{ aspExample({ code: "", nunjucks: "", json: "", title: "", example: "green", id: "65a92fd59d57e" }) }}

Table ordering

WIP – There is a visually hidden span which is read out by screenreaders that states the sorting order that will be applied when the button is next clicked. This can be either descending or ascending.

The form should submit with params, so the page can be reloaded/shared with the current state, also history can be preserved per pageload.

{{ aspExample({ code: "<form action=\"#results\">
<div class=\"form-table-order\">
<div class=\"form__group\">
<label class=\"form__label\" for=\"asp-js-select\">Order by:</label>
<select class=\"form__input asp-js-select\" id=\"asp-js-select\" name=\"order\">
<option value=\"value-1\">SmartSTORM reference ascending</option>
<option value=\"value-2\" selected>SmartSTORM reference descending</option>
<option value=\"value-3\">Incident type ascending</option>
<option value=\"value-4\">Incident type descending</option>
<option value=\"value-5\">Source ascending</option>
<option value=\"value-6\">Source descending</option>
<option value=\"value-7\">Response grading ascending</option>
<option value=\"value-8\">Response grading descending</option>
<option value=\"value-9\">Date and time ascending</option>
<option value=\"value-10\">Date and time descending</option>
<option value=\"value-11\">Call length ascending</option>
<option value=\"value-12\">Call length descending</option>
</select>
</div>
<noscript>
<!– should go to #results –>
<button class=\"asp-button asp-button–start asp-button–table-order\" type=\"submit\">Apply order</button>
</noscript>
</div>
<table class=\"asp-table\" id=\"results\">
<thead class=\"asp-table__head\">
<tr class=\"asp-table__row asp-table__row–head\">
<th class=\"asp-table__header asp-table__header–order asp-table__header–order-unread\">
<button class=\"asp-link–plain asp-table__button\" name=\"order-table\" value=\"value-1\" data-order=\"asc\">
SmartSTORM reference
<span class=\"sr-only\"> order by descending</span>
</button>
</th>
<th class=\"asp-table__header asp-table__header–order\">
<button class=\"asp-link–plain asp-table__button\" name=\"order-table\" value=\"value-3\" data-order=\"both\">
Incident type
<span class=\"sr-only\"> order by ascending</span>
</button>
</th>
<th class=\"asp-table__header asp-table__header–order\">
<button class=\"asp-link–plain asp-table__button\" name=\"order-table\" value=\"value-5\" data-order=\"both\">
Source
<span class=\"sr-only\"> order by ascending</span>
</button>
</th>
<th class=\"asp-table__header asp-table__header–order\">
<button class=\"asp-link–plain asp-table__button\" name=\"order-table\" value=\"value-7\" data-order=\"both\">
Response grading
<span class=\"sr-only\"> order by ascending</span>
</button>
</th>
<th class=\"asp-table__header asp-table__header–order\">
<button class=\"asp-link–plain asp-table__button\" name=\"order-table\" value=\"value-10\" data-order=\"both\">
Date and time
<span class=\"sr-only\"> order by descending</span>
</button>
</th>
<th class=\"asp-table__header asp-table__header–numeric asp-table__header–order\">
<button class=\"asp-link–plain asp-table__button\" name=\"order-table\" value=\"value-12\" data-order=\"both\">
Call length
<span class=\"sr-only\"> order by descending</span>
</button>
</th>
</tr>
</thead>
<tbody class=\"asp-table__body\">
<tr class=\"asp-table__row asp-table__row–unread asp-table__row–link\">
<td class=\"asp-table__cell\"><span class=\"asp-table__icon asp-table__icon–unread\"></span><span class=\"asp-table__responsive-heading\" aria-hidden=\"true\">SmartSTORM reference </span><a class=\"asp-table__link\" href=\"#\">AS-20241120-XXXX</a></td>
<td class=\"asp-table__cell\"><span class=\"asp-table__responsive-heading\" aria-hidden=\"true\">Incident type </span>PUBLIC ORDER</td>
<td class=\"asp-table__cell\"><span class=\"asp-table__responsive-heading\" aria-hidden=\"true\">Source </span>999</td>
<td class=\"asp-table__cell\"><span class=\"asp-table__responsive-heading\" aria-hidden=\"true\">Response grading </span>Routine</td>
<td class=\"asp-table__cell\"><span class=\"asp-table__responsive-heading\" aria-hidden=\"true\">Date and time </span>20 November 2024 17:30</td>
<td class=\"asp-table__cell asp-table__cell–numeric\"><span class=\"asp-table__responsive-heading\" aria-hidden=\"true\">Call length </span>11:18</td>
</tr>
<tr class=\"asp-table__row asp-table__row–unread asp-table__row–link\">
<td class=\"asp-table__cell\"><span class=\"asp-table__icon asp-table__icon–unread\"></span><span class=\"asp-table__responsive-heading\" aria-hidden=\"true\">SmartSTORM reference </span><a class=\"asp-table__link\" href=\"#\">AS-20241120-XXXX</a></td>
<td class=\"asp-table__cell\"><span class=\"asp-table__responsive-heading\" aria-hidden=\"true\">Incident type </span>CONCERN FOR WELFARE</td>
<td class=\"asp-table__cell\"><span class=\"asp-table__responsive-heading\" aria-hidden=\"true\">Source </span>999</td>
<td class=\"asp-table__cell\"><span class=\"asp-table__responsive-heading\" aria-hidden=\"true\">Response grading </span>Res without deploy</td>
<td class=\"asp-table__cell\"><span class=\"asp-table__responsive-heading\" aria-hidden=\"true\">Date and time </span>20 November 2024 15:20</td>
<td class=\"asp-table__cell asp-table__cell–numeric\"><span class=\"asp-table__responsive-heading\" aria-hidden=\"true\">Call length </span>09:57</td>
</tr>
<tr class=\"asp-table__row asp-table__row–unread asp-table__row–link\">
<td class=\"asp-table__cell\"><span class=\"asp-table__icon asp-table__icon–unread\"></span><span class=\"asp-table__responsive-heading\" aria-hidden=\"true\">SmartSTORM reference </span><a class=\"asp-table__link\" href=\"#\">AS-20241120-XXXX</a></td>
<td class=\"asp-table__cell\"><span class=\"asp-table__responsive-heading\" aria-hidden=\"true\">Incident type </span>THEFT FROM VEHICLE</td>
<td class=\"asp-table__cell\"><span class=\"asp-table__responsive-heading\" aria-hidden=\"true\">Source </span>101</td>
<td class=\"asp-table__cell\"><span class=\"asp-table__responsive-heading\" aria-hidden=\"true\">Response grading </span>Res without deploy</td>
<td class=\"asp-table__cell\"><span class=\"asp-table__responsive-heading\" aria-hidden=\"true\">Date and time </span>10 November 2024 08:25</td>
<td class=\"asp-table__cell asp-table__cell–numeric\"><span class=\"asp-table__responsive-heading\" aria-hidden=\"true\">Call length </span>08:46</td>
</tr>
</tbody>
</table>
</form>", nunjucks: "", json: "", title: "", example: "", id: "67b5d009920a3" }) }}

Numeric only

{{ aspExample({ code: "", nunjucks: "", json: "", title: "", example: "numeric-only", id: "6a43d6c933e9f" }) }}

First column as a header

{{ aspExample({ code: "", nunjucks: "", json: "", title: "", example: "first-column-header", id: "6a43d6c933ed9" }) }} {{ aspExample({ code: "", nunjucks: "", json: "", title: "", example: "blank-cell", id: "6a4420665c597" }) }}

Status of development

The below criteria all need to be met for a component to be considered as fully developed for use within the ASP Digital Design System.

Development criteria Status
WCAG 2.2 compliant Not started
WCAG 2.1 compliant Failing
HTML / Nunjucks version Complete
Figma version Not started
M365 versions Not started
Documentation In progress

Make a change to the Design System

Suggest an edit to this system, or any of the components in it, by submitting a Design System change request.