Bootstrap 5 Tables

A simple Bootstrap 5 table features horizontal dividers and minimal padding.

Basic styling is added to a table using the .table class:

Example

FirstnameLastnameEmail
JohnDoejohn@example.com
MaryMoemary@example.com
JulyDooleyjuly@example.com

Striped Rows

Zebra stripes are added to a table using the .table-striped class:

Example

FirstnameLastnameEmail
JohnDoejohn@example.com
MaryMoemary@example.com
JulyDooleyjuly@example.com

Bordered Table

Borders are added to the table and cells on both sides using the .table-bordered class:

Example

FirstnameLastnameEmail
JohnDoejohn@example.com
MaryMoemary@example.com
JulyDooleyjuly@example.com

Hover Rows

Table rows now have a hover effect (gray background color) thanks to the .table-hover class:

Example

FirstnameLastnameEmail
JohnDoejohn@example.com
MaryMoemary@example.com
JulyDooleyjuly@example.com

Black/Dark Table

The table’s backdrop is made black by the .table-dark class:

Example

FirstnameLastnameEmail
JohnDoejohn@example.com
MaryMoemary@example.com
JulyDooleyjuly@example.com

 

Dark Striped Table

To make a dark, striped table, combine .table-dark and .table-striped:

Example

FirstnameLastnameEmail
JohnDoejohn@example.com
MaryMoemary@example.com
JulyDooleyjuly@example.com

Hoverable Dark Table

Table rows now have a hover effect (gray background color) thanks to the .table-hover class:

Example

FirstnameLastnameEmail
JohnDoejohn@example.com
MaryMoemary@example.com
JulyDooleyjuly@example.com

Borderless Table

The table’s borders are eliminated by the .table-borderless class:

Example

FirstnameLastnameEmail
JohnDoejohn@example.com
MaryMoemary@example.com
JulyDooleyjuly@example.com

Contextual Classes

Table cells (<td>), table rows (<tr>), and the entire table (<table>) can all be colored with contextual classes.

Example

FirstnameLastnameEmail
DefaultDefaultsondef@somemail.com
PrimaryJoejoe@example.com
SuccessDoejohn@example.com
DangerMoemary@example.com
InfoDooleyjuly@example.com
WarningRefsbo@example.com
ActiveActivesonact@example.com
SecondarySecondsonsec@example.com
LightAngieangie@example.com
DarkBobo@example.com

Contextual classes that are available for use are:

ClassDescription
.table-primaryBlue: Indicates an important action
.table-successGreen: Indicates a successful or positive action
.table-dangerRed: Indicates a dangerous or potentially negative action
.table-infoLight blue: Indicates a neutral informative change or action
.table-warningOrange: Indicates a warning that might need attention
.table-activeGrey: Applies the hover color to the table row or table cell
.table-secondaryGrey: Indicates a slightly less important action
.table-lightLight grey table or table row background
.table-darkDark grey table or table row background

Table Head Colors

Table headers with a black background are added by the .thead-dark class, whereas those with a grey background are added by the .thead-light class:

Example

FirstnameLastnameEmail
JohnDoejohn@example.com
MaryMoemary@example.com
JulyDooleyjuly@example.com
FirstnameLastnameEmail
JohnDoejohn@example.com
MaryMoemary@example.com
JulyDooleyjuly@example.com

Small table

By halving the cell padding, the .table-sm class reduces the size of the table:

Example

FirstnameLastnameEmail
JohnDoejohn@example.com
MaryMoemary@example.com
JulyDooleyjuly@example.com

Responsive Tables

When the table becomes too large horizontally, the .table-responsive class adds a scrollbar to it:

Example

				
					<div class="table-responsive">
  <table class="table">
    ...
  </table>
</div>
				
			
#FirstnameLastnameAgeCityCountrySexExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample
1AnnaPitt35New YorkUSAFemaleYesYesYesYesYesYesYesYesYesYesYesYesYesYesYes

Depending on the screen width, you may also choose when the table should have a scrollbar:

ClassScreen width
.table-responsive-sm< 576px
.table-responsive-md< 768px
.table-responsive-lg< 992px
.table-responsive-xl< 1200px
.table-responsive-xxl< 1400px

Example

				
					<div class="table-responsive-sm">
  <table class="table">
    ...
  </table>
</div>
				
			
Share this Doc

BS5 Tables

Or copy link

Explore Topic