Table
Clean rows with thin lines and an ink rule under the header. Wrap it in .table-wrap for the bordered box that scrolls sideways on small screens.
Basic
A caption sits quietly under the table, and a <tfoot> row gets an ink line and bold text for totals. Use .num to right-align numbers.
| Invoice | Status | Method | Amount |
|---|---|---|---|
| INV-00123 | Paid | Credit card | $250.00 |
| INV-00118 | Pending | PayPal | $150.00 |
| INV-00105 | Unpaid | Bank transfer | $350.00 |
| INV-00092 | Paid | Credit card | $450.00 |
| Total | $1,200.00 | ||
<div class="table-wrap">
<table class="table">
<caption>Your recent invoices.</caption>
<thead>
<tr><th>Invoice</th><th>Status</th><th>Method</th><th class="num">Amount</th></tr>
</thead>
<tbody>
<tr><td>INV-00123</td><td><span class="badge badge-green">Paid</span></td><td>Credit card</td><td class="num">$250.00</td></tr>
<tr><td>INV-00118</td><td><span class="badge badge-yellow">Pending</span></td><td>PayPal</td><td class="num">$150.00</td></tr>
<tr><td>INV-00105</td><td><span class="badge badge-red">Unpaid</span></td><td>Bank transfer</td><td class="num">$350.00</td></tr>
<tr><td>INV-00092</td><td><span class="badge badge-green">Paid</span></td><td>Credit card</td><td class="num">$450.00</td></tr>
</tbody>
<tfoot>
<tr><td colspan="3">Total</td><td class="num">$1,200.00</td></tr>
</tfoot>
</table>
</div>People, actions and pages
A full list: .person cells, .cell-actions with flat icon buttons, a .cell-check column with a select-all box, sortable headers (data-momo-sort), and a .table-foot with a .pager. Click the headers to sort; tick boxes to highlight rows.
| Name | Employee ID | Phone | Join date | Role | Actions | |
|---|---|---|---|---|---|---|
VPVictoria Perezvictoria@momo.test |
LA-0234 | +1 416 555 0142 | 30 Apr 2020 | Web developer | ||
EHEula Hortoneula@momo.test |
LA-0187 | +1 416 555 0199 | 2 Nov 2021 | Web designer | ||
LFLucy Foxlucy@momo.test |
LA-0311 | +1 416 555 0107 | 15 Jun 2019 | Product manager | ||
IHIna Hoganina@momo.test |
LA-0099 | +1 416 555 0163 | 8 Jan 2018 | Web designer |
<div class="table-wrap shadow">
<table class="table table-hover" data-momo-sort id="people">
<thead>
<tr>
<th class="cell-check"><label class="check"><input type="checkbox" data-momo-check-all="#people tbody .cell-check input" aria-label="Select all"></label></th>
<th>Name</th><th>Employee ID</th><th>Phone</th><th>Join date</th><th>Role</th><th data-momo-nosort><span class="visually-hidden">Actions</span></th>
</tr>
</thead>
<tbody>
<tr>
<td class="cell-check"><label class="check"><input type="checkbox" aria-label="Select Victoria Perez"></label></td>
<td><div class="person"><span class="avatar avatar-sm bg-violet">VP</span><span class="person-text"><span class="person-name">Victoria Perez</span><span class="person-sub">victoria@momo.test</span></span></div></td>
<td>LA-0234</td><td class="nowrap">+1 416 555 0142</td><td data-sort="2020-04-30" class="nowrap">30 Apr 2020</td><td>Web developer</td>
<td><div class="cell-actions"><button class="btn btn-icon btn-sm btn-ghost" type="button" aria-label="Edit Victoria"><i class="mi mi-pencil"></i></button><button class="btn btn-icon btn-sm btn-ghost" type="button" aria-label="Delete Victoria"><i class="mi mi-trash-2"></i></button><button class="btn btn-icon btn-sm btn-ghost" type="button" aria-label="View Victoria"><i class="mi mi-eye"></i></button></div></td>
</tr>
<tr>
<td class="cell-check"><label class="check"><input type="checkbox" aria-label="Select Eula Horton"></label></td>
<td><div class="person"><span class="avatar avatar-sm bg-cyan">EH</span><span class="person-text"><span class="person-name">Eula Horton</span><span class="person-sub">eula@momo.test</span></span></div></td>
<td>LA-0187</td><td class="nowrap">+1 416 555 0199</td><td data-sort="2021-11-02" class="nowrap">2 Nov 2021</td><td>Web designer</td>
<td><div class="cell-actions"><button class="btn btn-icon btn-sm btn-ghost" type="button" aria-label="Edit Eula"><i class="mi mi-pencil"></i></button><button class="btn btn-icon btn-sm btn-ghost" type="button" aria-label="Delete Eula"><i class="mi mi-trash-2"></i></button><button class="btn btn-icon btn-sm btn-ghost" type="button" aria-label="View Eula"><i class="mi mi-eye"></i></button></div></td>
</tr>
<tr>
<td class="cell-check"><label class="check"><input type="checkbox" aria-label="Select Lucy Fox"></label></td>
<td><div class="person"><span class="avatar avatar-sm bg-orange">LF</span><span class="person-text"><span class="person-name">Lucy Fox</span><span class="person-sub">lucy@momo.test</span></span></div></td>
<td>LA-0311</td><td class="nowrap">+1 416 555 0107</td><td data-sort="2019-06-15" class="nowrap">15 Jun 2019</td><td>Product manager</td>
<td><div class="cell-actions"><button class="btn btn-icon btn-sm btn-ghost" type="button" aria-label="Edit Lucy"><i class="mi mi-pencil"></i></button><button class="btn btn-icon btn-sm btn-ghost" type="button" aria-label="Delete Lucy"><i class="mi mi-trash-2"></i></button><button class="btn btn-icon btn-sm btn-ghost" type="button" aria-label="View Lucy"><i class="mi mi-eye"></i></button></div></td>
</tr>
<tr>
<td class="cell-check"><label class="check"><input type="checkbox" aria-label="Select Ina Hogan"></label></td>
<td><div class="person"><span class="avatar avatar-sm bg-yellow">IH</span><span class="person-text"><span class="person-name">Ina Hogan</span><span class="person-sub">ina@momo.test</span></span></div></td>
<td>LA-0099</td><td class="nowrap">+1 416 555 0163</td><td data-sort="2018-01-08" class="nowrap">8 Jan 2018</td><td>Web designer</td>
<td><div class="cell-actions"><button class="btn btn-icon btn-sm btn-ghost" type="button" aria-label="Edit Ina"><i class="mi mi-pencil"></i></button><button class="btn btn-icon btn-sm btn-ghost" type="button" aria-label="Delete Ina"><i class="mi mi-trash-2"></i></button><button class="btn btn-icon btn-sm btn-ghost" type="button" aria-label="View Ina"><i class="mi mi-eye"></i></button></div></td>
</tr>
</tbody>
</table>
<div class="table-foot">
<span>4 of 24 people</span>
<nav aria-label="Pages">
<ul class="pager">
<li><a href="#" aria-label="Previous page" aria-disabled="true"><i class="mi mi-chevron-left"></i></a></li>
<li><a href="#" aria-current="page">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><span>…</span></li>
<li><a href="#">6</a></li>
<li><a href="#" aria-label="Next page"><i class="mi mi-chevron-right"></i></a></li>
</ul>
</nav>
</div>
</div>Rows become cards on phones
Add .table-stack and a data-label on each cell: under 640px wide, each row turns into a small card with the labels on the left. No sideways scrolling.
| Payment | Date | Status | Amount |
|---|---|---|---|
Online order | Oct 24, 10:42 | Completed | +$450.00 |
Cloud hosting | Oct 23, 09:15 | Pending | -$120.00 |
Team chat | Oct 22, 16:30 | Completed | -$15.00 |
<div class="table-wrap">
<table class="table table-stack">
<thead><tr><th>Payment</th><th>Date</th><th>Status</th><th class="num">Amount</th></tr></thead>
<tbody>
<tr><td><div class="person"><span class="avatar avatar-sm avatar-square bg-pink"><i class="mi mi-shopping-bag"></i></span><span class="person-name">Online order</span></div></td><td data-label="Date">Oct 24, 10:42</td><td data-label="Status"><span class="badge badge-green">Completed</span></td><td data-label="Amount" class="num">+$450.00</td></tr>
<tr><td><div class="person"><span class="avatar avatar-sm avatar-square bg-cyan"><i class="mi mi-cloud"></i></span><span class="person-name">Cloud hosting</span></div></td><td data-label="Date">Oct 23, 09:15</td><td data-label="Status"><span class="badge badge-yellow">Pending</span></td><td data-label="Amount" class="num">-$120.00</td></tr>
<tr><td><div class="person"><span class="avatar avatar-sm avatar-square bg-yellow"><i class="mi mi-message-square"></i></span><span class="person-name">Team chat</span></div></td><td data-label="Date">Oct 22, 16:30</td><td data-label="Status"><span class="badge badge-green">Completed</span></td><td data-label="Amount" class="num">-$15.00</td></tr>
</tbody>
</table>
</div>Make the window narrow, or open this page on a phone, to see it.
Styles
.table-head-fill tints the header, .table-striped shades every other row, .table-lines draws ink lines everywhere, .table-sm is compact.
| Sprint | Done | Points |
|---|---|---|
| Sprint 40 | 18/20 | 42 |
| Sprint 41 | 15/20 | 36 |
| Sprint 42 | 14/20 | 31 |
| Product | Category | Stock |
|---|---|---|
| Camera | Technology | 140 |
| Sneakers | Clothing | 239 |
| Headphones | Technology | 155 |
| Watches | Smart wear | 38 |
<div class="table-wrap">
<table class="table table-sm table-lines table-head-fill">
<thead><tr><th>Sprint</th><th>Done</th><th class="num">Points</th></tr></thead>
<tbody>
<tr><td>Sprint 40</td><td>18/20</td><td class="num">42</td></tr>
<tr><td>Sprint 41</td><td>15/20</td><td class="num">36</td></tr>
<tr><td>Sprint 42</td><td>14/20</td><td class="num">31</td></tr>
</tbody>
</table>
</div>
<p></p>
<div class="table-wrap">
<table class="table table-striped">
<thead><tr><th>Product</th><th>Category</th><th class="num">Stock</th></tr></thead>
<tbody>
<tr><td>Camera</td><td>Technology</td><td class="num">140</td></tr>
<tr><td>Sneakers</td><td>Clothing</td><td class="num">239</td></tr>
<tr><td>Headphones</td><td>Technology</td><td class="num">155</td></tr>
<tr><td>Watches</td><td>Smart wear</td><td class="num">38</td></tr>
</tbody>
</table>
</div>Striped columns and group lines
.table-striped-columns tints every second column: good for tables you read downwards, like a plan comparison. .table-group-divider on a <tbody> (or one row) draws a thicker line above it, to part groups of rows.
| Plan | Free | Team | Business |
|---|---|---|---|
| Storage | 5 GB | 50 GB | 500 GB |
| Projects | 3 | 25 | No limit |
| Team members | 1 | 10 | No limit |
| Support | Email and chat | Phone |
<div class="table-wrap">
<table class="table table-striped-columns" id="tb-cols">
<thead><tr><th>Plan</th><th>Free</th><th>Team</th><th>Business</th></tr></thead>
<tbody>
<tr><th scope="row">Storage</th><td>5 GB</td><td>50 GB</td><td>500 GB</td></tr>
<tr><th scope="row">Projects</th><td>3</td><td>25</td><td>No limit</td></tr>
</tbody>
<tbody class="table-group-divider">
<tr><th scope="row">Team members</th><td>1</td><td>10</td><td>No limit</td></tr>
<tr><th scope="row">Support</th><td>Email</td><td>Email and chat</td><td>Phone</td></tr>
</tbody>
</table>
</div>Sizes
.table-sm is compact, the default sits in the middle, .table-lg is roomy with larger text.
| Small | Qty |
|---|---|
| Mugs | 12 |
| Totes | 40 |
| Default | Qty |
|---|---|
| Mugs | 12 |
| Totes | 40 |
| Large | Qty |
|---|---|
| Mugs | 12 |
| Totes | 40 |
<div class="grid lg:grid-cols-3 gap-4 items-start">
<div class="table-wrap"><table class="table table-sm"><thead><tr><th>Small</th><th class="num">Qty</th></tr></thead><tbody><tr><td>Mugs</td><td class="num">12</td></tr><tr><td>Totes</td><td class="num">40</td></tr></tbody></table></div>
<div class="table-wrap"><table class="table"><thead><tr><th>Default</th><th class="num">Qty</th></tr></thead><tbody><tr><td>Mugs</td><td class="num">12</td></tr><tr><td>Totes</td><td class="num">40</td></tr></tbody></table></div>
<div class="table-wrap"><table class="table table-lg"><thead><tr><th>Large</th><th class="num">Qty</th></tr></thead><tbody><tr><td>Mugs</td><td class="num">12</td></tr><tr><td>Totes</td><td class="num">40</td></tr></tbody></table></div>
</div>Header colors
.table-head-<color> fills the header with a pop color, .table-head-<color>-soft with a soft tint, .table-head-ink with ink.
| Plan | Seats | Price |
|---|---|---|
| Starter | 3 | $9 |
| Team | 10 | $29 |
| Plan | Seats | Price |
|---|---|---|
| Starter | 3 | $9 |
| Team | 10 | $29 |
| Plan | Seats | Price |
|---|---|---|
| Starter | 3 | $9 |
| Team | 10 | $29 |
<div class="stack gap-4">
<div class="table-wrap"><table class="table table-head-violet"><thead><tr><th>Plan</th><th>Seats</th><th class="num">Price</th></tr></thead><tbody><tr><td>Starter</td><td>3</td><td class="num">$9</td></tr><tr><td>Team</td><td>10</td><td class="num">$29</td></tr></tbody></table></div>
<div class="table-wrap"><table class="table table-head-lime-soft"><thead><tr><th>Plan</th><th>Seats</th><th class="num">Price</th></tr></thead><tbody><tr><td>Starter</td><td>3</td><td class="num">$9</td></tr><tr><td>Team</td><td>10</td><td class="num">$29</td></tr></tbody></table></div>
<div class="table-wrap"><table class="table table-head-ink"><thead><tr><th>Plan</th><th>Seats</th><th class="num">Price</th></tr></thead><tbody><tr><td>Starter</td><td>3</td><td class="num">$9</td></tr><tr><td>Team</td><td>10</td><td class="num">$29</td></tr></tbody></table></div>
</div>Width
A table fills its box. .table-fit shrinks the table and its box to the content. Any width works too: style="--table-width: 32rem" on the table, or a width on the box. .table-fixed makes columns keep the widths you give their headers, and long text is cut with "…".
| Fit | Score |
|---|---|
| Ana | 92 |
| Max | 87 |
| Fixed 20% | 50% | The rest |
|---|---|---|
| Short | A long note that keeps going and going so it gets cut neatly at the edge | Done |
<div class="stack gap-4">
<div class="table-wrap"><table class="table table-sm table-fit"><thead><tr><th>Fit</th><th class="num">Score</th></tr></thead><tbody><tr><td>Ana</td><td class="num">92</td></tr><tr><td>Max</td><td class="num">87</td></tr></tbody></table></div>
<div class="table-wrap"><table class="table table-sm table-fixed"><thead><tr><th style="width: 20%">Fixed 20%</th><th style="width: 50%">50%</th><th>The rest</th></tr></thead><tbody><tr><td>Short</td><td>A long note that keeps going and going so it gets cut neatly at the edge</td><td>Done</td></tr></tbody></table></div>
</div>Flush
.table-flush drops the box and the outer padding, so the table lines up with the text around it: good inside a card.
This week
| Day | Orders |
|---|---|
| Monday | 38 |
| Tuesday | 41 |
| Wednesday | 29 |
<div class="card w-96">
<div class="card-body">
<h3 class="card-title">This week</h3>
<table class="table table-sm table-flush">
<thead><tr><th>Day</th><th class="num">Orders</th></tr></thead>
<tbody><tr><td>Monday</td><td class="num">38</td></tr><tr><td>Tuesday</td><td class="num">41</td></tr><tr><td>Wednesday</td><td class="num">29</td></tr></tbody>
</table>
</div>
</div>Row highlights
.is-highlight on a row marks it in yellow; .row-<color> gives any soft tint. Momo.table.flash(row) blinks a row that just changed (it fades back by itself).
| Order | Status | Total |
|---|---|---|
| #10421 | Shipped | $129.00 |
| #10422 | Needs a look | $58.00 |
| #10423 | Paid | $212.00 |
| #10424 | Card declined | $40.00 |
<div class="table-wrap">
<table class="table" id="tbl-flash">
<thead><tr><th>Order</th><th>Status</th><th class="num">Total</th></tr></thead>
<tbody>
<tr><td>#10421</td><td>Shipped</td><td class="num">$129.00</td></tr>
<tr class="is-highlight"><td>#10422</td><td>Needs a look</td><td class="num">$58.00</td></tr>
<tr class="row-green"><td>#10423</td><td>Paid</td><td class="num">$212.00</td></tr>
<tr class="row-red"><td>#10424</td><td>Card declined</td><td class="num">$40.00</td></tr>
</tbody>
</table>
</div>
<button class="btn btn-sm mt-3" type="button" onclick="Momo.table.flash(document.querySelector('#tbl-flash tbody tr'))"><i class="mi mi-sparkles"></i> Flash the first row</button>Sticky columns
In a wide table that scrolls sideways, .table-sticky-start keeps the first column in place and .table-sticky-end the last one (handy for actions). For another column, put .cell-sticky on its cells and set --sticky-start. Scroll the table below sideways.
| Product | SKU | Color | Size | Supplier | Warehouse | Stock | Price | Actions |
|---|---|---|---|---|---|---|---|---|
| Linen shirt | LS-01 | Sand | M | Atelier Nord | Lisbon | 124 | $49.00 | |
| Canvas tote | CT-07 | Ink | One | Bag Co. | Porto | 312 | $29.00 | |
| Wool beanie | WB-12 | Rust | One | Knit House | Lisbon | 88 | $24.00 |
<div class="table-wrap">
<table class="table table-sm table-sticky-start table-sticky-end table-head-fill" style="--table-width: 70rem">
<thead><tr><th>Product</th><th>SKU</th><th>Color</th><th>Size</th><th>Supplier</th><th>Warehouse</th><th class="num">Stock</th><th class="num">Price</th><th><span class="visually-hidden">Actions</span></th></tr></thead>
<tbody>
<tr><td>Linen shirt</td><td>LS-01</td><td>Sand</td><td>M</td><td>Atelier Nord</td><td>Lisbon</td><td class="num">124</td><td class="num">$49.00</td><td><div class="cell-actions"><button class="btn btn-icon btn-sm btn-ghost" type="button" aria-label="Edit Linen shirt"><i class="mi mi-pencil"></i></button></div></td></tr>
<tr><td>Canvas tote</td><td>CT-07</td><td>Ink</td><td>One</td><td>Bag Co.</td><td>Porto</td><td class="num">312</td><td class="num">$29.00</td><td><div class="cell-actions"><button class="btn btn-icon btn-sm btn-ghost" type="button" aria-label="Edit Canvas tote"><i class="mi mi-pencil"></i></button></div></td></tr>
<tr><td>Wool beanie</td><td>WB-12</td><td>Rust</td><td>One</td><td>Knit House</td><td>Lisbon</td><td class="num">88</td><td class="num">$24.00</td><td><div class="cell-actions"><button class="btn btn-icon btn-sm btn-ghost" type="button" aria-label="Edit Wool beanie"><i class="mi mi-pencil"></i></button></div></td></tr>
</tbody>
</table>
</div>Sticky header
.table-scroll on the wrap gives it a fixed height (--table-height, 24rem) with the header staying on top while you scroll.
Empty
| Name | Role |
|---|---|
| No people yet. | |
<div class="table-wrap">
<table class="table">
<thead><tr><th>Name</th><th>Role</th></tr></thead>
<tbody><tr class="table-empty"><td colspan="2"><i class="mi mi-inbox"></i> No people yet.</td></tr></tbody>
</table>
</div>Sorting
For search, pages, rows that open, tree rows, groups and editing cells, see Data table.
Add data-momo-sort to the table: every header becomes a button (skip one with data-momo-nosort). Numbers, money, percents and dates sort by value. When the text is not the value, set data-sort on the cell (like data-sort="2020-04-30" for "30 Apr 2020").
table.addEventListener('momo:sort', (e) => console.log(e.detail.column, e.detail.direction));
Momo.table.sort(table, 4, 'descending');Accessibility
- Sort buttons tell screen readers the order with
aria-sort. - Icon-only action buttons need an
aria-labelthat names the row ("Edit Victoria"). - Give each row checkbox its own label too.
Variables
| Variable | Default |
|---|---|
--table-pad-y / --table-pad-x | .8rem / 1rem |
--table-line | Ink at 22% (row lines) |
--table-height | 24rem (with .table-scroll) |