Components
Table
Example
Default table
#
First
Last
Handle
1
Mark
Otto
@mdo
2
Jacob
Thornton
@fat
3
Larry the Bird
@twitter
HTML
React
Web Component
Copy <div class= "table-responsive-lg" >
<table class= "table" >
<thead>
<tr>
<th scope= "col" > #</th>
<th scope= "col" > First</th>
<th scope= "col" > Last</th>
<th scope= "col" > Handle</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>
</div>
[**DEV**]View on React storybook
View on Web component storybook
Small table
#
First
Last
Handle
1
Mark
Otto
@mdo
2
Jacob
Thornton
@fat
3
Larry the Bird
@twitter
HTML
React
Web Component
Copy <div class= "table-responsive-lg" >
<table class= "table table-sm" >
<thead>
<tr>
<th scope= "col" > #</th>
<th scope= "col" > First</th>
<th scope= "col" > Last</th>
<th scope= "col" > Handle</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>
</div>
[**DEV**]View on React storybook
View on Web component storybook
Striped body
#
First
Last
Handle
1
Mark
Otto
@mdo
2
Jacob
Thornton
@fat
3
Larry the Bird
@twitter
HTML
React
Web Component
Copy <div class= "table-responsive-lg" >
<table class= "table table-striped" >
<thead>
<tr>
<th scope= "col" > #</th>
<th scope= "col" > First</th>
<th scope= "col" > Last</th>
<th scope= "col" > Handle</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>
</div>
[**DEV**]View on React storybook
View on Web component storybook
Bordered body
#
First
Last
Handle
1
Mark
Otto
@mdo
2
Jacob
Thornton
@fat
3
Larry the Bird
@twitter
HTML
React
Web Component
Copy <div class= "table-responsive-lg" >
<table class= "table table-bordered" >
<thead>
<tr>
<th scope= "col" > #</th>
<th scope= "col" > First</th>
<th scope= "col" > Last</th>
<th scope= "col" > Handle</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>
</div>
[**DEV**]View on React storybook
View on Web component storybook
Borderless body
#
First
Last
Handle
1
Mark
Otto
@mdo
2
Jacob
Thornton
@fat
3
Larry the Bird
@twitter
HTML
React
Web Component
Copy <div class= "table-responsive-lg" >
<table class= "table table-borderless" >
<thead>
<tr>
<th scope= "col" > #</th>
<th scope= "col" > First</th>
<th scope= "col" > Last</th>
<th scope= "col" > Handle</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>
</div>
[**DEV**]View on React storybook
View on Web component storybook
Hoverable body
#
First
Last
Handle
1
Mark
Otto
@mdo
2
Jacob
Thornton
@fat
3
Larry the Bird
@twitter
HTML
React
Web Component
Copy <div class= "table-responsive-lg" >
<table class= "table table-hover" >
<thead>
<tr>
<th scope= "col" > #</th>
<th scope= "col" > First</th>
<th scope= "col" > Last</th>
<th scope= "col" > Handle</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>
</div>
[**DEV**]View on React storybook
View on Web component storybook
Dark table
#
First
Last
Handle
1
Mark
Otto
@mdo
2
Jacob
Thornton
@fat
3
Larry the Bird
@twitter
HTML
React
Web Component
Copy <div class= "table-responsive-lg" >
<table class= "table table-dark" >
<thead>
<tr>
<th scope= "col" > #</th>
<th scope= "col" > First</th>
<th scope= "col" > Last</th>
<th scope= "col" > Handle</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>
</div>
[**DEV**]View on React storybook
View on Web component storybook
Responsive table
Across every breakpoint, use .table-responsive
for horizontally scrolling tables. Use
.table-responsive{-sm|-md|-lg|-xl|-xxl}
as needed to create responsive tables up to a particular
breakpoint.
#
First
Last
Handle
#
First
Last
Handle
#
First
Last
Handle
1
Mark
Otto
@mdo
Mark
Otto
@mdo
Mark
Otto
@mdo
Mark
Otto
@mdo
2
Jacob
Thornton
@fat
Jacob
Thornton
@fat
Jacob
Thornton
@fat
Jacob
Thornton
@fat
3
Larry the Bird
@twitter
Larry the Bird
@twitter
Larry the Bird
@twitter
Larry the Bird
@twitter
HTML
React
Web Component
Copy <div class= "table-responsive" >
<table class= "table" >
<thead>
<tr>
<th scope= "col" > #</th>
<th scope= "col" > First</th>
<th scope= "col" > Last</th>
<th scope= "col" > Handle</th>
<th scope= "col" > #</th>
<th scope= "col" > First</th>
<th scope= "col" > Last</th>
<th scope= "col" > Handle</th>
<th scope= "col" > #</th>
<th scope= "col" > First</th>
<th scope= "col" > Last</th>
<th scope= "col" > Handle</th>
</tr>
</thead>
<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>
<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>
<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 colspan= "2" > Larry the Bird</td>
<td> @twitter</td>
<td colspan= "2" > Larry the Bird</td>
<td> @twitter</td>
<td colspan= "2" > Larry the Bird</td>
<td> @twitter</td>
<td colspan= "2" > Larry the Bird</td>
<td> @twitter</td>
</tr>
</tbody>
</table>
</div>
[**DEV**]View on React storybook
View on Web component storybook
Usage guidelines
Best practices:
Information should be organised in a meaningful way, such as hierarchy or in alphabetical order.
Tables should allow user interaction so that a data display is customisable and interactive.
Tables should be easy to use, with a logical structure that makes content easy to understand.
Table total page count usually reduce after filter data, which by default return to first page in case current page is out of filtered results.
Table should be used when:
You want to show tabular information, such as statistics.
Displaying directories where content of similar nature and structure are grouped together.
Users are required to sort, search, paginate and filter data.
Table should not be used when:
There is complex data visualisation, you may want to use inforgraphics or bars and charts.
Usability guidelines
Keep tables simple
Tables are useful when displaying data and complex information. Try to use minimal visual styling to surface
information easily.
Consider mobile applications
As table rows can be long in nature, do consider if your content requires to be in a table.
Enable sorting
Do enable sorting where applicable as this will help users move through content within the table.
Behaviour
Row hover - row displays a background colour when user hovers over a row
Column hover - if sorting is enabled, an arrow icon can appear next to the column header.
Accessibility guidelines
Aria attributes
If there is an element in the user interface that serves as a label for the table, aria-labelledby
is set on the table element with a value that refers to the labelling element. Otherwise, a label is specified for the table element using aria-label
.
If the table has a caption or description, <ßcode>aria-describedby is set on the table element with a value referring to the element containing the description.
Keyboard accessibility
If the table is purely informational and has no interactive elements, it does not need to be keyboard focusable or operable. If there are interactive elements such as text links or sorting arrows, users should be able to navigate using standard keyboard controls.
Focus indicator
Ensure that any interactive element within the table is highly visible and distinct, making it stand out against the rest of the table content.
When an interactive element in the table is focused, provide a clear visual indication of focus.
Table design tokens $table-cell-padding-y : 1rem ! default ;
$table-cell-padding-x : 1rem ! default ;
$table-cell-padding-y-sm : .5rem ! default ;
$table-cell-padding-x-sm : .5rem ! default ;
$table-cell-vertical-align : top ! default ;
$table-color : $body-color ! default ;
$table-bg : transparent ! default ;
$table-accent-bg : transparent ! default ;
$table-th-font-weight : null ! default ;
$table-striped-color : $table-color ! default ;
$table-striped-bg-factor : .05 ! default ;
$table-striped-bg : rgba ( $black , $table-striped-bg-factor ) ! default ;
$table-active-color : $table-color ! default ;
$table-active-bg-factor : .1 ! default ;
$table-active-bg : rgba ( $black , $table-active-bg-factor ) ! default ;
$table-hover-color : $table-color ! default ;
$table-hover-bg-factor : .075 ! default ;
$table-hover-bg : rgba ( $black , $table-hover-bg-factor ) ! default ;
$table-border-factor : .1 ! default ;
$table-border-width : $border-width ! default ;
$table-border-color : $gray-400 ! default ;
$table-striped-order : odd ! default ;
$table-group-separator-color : currentColor ! default ;
$table-caption-color : $text-muted ! default ;
$table-bg-scale : 100% ! default ;
$table-variants : ( "primary" : shift-color ( $primary , $table-bg-scale ) ,
" secondary " : shift-color ( $secondary , $table-bg-scale ) ,
" success " : shift-color ( $success , $table-bg-scale ) ,
" info " : shift-color ( $info , $table-bg-scale ) ,
" warning " : shift-color ( $warning , $table-bg-scale ) ,
" danger " : shift-color ( $danger , $table-bg-scale ) ,
" light " : $light ,
" dark " : $dark ,
) ! default ;