Skip to content
v0.9.1
Components

Data table

The plain table, with superpowers: search, pages, sorting, rows that open, tree rows, groups that fold, and cells you can edit in place. Each is one attribute or class, and they all work together.

Search, pages and sorting

Add data-momo-datatable to the table. It gets a search box above, and under it the count, a "rows per page" picker and page buttons. Headers sort. data-page-size sets the rows per page (10), data-page-sizes the choices ("" hides the picker), data-search="false" hides the search, and data-noun names the rows in the count.

NameRoleCityJoined
Ana KimDesignerToronto2019
Max RuizSupportMadrid2021
Lea NovakEngineerLjubljana2018
Sam OkaforSalesLagos2022
Iris TanEngineerSingapore2020
Omar HaddadDesignerAmman2023
Nora BergProductOslo2017
Luis MoraEngineerLima2021
Yuki SatoSupportOsaka2020
Chloé MartinMarketingLyon2022
Dara SinghSalesDelhi2019
Ben ColeEngineerDublin2024
Mia RossiProductMilan2018
<div class="table-wrap">
  <table class="table table-hover" data-momo-datatable data-page-size="5" data-page-sizes="5,10,20" data-noun="people" aria-label="Team">
    <thead><tr><th>Name</th><th>Role</th><th>City</th><th class="num">Joined</th></tr></thead>
    <tbody>
      <tr><td>Ana Kim</td><td>Designer</td><td>Toronto</td><td class="num">2019</td></tr>
      <tr><td>Max Ruiz</td><td>Support</td><td>Madrid</td><td class="num">2021</td></tr>
      <tr><td>Lea Novak</td><td>Engineer</td><td>Ljubljana</td><td class="num">2018</td></tr>
      <tr><td>Sam Okafor</td><td>Sales</td><td>Lagos</td><td class="num">2022</td></tr>
      <tr><td>Iris Tan</td><td>Engineer</td><td>Singapore</td><td class="num">2020</td></tr>
      <tr><td>Omar Haddad</td><td>Designer</td><td>Amman</td><td class="num">2023</td></tr>
      <tr><td>Nora Berg</td><td>Product</td><td>Oslo</td><td class="num">2017</td></tr>
      <tr><td>Luis Mora</td><td>Engineer</td><td>Lima</td><td class="num">2021</td></tr>
      <tr><td>Yuki Sato</td><td>Support</td><td>Osaka</td><td class="num">2020</td></tr>
      <tr><td>Chloé Martin</td><td>Marketing</td><td>Lyon</td><td class="num">2022</td></tr>
      <tr><td>Dara Singh</td><td>Sales</td><td>Delhi</td><td class="num">2019</td></tr>
      <tr><td>Ben Cole</td><td>Engineer</td><td>Dublin</td><td class="num">2024</td></tr>
      <tr><td>Mia Rossi</td><td>Product</td><td>Milan</td><td class="num">2018</td></tr>
    </tbody>
  </table>
</div>
table.addEventListener('momo:page', (e) => console.log(e.detail.page, e.detail.pages, e.detail.total));
Momo.table.page(table, 2);
Momo.table.search(table, 'engineer');

Rows that open

Put a <button class="row-toggle" data-momo-row-toggle> in a row and a tr.row-detail (hidden) right under it: the button opens it. Anything fits inside, even another table. Sorting and pages keep the detail with its row.

OrderCustomerTotal
#10421Ana Kim$129.00
#10422Max Ruiz$58.00
#10423Lea Novak$212.00
<div class="table-wrap">
  <table class="table" data-momo-sort>
    <thead><tr><th>Order</th><th>Customer</th><th class="num">Total</th></tr></thead>
    <tbody>
      <tr><td><button class="row-toggle" type="button" data-momo-row-toggle aria-label="Show items of #10421"></button>#10421</td><td>Ana Kim</td><td class="num">$129.00</td></tr>
      <tr class="row-detail" hidden><td colspan="3"><div class="row-detail-body">
        <table class="table table-sm table-flush m-0"><thead><tr><th>Item</th><th class="num">Qty</th><th class="num">Price</th></tr></thead><tbody><tr><td>Momo Mug</td><td class="num">2</td><td class="num">$48.00</td></tr><tr><td>Canvas tote</td><td class="num">1</td><td class="num">$29.00</td></tr><tr><td>Sticker pack</td><td class="num">4</td><td class="num">$52.00</td></tr></tbody></table>
      </div></td></tr>
      <tr><td><button class="row-toggle" type="button" data-momo-row-toggle aria-label="Show items of #10422"></button>#10422</td><td>Max Ruiz</td><td class="num">$58.00</td></tr>
      <tr class="row-detail" hidden><td colspan="3"><div class="row-detail-body"><p class="m-0"><b>Ships to</b> Calle Mayor 12, Madrid. <b>Note:</b> leave at the door.</p></div></td></tr>
      <tr><td><button class="row-toggle" type="button" data-momo-row-toggle aria-label="Show items of #10423"></button>#10423</td><td>Lea Novak</td><td class="num">$212.00</td></tr>
      <tr class="row-detail" hidden><td colspan="3"><div class="row-detail-body"><p class="m-0">Gift wrapped, with a card.</p></div></td></tr>
    </tbody>
  </table>
</div>

Tree rows

Give rows data-level="1", "2", "3": the first cell indents, and a row with deeper rows under it gets a fold button. Folding hides everything under it; a folded row inside stays folded when you open its parent again.

FolderOwnerSize
DesignAna2.4 GB
BrandAna820 MB
logo.svgAna24 KB
colors.pdfAna1.2 MB
WebsiteIris1.6 GB
FinanceNora340 MB
2026 budget.xlsxNora2 MB
Readme.txtMax4 KB
<div class="table-wrap">
  <table class="table" id="tbl-tree">
    <thead><tr><th>Folder</th><th>Owner</th><th class="num">Size</th></tr></thead>
    <tbody>
      <tr data-level="1"><td>Design</td><td>Ana</td><td class="num">2.4 GB</td></tr>
      <tr data-level="2"><td>Brand</td><td>Ana</td><td class="num">820 MB</td></tr>
      <tr data-level="3"><td>logo.svg</td><td>Ana</td><td class="num">24 KB</td></tr>
      <tr data-level="3"><td>colors.pdf</td><td>Ana</td><td class="num">1.2 MB</td></tr>
      <tr data-level="2"><td>Website</td><td>Iris</td><td class="num">1.6 GB</td></tr>
      <tr data-level="1"><td>Finance</td><td>Nora</td><td class="num">340 MB</td></tr>
      <tr data-level="2"><td>2026 budget.xlsx</td><td>Nora</td><td class="num">2 MB</td></tr>
      <tr data-level="1"><td>Readme.txt</td><td>Max</td><td class="num">4 KB</td></tr>
    </tbody>
  </table>
</div>

Groups

A tr.row-group with one cell starts a group: click it to fold the rows under it. A <span class="badge-count" data-momo-count> inside counts the rows by itself. Sorting sorts inside each group.

ProductStockPrice
Kitchen
Momo Mug4$24.00
Plate set31$58.00
Tea towel120$12.00
Bags
Canvas tote312$29.00
Backpack18$89.00
<div class="table-wrap">
  <table class="table" data-momo-sort>
    <thead><tr><th>Product</th><th class="num">Stock</th><th class="num">Price</th></tr></thead>
    <tbody>
      <tr class="row-group"><th colspan="3" scope="colgroup">Kitchen <span class="badge-count" data-momo-count></span></th></tr>
      <tr><td>Momo Mug</td><td class="num">4</td><td class="num">$24.00</td></tr>
      <tr><td>Plate set</td><td class="num">31</td><td class="num">$58.00</td></tr>
      <tr><td>Tea towel</td><td class="num">120</td><td class="num">$12.00</td></tr>
      <tr class="row-group"><th colspan="3" scope="colgroup">Bags <span class="badge-count" data-momo-count></span></th></tr>
      <tr><td>Canvas tote</td><td class="num">312</td><td class="num">$29.00</td></tr>
      <tr><td>Backpack</td><td class="num">18</td><td class="num">$89.00</td></tr>
    </tbody>
  </table>
</div>

Colored groups

Any .bg-* class on the group row colors it: a pop color like .bg-violet (the text turns ink to stay readable) or a soft tint like .bg-cyan-soft. The same classes work on any row or single cell, and a colored row keeps its color when you hover it, in striped tables and in sticky columns.

TaskOwnerDue
To do
Write the product briefAnaDec 4
Order packagingMaxDec 6
In progress
New checkoutLeaDec 2
Done
Holiday bannerIrisNov 28
Fix card paymentsSamNov 27
<div class="table-wrap">
  <table class="table table-hover" data-momo-sort>
    <thead><tr><th>Task</th><th>Owner</th><th class="num">Due</th></tr></thead>
    <tbody>
      <tr class="row-group bg-violet"><th colspan="3" scope="colgroup">To do <span class="badge-count" data-momo-count></span></th></tr>
      <tr><td>Write the product brief</td><td>Ana</td><td class="num">Dec 4</td></tr>
      <tr><td>Order packaging</td><td>Max</td><td class="num">Dec 6</td></tr>
      <tr class="row-group bg-yellow"><th colspan="3" scope="colgroup">In progress <span class="badge-count" data-momo-count></span></th></tr>
      <tr><td>New checkout</td><td>Lea</td><td class="num">Dec 2</td></tr>
      <tr class="row-group bg-green-soft"><th colspan="3" scope="colgroup">Done <span class="badge-count" data-momo-count></span></th></tr>
      <tr><td>Holiday banner</td><td>Iris</td><td class="num">Nov 28</td></tr>
      <tr class="bg-red-soft"><td>Fix card payments</td><td>Sam</td><td class="num">Nov 27</td></tr>
    </tbody>
  </table>
</div>
<tr class="row-group bg-violet"><th colspan="3">To do</th></tr>     <!-- a pop color -->
<tr class="row-group bg-green-soft"><th colspan="3">Done</th></tr>  <!-- a soft tint -->
<tr class="bg-red-soft">…</tr>                                        <!-- any row -->
<td class="bg-yellow-soft">…</td>                                     <!-- one cell -->

Edit a cell

Add data-momo-edit to a header to make its column editable (or to one cell). Click a cell, or press Enter or F2 on it, and an input fills the whole cell. Enter or clicking away saves, Esc puts it back, Tab saves and moves to the next cell. data-momo-edit="number" gives a number field, "select" a list from data-options. A saved row blinks.

ProductStatusStockPrice
Momo MugLive4$24.00
Canvas toteLive312$29.00
Sticker packDraft0$13.00

Click a cell to edit it.

<div class="table-wrap">
  <table class="table" id="tbl-edit" data-momo-sort>
    <thead><tr><th data-momo-edit>Product</th><th data-momo-edit="select" data-options="Draft, Live, Sold out">Status</th><th class="num" data-momo-edit="number">Stock</th><th class="num" data-momo-edit="number">Price</th></tr></thead>
    <tbody>
      <tr><td>Momo Mug</td><td>Live</td><td class="num">4</td><td class="num" data-format="money">$24.00</td></tr>
      <tr><td>Canvas tote</td><td>Live</td><td class="num">312</td><td class="num" data-format="money">$29.00</td></tr>
      <tr><td>Sticker pack</td><td>Draft</td><td class="num">0</td><td class="num" data-format="money">$13.00</td></tr>
    </tbody>
  </table>
</div>
<p class="text-sm text-muted mt-2" id="tbl-edit-log">Click a cell to edit it.</p>
<script>
  document.getElementById('tbl-edit').addEventListener('momo:edit', function (e) {
    var log = document.getElementById('tbl-edit-log');
    setTimeout(function () { log.textContent = e.defaultPrevented ? 'Refused: it stays "' + e.detail.old + '".' : 'Saved: "' + e.detail.old + '" became "' + e.detail.value + '".'; });
  });
</script>

The field is flat by default. Add .table-edit-shadow to the table for a hard shadow on it (pages with momo-shadows on <html> get it too).

ProductStock
Momo Mug4
Canvas tote312
<div class="table-wrap">
  <table class="table table-edit-shadow" id="tbl-edit-shadow">
    <thead><tr><th data-momo-edit>Product</th><th class="num" data-momo-edit="number">Stock</th></tr></thead>
    <tbody>
      <tr><td>Momo Mug</td><td class="num">4</td></tr>
      <tr><td>Canvas tote</td><td class="num">312</td></tr>
    </tbody>
  </table>
</div>

On colored tables

Editing works the same on colored headers, colored rows and stripes: the field is always a clean surface with ink text, so it reads on any color.

TaskStatusHours
Write the briefDoing3
Order packagingTo do1
Fix card paymentsDoing5
Holiday bannerDone2
Reply to leadsTo do1
<div class="table-wrap">
  <table class="table table-head-violet table-striped" id="tbl-edit-color">
    <thead><tr><th data-momo-edit>Task</th><th data-momo-edit="select" data-options="To do, Doing, Done">Status</th><th class="num" data-momo-edit="number">Hours</th></tr></thead>
    <tbody>
      <tr><td>Write the brief</td><td>Doing</td><td class="num">3</td></tr>
      <tr><td>Order packaging</td><td>To do</td><td class="num">1</td></tr>
      <tr class="bg-yellow"><td>Fix card payments</td><td>Doing</td><td class="num">5</td></tr>
      <tr class="bg-green-soft"><td>Holiday banner</td><td>Done</td><td class="num">2</td></tr>
      <tr><td>Reply to leads</td><td>To do</td><td class="num">1</td></tr>
    </tbody>
  </table>
</div>
table.addEventListener('momo:edit', (e) => {
  const { cell, row, column, value, old } = e.detail;
  if (!save(row.dataset.id, column, value)) e.preventDefault();   // refuse: the old value stays
});

Notes

Start

OverviewStart Getting startedStart CustomizeStart

Guides

AccessibilityGuides BreakpointsGuides ChangelogGuides Customize componentsGuides JavaScriptGuides MotionGuides OptimizeGuides PhonesGuides RebootGuides Right-to-left (RTL)Guides Stacking orderGuides Using Momo with AIGuides

Foundations

ColorsFoundations TypographyFoundations ProseFoundations Images & figuresFoundations CodeFoundations Lines & shadowsFoundations Dark modeFoundations

Forms

Checkbox & switchForms ComboboxForms Date pickerForms Date rangeForms Fields & labelsForms File uploadForms Floating labelsForms Number stepperForms PasswordForms PIN codeForms RatingForms SelectForms SliderForms Tag inputForms Time pickerForms ValidationForms

Components

AccordionComponents Alert & bannerComponents AvatarComponents BadgeComponents BreadcrumbComponents ButtonComponents Button groupComponents CalendarComponents CardComponents CarouselComponents ChartsComponents ChipsComponents CollapseComponents Command paletteComponents CommentsComponents Confirm dialogsComponents Cookie bannerComponents Data tableComponents Description listComponents Dialog & toastComponents DividerComponents DrawerComponents Dropdown menuComponents Empty stateComponents File managerComponents Filter & sortComponents Gallery & lightboxComponents Inbox & chatComponents Infinite scrollComponents KanbanComponents Keyboard shortcutsComponents List groupComponents MarqueeComponents Media objectComponents Nav overflowComponents Notification centerComponents PaginationComponents ProgressComponents Pull to refreshComponents SkeletonComponents SortableComponents SpinnerComponents Split viewComponents Stat cardComponents Steps & wizardComponents Swipe actionsComponents TableComponents TabsComponents TimelineComponents TogglerComponents Tooltip & popoverComponents TourComponents Tree viewComponents VideoComponents WhiteboardComponents

Layout

Announcement barLayout App shellLayout Back to topLayout Container & sectionLayout ExamplesLayout FooterLayout HeroLayout JumbotronLayout Mega menuLayout NavbarLayout Site sidebarLayout

Sections

Bento gridSections Blog cardsSections Call to actionSections Contact & newsletterSections FAQSections FeaturesSections Logo cloudSections PricingSections TeamSections TestimonialsSections

Utilities

OverviewUtilities State variantsUtilities Display & flexUtilities Grid & gapUtilities SpacingUtilities SizingUtilities TextUtilities Links & color strengthUtilities Position & overflowUtilities BackgroundsUtilities Borders & effectsUtilities Transforms & filtersUtilities InteractionsUtilities

Helpers

Fixed, sticky & frostedHelpers Hover & focusHelpers Hover revealHelpers Icon linkHelpers PrintHelpers Relative timeHelpers Screen reader textHelpers Scroll inHelpers ScrollspyHelpers Share buttonHelpers Skip linkHelpers StacksHelpers Stretched linkHelpers Theme toggleHelpers Truncated textHelpers

Page patterns

404 pagePage patterns Coming soonPage patterns Login & registerPage patterns SettingsPage patterns ProfilePage patterns CRM contactsPage patterns ProjectsPage patterns File manager pagePage patterns Billing & plansPage patterns Help centerPage patterns Mobile app screensPage patterns
↑ ↓ moveEnter openEsc close