UI Patterns

Table with scrolling overflowStatusdevelopment

An example of markup and styling for a scrollable table wrapper

Guidance

Tabular data can be difficult to display at smaller breakpoints. The reduced width of mobile screens does not allow space for table rows to stretch out and data can end up looking very compressed, or cutting off to the right of the screen.

One option to handle this is to wrap the table in a container. This container is styled to scroll horizontally when it needs to, while keeping the rest of the page contained within the screen width.

This pattern is best used when the tabular data needs to be scanned by the user in the context of the other rows around it. It allows for easier visual comparison between table row entries.

If this is not necessary, you may wish to consider the alterntative responsive card table pattern.

Example with scrolling overflow

Open in a new tab

<div class="table__container table__container--overflow" tabindex="0" aria-labelledby="scrolltableCaption"><table class="table table--has-caption"><caption id="scrolltableCaption" class="table__caption">Example table</caption><thead class="table__head"><tr class="table__row"><th class="table__th" scope="col">Name</th><th class="table__th" scope="col">Job title</th><th class="table__th" scope="col">Date of birth</th></tr></thead><tbody class="table__bd"><tr class="table__row"><td data-th="Name" class="table__td">Joe Example</td><td data-th="Job title" class="table__td">Web developer</td><td data-th="Date of birth" class="table__td">1 Jan 1970</td></tr><tr class="table__row"><td data-th="Name" class="table__td">Joe Example</td><td data-th="Job title" class="table__td">Web developer</td><td data-th="Date of birth" class="table__td">1 Jan 1970</td></tr><tr class="table__row"><td data-th="Name" class="table__td">Joe Example</td><td data-th="Job title" class="table__td">Web developer</td><td data-th="Date of birth" class="table__td">1 Jan 1970</td></tr></tbody></table></div>

Example with scrolling overflow and sticky column

Open in a new tab

<div class="table__container table__container--overflow table__container--overflow-sticky" tabindex="0" aria-labelledby="scrolltableStickyCaption"><table class="table table--has-caption"><caption id="scrolltableStickyCaption" class="table__caption">Example table</caption><thead class="table__head"><tr class="table__row"><th class="table__th" scope="col">Name</th><th class="table__th" scope="col">Job title</th><th class="table__th" scope="col">Date of birth</th></tr></thead><tbody class="table__bd"><tr class="table__row"><td data-th="Name" class="table__td">Joe Example</td><td data-th="Job title" class="table__td">Web developer</td><td data-th="Date of birth" class="table__td">1 Jan 1970</td></tr><tr class="table__row"><td data-th="Name" class="table__td">Joe Example</td><td data-th="Job title" class="table__td">Web developer</td><td data-th="Date of birth" class="table__td">1 Jan 1970</td></tr><tr class="table__row"><td data-th="Name" class="table__td">Joe Example</td><td data-th="Job title" class="table__td">Web developer</td><td data-th="Date of birth" class="table__td">1 Jan 1970</td></tr></tbody></table></div>

Acceptance criteria

The following is a list of example acceptance criteria to test against when using this pattern. These critera should test that the specific markup requirements are met, and that the search behaves visually and functionally as expected.

For validation in developer tools / web inspector

For visual validation

References