Using the most basic table markup, here’s how .table
-based tables look in Bootstrap. You can use any example of below table for your table and it can be use with any type of bootstrap tables.
Example 1: Table with outer spacing
# | First Name | Last Name | Username |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird |
Example 2: Minimal Table with no outer spacing.
# | First Name | Last Name | Username |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird |
You can also invert the colors—with light text on dark backgrounds—with .bg-info, .bg-success, .bg-warning and .bg-danger classes
.
To set the light background color use .bg-[color]
class where [color]
is the value of your selected color from robust color palette. So for green color background class will be .bg-green
. Refer HTML markup line no 1. Background color class is a optional if you don't it will take white background default.
To set the selected background color lighten use .bg-lighten-[*]
class where [*]
is the value between '1-5' of your selected lighten color from robust color palette. So for color lighten 4 background class will be .bg-lighten-4
. Refer HTML markup line no 1. Background lighten color class is a optional if you don't it will take white background default.
# | First Name | Last Name | Username |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird |
Similar to default and inverse tables, use one of two modifier classes .thead-default
or .thead-inverse
to make <thead>
s appear light or dark gray.
# | 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 |
Use background classes bg-*
to make custom thead
background. You can also use Robust Admin color palette classes for background.
# | 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 |
Use .table-inverse
with .table-striped
to add zebra-striping to any inverse table row within the <tbody>
. This styling doesn't work in IE8 and below as :nth-child
CSS selector isn't supported.
# | First Name | Last Name | Username |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird |
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 |
# | First Name | Last Name | Username |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird | |
4 | Larry | the Bird | |
5 | Larry | the Bird | |
6 | Larry | the Bird | |
7 | Larry | the Bird | |
8 | Larry | the Bird | |
8 | Larry | the Bird |
Regular table background variants are not available with the inverse table, however, you may use text or background utilities to achieve similar styles.
# | First Name | Last Name | Username |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird | |
4 | Larry | the Bird | |
5 | Larry | the Bird | |
6 | Larry | the Bird | |
7 | Larry | the Bird | |
8 | Larry | the Bird | |
8 | Larry | the Bird |
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.
# | First Name | Last Name | Username |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird |
Turn traditional tables on their side by using table-reflow
. When using reflow, the table header becomes the first column of the table, the first row within the table body becomes the second column, the second row becomes the third column, etc.
Content order and complex tables
Beware that the table-reflow
style changes the visual order of content. Make sure that you only apply this style to well-formed and simple data tables (and in particular, don’t use this for layout tables) with appropriate <th>
table header cells for each row and column.
In addition, this class will not work correctly for tables with cells that span multiple rows or columns (using rowspan
or colspan
attributes).
# | 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 |
4 | Table cell | Table cell | Table cell | Table cell | Table cell | Table cell |
5 | Table cell | Table cell | Table cell | Table cell | Table cell | Table cell |
6 | Table cell | Table cell | Table cell | Table cell | Table cell | Table cell |