Flickr-Gallery.com

Bootstrap Tables Design

Introduction

Tables are existing in most programs (web, desktop or mobile app) and they are a important component in delivering records to the end user. The HTML tables are really used to present info in framework manner like columns and rows . With working with Bootstrap 4 framework you are capable to easily improve the look of the table.

Nowadays, with the importance that the user interface has, realising precisely how to enhance the appearance of a Bootstrap table becomes as relevant as it is. In this scenario, one of the technologies that have come to be reference is Bootstrap. This front-end framework, within a lot of other features , delivers a number of elements for designing and optimising the display of various elements, such as tables.

Basic table in Bootstrap

To format a table using Bootstrap, just incorporate the table class to the

<table>
tag, and certain visional format will actually be applied , as shown on the screenshot .

Bootstrap  standard table

<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>

Inverse tables.

Among the latest tables in Bootsrap 4 is the inverse tables. Class

.table-inverse
has the ability to transform the colour of the table.

Bootstrap inverse table
<table class="table table-inverse">
  <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>

Extra classes

For tables there are also some classes that allow you to apply a variety of looks to a table ( additional info), they are:

table-striped
Toggles the color tone of table rows;

table-bordered
Adds border to table;

table-hover
Switches on the highlight of a Bootstrap Tables Responsive line when we hover the mouse pointer over it;

table-condensed
Decreases the height of table rows, making it more compact.

To apply all of these designs, just add in the desired classes to the: <table>: <table class="table table-striped table-bordered table-condensed table-hover">

Table head opportunities

Similar to default and inverse tables, work with one of two modifier classes to get

<thead>
appear light or dark gray.

Table head options
<table class="table">
  <thead class="thead-inverse">
    <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 class="table">
  <thead class="thead-default">
    <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>

Striped rows

Zebra-like stripes can be provided with the

.table-striped
class, an example

Bootstrap striped rows
<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>

Hover Rows

To generate a hover side effect in the rows of your table bring in the

.table-hover
class ( read more here):

Bootstrap hover rows
<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>

Bordered Table

You can easily incorporate the borders on each and every table slide and a cell by the

.table-bordered
class:

Bootstrap bordered table
<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>

Condensed Table

In case you like to make your table even more small - then you can cut cell padding in half using this class:

.table-condensed
.

Take note that, while Bootstrap 4 uses

.table-sm
to condense a table, Bootstrap 3 uses
.table-condensed
. Both of these cut cell padding in half.

Bootstrap condensed table
<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 of Bootstrap Tables Layout

Use the contextual classes to color a table cells (

<td>
) and table rows (
<tr>
):

Bootstrap contextual classes
<!-- 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>

Changing the rows of a table Bootstrap 3 doesn't use the

.table-
prefix for its contextual classes. As an example, Bootstrap 3 uses
.active
while Bootstrap 4 uses
.table-active
. Other than that, both versions use the identical 5 contextual keywords (active, success, info, warning, danger). In this article you are able to inspect the information of each one possible option:

● active: Applies the focus color to the table row or table cell

● success: Indicates a successful or positive action

● info: Signifies a neutral information change or action

● warning: Displays a warning that you may need attention

● danger: Signifies a potentially negative or dangerous action

Responsive Tables

To create a responsive table - use the

.table-responsive
class. Table scrolls in the horizontal direction on devices that under 768px. If the machine is larger sized than 768px wide, then you will see no big difference :

Bootstrap responsive tables

Bootstrap 4 allows you to add the

.table-responsive
class to the actual <table> element. Bootstrap 3 tables required that you add that class to a parent <div> element.

Take a look at a couple of video training about Bootstrap 4 tables

Related topics:

Bootstrap Table Example

__

W3schools:Bootstrap table tutorial

Bootstrap table  short training

Bootstrap Tables Lecture

Bootstrap Tables Lecture