Bootstrap Table
Bootstrap tables present data in a system of columns and rows. Used for various purposes like time pickers and calendars.
Responsive tables with buttons, checkboxes, graphics and variety of data segregation methods are all at your disposal.
Note: Due to the widespread use of tables across third-party widgets like calendars and date
pickers, we’ve designed our tables to be opt-in. Just add the base class .table
to any <table>
.
Basic examples
Using the most basic table markup, here’s how .table
-based tables look in Bootstrap. All table styles are inherited in Bootstrap 4,
meaning any nested tables will be styled in the same manner as the parent.
# | First Name | Last Name | Username |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird |
<table class="table">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</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>Larry</td>
<td>the Bird</td>
<td>@twitter</td>
</tr>
</tbody>
</table>
Table head options
To change a background-color of <thead>
(or any other element) use our color classes. If you are going to use a dark background you should also consider white text (to provide a proper contrast) by adding .text-white
class.
# | First Name | Last Name | Username |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird |
# | First Name | Last Name | Username |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird |
<!--Table-->
<table class="table">
<!--Table head-->
<thead class="blue-grey lighten-4">
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<!--Table head-->
<!--Table body-->
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</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>Larry</td>
<td>the Bird</td>
<td>@twitter</td>
</tr>
</tbody>
<!--Table body-->
</table>
<!--Table-->
<!--Table-->
<table class="table">
<!--Table head-->
<thead class="mdb-color darken-3">
<tr class="text-white">
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<!--Table head-->
<!--Table body-->
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</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>Larry</td>
<td>the Bird</td>
<td>@twitter</td>
</tr>
</tbody>
<!--Table body-->
</table>
<!--Table-->
Striped rows
Use .table-striped
to add zebra-striping to any table row within the <tbody>
.
# | First Name | Last Name | Username |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird |
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</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>Larry</td>
<td>the Bird</td>
<td>@twitter</td>
</tr>
</tbody>
</table>
Bordered table
Add .table-bordered
for borders on all sides of the table and cells.
# | First Name | Last Name | Username |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Mark | Otto | @TwBootstrap |
3 | Jacob | Thornton | @fat |
4 | Larry the Bird |
<table class="table table-bordered">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Mark</td>
<td>Otto</td>
<td>@TwBootstrap</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Jacob</td>
<td>Thornton</td>
<td>@fat</td>
</tr>
<tr>
<th scope="row">4</th>
<td colspan="2">Larry the Bird</td>
<td>@twitter</td>
</tr>
</tbody>
</table>
Hoverable rows
Add .table-hover
to enable a hover state on table rows within a <tbody>
.
# | First Name | Last Name | Username |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
<table class="table table-hover">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</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>
Small table
Add .table-sm
to make tables more compact by cutting cell padding in half.
# | First Name | Last Name | Username |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
<table class="table table-sm">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</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>
Contextual classes
Use contextual classes to color table rows or individual cells.
Class | Description |
---|---|
.table-active |
Applies the hover color to a particular row or cell |
.table-success |
Indicates a successful or positive action |
.table-info |
Indicates a neutral informative change or action |
.table-warning |
Indicates a warning that might need attention |
.table-danger |
Indicates a dangerous or potentially negative action |
# | Column heading | Column heading | Column heading |
---|---|---|---|
1 | Column content | Column content | Column content |
2 | Column content | Column content | Column content |
3 | Column content | Column content | Column content |
4 | Column content | Column content | Column content |
5 | Column content | Column content | Column content |
6 | Column content | Column content | Column content |
7 | Column content | Column content | Column content |
8 | Column content | Column content | Column content |
9 | Column content | Column content | Column content |
<!-- On rows -->
<tr class="table-active">...</tr>
<tr class="table-success">...</tr>
<tr class="table-warning">...</tr>
<tr class="table-danger">...</tr>
<tr class="table-info">...</tr>
<!-- On cells (`td` or `th`) -->
<tr>
<td class="table-active">...</td>
<td class="table-success">...</td>
<td class="table-warning">...</td>
<td class="table-danger">...</td>
<td class="table-info">...</td>
</tr>
Conveying meaning to assistive technologies
Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the
.sr-only
class.
Responsive tables
Create responsive tables by wrapping any .table
in .table-responsive
to make them scroll
horizontally on small devices (under 768px). When viewing on anything larger than 768px wide, you will not see
any difference in these tables.
Vertical clipping/truncation
Responsive tables make use of
overflow-y: hidden
, which clips off any content that goes beyond the bottom or top edges of the table. In particular, this can clip off dropdown menus and other third-party widgets.
# | Table heading | Table heading | Table heading | Table heading | Table heading | Table heading |
---|---|---|---|---|---|---|
1 | Table cell | Table cell | Table cell | Table cell | Table cell | Table cell |
2 | Table cell | Table cell | Table cell | Table cell | Table cell | Table cell |
3 | Table cell | Table cell | Table cell | Table cell | Table cell | Table cell |
# | Table heading | Table heading | Table heading | Table heading | Table heading | Table heading |
---|---|---|---|---|---|---|
1 | Table cell | Table cell | Table cell | Table cell | Table cell | Table cell |
2 | Table cell | Table cell | Table cell | Table cell | Table cell | Table cell |
3 | Table cell | Table cell | Table cell | Table cell | Table cell | Table cell |
<table class="table table-responsive">
...
</table>
Table with sorting
Name | Position | Office | Age | Start date | Salary |
---|---|---|---|---|---|
Name | Position | Office | Age | Start date | Salary |
Tiger Nixon | System Architect | Edinburgh | 61 | 2011/04/25 | $320,800 |
Garrett Winters | Accountant | Tokyo | 63 | 2011/07/25 | $170,750 |
Ashton Cox | Junior Technical Author | San Francisco | 66 | 2009/01/12 | $86,000 |
Cedric Kelly | Senior Javascript Developer | Edinburgh | 22 | 2012/03/29 | $433,060 |
Airi Satou | Accountant | Tokyo | 33 | 2008/11/28 | $162,700 |
Brielle Williamson | Integration Specialist | New York | 61 | 2012/12/02 | $372,000 |
Herrod Chandler | Sales Assistant | San Francisco | 59 | 2012/08/06 | $137,500 |
Rhona Davidson | Integration Specialist | Tokyo | 55 | 2010/10/14 | $327,900 |
Colleen Hurst | Javascript Developer | San Francisco | 39 | 2009/09/15 | $205,500 |
Sonya Frost | Software Engineer | Edinburgh | 23 | 2008/12/13 | $103,600 |
Jena Gaines | Office Manager | London | 30 | 2008/12/19 | $90,560 |
Quinn Flynn | Support Lead | Edinburgh | 22 | 2013/03/03 | $342,000 |
Charde Marshall | Regional Director | San Francisco | 36 | 2008/10/16 | $470,600 |
Haley Kennedy | Senior Marketing Designer | London | 43 | 2012/12/18 | $313,500 |
Tatyana Fitzpatrick | Regional Director | London | 19 | 2010/03/17 | $385,750 |
Michael Silva | Marketing Designer | London | 66 | 2012/11/27 | $198,500 |
Paul Byrd | Chief Financial Officer (CFO) | New York | 64 | 2010/06/09 | $725,000 |
Gloria Little | Systems Administrator | New York | 59 | 2009/04/10 | $237,500 |
Bradley Greer | Software Engineer | London | 41 | 2012/10/13 | $132,000 |
Dai Rios | Personnel Lead | Edinburgh | 35 | 2012/09/26 | $217,500 |
Jenette Caldwell | Development Lead | New York | 30 | 2011/09/03 | $345,000 |
Yuri Berry | Chief Marketing Officer (CMO) | New York | 40 | 2009/06/25 | $675,000 |
Caesar Vance | Pre-Sales Support | New York | 21 | 2011/12/12 | $106,450 |
Doris Wilder | Sales Assistant | Sidney | 23 | 2010/09/20 | $85,600 |
Angelica Ramos | Chief Executive Officer (CEO) | London | 47 | 2009/10/09 | $1,200,000 |
Gavin Joyce | Developer | Edinburgh | 42 | 2010/12/22 | $92,575 |
Jennifer Chang | Regional Director | Singapore | 28 | 2010/11/14 | $357,650 |
Brenden Wagner | Software Engineer | San Francisco | 28 | 2011/06/07 | $206,850 |
Fiona Green | Chief Operating Officer (COO) | San Francisco | 48 | 2010/03/11 | $850,000 |
Shou Itou | Regional Marketing | Tokyo | 20 | 2011/08/14 | $163,000 |
Michelle House | Integration Specialist | Sidney | 37 | 2011/06/02 | $95,400 |
Suki Burks | Developer | London | 53 | 2009/10/22 | $114,500 |
Prescott Bartlett | Technical Author | London | 27 | 2011/05/07 | $145,000 |
Gavin Cortez | Team Leader | San Francisco | 22 | 2008/10/26 | $235,500 |
Martena Mccray | Post-Sales support | Edinburgh | 46 | 2011/03/09 | $324,050 |
Unity Butler | Marketing Designer | San Francisco | 47 | 2009/12/09 | $85,675 |
Howard Hatfield | Office Manager | San Francisco | 51 | 2008/12/16 | $164,500 |
Hope Fuentes | Secretary | San Francisco | 41 | 2010/02/12 | $109,850 |
Vivian Harrell | Financial Controller | San Francisco | 62 | 2009/02/14 | $452,500 |
Timothy Mooney | Office Manager | London | 37 | 2008/12/11 | $136,200 |
Jackson Bradshaw | Director | New York | 65 | 2008/09/26 | $645,750 |
Olivia Liang | Support Engineer | Singapore | 64 | 2011/02/03 | $234,500 |
Bruno Nash | Software Engineer | London | 38 | 2011/05/03 | $163,500 |
Sakura Yamamoto | Support Engineer | Tokyo | 37 | 2009/08/19 | $139,575 |
Thor Walton | Developer | New York | 61 | 2013/08/11 | $98,540 |
Finn Camacho | Support Engineer | San Francisco | 47 | 2009/07/07 | $87,500 |
Serge Baldwin | Data Coordinator | Singapore | 64 | 2012/04/09 | $138,575 |
Zenaida Frank | Software Engineer | New York | 63 | 2010/01/04 | $125,250 |
Zorita Serrano | Software Engineer | San Francisco | 56 | 2012/06/01 | $115,000 |
Jennifer Acosta | Junior Javascript Developer | Edinburgh | 43 | 2013/02/01 | $75,650 |
Cara Stevens | Sales Assistant | New York | 46 | 2011/12/06 | $145,600 |
Hermione Butler | Regional Director | London | 47 | 2011/03/21 | $356,250 |
Lael Greer | Systems Administrator | London | 21 | 2009/02/27 | $103,500 |
Jonas Alexander | Developer | San Francisco | 30 | 2010/07/14 | $86,500 |
Shad Decker | Regional Director | Edinburgh | 51 | 2008/11/13 | $183,000 |
Michael Bruce | Javascript Developer | Singapore | 29 | 2011/06/27 | $183,000 |
Donna Snider | Customer Support | New York | 27 | 2011/01/25 | $112,000 |
table.dataTable thead .sorting:before, table.dataTable thead .sorting:after, table.dataTable thead .sorting_asc:before, table.dataTable thead .sorting_asc:after, table.dataTable thead .sorting_desc:before, table.dataTable thead .sorting_desc:after {
padding: 5px;
}
.dataTables_wrapper .mdb-select {
border: none;
float: left;
}
.dataTables_wrapper .mdb-select.form-control {
padding-top: 0;
margin-top: -1rem;
margin-left: 0.7rem;
margin-right: 0.7rem;
width: 100px;
}
.dataTables_length label {
float: left;
}
table.dataTable {
margin-bottom: 3rem!important;
}
div.dataTables_wrapper div.dataTables_info {
padding-top: 0;
}
// Within <head></head> tags
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/dataTables.bootstrap4.min.css"/>
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.16/js/dataTables.bootstrap4.min.js"></script>
$(document).ready(function() {
$('#example').DataTable();
$('.dataTables_wrapper').find('label').each(function() {
$(this).parent().append($(this).children());
});
$('select').addClass('mdb-select');
$('.mdb-select').material_select();
});
<table id="example" class="table table-striped table-bordered table-responsive-md" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011/07/25</td>
<td>$170,750</td>
</tr>
<tr>
<td>Ashton Cox</td>
<td>Junior Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2009/01/12</td>
<td>$86,000</td>
</tr>
<tr>
<td>Cedric Kelly</td>
<td>Senior Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td>
<td>2012/03/29</td>
<td>$433,060</td>
</tr>
<tr>
<td>Airi Satou</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>33</td>
<td>2008/11/28</td>
<td>$162,700</td>
</tr>
<tr>
<td>Brielle Williamson</td>
<td>Integration Specialist</td>
<td>New York</td>
<td>61</td>
<td>2012/12/02</td>
<td>$372,000</td>
</tr>
<tr>
<td>Herrod Chandler</td>
<td>Sales Assistant</td>
<td>San Francisco</td>
<td>59</td>
<td>2012/08/06</td>
<td>$137,500</td>
</tr>
<tr>
<td>Rhona Davidson</td>
<td>Integration Specialist</td>
<td>Tokyo</td>
<td>55</td>
<td>2010/10/14</td>
<td>$327,900</td>
</tr>
<tr>
<td>Colleen Hurst</td>
<td>Javascript Developer</td>
<td>San Francisco</td>
<td>39</td>
<td>2009/09/15</td>
<td>$205,500</td>
</tr>
<tr>
<td>Sonya Frost</td>
<td>Software Engineer</td>
<td>Edinburgh</td>
<td>23</td>
<td>2008/12/13</td>
<td>$103,600</td>
</tr>
<tr>
<td>Jena Gaines</td>
<td>Office Manager</td>
<td>London</td>
<td>30</td>
<td>2008/12/19</td>
<td>$90,560</td>
</tr>
<tr>
<td>Quinn Flynn</td>
<td>Support Lead</td>
<td>Edinburgh</td>
<td>22</td>
<td>2013/03/03</td>
<td>$342,000</td>
</tr>
<tr>
<td>Charde Marshall</td>
<td>Regional Director</td>
<td>San Francisco</td>
<td>36</td>
<td>2008/10/16</td>
<td>$470,600</td>
</tr>
<tr>
<td>Haley Kennedy</td>
<td>Senior Marketing Designer</td>
<td>London</td>
<td>43</td>
<td>2012/12/18</td>
<td>$313,500</td>
</tr>
<tr>
<td>Tatyana Fitzpatrick</td>
<td>Regional Director</td>
<td>London</td>
<td>19</td>
<td>2010/03/17</td>
<td>$385,750</td>
</tr>
<tr>
<td>Michael Silva</td>
<td>Marketing Designer</td>
<td>London</td>
<td>66</td>
<td>2012/11/27</td>
<td>$198,500</td>
</tr>
<tr>
<td>Paul Byrd</td>
<td>Chief Financial Officer (CFO)</td>
<td>New York</td>
<td>64</td>
<td>2010/06/09</td>
<td>$725,000</td>
</tr>
<tr>
<td>Gloria Little</td>
<td>Systems Administrator</td>
<td>New York</td>
<td>59</td>
<td>2009/04/10</td>
<td>$237,500</td>
</tr>
<tr>
<td>Bradley Greer</td>
<td>Software Engineer</td>
<td>London</td>
<td>41</td>
<td>2012/10/13</td>
<td>$132,000</td>
</tr>
<tr>
<td>Dai Rios</td>
<td>Personnel Lead</td>
<td>Edinburgh</td>
<td>35</td>
<td>2012/09/26</td>
<td>$217,500</td>
</tr>
<tr>
<td>Jenette Caldwell</td>
<td>Development Lead</td>
<td>New York</td>
<td>30</td>
<td>2011/09/03</td>
<td>$345,000</td>
</tr>
<tr>
<td>Yuri Berry</td>
<td>Chief Marketing Officer (CMO)</td>
<td>New York</td>
<td>40</td>
<td>2009/06/25</td>
<td>$675,000</td>
</tr>
<tr>
<td>Caesar Vance</td>
<td>Pre-Sales Support</td>
<td>New York</td>
<td>21</td>
<td>2011/12/12</td>
<td>$106,450</td>
</tr>
<tr>
<td>Doris Wilder</td>
<td>Sales Assistant</td>
<td>Sidney</td>
<td>23</td>
<td>2010/09/20</td>
<td>$85,600</td>
</tr>
<tr>
<td>Angelica Ramos</td>
<td>Chief Executive Officer (CEO)</td>
<td>London</td>
<td>47</td>
<td>2009/10/09</td>
<td>$1,200,000</td>
</tr>
<tr>
<td>Gavin Joyce</td>
<td>Developer</td>
<td>Edinburgh</td>
<td>42</td>
<td>2010/12/22</td>
<td>$92,575</td>
</tr>
<tr>
<td>Jennifer Chang</td>
<td>Regional Director</td>
<td>Singapore</td>
<td>28</td>
<td>2010/11/14</td>
<td>$357,650</td>
</tr>
<tr>
<td>Brenden Wagner</td>
<td>Software Engineer</td>
<td>San Francisco</td>
<td>28</td>
<td>2011/06/07</td>
<td>$206,850</td>
</tr>
<tr>
<td>Fiona Green</td>
<td>Chief Operating Officer (COO)</td>
<td>San Francisco</td>
<td>48</td>
<td>2010/03/11</td>
<td>$850,000</td>
</tr>
<tr>
<td>Shou Itou</td>
<td>Regional Marketing</td>
<td>Tokyo</td>
<td>20</td>
<td>2011/08/14</td>
<td>$163,000</td>
</tr>
<tr>
<td>Michelle House</td>
<td>Integration Specialist</td>
<td>Sidney</td>
<td>37</td>
<td>2011/06/02</td>
<td>$95,400</td>
</tr>
<tr>
<td>Suki Burks</td>
<td>Developer</td>
<td>London</td>
<td>53</td>
<td>2009/10/22</td>
<td>$114,500</td>
</tr>
<tr>
<td>Prescott Bartlett</td>
<td>Technical Author</td>
<td>London</td>
<td>27</td>
<td>2011/05/07</td>
<td>$145,000</td>
</tr>
<tr>
<td>Gavin Cortez</td>
<td>Team Leader</td>
<td>San Francisco</td>
<td>22</td>
<td>2008/10/26</td>
<td>$235,500</td>
</tr>
<tr>
<td>Martena Mccray</td>
<td>Post-Sales support</td>
<td>Edinburgh</td>
<td>46</td>
<td>2011/03/09</td>
<td>$324,050</td>
</tr>
<tr>
<td>Unity Butler</td>
<td>Marketing Designer</td>
<td>San Francisco</td>
<td>47</td>
<td>2009/12/09</td>
<td>$85,675</td>
</tr>
<tr>
<td>Howard Hatfield</td>
<td>Office Manager</td>
<td>San Francisco</td>
<td>51</td>
<td>2008/12/16</td>
<td>$164,500</td>
</tr>
<tr>
<td>Hope Fuentes</td>
<td>Secretary</td>
<td>San Francisco</td>
<td>41</td>
<td>2010/02/12</td>
<td>$109,850</td>
</tr>
<tr>
<td>Vivian Harrell</td>
<td>Financial Controller</td>
<td>San Francisco</td>
<td>62</td>
<td>2009/02/14</td>
<td>$452,500</td>
</tr>
<tr>
<td>Timothy Mooney</td>
<td>Office Manager</td>
<td>London</td>
<td>37</td>
<td>2008/12/11</td>
<td>$136,200</td>
</tr>
<tr>
<td>Jackson Bradshaw</td>
<td>Director</td>
<td>New York</td>
<td>65</td>
<td>2008/09/26</td>
<td>$645,750</td>
</tr>
<tr>
<td>Olivia Liang</td>
<td>Support Engineer</td>
<td>Singapore</td>
<td>64</td>
<td>2011/02/03</td>
<td>$234,500</td>
</tr>
<tr>
<td>Bruno Nash</td>
<td>Software Engineer</td>
<td>London</td>
<td>38</td>
<td>2011/05/03</td>
<td>$163,500</td>
</tr>
<tr>
<td>Sakura Yamamoto</td>
<td>Support Engineer</td>
<td>Tokyo</td>
<td>37</td>
<td>2009/08/19</td>
<td>$139,575</td>
</tr>
<tr>
<td>Thor Walton</td>
<td>Developer</td>
<td>New York</td>
<td>61</td>
<td>2013/08/11</td>
<td>$98,540</td>
</tr>
<tr>
<td>Finn Camacho</td>
<td>Support Engineer</td>
<td>San Francisco</td>
<td>47</td>
<td>2009/07/07</td>
<td>$87,500</td>
</tr>
<tr>
<td>Serge Baldwin</td>
<td>Data Coordinator</td>
<td>Singapore</td>
<td>64</td>
<td>2012/04/09</td>
<td>$138,575</td>
</tr>
<tr>
<td>Zenaida Frank</td>
<td>Software Engineer</td>
<td>New York</td>
<td>63</td>
<td>2010/01/04</td>
<td>$125,250</td>
</tr>
<tr>
<td>Zorita Serrano</td>
<td>Software Engineer</td>
<td>San Francisco</td>
<td>56</td>
<td>2012/06/01</td>
<td>$115,000</td>
</tr>
<tr>
<td>Jennifer Acosta</td>
<td>Junior Javascript Developer</td>
<td>Edinburgh</td>
<td>43</td>
<td>2013/02/01</td>
<td>$75,650</td>
</tr>
<tr>
<td>Cara Stevens</td>
<td>Sales Assistant</td>
<td>New York</td>
<td>46</td>
<td>2011/12/06</td>
<td>$145,600</td>
</tr>
<tr>
<td>Hermione Butler</td>
<td>Regional Director</td>
<td>London</td>
<td>47</td>
<td>2011/03/21</td>
<td>$356,250</td>
</tr>
<tr>
<td>Lael Greer</td>
<td>Systems Administrator</td>
<td>London</td>
<td>21</td>
<td>2009/02/27</td>
<td>$103,500</td>
</tr>
<tr>
<td>Jonas Alexander</td>
<td>Developer</td>
<td>San Francisco</td>
<td>30</td>
<td>2010/07/14</td>
<td>$86,500</td>
</tr>
<tr>
<td>Shad Decker</td>
<td>Regional Director</td>
<td>Edinburgh</td>
<td>51</td>
<td>2008/11/13</td>
<td>$183,000</td>
</tr>
<tr>
<td>Michael Bruce</td>
<td>Javascript Developer</td>
<td>Singapore</td>
<td>29</td>
<td>2011/06/27</td>
<td>$183,000</td>
</tr>
<tr>
<td>Donna Snider</td>
<td>Customer Support</td>
<td>New York</td>
<td>27</td>
<td>2011/01/25</td>
<td>$112,000</td>
</tr>
</tbody>
</table>
Table with search
.input-group.md-form.form-sm.form-2 input {
border: 1px solid #bdbdbd;
border-top-left-radius: 0.25rem;
border-bottom-left-radius: 0.25rem;
}
.input-group.md-form.form-sm.form-2 input.grey-border {
border: 1px solid #e9ecef;
}
.input-group input[type=text]:focus:not([readonly]) {
box-shadow: none;
}
.form-2 .input-group-text {
border: 1px solid #e9ecef;
}
<div class="card">
<div class="card-body">
<!-- Grid row -->
<div class="row">
<!-- Grid column -->
<div class="col-md-12 mt-4">
<div class="input-group md-form form-sm form-2 pl-0">
<input class="form-control my-0 py-1 grey-border" type="text" placeholder="Search" aria-label="Search">
<div class="input-group-append">
<span class="input-group-text waves-effect grey lighten-3" id="basic-addon1">
<a><i class="fa fa-search text-grey" aria-hidden="true"></i></a>
</span>
</div>
</div>
</div>
<!-- Grid column -->
</div>
<!-- Grid row -->
<!--Table-->
<table class="table table-striped">
<!--Table head-->
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<!--Table head-->
<!--Table body-->
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</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>Larry</td>
<td>the Bird</td>
<td>@twitter</td>
</tr>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</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>Larry</td>
<td>the Bird</td>
<td>@twitter</td>
</tr>
</tbody>
<!--Table body-->
</table>
<!--Table-->
</div>
</div>
Table with scroll
# | Name | Surname | Country | City | Position | Age |
---|---|---|---|---|---|---|
1 | Kate | Moss | USA | New York City | Web Designer | 23 |
2 | Anna | Wintour | United Kingdom | London | Frontend Developer | 36 |
3 | Tom | Bond | Spain | Madrid | Photographer | 25 |
4 | Jerry | Horwitz | Italy | Bari | Editor-in-chief | 41 |
5 | Janis | Joplin | Poland | Warsaw | Video Maker | 39 |
6 | Gary | Winogrand | Germany | Berlin | Photographer | 37 |
7 | Angie | Smith | USA | San Francisco | Teacher | 52 |
8 | John | Mattis | France | Paris | Actor | 28 |
9 | Otto | Morris | Germany | Munich | Singer | 35 |
.table-wrapper-2 {
display: block;
max-height: 300px;
overflow-y: auto;
-ms-overflow-style: -ms-autohiding-scrollbar;
}
<div class="card">
<div class="card-body">
<div class="table-wrapper-2">
<!--Table-->
<table class="table table-responsive-md">
<thead class="mdb-color lighten-4">
<tr>
<th>#</th>
<th class="th-lg">Name</th>
<th class="th-lg">Surname</th>
<th class="th-lg">Country</th>
<th class="th-lg">City</th>
<th class="th-lg">Position</th>
<th class="th-lg">Age</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Kate</td>
<td>Moss</td>
<td>USA</td>
<td>New York City</td>
<td>Web Designer</td>
<td>23</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Anna</td>
<td>Wintour</td>
<td>United Kingdom</td>
<td>London</td>
<td>Frontend Developer</td>
<td>36</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Tom</td>
<td>Bond</td>
<td>Spain</td>
<td>Madrid</td>
<td>Photographer</td>
<td>25</td>
</tr>
<tr>
<th scope="row">4</th>
<td>Jerry</td>
<td>Horwitz</td>
<td>Italy</td>
<td>Bari</td>
<td>Editor-in-chief</td>
<td>41</td>
</tr>
<tr>
<th scope="row">5</th>
<td>Janis</td>
<td>Joplin</td>
<td>Poland</td>
<td>Warsaw</td>
<td>Video Maker</td>
<td>39</td>
</tr>
<tr>
<th scope="row">6</th>
<td>Gary</td>
<td>Winogrand</td>
<td>Germany</td>
<td>Berlin</td>
<td>Photographer</td>
<td>37</td>
</tr>
<tr>
<th scope="row">7</th>
<td>Angie</td>
<td>Smith</td>
<td>USA</td>
<td>San Francisco</td>
<td>Teacher</td>
<td>52</td>
</tr>
<tr>
<th scope="row">8</th>
<td>John</td>
<td>Mattis</td>
<td>France</td>
<td>Paris</td>
<td>Actor</td>
<td>28</td>
</tr>
<tr>
<th scope="row">9</th>
<td>Otto</td>
<td>Morris</td>
<td>Germany</td>
<td>Munich</td>
<td>Singer</td>
<td>35</td>
</tr>
</tbody>
</table>
<!--Table-->
</div>
</div>
</div>
Table with pagination
<div class="card card-cascade narrower mt-5">
<!--Card image-->
<div class="view gradient-card-header purple-gradient narrower py-4 mx-4 mb-3 d-flex justify-content-center align-items-center">
<h4 class="white-text font-bold font-up mb-0">Table name</h4>
</div>
<!--/Card image-->
<div class="px-4">
<!--Table-->
<table class="table table-hover table-responsive-md mb-0">
<!--Table head-->
<thead>
<tr>
<th scope="row">#</th>
<th class="th-lg"><a>First Name <i class="fa fa-sort ml-1"></i></a></th>
<th class="th-lg"><a href="">Last Name<i class="fa fa-sort ml-1"></i></a></th>
<th class="th-lg"><a href="">Username<i class="fa fa-sort ml-1"></i></a></th>
<th class="th-lg"><a href="">Username<i class="fa fa-sort ml-1"></i></a></th>
<th class="th-lg"><a href="">Username<i class="fa fa-sort ml-1"></i></a></th>
<th class="th-lg"><a href="">Username<i class="fa fa-sort ml-1"></i></a></th>
</tr>
</thead>
<!--Table head-->
<!--Table body-->
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>@fat</td>
<td>Jacob</td>
<td>Thornton</td>
<td>@fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>@twitter</td>
<td>Larry</td>
<td>the Bird</td>
<td>@twitter</td>
</tr>
<tr>
<th scope="row">4</th>
<td>Paul</td>
<td>Topolski</td>
<td>@P_Topolski</td>
<td>Paul</td>
<td>Topolski</td>
<td>@P_Topolski</td>
</tr>
<tr>
<th scope="row">5</th>
<td>Larry</td>
<td>the Bird</td>
<td>@twitter</td>
<td>Larry</td>
<td>the Bird</td>
<td>@twitter</td>
</tr>
</tbody>
<!--Table body-->
</table>
</div>
<hr class="my-0">
<!--Bottom Table UI-->
<div class="d-flex justify-content-center">
<!--Pagination -->
<nav class="my-4 pt-2">
<ul class="pagination pagination-circle pg-purple mb-0">
<!--First-->
<li class="page-item disabled clearfix d-none d-md-block"><a class="page-link">First</a></li>
<!--Arrow left-->
<li class="page-item disabled">
<a class="page-link" aria-label="Previous">
<span aria-hidden="true">«</span>
<span class="sr-only">Previous</span>
</a>
</li>
<!--Numbers-->
<li class="page-item active"><a class="page-link">1</a></li>
<li class="page-item"><a class="page-link">2</a></li>
<li class="page-item"><a class="page-link">3</a></li>
<li class="page-item"><a class="page-link">4</a></li>
<li class="page-item"><a class="page-link">5</a></li>
<!--Arrow right-->
<li class="page-item">
<a class="page-link" aria-label="Next">
<span aria-hidden="true">»</span>
<span class="sr-only">Next</span>
</a>
</li>
<!--First-->
<li class="page-item clearfix d-none d-md-block"><a class="page-link">Last</a></li>
</ul>
</nav>
<!--/Pagination -->
</div>
<!--Bottom Table UI-->
</div>
Table with auto width
# | Name | Surname | Country | City | Position | Age |
---|---|---|---|---|---|---|
1 | Kate | Moss | USA | New York City | Web Designer | 23 |
2 | Anna | Wintour | United Kingdom | London | Frontend Developer | 36 |
3 | Tom | Bond | Spain | Madrid | Photographer | 25 |
4 | Jerry | Horwitz | Italy | Bari | Editor-in-chief | 41 |
5 | Janis | Joplin | Poland | Warsaw | Video Maker | 39 |
6 | Gary | Winogrand | Germany | Berlin | Photographer | 37 |
7 | Angie | Smith | USA | San Francisco | Teacher | 52 |
8 | John | Mattis | France | Paris | Actor | 28 |
9 | Otto | Morris | Germany | Munich | Singer | 35 |
.w-auto {
width: auto;
}
<table class="table table-striped table-responsive w-auto">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Surname</th>
<th>Country</th>
<th>City</th>
<th>Position</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr class="table-info">
<th scope="row">1</th>
<td>Kate</td>
<td>Moss</td>
<td>USA</td>
<td>New York City</td>
<td>Web Designer</td>
<td>23</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Anna</td>
<td>Wintour</td>
<td>United Kingdom</td>
<td>London</td>
<td>Frontend Developer</td>
<td>36</td>
</tr>
<tr class="table-info">
<th scope="row">3</th>
<td>Tom</td>
<td>Bond</td>
<td>Spain</td>
<td>Madrid</td>
<td>Photographer</td>
<td>25</td>
</tr>
<tr>
<th scope="row">4</th>
<td>Jerry</td>
<td>Horwitz</td>
<td>Italy</td>
<td>Bari</td>
<td>Editor-in-chief</td>
<td>41</td>
</tr>
<tr class="table-info">
<th scope="row">5</th>
<td>Janis</td>
<td>Joplin</td>
<td>Poland</td>
<td>Warsaw</td>
<td>Video Maker</td>
<td>39</td>
</tr>
<tr>
<th scope="row">6</th>
<td>Gary</td>
<td>Winogrand</td>
<td>Germany</td>
<td>Berlin</td>
<td>Photographer</td>
<td>37</td>
</tr>
<tr class="table-info">
<th scope="row">7</th>
<td>Angie</td>
<td>Smith</td>
<td>USA</td>
<td>San Francisco</td>
<td>Teacher</td>
<td>52</td>
</tr>
<tr>
<th scope="row">8</th>
<td>John</td>
<td>Mattis</td>
<td>France</td>
<td>Paris</td>
<td>Actor</td>
<td>28</td>
</tr>
<tr class="table-info">
<th scope="row">9</th>
<td>Otto</td>
<td>Morris</td>
<td>Germany</td>
<td>Munich</td>
<td>Singer</td>
<td>35</td>
</tr>
</tbody>
</table>
Table with fixed column width
# | Name | Surname | Country | City | Position | Age |
---|---|---|---|---|---|---|
4 | Jerry | Horwitz | Italy | Bari | Editor-in-chief | 41 |
5 | Janis | Joplin | Poland | Warsaw | Video Maker | 39 |
6 | Gary | Winogrand | Germany | Berlin | Photographer | 37 |
7 | Angie | Smith | USA | San Francisco | Teacher | 52 |
8 | John | Mattis | France | Paris | Actor | 28 |
9 | Otto | Morris | Germany | Munich | Singer | 35 |
.table-fixed {
table-layout: fixed;
overflow: hidden;
}
<div class="card">
<div class="card-body">
<table class="table table-hover table-responsive-md table-fixed">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Surname</th>
<th>Country</th>
<th>City</th>
<th>Position</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">4</th>
<td>Jerry</td>
<td>Horwitz</td>
<td>Italy</td>
<td>Bari</td>
<td>Editor-in-chief</td>
<td>41</td>
</tr>
<tr>
<th scope="row">5</th>
<td>Janis</td>
<td>Joplin</td>
<td>Poland</td>
<td>Warsaw</td>
<td>Video Maker</td>
<td>39</td>
</tr>
<tr>
<th scope="row">6</th>
<td>Gary</td>
<td>Winogrand</td>
<td>Germany</td>
<td>Berlin</td>
<td>Photographer</td>
<td>37</td>
</tr>
<tr>
<th scope="row">7</th>
<td>Angie</td>
<td>Smith</td>
<td>USA</td>
<td>San Francisco</td>
<td>Teacher</td>
<td>52</td>
</tr>
<tr>
<th scope="row">8</th>
<td>John</td>
<td>Mattis</td>
<td>France</td>
<td>Paris</td>
<td>Actor</td>
<td>28</td>
</tr>
<tr>
<th scope="row">9</th>
<td>Otto</td>
<td>Morris</td>
<td>Germany</td>
<td>Munich</td>
<td>Singer</td>
<td>35</td>
</tr>
</tbody>
</table>
</div>
</div>
Table with panel MDB Pro component
.table-wrapper {
display: block;
max-height: 300px;
overflow-y: auto;
-ms-overflow-style: -ms-autohiding-scrollbar;
}
<!--Top Table UI-->
<div class="card p-2 mb-5">
<!--Grid row-->
<div class="row">
<!--Grid column-->
<div class="col-lg-3 col-md-12">
<!--Name-->
<select class="mdb-select colorful-select dropdown-primary mx-2">
<option value="" disabled selected>Bulk actions</option>
<option value="1">Delate</option>
<option value="2">Export</option>
<option value="3">Change segment</option>
</select>
</div>
<!--Grid column-->
<!--Grid column-->
<div class="col-lg-3 col-md-6">
<!--Blue select-->
<select class="mdb-select colorful-select dropdown-primary mx-2">
<option value="" disabled selected>Show only</option>
<option value="1">All <span> (2000)</span></option>
<option value="2">Never opened <span> (200)</span></option>
<option value="3">Opened but unanswered <span> (1800)</span></option>
<option value="4">Answered <span> (200)</span></option>
<option value="5">Unsunscribed <span> (50)</span></option>
</select>
<!--/Blue select-->
</div>
<!--Grid column-->
<!--Grid column-->
<div class="col-lg-3 col-md-6">
<!--Blue select-->
<select class="mdb-select colorful-select dropdown-primary mx-2">
<option value="" disabled selected>Filter segments</option>
<option value="1">Contacts in no segments <span> (100)</span></option>
<option value="1">Segment 1 <span> (2000)</span></option>
<option value="2">Segment 2 <span> (1000)</span></option>
<option value="3">Segment 3 <span> (4000)</span></option>
</select>
<!--/Blue select-->
</div>
<!--Grid column-->
<!--Grid column-->
<div class="col-lg-3 col-md-6">
<form class="form-inline mt-2 ml-2">
<input class="form-control my-0 py-0" type="text" placeholder="Search" style="max-width: 150px;">
<button class="btn btn-sm btn-primary ml-2 px-1"><i class="fa fa-search"></i> </button>
</form>
</div>
<!--Grid column-->
</div>
<!--Grid row-->
</div>
<!--Top Table UI-->
<div class="card card-cascade narrower">
<!--Card image-->
<div class="view gradient-card-header blue-gradient narrower py-2 mx-4 mb-3 d-flex justify-content-between align-items-center">
<div>
<button type="button" class="btn btn-outline-white btn-rounded btn-sm px-2"><i class="fa fa-th-large mt-0"></i></button>
<button type="button" class="btn btn-outline-white btn-rounded btn-sm px-2"><i class="fa fa-columns mt-0"></i></button>
</div>
<a href="" class="white-text mx-3">Table name</a>
<div>
<button type="button" class="btn btn-outline-white btn-rounded btn-sm px-2"><i class="fa fa-pencil mt-0"></i></button>
<button type="button" class="btn btn-outline-white btn-rounded btn-sm px-2"><i class="fa fa-remove mt-0"></i></button>
<button type="button" class="btn btn-outline-white btn-rounded btn-sm px-2"><i class="fa fa-info-circle mt-0"></i></button>
</div>
</div>
<!--/Card image-->
<div class="px-4">
<div class="table-wrapper">
<!--Table-->
<table class="table table-hover mb-0">
<!--Table head-->
<thead>
<tr>
<th>
<input type="checkbox" id="checkbox">
<label for="checkbox" class="mr-2 label-table"></label>
</th>
<th class="th-lg"><a>First Name <i class="fa fa-sort ml-1"></i></a></th>
<th class="th-lg"><a href="">Last Name<i class="fa fa-sort ml-1"></i></a></th>
<th class="th-lg"><a href="">Username<i class="fa fa-sort ml-1"></i></a></th>
<th class="th-lg"><a href="">Username<i class="fa fa-sort ml-1"></i></a></th>
<th class="th-lg"><a href="">Username<i class="fa fa-sort ml-1"></i></a></th>
<th class="th-lg"><a href="">Username<i class="fa fa-sort ml-1"></i></a></th>
</tr>
</thead>
<!--Table head-->
<!--Table body-->
<tbody>
<tr>
<th scope="row">
<input type="checkbox" id="checkbox1">
<label for="checkbox1" class="label-table"></label>
</th>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
</tr>
<tr>
<th scope="row">
<input type="checkbox" id="checkbox2">
<label for="checkbox2" class="label-table"></label>
</th>
<td>Jacob</td>
<td>Thornton</td>
<td>@fat</td>
<td>Jacob</td>
<td>Thornton</td>
<td>@fat</td>
</tr>
<tr>
<th scope="row">
<input type="checkbox" id="checkbox3">
<label for="checkbox3" class="label-table"></label>
</th>
<td>Larry</td>
<td>the Bird</td>
<td>@twitter</td>
<td>Larry</td>
<td>the Bird</td>
<td>@twitter</td>
</tr>
<tr>
<th scope="row">
<input type="checkbox" id="checkbox4">
<label for="checkbox4" class="label-table"></label>
</th>
<td>Paul</td>
<td>Topolski</td>
<td>@P_Topolski</td>
<td>Paul</td>
<td>Topolski</td>
<td>@P_Topolski</td>
</tr>
<tr>
<th scope="row">
<input type="checkbox" id="checkbox5">
<label for="checkbox5" class="label-table"></label>
</th>
<td>Larry</td>
<td>the Bird</td>
<td>@twitter</td>
<td>Larry</td>
<td>the Bird</td>
<td>@twitter</td>
</tr>
</tbody>
<!--Table body-->
</table>
<!--Table-->
</div>
<hr class="my-0">
<!--Bottom Table UI-->
<div class="d-flex justify-content-between">
<!--Name-->
<select class="mdb-select colorful-select dropdown-primary mt-2 hidden-md-down">
<option value="" disabled >Rows number</option>
<option value="1" selected>10 rows</option>
<option value="2">25 rows</option>
<option value="3">50 rows</option>
<option value="4">100 rows</option>
</select>
<!--Pagination -->
<nav class="my-4">
<ul class="pagination pagination-circle pg-blue mb-0">
<!--First-->
<li class="page-item disabled"><a class="page-link">First</a></li>
<!--Arrow left-->
<li class="page-item disabled">
<a class="page-link" aria-label="Previous">
<span aria-hidden="true">«</span>
<span class="sr-only">Previous</span>
</a>
</li>
<!--Numbers-->
<li class="page-item active"><a class="page-link">1</a></li>
<li class="page-item"><a class="page-link">2</a></li>
<li class="page-item"><a class="page-link">3</a></li>
<li class="page-item"><a class="page-link">4</a></li>
<li class="page-item"><a class="page-link">5</a></li>
<!--Arrow right-->
<li class="page-item">
<a class="page-link" aria-label="Next">
<span aria-hidden="true">»</span>
<span class="sr-only">Next</span>
</a>
</li>
<!--First-->
<li class="page-item"><a class="page-link">Last</a></li>
</ul>
</nav>
<!--/Pagination -->
</div>
<!--Bottom Table UI-->
</div>
</div>
Editable table MDB Pro component
.pt-3-half {
padding-top: 1.4rem;
}
var $TABLE = $('#table');
var $BTN = $('#export-btn');
var $EXPORT = $('#export');
$('.table-add').click(function () {
var $clone = $TABLE.find('tr.hide').clone(true).removeClass('hide table-line');
$TABLE.find('table').append($clone);
});
$('.table-remove').click(function () {
$(this).parents('tr').detach();
});
$('.table-up').click(function () {
var $row = $(this).parents('tr');
if ($row.index() === 1) return; // Don't go above the header
$row.prev().before($row.get(0));
});
$('.table-down').click(function () {
var $row = $(this).parents('tr');
$row.next().after($row.get(0));
});
// A few jQuery helpers for exporting only
jQuery.fn.pop = [].pop;
jQuery.fn.shift = [].shift;
$BTN.click(function () {
var $rows = $TABLE.find('tr:not(:hidden)');
var headers = [];
var data = [];
// Get the headers (add special header logic here)
$($rows.shift()).find('th:not(:empty)').each(function () {
headers.push($(this).text().toLowerCase());
});
// Turn all existing rows into a loopable array
$rows.each(function () {
var $td = $(this).find('td');
var h = {};
// Use the headers from earlier to name our hash keys
headers.forEach(function (header, i) {
h[header] = $td.eq(i).text();
});
data.push(h);
});
<!-- Editable table -->
<div class="card">
<h3 class="card-header text-center font-bold font-up py-4">Editable table</h3>
<div class="card-body">
<div id="table" class="table-editable">
<span class="table-add float-right mb-3 mr-2"><a href="#!" class="text-success"><i class="fa fa-plus fa-2x" aria-hidden="true"></i></a></span>
<table class="table table-bordered table-responsive-md table-striped text-center">
<tr>
<th class="text-center">Person Name</th>
<th class="text-center">Age</th>
<th class="text-center">Company Name</th>
<th class="text-center">Country</th>
<th class="text-center">City</th>
<th class="text-center">Sort</th>
<th class="text-center">Remove</th>
</tr>
<tr>
<td class="pt-3-half" contenteditable="true">Aurelia Vega</td>
<td class="pt-3-half" contenteditable="true">30</td>
<td class="pt-3-half" contenteditable="true">Deepends</td>
<td class="pt-3-half" contenteditable="true">Spain</td>
<td class="pt-3-half" contenteditable="true">Madrid</td>
<td class="pt-3-half">
<span class="table-up"><a href="#!" class="indigo-text"><i class="fa fa-long-arrow-up" aria-hidden="true"></i></a></span>
<span class="table-down"><a href="#!" class="indigo-text"><i class="fa fa-long-arrow-down" aria-hidden="true"></i></a></span>
</td>
<td>
<span class="table-remove"><button type="button" class="btn btn-danger btn-rounded btn-sm my-0">Remove</button></span>
</td>
</tr>
<!-- This is our clonable table line -->
<tr>
<td class="pt-3-half" contenteditable="true">Guerra Cortez</td>
<td class="pt-3-half" contenteditable="true">45</td>
<td class="pt-3-half" contenteditable="true">Insectus</td>
<td class="pt-3-half" contenteditable="true">USA</td>
<td class="pt-3-half" contenteditable="true">San Francisco</td>
<td class="pt-3-half">
<span class="table-up"><a href="#!" class="indigo-text"><i class="fa fa-long-arrow-up" aria-hidden="true"></i></a></span>
<span class="table-down"><a href="#!" class="indigo-text"><i class="fa fa-long-arrow-down" aria-hidden="true"></i></a></span>
</td>
<td>
<span class="table-remove"><button type="button" class="btn btn-danger btn-rounded btn-sm my-0">Remove</button></span>
</td>
</tr>
<!-- This is our clonable table line -->
<tr>
<td class="pt-3-half" contenteditable="true">Guadalupe House</td>
<td class="pt-3-half" contenteditable="true">26</td>
<td class="pt-3-half" contenteditable="true">Isotronic</td>
<td class="pt-3-half" contenteditable="true">Germany</td>
<td class="pt-3-half" contenteditable="true">Frankfurt am Main</td>
<td class="pt-3-half">
<span class="table-up"><a href="#!" class="indigo-text"><i class="fa fa-long-arrow-up" aria-hidden="true"></i></a></span>
<span class="table-down"><a href="#!" class="indigo-text"><i class="fa fa-long-arrow-down" aria-hidden="true"></i></a></span>
</td>
<td>
<span class="table-remove"><button type="button" class="btn btn-danger btn-rounded btn-sm my-0">Remove</button></span>
</td>
</tr>
<!-- This is our clonable table line -->
<tr class="hide">
<td class="pt-3-half" contenteditable="true">Elisa Gallagher</td>
<td class="pt-3-half" contenteditable="true">31</td>
<td class="pt-3-half" contenteditable="true">Portica</td>
<td class="pt-3-half" contenteditable="true">United Kingdom</td>
<td class="pt-3-half" contenteditable="true">London</td>
<td class="pt-3-half">
<span class="table-up"><a href="#!" class="indigo-text"><i class="fa fa-long-arrow-up" aria-hidden="true"></i></a></span>
<span class="table-down"><a href="#!" class="indigo-text"><i class="fa fa-long-arrow-down" aria-hidden="true"></i></a></span>
</td>
<td>
<span class="table-remove"><button type="button" class="btn btn-danger btn-rounded btn-sm my-0">Remove</button></span>
</td>
</tr>
</table>
</div>
</div>
</div>
<!-- Editable table -->