Welcome Getting started Layout styles github-circle-black-transparent Source
Components
Badges
App bars
Bottom app bars Top app bars
Buttons
Common buttons FAB Icon buttons Segmented buttons
Cards Carousel Checkboxes Chips Date pickers Dialogs Forms Icons Lists Menus Navigation Progress indicators Pull to refresh Radios Search Selects
Sheets
Bottom sheets Side sheets
Sliders Snackbars Switches Tables Tabs Text fields Time pickers Tooltips Utilities
home apps Buttons palette Two
Materially
github-circle-black-transparent

Tables

Tables with sorting, pagination, and asynchronous data loading

Table example

Table with static html. Click on headers to change sort
Name Breed Gender Age
LunaDomestic ShorthairFemale11
EliseDomestic LonghairFemale12
PigDomestic ShorthairFemale8
CrackersMaine CoonMale5
ZumaRagdollMale8
<mc-table>
  <table>
    <thead>
      <tr>
        <th>Name</th>
        <th>Breed</th>
        <th>Gender</th>
        <th>Age</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Luna</td>
        <td>Domestic Shorthair</td>
        <td>Female</td>
        <td>11</td>
      </tr>
      <tr>
        <td>Elise</td>
        <td>Domestic Longhair</td>
        <td>Female</td>
        <td>12</td>
      </tr>
      ...
    </tbody>
  </table>

  <!--
    mc-table-pagination is optional
    mc-table-pagination[sizes] - Comma separated list of rows to show per page
    mc-table-pagination[size] - default amount of rows to show per page

    mc-table-pagination[total] - (Set) Used to show page item count info
    mc-table-pagination[total] - (Not set) Page item count will not display and there will be no last page button
  -->
  <mc-table-pagination
    sizes="5,10"
    size="5"
    total="8"
  ></mc-table-pagination>
</mc-table>

<!-- Optional sort attributes -->
<mc-table sort="Name" direction="ascending">
  <table>
    <thead>
      <tr>
        <th>Name</th>
        <!-- you can set an alternate property name or use the text -->
        <th property="breed">Breed</th>
        <th>Gender</th>
        <th>Age</th>
      </tr>
    </thead>
    <tbody>
    ...
    </tbody>
  </table>
</mc-table>

                

Dynamic async table data

You can dynamically manage table data
Name Breed Gender Age
BellaPersianFemale4
CharlieSphynxMale6
ChloeBirmanFemale3
DaisyTurkish AngoraFemale2
JackOriental ShorthairMale7
<mc-table id="tableasync" select sort="name" async>
  <table>
    <thead>
      <tr>
        <th property="name">Name</th>
        <th property="breed">Breed</th>
        <th property="gender">Gender</th>
        <th property="age">Age</th>
      </tr>
    </thead>
    <tbody></tbody>
  </table>
  <mc-table-pagination sizes="5,10" size="5"></mc-table-pagination>
</mc-table>
            
let table = document.querySelector('#tableasync');
table.addEventListener('sort', onPageOrSort);
table.addEventListener('page', onPageOrSort);


function onPageOrSort(event) {
  handleTableData({
    page: event.target.page,
    pageSize: event.target.pageSize,
    sort: event.target.sort,
    direction: event.target.direction
  });
}

async function handleTableData(listFilter = {
  page: 0,
  pageSize: 5,
  sort: 'id',
  direction: 'ascending'
}) {
  // show progress indicator and lock interactions
  table.loading();
  let data = await getData();
  table.rowData = data;
  table.resolveLoading();
}


async function getData() {
  ...
  /*
    [{
      name: 'Zuna',
      breed: 'Ragdoll',
      gender: 'male',
      age: 5
    }]
  */
}
            

Table with selectable rows

Adding a checkbox is option, if you do not add one to the html then the checkboxes will be inserted as the first column
Name Breed Gender Age
LunaDomestic ShorthairFemale11
EliseDomestic LonghairFemale12
PigDomestic ShorthairFemale8
CrackersMaine CoonMale5
ZumaRagdollMale8
<!-- Select will auto insert checkboxes as the first column -->
<mc-table>
  <table select onchange="console.log(this.value)">
    <thead>
      <tr>
        <th>Name</th>
        <th>Breed</th>
        <th>Gender</th>
        <th>Age</th>
      </tr>
    </thead>
    <tbody>
      <tr value="Luna">
        <td>Luna</td>
        <td>Domestic Shorthair</td>
        <td>Female</td>
        <td>11</td>
      </tr>
      <tr value="Elise">
        <td>Elise</td>
        <td>Domestic Longhair</td>
        <td>Female</td>
        <td>12</td>
      </tr>
      ...
    </tbody>
  </table>
  <mc-table-pagination sizes="5,10" size="5"></mc-table-pagination>
</mc-table>


<!-- Place checkboxes on the right -->
<mc-table>
  <table select onchange="console.log(this.value)">
    <thead>
      <tr>
        <th>Name</th>
        <th>Breed</th>
        <th>Gender</th>
        <th>Age</th>
        <th><mc-checkbox></mc-checkbox></th>
      </tr>
    </thead>
    <tbody>
      <tr value="Luna">
        <td>Luna</td>
        <td>Domestic Shorthair</td>
        <td>Female</td>
        <td>11</td>
        <td><mc-checkbox></mc-checkbox></td>
      </tr>
      <tr value="Elise">
        <td>Elise</td>
        <td>Domestic Longhair</td>
        <td>Female</td>
        <td>12</td>
        <td><mc-checkbox></mc-checkbox></td>
      </tr>
      ...
    </tbody>
  </table>
  <mc-table-pagination sizes="5,10" size="5"></mc-table-pagination>
</mc-table>
                
menu home apps Get started