Typography
Documentation and examples for waw framework typography, including global settings, headings, body text, lists, and more.
waw css sets basic global display, typography, and link styles. When more control is needed, check out the textual utility classes.
- Use a native font stack that selects the best font-family for each OS and device.
- For a more inclusive and accessible type scale, we use the browser’s default root font-size (typically 16px) so visitors can customize their browser defaults as needed.
- Use the $font-family-base, $font-size-base, and $line-height-base attributes as our typographic base applied to the <body>.
- Set the global link color via $link-color.
- Use $body-bg to set a background-color on the <body> (#fff by default).
These styles can be found within _reboot.scss, and the global variables are defined in _variables.scss. Make sure to set $font-size-base in rem.
Headings
All HTML headings, <h1> through <h6>, are available.
| Heading | Example |
|---|---|
| <h1></h1> | h1. waw heading |
| <h2></h2> | h2. waw heading |
| <h3></h3> | h3. waw heading |
| <h4></h4> | h4. waw heading |
| <h5></h5> | h5. waw heading |
| <h6></h6> | h6. waw heading |
- <h1>h1. waw heading</h1>
- <h2>h2. waw heading</h2>
- <h3>h3. waw heading</h3>
- <h4>h4. waw heading</h4>
- <h5>h5. waw heading</h5>
- <h6>h6. waw heading</h6>
.h1 through .h6 classes are also available, for when you want to match the font styling of a heading but cannot use the associated HTML element.
-
h1. waw heading -
h2. waw heading -
h3. waw heading -
h4. waw heading -
h5. waw heading -
h6. waw heading
HTML:
- <p class="h1">h1. waw heading</p>
- <p class="h2">h2. waw heading</p>
- <p class="h3">h3. waw heading</p>
- <p class="h4">h4. waw heading</p>
- <p class="h5">h5. waw heading</p>
- <p class="h6">h6. waw heading</p>
Customizing headings
Use the included utility classes to recreate the small secondary heading text.
Fancy display heading With faded secondary text
HTML:
- <h3>
- Fancy display heading
- <small class="text-body-secondary">With faded secondary text</small>
- </h3>
Display headings
Traditional heading elements are designed to work best in the meat of your page content. When you need a heading to stand out, consider using a display heading — a larger, slightly more opinionated heading style.
Display 1
Display 2
Display 3
Display 4
Display 5
Display 6
- <h1 class="display-1">Display 1<h1>
- <h1 class="display-2">Display 2<h1>
- <h1 class="display-3">Display 3<h1>
- <h1 class="display-4">Display 4<h1>
- <h1 class="display-5">Display 5<h1>
- <h1 class="display-6">Display 6<h1>
Display headings are configured via the $display-font-sizes Sass map and two variables, $display-font-weight and $display-line-height.
Display headings are customizable via two variables, $display-font-family and $display-font-style.
scss/_variables.scss:
- $display-font-sizes: (
- 1: 5rem,
- 2: 4.5rem,
- 3: 4rem,
- 4: 3.5rem,
- 5: 3rem,
- 6: 2.5rem
- );
- $display-font-family: null;
- $display-font-style: null;
- $display-font-weight: 300;
- $display-line-height: $headings-line-height;
Lead
Make a paragraph stand out by adding .lead.
This is a lead paragraph. It stands out from regular paragraphs.
HTML:
- <p class="lead">
- This is a lead paragraph. It stands out from regular paragraphs.
- </p>
Inline text elements
Styling for common inline HTML5 elements.
You can use the mark tag to highlight text.
This line of text is meant to be treated as deleted text.
This line of text is meant to be treated as no longer accurate.
This line of text is meant to be treated as an addition to the document.
This line of text will render as underlined.
This line of text is meant to be treated as fine print.
This line rendered as bold text.
This line rendered as italicized text.
HTML:
- <p>You can use the mark tag to <mark>highlight</mark> text.</p>
- <p><del>This line of text is meant to be treated as deleted text.</del></p>
- <p><s>This line of text is meant to be treated as no longer accurate.</s></p>
- <p><ins>This line of text is meant to be treated as an addition to the document.</ins></p>
- <p><u>This line of text will render as underlined.</u></p>
- <p><small>This line of text is meant to be treated as fine print.</small></p>
- <p><strong>This line rendered as bold text.</strong></p>
- <p><em>This line rendered as italicized text.</em></p>
Beware that those tags should be used for semantic purpose:
- <mark> represents text which is marked or highlighted for reference or notation purposes.
- <small> represents side-comments and small print, like copyright and legal text.
- <s> represents element that are no longer relevant or no longer accurate.
- <u> represents a span of inline text which should be rendered in a way that indicates that it has a non-textual annotation.
If you want to style your text, you should use the following classes instead:
- .mark will apply the same styles as <mark>
- .small will apply the same styles as <small>
- .text-decoration-underline will apply the same styles as <s>
- .text-decoration-line-through will apply the same styles as <u>
While not shown above, feel free to use <b> and <i> in HTML5. <b> is meant to highlight words or phrases without conveying additional importance, while <i> is mostly for voice, technical terms, etc.
Text utilities
Change text alignment, transform, style, weight, line-height, decoration and color with our text utilities and color utilities .
Abbreviations
Stylized implementation of HTML’s <abbr> element for abbreviations and acronyms to show the expanded version on hover. Abbreviations have a default underline and gain a help cursor to provide additional context on hover and to users of assistive technologies.
Add .initialism to an abbreviation for a slightly smaller font-size.
attr
HTML
HTML:
- <p> <abbr title="attribute">attr</abbr></p>
- <p> <abbr title="HyperText Markup Language" class="initialism">HTML</abbr></p>
Blockquotes
For quoting blocks of content from another source within your document. Wrap <blockquote class="blockquote"> around any HTML as the quote.
A well-known quote, contained in a blockquote element.
HTML:
- <blockquote class="blockquote">
- <p>A well-known quote, contained in a blockquote element.</p>
- </blockquote>
Naming a source
The HTML spec requires that blockquote attribution be placed outside the <blockquote>. When providing attribution, wrap your <blockquote> in a <figure> and use a <figcaption> or a block level element (e.g., <p>) with the .blockquote-footer class. Be sure to wrap the name of the source work in <cite> as well.
A well-known quote, contained in a blockquote element.
HTML:
- <figure>
- <blockquote class="blockquote">
- <p>A well-known quote, contained in a blockquote element.</p>
- </blockquote>
- <figcaption class="blockquote-footer">
- - Someone famous in <cite title="Source Title">Source Title</cite>
- </figcaption>
- </figure>
Alignment
Use text utilities as needed to change the alignment of your blockquote.
A well-known quote, contained in a blockquote element.
HTML:
- <figure class="text-center">
- <blockquote class="blockquote">
- <p>A well-known quote, contained in a blockquote element.</p>
- </blockquote>
- <figcaption class="blockquote-footer">
- - Someone famous in <cite title="Source Title">Source Title</cite>
- </figcaption>
- </figure>
A well-known quote, contained in a blockquote element.
HTML:
- <figure class="text-end">
- <blockquote class="blockquote">
- <p>A well-known quote, contained in a blockquote element.</p>
- </blockquote>
- <figcaption class="blockquote-footer">
- Someone famous in <cite title="Source Title">Source Title</cite>
- </figcaption>
- </figure>
Lists
Unstyled
Remove the default list-style and left margin on list items (immediate children only). This only applies to immediate children list items, meaning you will need to add the class for any nested lists as well.
- This is a list.
- It appears completely unstyled.
- Structurally, it's still a list.
- However, this style only applies to immediate child elements.
- Nested lists:
- are unaffected by this style
- will still show a bullet
- and have appropriate left margin
- This may still come in handy in some situations.
HTML:
- <ul class="list-unstyled">
- <li>This is a list.</li>
- <li>It appears completely unstyled.</li>
- <li>Structurally, it's still a list.</li>
- <li>However, this style only applies to immediate child elements.</li>
- <li>Nested lists:
- <ul>
- <li>are unaffected by this style</li>
- <li>will still show a bullet</li>
- <li>and have appropriate left margin</li>
- </ul>
- </li>
- <li>This may still come in handy in some situations.</li>
- </ul>
Inline
Remove a list’s bullets and apply some light margin with a combination of two classes, .list-inline and .list-inline-item.
- This is a list item.
- And another one.
- But they're displayed inline.
HTML:
- <ul class="list-inline">
- <li class="list-inline-item">This is a list item.</li>
- <li class="list-inline-item">And another one.</li>
- <li class="list-inline-item">But they're displayed inline.</li>
- </ul>
Description list alignment
Align terms and descriptions horizontally by using our grid system’s predefined classes (or semantic mixins). For longer terms, you can optionally add a .text-truncate class to truncate the text with an ellipsis.
- Description lists
- A description list is perfect for defining terms.
- Term
-
Definition for the term.
And some more placeholder definition text.
- Another term
- This definition is short, so no extra paragraphs or anything.
- Truncated term is truncated
- This can be useful when space is tight. Adds an ellipsis at the end.
- Nesting
-
- Nested definition list
- I heard you like definition lists. Let me put a definition list inside your definition list.
HTML:
- <dl class="row">
- <dt class="col-sm-3">Description lists</dt>
- <dd class="col-sm-9">A description list is perfect for defining terms.</dd>
- <dt class="col-sm-3">Term</dt>
- <dd class="col-sm-9">
- <p>Definition for the term.</p>
- <p>And some more placeholder definition text.</p>
- </dd>
- <dt class="col-sm-3">Another term</dt>
- <dd class="col-sm-9">This definition is short, so no extra paragraphs or anything.</dd>
- <dt class="col-sm-3 text-truncate">Truncated term is truncated</dt>
- <dd class="col-sm-9">This can be useful when space is tight. Adds an ellipsis at the end.</dd>
- <dt class="col-sm-3">Nesting</dt>
- <dd class="col-sm-9">
- <dl class="row">
- <dt class="col-sm-4">Nested definition list</dt>
- <dd class="col-sm-8">I heard you like definition lists. Let me put a definition list inside your definition list.</dd>
- </dl>
- </dd>
- </dl>
Responsive font sizes
In Bootstrap 5, we’ve enabled responsive font sizes by default, allowing text to scale more naturally across device and viewport sizes. Have a look at the RFS page to find out how this works.
CSS
Sass variables
Headings have some dedicated variables for sizing and spacing.
scss/_variables.scss:
- $headings-margin-bottom: $spacer * .5;
- $headings-font-family: null;
- $headings-font-style: null;
- $headings-font-weight: 500;
- $headings-line-height: 1.2;
- $headings-color: inherit;
Miscellaneous typography elements covered here and in Reboot also have dedicated variables.
scss/_variables.scss:
- $lead-font-size: $font-size-base * 1.25;
- $lead-font-weight: 300;
- $small-font-size: .875em;
- $sub-sup-font-size: .75em;
- // fusv-disable
- $text-muted: var(--#{$prefix}secondary-color); // Deprecated in 5.3.0
- // fusv-enable
- $initialism-font-size: $small-font-size;
- $blockquote-margin-y: $spacer;
- $blockquote-font-size: $font-size-base * 1.25;
- $blockquote-footer-color: $gray-600;
- $blockquote-footer-font-size: $small-font-size;
- $hr-margin-y: $spacer;
- $hr-color: inherit;
- // fusv-disable
- $hr-bg-color: null; // Deprecated in v5.2.0
- $hr-height: null; // Deprecated in v5.2.0
- // fusv-enable
- $hr-border-color: null; // Allows for inherited colors
- $hr-border-width: var(--#{$prefix}border-width);
- $hr-opacity: .25;
- $vr-border-width: var(--#{$prefix}border-width);
- $legend-margin-bottom: .5rem;
- $legend-font-size: 1.5rem;
- $legend-font-weight: null;
- $dt-font-weight: $font-weight-bold;
- $list-inline-padding: .5rem;
- $mark-padding: .1875em;
- $mark-color: $body-color;
- $mark-bg: $yellow-100;
Sass mixins
There are no dedicated mixins for typography, but Bootstrap does use Responsive Font Sizing (RFS).
Images
Documentation and examples for opting images into responsive behavior (so they never become wider than their parent) and add lightweight styles to them — all via classes.
Responsive images
Images in waw framework are made responsive with .img-fluid. This applies max-width: 100%; and height: auto; to the image so that it scales with the parent width.
HTML:
<img src="..." class="img-fluid" alt="...">
Image thumbnails
In addition to our border-radius utilities, you can use .img-thumbnail to give an image a rounded 1px border appearance.
HTML:
<img src="..." class="img-thumbnail" alt="...">
Aligning images
Align images with the helper float classes or text alignment classes. block-level images can be centered using the .mx-auto margin utility class.
HTML:
- <img src="..." class="rounded float-start" alt="...">
- <img src="..." class="rounded float-end" alt="...">
HTML:
- <img src="..." class="rounded mx-auto d-block" alt="...">
HTML:
- <div class="text-center">
- <img src="..." class="rounded" alt="...">
- </div>
Picture
If you are using the <picture> element to specify multiple <source> elements for a specific <img>, make sure to add the .img-* classes to the <img> and not to the <picture> tag.
- <picture>
- <source srcset="..." type="image/svg+xml">
- <img src="..." class="img-fluid img-thumbnail" alt="...">
- </picture>
CSS
Sass variables
Variables are available for image thumbnails.
scss/_variables.scss
- $thumbnail-padding: .25rem;
- $thumbnail-bg: var(--#{$prefix}body-bg);
- $thumbnail-border-width: var(--#{$prefix}border-width);
- $thumbnail-border-color: var(--#{$prefix}border-color);
- $thumbnail-border-radius: var(--#{$prefix}border-radius);
- $thumbnail-box-shadow: var(--#{$prefix}box-shadow-sm);
Tables
Documentation and examples for opt-in styling of tables.
Overview
Due to the widespread use of <table> elements across third-party widgets like calendars and date pickers, waw tables are opt-in. Add the base class .table to any <table>, then extend with our optional modifier classes or custom styles. All table styles are not inherited in waw, meaning any nested tables can be styled independent from the parent.
Using the most basic table markup, here’s how .table-based tables look in waw.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Larry the Bird | ||
- <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>
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 |
- <table class="table">
- <thead>
- <tr>
- <th scope="col">Class</th>
- <th scope="col">Heading</th>
- <th scope="col">Heading</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <th scope="row">Default</th>
- <td>Cell</td>
- <td>Cell</td>
- </tr>
- <tr class="table-primary">
- <th scope="row">Primary</th>
- <td>Cell</td>
- <td>Cell</td>
- </tr>
- <tr class="table-secondary">
- <th scope="row">Secondary</th>
- <td>Cell</td>
- <td>Cell</td>
- </tr>
- <tr class="table-success">
- <th scope="row">Success</th>
- <td>Cell</td>
- <td>Cell</td>
- </tr>
- <tr class="table-danger">
- <th scope="row">Danger</th>
- <td>Cell</td>
- <td>Cell</td>
- </tr>
- <tr class="table-warning">
- <th scope="row">Warning</th>
- <td>Cell</td>
- <td>Cell</td>
- </tr>
- <tr class="table-info">
- <th scope="row">Info</th>
- <td>Cell</td>
- <td>Cell</td>
- </tr>
- <tr class="table-light">
- <th scope="row">Light</th>
- <td>Cell</td>
- <td>Cell</td>
- </tr>
- <tr class="table-dark">
- <th scope="row">Dark</th>
- <td>Cell</td>
- <td>Cell</td>
- </tr>
- </tbody>
- </table>
Accented tables
Striped rows
Use .table-striped 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 | ||
- <table class="table striped-light">
- ...
- </table>
Striped columns
Use .table-striped-columns to add zebra-striping to any table column.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Larry the Bird | ||
- <table class="table striped-columns-light">
- ...
- </table>
These classes can also be added to table variants:
| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Larry the Bird | ||
- <table class="table table-dark striped-light">
- ...
- </table>
| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Larry the Bird | ||
- <table class="table table-dark striped-columns-light">
- ...
- </table>
| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Larry the Bird | ||
- <table class="table table-warning striped-dark">
- ...
- </table>
| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Larry the Bird | ||
- <table class="table table-warning striped-columns-dark">
- ...
- </table>
Hoverable rows
Add .table-hover 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 |
- <table class="table table-hover">
- ...
- </table>
| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Larry the Bird |
- <table class="table table-light table-hover">
- ...
- </table>
| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Larry the Bird |
- <table class="table striped-light table-hover">
- ...
- </table>
Active tables
Highlight a table row or cell by adding a .table-active-light or .table-active-dark class.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Larry the Bird | ||
- <table class="table">
- <thead>
- ...
- </thead>
- <tbody>
- <tr class="table-active-light">
- ...
- </tr>
- <tr>
- ...
- </tr>
- <tr>
- <th scope="row">3</th>
- <td colspan="2" class="table-active-light">Larry the Bird</td>
- <td>@twitter</td>
- </tr>
- </tbody>
- </table>
| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Larry the Bird | ||
- <table class="table table-light">
- <thead>
- ...
- </thead>
- <tbody>
- <tr class="table-active-dark">
- ...
- </tr>
- <tr>
- ...
- </tr>
- <tr>
- <th scope="row">3</th>
- <td colspan="2" class="table-active-dark">Larry the Bird</td>
- <td>@twitter</td>
- </tr>
- </tbody>
- </table>
For the accented tables (striped rows, striped columns, hoverable rows, and active tables), we used some techniques to make these effects work for all our table variants:
- We start by setting the background of a table cell with the --bs-table-bg custom property. All table variants then set that custom property to colorize the table cells. This way, we don’t get into trouble if semi-transparent colors are used as table backgrounds.
- Then we add an inset box shadow on the table cells with box-shadow: inset 0 0 0 9999px var(--bs-table-bg-state, var(--bs-table-bg-type, var(--bs-table-accent-bg))); to layer on top of any specified background-color. It uses custom cascade to override the box-shadow, regardless the CSS specificity. Because we use a huge spread and no blur, the color will be monotone. Since --bs-table-accent-bg is set to transparent by default, we don’t have a default box shadow.
- When either .table-striped, .table-striped-columns, .table-hover or .table-active classes are added, either --bs-table-bg-type or --bs-table-bg-state (by default set to initial) are set to a semitransparent color (--bs-table-striped-bg, --bs-table-active-bg or --bs-table-hover-bg) to colorize the background and override default --bs-table-accent-bg.
- For each table variant, we generate a --bs-table-accent-bg color with the highest contrast depending on that color. For example, the accent color for .table-primary is darker while .table-dark has a lighter accent color.
- Text and border colors are generated the same way, and their colors are inherited by default.
Behind the scenes it looks like this:
Table borders
Bordered tables
Add .table-bordered 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 | ||
- <table class="table table-bordered">
- ...
- </table>
Border color utilities can be added to change colors:
| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Larry the Bird | ||
- <table class="table table-bordered border-primary">
- ...
- </table>
Tables without borders
Add .table-borderless for a table without borders.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Larry the Bird | ||
- <table class="table table-borderless">
- ...
- </table>
Border color utilities can be added to change colors:
| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Larry the Bird | ||
- <table class="table table-light table-borderless">
- ...
- </table>
Small tables
Add .table-sm to make any .table more compact by cutting all cell padding in half.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Larry the Bird | ||
- <table class="table table-sm">
- ...
- </table>
| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Larry the Bird | ||
- <table class="table table-light table-sm">
- ...
- </table>
Table group dividers
Add a thicker border, darker between table groups - <thead>, <tbody> and <tfoot> - with .table-group-divider. Customize the color 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 | ||
HTML:
- <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 class="table-group-divider">
- <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>
Vertical alignment
Table cells of <thead> are always vertical aligned to the bottom. Table cells in <tbody> inherit their alignment from <table> and are aligned to 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 | This here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells. |
| 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 | This here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells. |
| 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. | This here is some placeholder text, intended to take up quite a bit of vertical space, to demonstrate how the vertical alignment works in the preceding cells. |
HTML:
- <table class="table align-middle">
- <thead>
- <tr>
- <th scope="col" class="w-25">Heading 1</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- ...
- </tr>
- <tr class="align-bottom">
- ...
- </tr>
- <tr>
- <td>...</td>
- <td>...</td>
- <td class="align-top">This cell is aligned to the top.</td>
- <td>...</td>
- </tr>
- </tbody>
- </table>
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 | |||||||||||||
HTML:
- <table class="table table-striped table-bordered">
- <thead>
- ...
- </thead>
- <tbody>
- <tr class="table-active-light">
- ...
- </tr>
- <tr>
- <td colspan="4">
- <table class="table">
- ...
- </table>
- </td>
- </tr>
- <tr class="table-active-light">
- ...
- </tr>
- </tbody>
- </table>
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 tds and ths 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 tds and ths 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.
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 |
- <table class="table">
- <thead class="table-light">
- ...
- </thead>
- <tbody>
- ...
- </tbody>
- </table>
| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Larry the Bird | ||
- <table class="table">
- <thead class="table-dark">
- ...
- </thead>
- <tbody>
- ...
- </tbody>
- </table>
Table foot
| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Larry | the Bird | |
| Footer | Footer | Footer | Footer |
- <table class="table">
- <thead>
- ...
- </thead>
- <tbody>
- ...
- </tbody>
- <tfoot>
- ...
- </tfoot>
- </table>
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 | ||
- <table class="table caption-bottom">
- <caption>List of users</caption>
- <thead>
- ...
- </thead>
- <tbody>
- ...
- </tbody>
- </table>
You can also put the <caption> on the top of the table with .caption-top.
| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Larry | the Bird |
HTML:
- <table class="table caption-top">
- <caption>List of users</caption>
- <thead>
- ...
- </thead>
- <tbody>
- ...
- </tbody>
- </table>
Responsive tables
Responsive tables allow tables to be scrolled horizontally with ease. Make any table responsive across all viewports by wrapping a .table with .hscroll. Or, pick a maximum breakpoint with which to have a responsive table up to by using ..hscroll{-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 .hscroll 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 |
- <div class="hscroll">
- <table class="table">
- ...
- </table>
- </div>
Breakpoint specific
Use .hscroll{-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 |
- <div class="hscroll">
- <table class="table">
- ...
- </table>
- </div>
- <div class="hscroll-sm">
- <table class="table">
- ...
- </table>
- </div>
- <div class="hscroll-md">
- <table class="table">
- ...
- </table>
- </div>
- <div class="hscroll-lg">
- <table class="table">
- ...
- </table>
- </div>
- <div class="hscroll-xl">
- <table class="table">
- ...
- </table>
- </div>
- <div class="hscroll-xxl">
- <table class="table">
- ...
- </table>
- </div>
CSS
Sass variables
scss/_variables.scss
- $table-cell-padding-y: .5rem;
- $table-cell-padding-x: .5rem;
- $table-cell-padding-y-sm: .25rem;
- $table-cell-padding-x-sm: .25rem;
- $table-cell-vertical-align: top;
- $table-color: var(--#{$prefix}emphasis-color);
- $table-bg: var(--#{$prefix}body-bg);
- $table-accent-bg: transparent;
- $table-th-font-weight: null;
- $table-striped-color: $table-color;
- $table-striped-bg-factor: .05;
- $table-striped-bg: rgba(var(--#{$prefix}emphasis-color-rgb), $table-striped-bg-factor);
- $table-active-color: $table-color;
- $table-active-bg-factor: .1;
- $table-active-bg: rgba(var(--#{$prefix}emphasis-color-rgb), $table-active-bg-factor);
- $table-hover-color: $table-color;
- $table-hover-bg-factor: .075;
- $table-hover-bg: rgba(var(--#{$prefix}emphasis-color-rgb), $table-hover-bg-factor);
- $table-border-factor: .2;
- $table-border-width: var(--#{$prefix}border-width);
- $table-border-color: var(--#{$prefix}border-color);
- $table-striped-order: odd;
- $table-striped-columns-order: even;
- $table-group-separator-color: currentcolor;
- $table-caption-color: var(--#{$prefix}secondary-color);
- $table-bg-scale: -80%;
Sass loops
scss/_variables.scss
- $table-variants: (
- "primary": shift-color($primary, $table-bg-scale),
- "secondary": shift-color($secondary, $table-bg-scale),
- "success": shift-color($success, $table-bg-scale),
- $table-cell-vertical-align: top;
- "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,
- );
- 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-scale variable.