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 Jan 31, 2024
1 parent 8de7b2c commit c8b9281
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 5 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"dependencies": {
"accessible-autocomplete": "^2.0.4",
"clipboard": "^2.0.11",
"govuk-frontend": "^5.0.0",
"govuk-frontend": "github:alphagov/govuk-frontend#729155478",
"iframe-resizer": "^4.3.9",
"lunr": "^2.3.9"
},
Expand Down
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 mulltiple pages.

If you can't 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.

{{ 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 c8b9281

Please sign in to comment.