Table

The table reset provides minimal styles and responsive functionality to semantic HTML5 tables.

Responsive

By default, tables will be responsive, meaning its rows will collapse down to a single-column of information.

Unresponsive

When you add a data-responsive="false" attribute to a table element, it will no longer collapse rows down to assingle-column of information. Instead, the table will horizontally scroll when its width exceeds its wrapping container's width (i.e. main column in most circumstances).

Tips

Javascript

For each table within a page:

  1. It's wrapped with a .cwf-scroll.cwf-scroll--x element to ensure horizontal scrolling when the table's width exceeds the viewport width.
  2. If its first body row is only headings, that row is given a .sr-only__below--md class to ensure it's hidden on mobile viewports.
  3. If it hasn't been explicitly set to be unresponsive (via a data-responsive="false" attribute), data attributes are added to be used for the responsive heading labels.

Examples

Responsive (column headings)

I am a table caption
I am a table summary
Column 1Column 2Column 3Column 4Column 5
1:1 one:one1:2 one:two1:3 one:three1:4 one:four1:5 one:five
2:1 two:one2:2 two:two2:3 two:three2:4 two:four2:5 two:five
3:1 three:one3:2 three:two3:3 three:three3:4 three:four3:5 three:five

Responsive (column/row headings)

Column 1Column 2Column 3Column 4Column 5
Row 11:2 one:two1:3 one:three1:4 one:four1:5 one:five
Row 22:2 two:two2:3 two:three2:4 two:four2:5 two:five
Row 33:2 three:two3:3 three:three3:4 three:four3:5 three:five

Responsive (first body row of column headings)

Column 1Column 2Column 3Column 4Column 5
1:1 one:one1:2 one:two1:3 one:three1:4 one:four1:5 one:five
2:1 two:one2:2 two:two2:3 two:three2:4 two:four2:5 two:five
3:1 three:one3:2 three:two3:3 three:three3:4 three:four3:5 three:five

Unresponsive

Column 1Column 2Column 3Column 4Column 5
Row 11:2 one:two1:3 one:three1:4 one:four1:5 one:five
Row 22:2 two:two2:3 two:three2:4 two:four2:5 two:five
Row 33:2 three:two3:3 three:three3:4 three:four3:5 three:five