Skip to content

Commit

Permalink
Add guidance for tables with lots of data
Browse files Browse the repository at this point in the history
  • Loading branch information
owenatgov committed Feb 8, 2024
1 parent c55fc67 commit 168d9b3
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/table/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,13 @@ If the [width override classes](/styles/layout/#width-override-classes) do not m
To learn more about this, read guidance on [extending and modifying components in production](/get-started/extending-and-modifying-components/).

{{ example({ group: "components", item: "table", example: "column-widths-custom-classes", html: true, nunjucks: true, open: false, size: "m" }) }}

## Tables with a lot of data

If possible, you should aim to have less data in your tables. If you have a lot of data, try to organise it into multiple tables or multiple pages.

If you cannot split your data, you can use the CSS class `govuk-table--small-text-until-tablet`. This class reduces the size of the text on small screens so that the large amount of data is easier to read on smaller screens.

You should not use this class on tables unless your table has a lot of data because a smaller amount of data is easier to read if the text is larger.

{{ example({ group: "components", item: "table", example: "lots-of-data", html: true, nunjucks: true, open: false, size: "m" }) }}
81 changes: 81 additions & 0 deletions src/components/table/lots-of-data/index.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
title: Lots of data – Table
layout: layout-example.njk
---

{% from "govuk/components/table/macro.njk" import govukTable %}

{{ govukTable({
caption: "Dates and amounts",
captionClasses: "govuk-table__caption--m",
firstCellIsHeader: true,
classes: "govuk-table--small-text-until-tablet",
head: [
{
text: "Date"
},
{
text: "First amount"
},
{
text: "Second amount"
}
],
rows: [
[
{
text: "First 3 weeks"
},
{
text: "£27.45 per week"
},
{
text: "£33.90 per week"
}
],
[
{
text: "Next 6 weeks"
},
{
text: "£27.45 per week"
},
{
text: "£33.90 per week"
}
],
[
{
text: "Next 24 weeks"
},
{
text: "£27.45 per week"
},
{
text: "£33.90 per week"
}
],
[
{
text: "Next 33 weeks"
},
{
text: "£27.45 per week"
},
{
text: "£33.90 per week"
}
],
[
{
text: "Total estimated pay"
},
{
text: "£4,282.20"
},
{
text: "£5,288.40"
}
]
]
}) }}

0 comments on commit 168d9b3

Please sign in to comment.