skip to content

Table

Data tables must be accessible. Each must have a <caption> element. It is permissable to use a heading element inside the <caption> so screen reader users can navigate to it using heading shortcuts. For the sake of avoiding redundancy, if you do use a heading element inside the <caption> you should no longer introduce the table with a heading.

Light theme

Basic table with column headers

Column 1 Column 2 Column 3
Row 1 / cell 1 Row 1 / cell 2 Row 1 / cell 3
Row 2 / cell 1 Row 2 / cell 2 Row 2 / cell 3
Row 3 / cell 1 Row 3 / cell 2 Row 3 / cell 3

Dark theme

Invoke the dark theme on any component by applying class="ds-dark" to a container element.

Basic table with column headers

Column 1 Column 2 Column 3
Row 1 / cell 1 Row 1 / cell 2 Row 1 / cell 3
Row 2 / cell 1 Row 2 / cell 2 Row 2 / cell 3
Row 3 / cell 1 Row 3 / cell 2 Row 3 / cell 3
<div class="ds-table">
  <table>
    <caption><h2>Basic table with column headers</h2></caption>
    <tr>
      <th>Column 1</th>
      <th>Column 2</th>
      <th>Column 3</th>
    </tr>
    <!-- rows here -->
  </table>
</div>

Row headers

You can use either column headers (<th> in the above example), row headers (<th> with scope="row" on each row’s first child) or both.

Light theme

Basic table with column and row headers
Column 1 Column 2 Column 3
Row 1 / row header Row 1 / cell 2 Row 1 / cell 3
Row 2 / row header Row 2 / cell 2 Row 2 / cell 3
Row 3 / row header Row 3 / cell 2 Row 3 / cell 3

Dark theme

Invoke the dark theme on any component by applying class="ds-dark" to a container element.
Basic table with column and row headers
Column 1 Column 2 Column 3
Row 1 / row header Row 1 / cell 2 Row 1 / cell 3
Row 2 / row header Row 2 / cell 2 Row 2 / cell 3
Row 3 / row header Row 3 / cell 2 Row 3 / cell 3
<div class="ds-table">
  <table>
    <caption>Basic table with column headers</caption>
    <tr>
      <th>Column 1</th>
      <th>Column 2</th>
      <th>Column 3</th>
    </tr>
    <tr>
      <th scope="row">Row 1 / row header</th>
      <td>Row 1 / cell 2</td>
      <td>Row 1 / cell 3</td>
    </tr>
    <tr>
      <th scope="row">Row 2 / row header</th>
      <td>Row 2 / cell 2</td>
      <td>Row 2 / cell 3</td>
    </tr>
    <tr>
      <th scope="row">Row 3 / row header</th>
      <td>Row 3 / cell 2</td>
      <td>Row 3 / cell 3</td>
    </tr>
  </table>
</div>

Responsiveness

Tables should retain their structure for comprehension. Ensuring they can be used and viewed with many columns, or in smaller viewports, the containing class="ds-table" element is scrollable along the horizontal axis.

Light theme

Basic table with column headers

Column 1 Column 2 Column 3 Column 4 Column 5 Column 6 Column 7 Column 8 Column 9 Column 10 Column 11 Column 12 Column 13 Column 14 Column 15
Row 1 / cell 1 Row 1 / cell 2 Row 1 / cell 3 Row 1 / cell 4 Row 1 / cell 5 Row 1 / cell 6 Row 1 / cell 7 Row 1 / cell 8 Row 1 / cell 9 Row 1 / cell 10 Row 1 / cell 11 Row 1 / cell 12 Row 1 / cell 13 Row 1 / cell 14 Row 1 / cell 15
Row 2 / cell 1 Row 3 / cell 2 Row 4 / cell 3 Row 5 / cell 4 Row 6 / cell 5 Row 7 / cell 6 Row 8 / cell 7 Row 9 / cell 8 Row 9 / cell 9 Row 9 / cell 10 Row 9 / cell 11 Row 9 / cell 12 Row 9 / cell 13 Row 9 / cell 14 Row 9 / cell 15

Dark theme

Invoke the dark theme on any component by applying class="ds-dark" to a container element.

Basic table with column headers

Column 1 Column 2 Column 3 Column 4 Column 5 Column 6 Column 7 Column 8 Column 9 Column 10 Column 11 Column 12 Column 13 Column 14 Column 15
Row 1 / cell 1 Row 1 / cell 2 Row 1 / cell 3 Row 1 / cell 4 Row 1 / cell 5 Row 1 / cell 6 Row 1 / cell 7 Row 1 / cell 8 Row 1 / cell 9 Row 1 / cell 10 Row 1 / cell 11 Row 1 / cell 12 Row 1 / cell 13 Row 1 / cell 14 Row 1 / cell 15
Row 2 / cell 1 Row 3 / cell 2 Row 4 / cell 3 Row 5 / cell 4 Row 6 / cell 5 Row 7 / cell 6 Row 8 / cell 7 Row 9 / cell 8 Row 9 / cell 9 Row 9 / cell 10 Row 9 / cell 11 Row 9 / cell 12 Row 9 / cell 13 Row 9 / cell 14 Row 9 / cell 15

Tables in cards

You can use a Card to “lift” a table and give it more affordance in the page.

Light theme

Table inside a card
Column 1 Column 2 Column 3
Row 1 / row header Row 1 / cell 2 Row 1 / cell 3
Row 2 / row header Row 2 / cell 2 Row 2 / cell 3
Row 3 / row header Row 3 / cell 2 Row 3 / cell 3

Dark theme

Invoke the dark theme on any component by applying class="ds-dark" to a container element.
Table inside a card
Column 1 Column 2 Column 3
Row 1 / row header Row 1 / cell 2 Row 1 / cell 3
Row 2 / row header Row 2 / cell 2 Row 2 / cell 3
Row 3 / row header Row 3 / cell 2 Row 3 / cell 3
<div class="ds-card ds-padded">
  <div class="ds-table">
    <table>
      <!-- table markup -->
    </table>
  </div>
</div>