Overview

The table component is designed to handle tabular data in a flexible, responsive way. It supports various layout options, such as fixed column widths and striped rows, and is enhanced for mobile devices with automatic scrolling functionality.

1. Table Structure

The table component follows a clear, accessible structure. It includes a <table> element wrapped inside a <figure> to group the table with its caption. The table contains three key sections: <thead> for headers, <tbody> for the main content, and <tfoot> for footers.

Key elements:

HTML Markup Example

<figure class="bt1d-table-wrapper">
  <table class="bt1d-table">
    <thead>
      <tr>
        <th>Header 1</th>
        <th>Header 2</th>
        <th>Header 3</th>
        <th>Header 4</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Content 1</td>
        <td>Content 2</td>
        <td>Content 3</td>
        <td>Content 4</td>
      </tr>
    </tbody>
    <tfoot>
      <tr>
        <td>Footer 1</td>
        <td>Footer 2</td>
        <td>Footer 3</td>
        <td>Footer 4</td>
      </tr>
    </tfoot>
  </table>
  <figcaption class="bt1d-table-caption">Table Caption</figcaption>
</figure>

2. Key Classes

The table component comes with several classes that control layout and styling.

3. Responsive Behavior (JS-Enhanced)

On mobile devices or smaller screens, the table automatically becomes scrollable when its content overflows horizontally. JavaScript detects this overflow and applies the necessary classes for a smooth, scrollable experience.

Example of a scrollable table:

<figure class="bt1d-table-wrapper">
  <table class="bt1d-table bt1d-table--scrollable">
    <thead>
      <tr>
        <th>Header 1</th>
        <th>Header 2</th>
        <th>Header 3</th>
        <th>Header 4</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Content 1</td>
        <td>Content 2</td>
        <td>Content 3</td>
        <td>Content 4</td>
      </tr>
    </tbody>
  </table>
  <figcaption class="bt1d-table-caption">Scrollable Table Example</figcaption>
</figure>

4. CSS and Layout Options

The table component offers several layout options to improve presentation and usability:

Example (default):

<figure class="bt1d-table-wrapper">
  <table class="bt1d-table">
    <thead>
      <tr>
        <th>Header 1</th>
        <th>Header 2</th>
        <th>Header 3</th>
        <th>Header 4</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Content 1</td>
        <td>Content 2</td>
        <td>Content 3</td>
        <td>Content 4</td>
      </tr>
    </tbody>
  </table>
  <figcaption class="bt1d-table-caption">Striped Table Example</figcaption>
</figure>
Header LabelSecondary HeaderTertiary HeaderLast Header Label
Table ContentTable ContentTable ContentTable Content
Table ContentDeserunt enim cupidatat Lorem ad ipsum labore nisi eu aliquip.Table ContentTable Content
Table ContentTable ContentTable ContentTable Content
Footer LabelSecondary FooterTertiary FooterLast Footer Item
Table Caption

Example with striped rows:

<figure class="bt1d-table-wrapper">
  <table class="bt1d-table bt1d-table--stripes">
    <thead>
      <tr>
        <th>Header 1</th>
        <th>Header 2</th>
        <th>Header 3</th>
        <th>Header 4</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Content 1</td>
        <td>Content 2</td>
        <td>Content 3</td>
        <td>Content 4</td>
      </tr>
    </tbody>
  </table>
  <figcaption class="bt1d-table-caption">Striped Table Example</figcaption>
</figure>
Header LabelSecondary HeaderTertiary HeaderLast Header Label
Table ContentTable ContentTable ContentTable Content
Table ContentDeserunt enim cupidatat Lorem ad ipsum labore nisi eu aliquip.Table ContentTable Content
Table ContentTable ContentTable ContentTable Content
Footer LabelSecondary FooterTertiary FooterLast Footer Item
Table Caption

Full example with fixed layout, striped rows, and scrollable behavior:

<figure class="bt1d-table-wrapper">
  <table class="bt1d-table bt1d-table--fixed-layout bt1d-table--stripes">
    <thead>
      <tr>
        <th>Header 1</th>
        <th>Header 2</th>
        <th>Header 3</th>
        <th>Header 4</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Content 1</td>
        <td>Content 2</td>
        <td>Content 3</td>
        <td>Content 4</td>
      </tr>
      <tr>
        <td>Content 5</td>
        <td>Content 6</td>
        <td>Content 7</td>
        <td>Content 8</td>
      </tr>
    </tbody>
    <tfoot>
      <tr>
        <td>Footer 1</td>
        <td>Footer 2</td>
        <td>Footer 3</td>
        <td>Footer 4</td>
      </tr>
    </tfoot>
  </table>
  <figcaption class="bt1d-table-caption">Full Table Example</figcaption>
</figure>
Header LabelSecondary HeaderTertiary HeaderLast Header Label
Table ContentTable ContentTable ContentTable Content
Table ContentDeserunt enim cupidatat Lorem ad ipsum labore nisi eu aliquip.Table ContentTable Content
Table ContentTable ContentTable ContentTable Content
Footer LabelSecondary FooterTertiary FooterLast Footer Item
Table Caption

6. Summary

The Table Component offers flexibility for presenting tabular data: