domestic-ui GitHub

Scroll

A scroll container for content wider than the screen, such as a data table, so it scrolls on its own instead of widening the page.

Where a scroll region is used A scroll region holds a data table wider than the content area, so the table scrolls sideways on its own and the page does not.

Live example

Scroll region

<section data-scroll="inline" aria-labelledby="viewports-caption" tabindex="0">
  <table>
    <caption id="viewports-caption">Viewports every page is checked at</caption>
    <thead>
      <tr>
        <th scope="col">Width</th>
        <th scope="col">Height</th>
        <th scope="col">Engines</th>
        <th scope="col">Checks</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>320px</td>
        <td>640px</td>
        <td>Chromium, Firefox, WebKit</td>
        <td>No sideways page scroll, no axe violations</td>
      </tr>
      <tr>
        <td>375px</td>
        <td>812px</td>
        <td>Chromium, Firefox, WebKit</td>
        <td>No sideways page scroll, no axe violations</td>
      </tr>
    </tbody>
  </table>
</section>

API

Attribute or valueEffect
data-scroll="inline"scroll along the inline axis (left/right in English)
data-scroll="block inline"also scroll along the block axis, at most --dui-size-pane (the viewport) tall, so a sticky table header stays in view (css/components/organisms/data-table.css)
  • Add tabindex="0" so keyboard users can scroll it (WCAG 2.1.1, axe rule).
  • Our choice: a <section> with aria-labelledby, not <div role="region">, because the native element already has the role.
  • A table inside keeps display: table, or it can lose its semantics (Adrian Roselli).

Accessibility

  • WCAG 1.4.10 allows two-dimensional scrolling for data tables.
  • A named <section> is a region landmark (HTML-AAM), so the focus stop is announced.

Specifications

See also

How other systems do it

For comparison only; these are not the standard this system follows.

Search