Bootstrap 4 Tables
Bootstrap 4 Basic Table
A basic Bootstrap 4 table has a light padding and horizontal dividers.
The .table class adds basic styling to a table:
Example
| Firstname | Lastname | |
|---|---|---|
| John | Doe | [email protected] |
| Mary | Moe | [email protected] |
| July | Dooley | [email protected] |
Striped Rows
The .table-striped class adds zebra-stripes to a table:
Example
| Firstname | Lastname | |
|---|---|---|
| John | Doe | [email protected] |
| Mary | Moe | [email protected] |
| July | Dooley | [email protected] |
Bordered Table
The .table-bordered class adds borders on all sides of the table and cells:
Example
| Firstname | Lastname | |
|---|---|---|
| John | Doe | [email protected] |
| Mary | Moe | [email protected] |
| July | Dooley | [email protected] |
Hover Rows
The .table-hover class adds a hover effect (grey background color) on table rows:
Example
| Firstname | Lastname | |
|---|---|---|
| John | Doe | [email protected] |
| Mary | Moe | [email protected] |
| July | Dooley | [email protected] |
Black/Dark Table
The .table-dark class adds a black background to the table:
Example
| Firstname | Lastname | |
|---|---|---|
| John | Doe | [email protected] |
| Mary | Moe | [email protected] |
| July | Dooley | [email protected] |
Dark Striped Table
Combine .table-dark and .table-striped to create a dark, striped table:
Example
| Firstname | Lastname | |
|---|---|---|
| John | Doe | [email protected] |
| Mary | Moe | [email protected] |
| July | Dooley | [email protected] |
Hoverable Dark Table
The .table-hover class adds a hover effect (grey background color) on table rows:
Example
| Firstname | Lastname | |
|---|---|---|
| John | Doe | [email protected] |
| Mary | Moe | [email protected] |
| July | Dooley | [email protected] |
Borderless Table
The .table-borderless class removes borders from the table:
Example
| Firstname | Lastname | |
|---|---|---|
| John | Doe | [email protected] |
| Mary | Moe | [email protected] |
| July | Dooley | [email protected] |
Contextual Classes
Contextual classes can be used to color the whole table (<table>),
the table rows (<tr>) or table cells (<td>).
Example
| Firstname | Lastname | |
|---|---|---|
| Default | Defaultson | [email protected] |
| Primary | Joe | [email protected] |
| Success | Doe | [email protected] |
| Danger | Moe | [email protected] |
| Info | Dooley | [email protected] |
| Warning | Refs | [email protected] |
| Active | Activeson | [email protected] |
| Secondary | Secondson | [email protected] |
| Light | Angie | [email protected] |
| Dark | Bo | [email protected] |
The contextual classes that can be used are:
| Class | Description |
|---|---|
.table-primary |
Blue: Indicates an important action |
.table-success |
Green: Indicates a successful or positive action |
.table-danger |
Red: Indicates a dangerous or potentially negative action |
.table-info |
Light blue: Indicates a neutral informative change or action |
.table-warning |
Orange: Indicates a warning that might need attention |
.table-active |
Grey: Applies the hover color to the table row or table cell |
.table-secondary |
Grey: Indicates a slightly less important action |
.table-light |
Light grey table or table row background |
.table-dark |
Dark grey table or table row background |
Table Head Colors
The .thead-dark class adds a black background to table headers, and the .thead-light class adds a grey background to table headers:
Example
| Firstname | Lastname | |
|---|---|---|
| John | Doe | [email protected] |
| Mary | Moe | [email protected] |
| July | Dooley | [email protected] |
| Firstname | Lastname | |
|---|---|---|
| John | Doe | [email protected] |
| Mary | Moe | [email protected] |
| July | Dooley | [email protected] |
Small table
The .table-sm class makes the table smaller by cutting cell padding in half:
Example
| Firstname | Lastname | |
|---|---|---|
| John | Doe | [email protected] |
| Mary | Moe | [email protected] |
| July | Dooley | [email protected] |
Responsive Tables
The .table-responsive class adds a scrollbar
to the table when needed (when it is too big horizontally):
You can also decide when the table should get a scrollbar, depending on screen width:
| Class | Screen width |
|---|---|
.table-responsive-sm |
< 576px |
.table-responsive-md |
< 768px |
.table-responsive-lg |
< 992px |
.table-responsive-xl |
< 1200px |
Example
<div class="table-responsive-sm">
<table class="table">
...
</table>
</div>
Try it Yourself »
