Table layout

Utilities for controlling the table layout algorithm.

In this article

Class Properties
.table-auto table-layout: auto;
.table-fixed table-layout: fixed;

Usage

Use .table-auto to allow the table to automatically size columns to fit the contents of the cell.

<table class="table table-auto">
  <tr>
    <th>Request title</th>
    <th>Requester</th>
  </tr>
  <tr>
    <td>My printer is on fire!</td>
    <td>John Smith</td>
  </tr>
  <tr>
    <td>Please help me with this really long winded request.</td>
    <td>Jane Doe</td>
  </tr>
</table>

Use .table-fixed to allow the table to ignore the content and use fixed widths for columns.

<table class="table table-fixed">
  <tr>
    <th>Request title</th>
    <th>Requester</th>
  </tr>
  <tr>
    <td>My printer is on fire!</td>
    <td>John Smith</td>
  </tr>
  <tr>
    <td>Please help me with this really long winded request.</td>
    <td>Jane Doe</td>
  </tr>
</table>

The width of the first row will set the column widths for the whole table.

You can manually set the widths for some columns and the rest of the available width will be divided evenly amongst the columns without explicit width.

Variants

By default, no responsive or hover-state variants are generated for table layout utilities.

Responsive

To include responsive variants like .md:table-fixed, add "table-layout" to the $responsive-variants variable in your theme’s _variables.scss file when recompiling your CSS:

$responsive-variants: (
  // ...
  "table-layout",
);

Hover-state

To include hover-state variants like .hover:table-fixed, add "table-layout" to the $hover-variants variable:

$hover-variants: (
  // ...
  "table-layout",
);

Questions or feedback about this article? Let us know