Skip to main content

Content

Tables

Opt-in table styles — variants, stripes, borders, sizing, alignment and responsive wrappers — on cream-300 rules.

Overview

Due to the widespread use of <table> elements across third-party widgets like calendars and date pickers, tables are opt-in. Add the base class .table to any <table>, then extend with the modifier classes or custom styles. All table styles are not inherited, meaning any nested tables can be styled independently of the parent.

What the theme sets:

  • Cell text is the emphasis colour (black in light, cream-50 in dark); the background is the body background.
  • Row rules are 1px in --bs-border-color: cream-300 in light, navy-500 in dark.
  • Cell padding is .5rem, vertical alignment is top.
  • Stripes, hover and active states are alpha tints of the emphasis colour — 5%, 7.5% and 10% — so they work on any variant.

Using the most basic table markup, here is how .table-based tables look in this theme.

# Wrestler Billed from Finisher
1 Mark Parts Unknown @mdo
2 Jacob Thornton @fat
3 Larry the Bird @twitter
HTML
<table class="table">
  <thead>
    <tr>
      <th scope="col">#</th>
      <th scope="col">Wrestler</th>
      <th scope="col">Billed from</th>
      <th scope="col">Finisher</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">1</th>
      <td>Mark</td>
      <td>Parts Unknown</td>
      <td>@mdo</td>
    </tr>
    <tr>
      <th scope="row">2</th>
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
      <th scope="row">3</th>
      <td colspan="2">Larry the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>

Variants

Use contextual classes to colour tables, table rows or individual cells.

Class Heading Heading
Default Cell Cell
Primary Cell Cell
Secondary Cell Cell
Success Cell Cell
Danger Cell Cell
Warning Cell Cell
Info Cell Cell
Light Cell Cell
Dark Cell Cell
HTML
<table class="table">
  <thead>
    <tr>
      <th scope="col">Class</th>
      <th scope="col">Heading</th>
      <th scope="col">Heading</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">Default</th>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
    <tr class="table-primary">
      <th scope="row">Primary</th>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
    <tr class="table-secondary">
      <th scope="row">Secondary</th>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
    <tr class="table-success">
      <th scope="row">Success</th>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
    <tr class="table-danger">
      <th scope="row">Danger</th>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
    <tr class="table-warning">
      <th scope="row">Warning</th>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
    <tr class="table-info">
      <th scope="row">Info</th>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
    <tr class="table-light">
      <th scope="row">Light</th>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
    <tr class="table-dark">
      <th scope="row">Dark</th>
      <td>Cell</td>
      <td>Cell</td>
    </tr>
  </tbody>
</table>
<!-- On tables -->
<table class="table-primary">...</table>
<table class="table-secondary">...</table>
<table class="table-success">...</table>
<table class="table-danger">...</table>
<table class="table-warning">...</table>
<table class="table-info">...</table>
<table class="table-light">...</table>
<table class="table-dark">...</table>

<!-- On rows -->
<tr class="table-primary">...</tr>

<!-- On cells (`td` or `th`) -->
<tr>
  <td class="table-primary">...</td>
</tr>

The variants are the eight Bootstrap theme colours tinted 80% towards white — primary is pale gold, secondary and info are pale navy, warning is pale gold-300. .table-light is cream-50 and .table-dark is navy-900 with cream text.

The three extra theme colours do not have table variants: there is no .table-gold, .table-navy or .table-cream in the compiled CSS. Bootstrap builds $table-variants before the theme extends $theme-colors. For a gold row use .table-primary (or .table-warning for the lighter gold-300); for navy use .table-info; for cream use .table-light. Or set --bs-table-bg on the row.
Accessibility tip: Using colour to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g. the visible text with a sufficient colour contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.

Accented tables

Striped rows

Use .table-striped to add zebra-striping to any table row within the <tbody>.

#MatchStipulationTime
1Opening contestSingles8:12
2Tag team titlesTornado tag11:40
3Main eventSteel cage19:55
HTML
<table class="table table-striped">
  <thead>
    <tr><th scope="col">#</th><th scope="col">Match</th><th scope="col">Stipulation</th><th scope="col">Time</th></tr>
  </thead>
  <tbody>
    <tr><th scope="row">1</th><td>Opening contest</td><td>Singles</td><td>8:12</td></tr>
    <tr><th scope="row">2</th><td>Tag team titles</td><td>Tornado tag</td><td>11:40</td></tr>
    <tr><th scope="row">3</th><td>Main event</td><td>Steel cage</td><td>19:55</td></tr>
  </tbody>
</table>

Striped columns

Use .table-striped-columns to add zebra-striping to any table column.

#MatchStipulationTime
1Opening contestSingles8:12
2Tag team titlesTornado tag11:40
3Main eventSteel cage19:55
HTML
<table class="table table-striped-columns">
  <thead>
    <tr><th scope="col">#</th><th scope="col">Match</th><th scope="col">Stipulation</th><th scope="col">Time</th></tr>
  </thead>
  <tbody>
    <tr><th scope="row">1</th><td>Opening contest</td><td>Singles</td><td>8:12</td></tr>
    <tr><th scope="row">2</th><td>Tag team titles</td><td>Tornado tag</td><td>11:40</td></tr>
    <tr><th scope="row">3</th><td>Main event</td><td>Steel cage</td><td>19:55</td></tr>
  </tbody>
</table>

These classes can also be added to table variants:

#MatchStipulationTime
1Opening contestSingles8:12
2Tag team titlesTornado tag11:40
3Main eventSteel cage19:55
HTML
<table class="table table-dark table-striped">
  <thead>
    <tr><th scope="col">#</th><th scope="col">Match</th><th scope="col">Stipulation</th><th scope="col">Time</th></tr>
  </thead>
  <tbody>
    <tr><th scope="row">1</th><td>Opening contest</td><td>Singles</td><td>8:12</td></tr>
    <tr><th scope="row">2</th><td>Tag team titles</td><td>Tornado tag</td><td>11:40</td></tr>
    <tr><th scope="row">3</th><td>Main event</td><td>Steel cage</td><td>19:55</td></tr>
  </tbody>
</table>
#MatchStipulationTime
1Opening contestSingles8:12
2Tag team titlesTornado tag11:40
3Main eventSteel cage19:55
HTML
<table class="table table-success table-striped">
  <thead>
    <tr><th scope="col">#</th><th scope="col">Match</th><th scope="col">Stipulation</th><th scope="col">Time</th></tr>
  </thead>
  <tbody>
    <tr><th scope="row">1</th><td>Opening contest</td><td>Singles</td><td>8:12</td></tr>
    <tr><th scope="row">2</th><td>Tag team titles</td><td>Tornado tag</td><td>11:40</td></tr>
    <tr><th scope="row">3</th><td>Main event</td><td>Steel cage</td><td>19:55</td></tr>
  </tbody>
</table>

Hoverable rows

Add .table-hover to enable a hover state on table rows within a <tbody>.

#MatchStipulationTime
1Opening contestSingles8:12
2Tag team titlesTornado tag11:40
3Main eventSteel cage19:55
HTML
<table class="table table-hover">
  <thead>
    <tr><th scope="col">#</th><th scope="col">Match</th><th scope="col">Stipulation</th><th scope="col">Time</th></tr>
  </thead>
  <tbody>
    <tr><th scope="row">1</th><td>Opening contest</td><td>Singles</td><td>8:12</td></tr>
    <tr><th scope="row">2</th><td>Tag team titles</td><td>Tornado tag</td><td>11:40</td></tr>
    <tr><th scope="row">3</th><td>Main event</td><td>Steel cage</td><td>19:55</td></tr>
  </tbody>
</table>

These hoverable rows can also be combined with the striped rows variant:

#MatchStipulationTime
1Opening contestSingles8:12
2Tag team titlesTornado tag11:40
3Main eventSteel cage19:55
HTML
<table class="table table-striped table-hover">
  <thead>
    <tr><th scope="col">#</th><th scope="col">Match</th><th scope="col">Stipulation</th><th scope="col">Time</th></tr>
  </thead>
  <tbody>
    <tr><th scope="row">1</th><td>Opening contest</td><td>Singles</td><td>8:12</td></tr>
    <tr><th scope="row">2</th><td>Tag team titles</td><td>Tornado tag</td><td>11:40</td></tr>
    <tr><th scope="row">3</th><td>Main event</td><td>Steel cage</td><td>19:55</td></tr>
  </tbody>
</table>

Active tables

Highlight a table row or cell by adding a .table-active class.

#MatchStipulationTime
1Opening contestSingles8:12
2Tag team titlesTornado tag11:40
3Main event19:55
HTML
<table class="table">
  <thead>
    <tr><th scope="col">#</th><th scope="col">Match</th><th scope="col">Stipulation</th><th scope="col">Time</th></tr>
  </thead>
  <tbody>
    <tr class="table-active"><th scope="row">1</th><td>Opening contest</td><td>Singles</td><td>8:12</td></tr>
    <tr><th scope="row">2</th><td>Tag team titles</td><td>Tornado tag</td><td>11:40</td></tr>
    <tr><th scope="row">3</th><td colspan="2">Main event</td><td class="table-active">19:55</td></tr>
  </tbody>
</table>

How do the variants and accented tables work?

For the accented tables (striped rows, striped columns, hoverable rows and active tables), Bootstrap uses a few techniques to make these effects work for all table variants:

  • The table cells are styled with a --bs-table-accent-bg background, transparent by default, under the real --bs-table-bg.
  • Each variant sets its own --bs-table-striped-bg, --bs-table-active-bg and --bs-table-hover-bg, pre-mixed against the variant colour.
  • Striped, active and hover each write --bs-table-color-type / --bs-table-bg-type or --bs-table-color-state / --bs-table-bg-state; the cell reads them in order of priority with a chain of var() fallbacks.

Because the base states are tints of --bs-emphasis-color, they automatically flip when the page goes dark.

Table borders

Bordered tables

Add .table-bordered for borders on all sides of the table and cells. Combine with the border colour utilities to change the rule — here the navy "bracket board" look.

#MatchStipulationTime
1Opening contestSingles8:12
2Tag team titlesTornado tag11:40
3Main event19:55
HTML
<table class="table table-bordered">
  <thead>
    <tr><th scope="col">#</th><th scope="col">Match</th><th scope="col">Stipulation</th><th scope="col">Time</th></tr>
  </thead>
  <tbody>
    <tr><th scope="row">1</th><td>Opening contest</td><td>Singles</td><td>8:12</td></tr>
    <tr><th scope="row">2</th><td>Tag team titles</td><td>Tornado tag</td><td>11:40</td></tr>
    <tr><th scope="row">3</th><td colspan="2">Main event</td><td>19:55</td></tr>
  </tbody>
</table>
#MatchStipulationTime
1Opening contestSingles8:12
2Tag team titlesTornado tag11:40
3Main event19:55
HTML
<table class="table table-bordered border-navy">
  <thead>
    <tr><th scope="col">#</th><th scope="col">Match</th><th scope="col">Stipulation</th><th scope="col">Time</th></tr>
  </thead>
  <tbody>
    <tr><th scope="row">1</th><td>Opening contest</td><td>Singles</td><td>8:12</td></tr>
    <tr><th scope="row">2</th><td>Tag team titles</td><td>Tornado tag</td><td>11:40</td></tr>
    <tr><th scope="row">3</th><td colspan="2">Main event</td><td>19:55</td></tr>
  </tbody>
</table>

Tables without borders

Add .table-borderless for a table without borders.

#MatchStipulationTime
1Opening contestSingles8:12
2Tag team titlesTornado tag11:40
3Main event19:55
HTML
<table class="table table-borderless">
  <thead>
    <tr><th scope="col">#</th><th scope="col">Match</th><th scope="col">Stipulation</th><th scope="col">Time</th></tr>
  </thead>
  <tbody>
    <tr><th scope="row">1</th><td>Opening contest</td><td>Singles</td><td>8:12</td></tr>
    <tr><th scope="row">2</th><td>Tag team titles</td><td>Tornado tag</td><td>11:40</td></tr>
    <tr><th scope="row">3</th><td colspan="2">Main event</td><td>19:55</td></tr>
  </tbody>
</table>
#MatchStipulationTime
1Opening contestSingles8:12
2Tag team titlesTornado tag11:40
3Main event19:55
HTML
<table class="table table-dark table-borderless">
  <thead>
    <tr><th scope="col">#</th><th scope="col">Match</th><th scope="col">Stipulation</th><th scope="col">Time</th></tr>
  </thead>
  <tbody>
    <tr><th scope="row">1</th><td>Opening contest</td><td>Singles</td><td>8:12</td></tr>
    <tr><th scope="row">2</th><td>Tag team titles</td><td>Tornado tag</td><td>11:40</td></tr>
    <tr><th scope="row">3</th><td colspan="2">Main event</td><td>19:55</td></tr>
  </tbody>
</table>

Small tables

Add .table-sm to make any .table more compact by cutting all cell padding in half, to .25rem.

#MatchStipulationTime
1Opening contestSingles8:12
2Tag team titlesTornado tag11:40
3Main event19:55
HTML
<table class="table table-sm">
  <thead>
    <tr><th scope="col">#</th><th scope="col">Match</th><th scope="col">Stipulation</th><th scope="col">Time</th></tr>
  </thead>
  <tbody>
    <tr><th scope="row">1</th><td>Opening contest</td><td>Singles</td><td>8:12</td></tr>
    <tr><th scope="row">2</th><td>Tag team titles</td><td>Tornado tag</td><td>11:40</td></tr>
    <tr><th scope="row">3</th><td colspan="2">Main event</td><td>19:55</td></tr>
  </tbody>
</table>
#MatchStipulationTime
1Opening contestSingles8:12
2Tag team titlesTornado tag11:40
3Main event19:55
HTML
<table class="table table-dark table-sm">
  <thead>
    <tr><th scope="col">#</th><th scope="col">Match</th><th scope="col">Stipulation</th><th scope="col">Time</th></tr>
  </thead>
  <tbody>
    <tr><th scope="row">1</th><td>Opening contest</td><td>Singles</td><td>8:12</td></tr>
    <tr><th scope="row">2</th><td>Tag team titles</td><td>Tornado tag</td><td>11:40</td></tr>
    <tr><th scope="row">3</th><td colspan="2">Main event</td><td>19:55</td></tr>
  </tbody>
</table>

Table group dividers

Add a thicker border, two times --bs-border-width in currentcolor, between table groups — <thead>, <tbody> and <tfoot> — with .table-group-divider. Customise the colour by changing the border-top-color.

#MatchStipulationTime
1Opening contestSingles8:12
2Tag team titlesTornado tag11:40
3Main event19:55
HTML
<table class="table">
  <thead>
    <tr><th scope="col">#</th><th scope="col">Match</th><th scope="col">Stipulation</th><th scope="col">Time</th></tr>
  </thead>
  <tbody class="table-group-divider">
    <tr><th scope="row">1</th><td>Opening contest</td><td>Singles</td><td>8:12</td></tr>
    <tr><th scope="row">2</th><td>Tag team titles</td><td>Tornado tag</td><td>11:40</td></tr>
    <tr><th scope="row">3</th><td colspan="2">Main event</td><td>19:55</td></tr>
  </tbody>
</table>

Vertical alignment

Table cells of <thead> are always vertical aligned to the bottom. Table cells in <tbody> inherit their alignment from <table> and are aligned to the top by default. Use the vertical align classes to re-align where needed.

Heading 1 Heading 2 Heading 3 Heading 4
This cell inherits vertical-align: middle; from the table This cell inherits vertical-align: middle; from the table This cell inherits vertical-align: middle; from the table This here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells.
This cell inherits vertical-align: bottom; from the table row This cell inherits vertical-align: bottom; from the table row This cell inherits vertical-align: bottom; from the table row This here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells.
This cell inherits vertical-align: middle; from the table This cell inherits vertical-align: middle; from the table This cell is aligned to the top. This here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells.
HTML
<div class="table-responsive">
  <table class="table align-middle">
    <thead>
      <tr>
        <th scope="col" class="w-25">Heading 1</th>
        <th scope="col" class="w-25">Heading 2</th>
        <th scope="col" class="w-25">Heading 3</th>
        <th scope="col" class="w-25">Heading 4</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>This cell inherits <code>vertical-align: middle;</code> from the table</td>
        <td>This cell inherits <code>vertical-align: middle;</code> from the table</td>
        <td>This cell inherits <code>vertical-align: middle;</code> from the table</td>
        <td>This here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells.</td>
      </tr>
      <tr class="align-bottom">
        <td>This cell inherits <code>vertical-align: bottom;</code> from the table row</td>
        <td>This cell inherits <code>vertical-align: bottom;</code> from the table row</td>
        <td>This cell inherits <code>vertical-align: bottom;</code> from the table row</td>
        <td>This here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells.</td>
      </tr>
      <tr>
        <td>This cell inherits <code>vertical-align: middle;</code> from the table</td>
        <td>This cell inherits <code>vertical-align: middle;</code> from the table</td>
        <td class="align-top">This cell is aligned to the top.</td>
        <td>This here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells.</td>
      </tr>
    </tbody>
  </table>
</div>

Nesting

Border styles, active styles and table variants are not inherited by nested tables.

#StableMembersFormed
1The Four Horsemen41985
MemberRoleTitle
ALeaderWorld
BEnforcerTelevision
CTag partnerTag team
3The Heenan Family61984
HTML
<table class="table table-striped table-bordered">
  <thead>
    <tr><th scope="col">#</th><th scope="col">Stable</th><th scope="col">Members</th><th scope="col">Formed</th></tr>
  </thead>
  <tbody>
    <tr><th scope="row">1</th><td>The Four Horsemen</td><td>4</td><td>1985</td></tr>
    <tr>
      <td colspan="4">
        <table class="table mb-0">
          <thead>
            <tr><th scope="col">Member</th><th scope="col">Role</th><th scope="col">Title</th></tr>
          </thead>
          <tbody>
            <tr><th scope="row">A</th><td>Leader</td><td>World</td></tr>
            <tr><th scope="row">B</th><td>Enforcer</td><td>Television</td></tr>
            <tr><th scope="row">C</th><td>Tag partner</td><td>Tag team</td></tr>
          </tbody>
        </table>
      </td>
    </tr>
    <tr><th scope="row">3</th><td>The Heenan Family</td><td>6</td><td>1984</td></tr>
  </tbody>
</table>

How nesting works

To prevent any styles from leaking to nested tables, Bootstrap uses the child combinator (>) selector in its CSS. Since it needs to target all the tds and ths in the thead, tbody and tfoot, the selector would look pretty long without it. The .table > :not(caption) > * > * selector targets all cells of direct children only.

Anatomy

Table head

Similar to tables and dark tables, use the modifier classes .table-light or .table-dark to make <thead>s appear light or dark. A navy head over cream rows is the "tale of the tape" look.

#MatchStipulationTime
1Opening contestSingles8:12
2Tag team titlesTornado tag11:40
3Main event19:55
HTML
<table class="table">
  <thead class="table-light">
    <tr><th scope="col">#</th><th scope="col">Match</th><th scope="col">Stipulation</th><th scope="col">Time</th></tr>
  </thead>
  <tbody>
    <tr><th scope="row">1</th><td>Opening contest</td><td>Singles</td><td>8:12</td></tr>
    <tr><th scope="row">2</th><td>Tag team titles</td><td>Tornado tag</td><td>11:40</td></tr>
    <tr><th scope="row">3</th><td colspan="2">Main event</td><td>19:55</td></tr>
  </tbody>
</table>
#MatchStipulationTime
1Opening contestSingles8:12
2Tag team titlesTornado tag11:40
3Main event19:55
HTML
<table class="table">
  <thead class="table-dark">
    <tr><th scope="col">#</th><th scope="col">Match</th><th scope="col">Stipulation</th><th scope="col">Time</th></tr>
  </thead>
  <tbody>
    <tr><th scope="row">1</th><td>Opening contest</td><td>Singles</td><td>8:12</td></tr>
    <tr><th scope="row">2</th><td>Tag team titles</td><td>Tornado tag</td><td>11:40</td></tr>
    <tr><th scope="row">3</th><td colspan="2">Main event</td><td>19:55</td></tr>
  </tbody>
</table>

Table foot

#MatchStipulationTime
1Opening contestSingles8:12
2Tag team titlesTornado tag11:40
3Main event19:55
Total3 matches39:47
HTML
<table class="table">
  <thead>
    <tr><th scope="col">#</th><th scope="col">Match</th><th scope="col">Stipulation</th><th scope="col">Time</th></tr>
  </thead>
  <tbody>
    <tr><th scope="row">1</th><td>Opening contest</td><td>Singles</td><td>8:12</td></tr>
    <tr><th scope="row">2</th><td>Tag team titles</td><td>Tornado tag</td><td>11:40</td></tr>
    <tr><th scope="row">3</th><td colspan="2">Main event</td><td>19:55</td></tr>
  </tbody>
  <tfoot>
    <tr><td>Total</td><td colspan="2">3 matches</td><td>39:47</td></tr>
  </tfoot>
</table>

Captions

A <caption> functions like a heading for a table. It helps users with screen readers to find a table and understand what it is about and decide if they want to read it. By default it sits below the table in the secondary text colour.

List of matches
#MatchStipulationTime
1Opening contestSingles8:12
2Tag team titlesTornado tag11:40
3Main event19:55
HTML
<table class="table">
  <caption>List of matches</caption>
  <thead>
    <tr><th scope="col">#</th><th scope="col">Match</th><th scope="col">Stipulation</th><th scope="col">Time</th></tr>
  </thead>
  <tbody>
    <tr><th scope="row">1</th><td>Opening contest</td><td>Singles</td><td>8:12</td></tr>
    <tr><th scope="row">2</th><td>Tag team titles</td><td>Tornado tag</td><td>11:40</td></tr>
    <tr><th scope="row">3</th><td colspan="2">Main event</td><td>19:55</td></tr>
  </tbody>
</table>

You can also put the <caption> on the top of the table with .caption-top.

List of matches
#MatchStipulationTime
1Opening contestSingles8:12
2Tag team titlesTornado tag11:40
3Main event19:55
HTML
<table class="table caption-top">
  <caption>List of matches</caption>
  <thead>
    <tr><th scope="col">#</th><th scope="col">Match</th><th scope="col">Stipulation</th><th scope="col">Time</th></tr>
  </thead>
  <tbody>
    <tr><th scope="row">1</th><td>Opening contest</td><td>Singles</td><td>8:12</td></tr>
    <tr><th scope="row">2</th><td>Tag team titles</td><td>Tornado tag</td><td>11:40</td></tr>
    <tr><th scope="row">3</th><td colspan="2">Main event</td><td>19:55</td></tr>
  </tbody>
</table>

Responsive tables

Responsive tables allow tables to be scrolled horizontally with ease. Make any table responsive across all viewports by wrapping a .table with .table-responsive. Or, pick a maximum breakpoint with which to have a responsive table up to by using .table-responsive{-sm|-md|-lg|-xl|-xxl}.

Vertical clipping/truncation. Responsive tables make use of overflow-x: auto, which clips off any content that goes beyond the bottom or top edges of the table. In particular, this can clip dropdown menus built on <details>. Use the popover dropdown variant instead — the top layer is never clipped.

Always responsive

Across every breakpoint, use .table-responsive for horizontally scrolling tables.

# HeadingHeadingHeading HeadingHeadingHeading HeadingHeadingHeading
1CellCellCellCellCellCellCellCellCell
2CellCellCellCellCellCellCellCellCell
3CellCellCellCellCellCellCellCellCell
HTML
<div class="table-responsive">
  <table class="table">
    <thead>
      <tr>
        <th scope="col">#</th>
        <th scope="col">Heading</th><th scope="col">Heading</th><th scope="col">Heading</th>
        <th scope="col">Heading</th><th scope="col">Heading</th><th scope="col">Heading</th>
        <th scope="col">Heading</th><th scope="col">Heading</th><th scope="col">Heading</th>
      </tr>
    </thead>
    <tbody>
      <tr><th scope="row">1</th><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td></tr>
      <tr><th scope="row">2</th><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td></tr>
      <tr><th scope="row">3</th><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td></tr>
    </tbody>
  </table>
</div>

Breakpoint specific

Use .table-responsive{-sm|-md|-lg|-xl|-xxl} as needed to create responsive tables up to a particular breakpoint. From that breakpoint and up, the table will behave normally and not scroll horizontally.

These tables may appear broken until their responsive styles apply at specific viewport widths.

# HeadingHeadingHeading HeadingHeadingHeading HeadingHeading
1CellCellCellCellCellCellCellCell
2CellCellCellCellCellCellCellCell
3CellCellCellCellCellCellCellCell
HTML
<div class="table-responsive-md">
  <table class="table">
    <thead>
      <tr>
        <th scope="col">#</th>
        <th scope="col">Heading</th><th scope="col">Heading</th><th scope="col">Heading</th>
        <th scope="col">Heading</th><th scope="col">Heading</th><th scope="col">Heading</th>
        <th scope="col">Heading</th><th scope="col">Heading</th>
      </tr>
    </thead>
    <tbody>
      <tr><th scope="row">1</th><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td></tr>
      <tr><th scope="row">2</th><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td></tr>
      <tr><th scope="row">3</th><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td><td>Cell</td></tr>
    </tbody>
  </table>
</div>
<div class="table-responsive">
  <table class="table">...</table>
</div>

<div class="table-responsive-sm">...</div>
<div class="table-responsive-md">...</div>
<div class="table-responsive-lg">...</div>
<div class="table-responsive-xl">...</div>
<div class="table-responsive-xxl">...</div>

CSS

Variables

Tables use local CSS variables on .table for enhanced real-time customisation. Values are set via Sass, so Sass customisation is still supported too. The variant classes and accent classes override these per table, row or cell.

.table {
  --bs-table-color-type: initial;
  --bs-table-bg-type: initial;
  --bs-table-color-state: initial;
  --bs-table-bg-state: initial;
  --bs-table-color: var(--bs-emphasis-color);
  --bs-table-bg: var(--bs-body-bg);
  --bs-table-border-color: var(--bs-border-color);
  --bs-table-accent-bg: transparent;
  --bs-table-striped-color: var(--bs-emphasis-color);
  --bs-table-striped-bg: rgba(var(--bs-emphasis-color-rgb), 0.05);
  --bs-table-active-color: var(--bs-emphasis-color);
  --bs-table-active-bg: rgba(var(--bs-emphasis-color-rgb), 0.1);
  --bs-table-hover-color: var(--bs-emphasis-color);
  --bs-table-hover-bg: rgba(var(--bs-emphasis-color-rgb), 0.075);
}

Sass variables

Bootstrap's table variables, all left at their defaults. They resolve against the theme's tokens at runtime.

$table-cell-padding-y:        .5rem;
$table-cell-padding-x:        .5rem;
$table-cell-padding-y-sm:     .25rem;
$table-cell-padding-x-sm:     .25rem;

$table-cell-vertical-align:   top;

$table-color:                 var(--bs-emphasis-color);
$table-bg:                    var(--bs-body-bg);
$table-accent-bg:             transparent;

$table-th-font-weight:        null;

$table-striped-color:         $table-color;
$table-striped-bg-factor:     .05;
$table-striped-bg:            rgba(var(--bs-emphasis-color-rgb), $table-striped-bg-factor);

$table-active-color:          $table-color;
$table-active-bg-factor:      .1;
$table-active-bg:             rgba(var(--bs-emphasis-color-rgb), $table-active-bg-factor);

$table-hover-color:           $table-color;
$table-hover-bg-factor:       .075;
$table-hover-bg:              rgba(var(--bs-emphasis-color-rgb), $table-hover-bg-factor);

$table-border-factor:         .2;
$table-border-width:          var(--bs-border-width);
$table-border-color:          var(--bs-border-color);   // cream-300 light / navy-500 dark

$table-striped-order:         odd;
$table-striped-columns-order: even;

$table-group-separator-color: currentcolor;

$table-caption-color:         var(--bs-secondary-color);

$table-bg-scale:              -80%;

Sass loop

The variants come from $table-variants. To add the brand colours, merge them into the map before importing the theme:

$table-variants: (
  "primary":    shift-color($primary, $table-bg-scale),
  "secondary":  shift-color($secondary, $table-bg-scale),
  "success":    shift-color($success, $table-bg-scale),
  "info":       shift-color($info, $table-bg-scale),
  "warning":    shift-color($warning, $table-bg-scale),
  "danger":     shift-color($danger, $table-bg-scale),
  "light":      $light,
  "dark":       $dark,
);