Tables
Vue Bootstrap 5 Tables
Tables allow you to aggregate a huge amount of data and present it in a clear and orderly way. MDB tables provide additional benefits like responsiveness and the possibility of manipulating the table styles.
Due to the widespread use of <table>
elements across third-party widgets
like calendars and date pickers, Bootstrap’s tables are opt-in. Add the base
class MDBTable
to any <table>
, then extend with our optional
modifier classes or custom styles. All table styles are not inherited in Bootstrap, meaning
any nested tables can be styled independent from the parent.
Basic example
Using the most basic table markup, here’s how
MDBTable
-based tables look in MDB.
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Advanced example
An advanced example of the table with images, badges, buttons, and secondary texts.
Name | Title | Status | Position | Actions |
---|---|---|---|---|
![]() John Doe john.doe@gmail.com |
Software engineer IT department |
Active | Senior | |
![]() Alex Ray alex.ray@gmail.com |
Consultant Finance |
Onboarding | Junior | |
![]() Kate Hunington kate.hunington@gmail.com |
Designer UI/UX |
Awaiting | Senior |
Variants
Use contextual classes to color tables, table rows or individual cells.
Class | Heading | Heading |
---|---|---|
Default | Cell | Cell |
Primary | Cell | Cell |
Secondary | Cell | Cell |
Success | Cell | Cell |
Danger | Cell | Cell |
Warning | Cell | Cell |
Info | Cell | Cell |
Light | Cell | Cell |
Dark | Cell | Cell |
Conveying meaning to assistive technologies:
Using color to add meaning only provides a visual indication, which will not be conveyed to
users of assistive technologies – such as screen readers. Ensure that information denoted by
the color is either obvious from the content itself (e.g. the visible text), or is included
through alternative means, such as additional text hidden with the
.visually-hidden
class.
Accented tables
Striped
Use striped
prop on MDBTable
to add zebra-striping to any table
row within the <tbody>
.
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
These classes can also be added to table variants:
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Hoverable
Add hover
prop to enable a hover state on table rows within a
<tbody>
.
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
These hoverable rows can also be combined with the striped variant:
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Active tables
Highlight a table row or cell by adding a
.table-active
class.
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Table borders
Bordered
Add bordered
prop for borders on all sides of the table and cells.
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Border color utilities can be added to change colors:
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Borderless
Add borderless
prop for a table without borders.
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Small
Add sm
prop to make any MDBTable
more compact by cutting all cell
padding
in half.
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Group dividers
Add a thicker border, darker between table groups—<thead>
, <tbody>
, and <tfoot>
—with .table-group-divider
. We customize the color by adding the .table-divider-color
class. You can also customize the color on your own by changing the border-top-color (which we don’t currently provide a utility class for at this time).
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
Vertical alignment
Table cells of <thead>
are always vertical aligned to the bottom. Table
cells in <tbody>
inherit their alignment from
<MDBTable>
and are aligned to the the top by default. Use the
vertical align
classes to re-align where needed.
Heading 1 | Heading 2 | Heading 3 | Heading 4 |
---|---|---|---|
This cell inherits vertical-align: middle; from the table |
This cell inherits vertical-align: middle; from the table |
This cell inherits vertical-align: middle; from the table |
Nulla vitae elit libero, a pharetra augue. Cras mattis consectetur purus sit amet fermentum. Vestibulum id ligula porta felis euismod semper. |
This cell inherits vertical-align: bottom; from the table row |
This cell inherits vertical-align: bottom; from the table row |
This cell inherits vertical-align: bottom; from the table row |
Nulla vitae elit libero, a pharetra augue. Cras mattis consectetur purus sit amet fermentum. Vestibulum id ligula porta felis euismod semper. |
This cell inherits vertical-align: middle; from the table |
This cell inherits vertical-align: middle; from the table |
This cell is aligned to the top. | Nulla vitae elit libero, a pharetra augue. Cras mattis consectetur purus sit amet fermentum. Vestibulum id ligula porta felis euismod semper. |
Nesting
Border styles, active styles, and table variants are not inherited by nested tables.
# | First | Last | Handle | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Mark | Otto | @mdo | ||||||||||||
|
|||||||||||||||
3 | Larry | the Bird |
How nesting works
To prevent any styles from leaking to nested tables, we use the child combinator
(>
) selector in our CSS. Since we need to target all the td
s and
th
s in the thead
, tbody
, and tfoot
, our
selector would look pretty long without it. As such, we use the rather odd looking
.table > :not(caption) > * > *
selector to target all td
s
and th
s of the .table
, but none of any potential nested tables.
Note that if you add <tr>
s as direct children of a table, those
<tr>
will be wrapped in a <tbody>
by default, thus
making our selectors work as intended.
Additional examples
A few practical examples of the use of tables with typical components such as buttons, checkboxes or icons.
Checkboxes
To learn more about checkboxes read Checkbox Docs.
|
Lorem | Ipsum | Dolor |
---|---|---|---|
|
Sit | Amet | Consectetur |
|
Adipisicing | Elit | Sint |
|
Hic | Fugiat | Temporibus |
Icons
To learn more about icons read Icons Docs.
Product Detail Views | Unique Purchases | Quantity | Product Revenue | Avg. Price | |
---|---|---|---|---|---|
Value | 18,492 | 228 | 350 | $4,787.64 | $13.68 |
Percentage change | -48.8% | 14.0% | 46.4% | 29.6% | -11.5% |
Absolute change | -17,654 | 28 | 111 | $1,092.72 | $-1.78 |
Anatomy
Table head
Similar to tables and dark tables, use the modifier classes
.table-light
or .table-dark
to make <thead>
s
appear light or dark gray.
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird |
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird |
Table foot
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird | |
Footer | Footer | Footer | Footer |
Captions
A <caption>
functions like a heading for a table. It helps users with
screen readers to find a table and understand what it’s about and decide if they want to
read it.
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry the Bird |
You can also put the <caption>
on the top of the table with
captionTop
prop.
# | First | Last | Handle |
---|---|---|---|
1 | Mark | Otto | @mdo |
2 | Jacob | Thornton | @fat |
3 | Larry | the Bird |
Responsive tables
Responsive tables allow tables to be scrolled horizontally with ease. Make any table
responsive across all viewports by adding a
responsive
prop tp MDBTable
. Or, pick a maximum breakpoint with
which to have a responsive table up to by using responsive="{sm|md|lg|xl|xxl}"
.
Vertical clipping/truncation:
Responsive tables make use of overflow-y: hidden
, which clips off any content
that goes beyond the bottom or top edges of the table. In particular, this can clip off
dropdown menus and other third-party widgets.
Always responsive
Across every breakpoint, use responsive
for horizontally scrolling tables.
# | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
---|---|---|---|---|---|---|---|---|---|
1 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
2 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
3 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
Breakpoint specific
Use responsive="{sm|md|lg|xl|xxl}"
as needed to create responsive tables up
to a particular breakpoint. From that breakpoint and up, the table will behave normally
and not scroll horizontally.
These tables may appear broken until their responsive styles apply at specific viewport widths.
# | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
---|---|---|---|---|---|---|---|---|
1 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
2 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
3 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
# | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
---|---|---|---|---|---|---|---|---|
1 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
2 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
3 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
# | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
---|---|---|---|---|---|---|---|---|
1 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
2 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
3 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
# | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
---|---|---|---|---|---|---|---|---|
1 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
2 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
3 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
# | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
---|---|---|---|---|---|---|---|---|
1 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
2 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
3 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
# | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
---|---|---|---|---|---|---|---|---|
1 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
2 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
3 | Cell | Cell | Cell | Cell | Cell | Cell | Cell | Cell |
Customizing in Sass
-
The factor variables (
$table-striped-bg-factor
,$table-active-bg-factor
&$table-hover-bg-factor
) are used to determine the contrast in table variants. -
Apart from the light & dark table variants, theme colors are lightened by the
$table-bg-level
variable.
Tables - API
Import
Properties
Name | Type | Default | Description | Example |
---|---|---|---|---|
tag
|
String | 'table' |
Defines tag of the MDBTable element |
<MDBTable tag="div" />
|
variant
|
String |
|
Sets table background color. Use our color palette |
<MDBTable variant="primary" />
|
dark
|
Boolean | false |
Shorthand for setting dark theme for the table | <MDBTable dark /> |
light
|
Boolean | false |
Shorthand for setting light theme for the table | <MDBTable light /> |
border
|
Boolean | String | false |
Adds border on all elements inside the table. Add value to set color of the border |
<MDBTable border />
<MDBTable border="primary" />
|
borderless
|
Boolean | false |
Disables border on al elements inside the table. |
<MDBTable borderless />
|
striped
|
Boolean | false |
Adds zebra-striping to any table row |
<MDBTable striped />
|
hover
|
Boolean | false |
Adds hover state on table rows (rows are marked on light-grey color) | <MDBTable hover /> |
responsive
|
Boolean | String | false |
Adds table wrapper that makes table scrollable horizontally on given breakpoint. When
no breakpoint is added it makes table scrollable horizontally when screen width is
smaller than table content (under 768px). It make use of
overflow-y: hidden which clips off content that goes beyon the bottom or
top edge of the table.
|
<MDBTable responsive />
<MDBTable responsive="md" />
|
align
|
String |
|
Sets vertival alignment for table cells. Use {'top', 'middle', 'bottom'}. Top is default. |
<MDBTable align="middle" />
|
sm |
Boolean | false |
Cuts cell's padding by half | <MDBTable sm /> |
captionTop
|
Boolean | false |
Position table caption at the top of the table |
<MDBTable captionTop />
|
tableStyle
|
String |
|
Sets additional styles for the table |
<MDBTable :tableStyle="{maxHeight: 200px}" />
|
CSS variables
As part of MDB’s evolving CSS variables approach, tables now uses local CSS variables on
.table
for enhanced real-time customization. Values for the CSS variables
are set via Sass, so Sass customization is still supported, too.
SCSS variables
-
The factor variables (
$table-striped-bg-factor
,$table-active-bg-factor
&$table-hover-bg-factor
) are used to determine the contrast in table variants. -
Apart from the light & dark table variants, theme colors are lightened by the
$table-bg-level
variable.