Table

Table

Tables style native <table> markup. Wrap one in table-wrap so wide tables scroll horizontally instead of breaking the layout.

Class names

Class nameTypeDescription
tableComponentBase table with borders and a shaded header
table-wrapPartScroll container; add role="region", an aria-label and tabindex="0"
table-zebraStyleShade every second body row
table-hoverStyleHighlight the body row under the pointer
table-smSizeCompact cell padding

Table

NameRoleStatus
AdaEngineerActive
GraceAdmiralAway
LinusMaintainerActive
<table class="table">
  <thead>
    <tr><th scope="col">Name</th><th scope="col">Role</th><th scope="col">Status</th></tr>
  </thead>
  <tbody>
    <tr><td>Ada</td><td>Engineer</td><td>Active</td></tr>
    <tr><td>Grace</td><td>Admiral</td><td>Away</td></tr>
    <tr><td>Linus</td><td>Maintainer</td><td>Active</td></tr>
  </tbody>
</table>

Zebra

NameRoleStatus
AdaEngineerActive
GraceAdmiralAway
LinusMaintainerActive
MargaretLeadActive
<table class="table table-zebra">
  <thead>
    <tr><th scope="col">Name</th><th scope="col">Role</th><th scope="col">Status</th></tr>
  </thead>
  <tbody>
    <tr><td>Ada</td><td>Engineer</td><td>Active</td></tr>
    <tr><td>Grace</td><td>Admiral</td><td>Away</td></tr>
    <tr><td>Linus</td><td>Maintainer</td><td>Active</td></tr>
    <tr><td>Margaret</td><td>Lead</td><td>Active</td></tr>
  </tbody>
</table>

Hover

NameRoleStatus
AdaEngineerActive
GraceAdmiralAway
LinusMaintainerActive
<table class="table table-hover">
  <thead>
    <tr><th scope="col">Name</th><th scope="col">Role</th><th scope="col">Status</th></tr>
  </thead>
  <tbody>
    <tr><td>Ada</td><td>Engineer</td><td>Active</td></tr>
    <tr><td>Grace</td><td>Admiral</td><td>Away</td></tr>
    <tr><td>Linus</td><td>Maintainer</td><td>Active</td></tr>
  </tbody>
</table>

Compact

Only a compact size exists; the default has no class.

NameRoleStatus
AdaEngineerActive
GraceAdmiralAway
<table class="table table-sm">
  <thead>
    <tr><th scope="col">Name</th><th scope="col">Role</th><th scope="col">Status</th></tr>
  </thead>
  <tbody>
    <tr><td>Ada</td><td>Engineer</td><td>Active</td></tr>
    <tr><td>Grace</td><td>Admiral</td><td>Away</td></tr>
  </tbody>
</table>

With a caption

Team members and their current status
NameRoleStatus
AdaEngineerActive
GraceAdmiralAway
<table class="table table-zebra">
  <caption>Team members and their current status</caption>
  <thead>
    <tr><th scope="col">Name</th><th scope="col">Role</th><th scope="col">Status</th></tr>
  </thead>
  <tbody>
    <tr><td>Ada</td><td>Engineer</td><td>Active</td></tr>
    <tr><td>Grace</td><td>Admiral</td><td>Away</td></tr>
  </tbody>
</table>

Scrollable wrapper

The wrapper is focusable so keyboard users can scroll it; label it for screen readers.

NameEmailRoleLast seenPlan
Ada Lovelaceada@example.comEngineerTodayPro
Grace Hoppergrace@example.comAdmiralYesterdayTeam
Linus Torvaldslinus@example.comMaintainerLast weekFree
<div class="table-wrap" role="region" aria-label="Users" tabindex="0">
  <table class="table table-zebra table-hover">
    <thead>
      <tr><th scope="col">Name</th><th scope="col">Email</th><th scope="col">Role</th><th scope="col">Last seen</th><th scope="col">Plan</th></tr>
    </thead>
    <tbody>
      <tr><td>Ada Lovelace</td><td>ada@example.com</td><td>Engineer</td><td>Today</td><td>Pro</td></tr>
      <tr><td>Grace Hopper</td><td>grace@example.com</td><td>Admiral</td><td>Yesterday</td><td>Team</td></tr>
      <tr><td>Linus Torvalds</td><td>linus@example.com</td><td>Maintainer</td><td>Last week</td><td>Free</td></tr>
    </tbody>
  </table>
</div>