Typography
Headings
Example body text
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec metus quam, rutrum sit amet euismod ac, bibendum ac ligula.
This text is intended to be treated as fine print. It is wrapped in the <small> element.
The following snippet of text is rendered as italicized text.
The following snippet of text is wrapped in the <b> element, rendered as bold text.
The following snippet of text is wrapped in the <strong> element, rendered as bolder text.
An abbreviation of the word attribute is attr.
This is a lead paragraph, class: .lead. It stands out from regular paragraphs.
Contextual colors & emojis
âšī¸ Text Info, class: text-info. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
â Text Success, class: text-success. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
â ī¸ Text Warning, class: text-warning. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
â Text Danger, class: text-danger. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
đ Text Muted, class: text-muted. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Use the <mark> element to highlight text.
Content columns and drop caps
The columns below are created from a single paragraph with the class 'columns3'. It is possible to create up to five columns from a single paragraph ('columns2', etc.). Using CSS classes instead of HTML, to split a paragraph into columns benefits semantics, SEO and accessibility. On small screens (< 768px), the paragraph is displayed in a single column.
A drop cap can be created by adding the class 'dropcap' to a paragraph.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec metus quam, rutrum sit amet euismod ac, bibendum ac ligula. Nam sit amet turpis laoreet, suscipit nulla in, convallis erat. Praesent sit amet odio non urna pharetra sagittis eu sed turpis. Praesent pulvinar metus sollicitudin velit aliquam, nec interdum augue tempus. Aliquam a viverra orci. Phasellus a rhoncus elit. Morbi sed sollicitudin mi. Curabitur eleifend auctor justo in blandit. Etiam at velit fermentum erat pellentesque accumsan id id diam. Pellentesque tincidunt enim ante. Cras ac leo ex.
Blockquote
For quoting blocks of content from another source within your document, wrap <blockquote> element around any HTML as the quote.
The HTML specification requires that a blockquote's attribution be placed outside the <blockquote> element. To provide attribution, add a paragraph <p> with the attribution class, immediately after the blockquote. Include the title of the source work in a <cite> element.
đđđ đđđđ đ đđ đđđĢđđđđđđą đđđđĢđđđą đđĢđđđđđđ đ đđđ¨đđ đđđđđđđą đđĢđđđđ đđđđđ đđđĢđĢđđą đđđđ°đđđđą đđđđđą đđđđ đđĢđđđđđąđđ đđĢđđ¯đą đđđĢđđđą đđ đđĢđđĢđđ đ°đđđđ đđđđđąđąđđ đđđĢđđđđđą đ đđđąđ đđđđą đ đđĢđđđđ đ°đđđĢđ đđđą đđ đđ đĢđ đđĢđđĢđ đđđđąđĢđđđđ đđĢđđąđđđđ đđĢđđđđđđą đđ đđđđđą đđđđĢđđ đđđ đđđđą đđđđĢđĢđđđą đđą đđĢ đąđ°đđ đđ đđđđđ đđĢđđđ đąđđđđ đđ đđđđđąđ°đđ đĢđđĢđđđą đđđ đđđđą đđđđą đđą đđđđ đ°đđĢđđą đđđą đđđđąđđ đđđ đąđĢđđđđ đđĢđąđ đđđđđ đđĢđđđđđđ đđ đĢđđđ
Homer, Iliad in Linear B.
Lists
For a list without list markers (Un-styled), add the 'list-unstyled' class to the top <ul> element.
Unordered
- Cras justo odio
- Dapibus ac facilisis in
- Morbi leo risus
- Cras justo odio
- Dapibus ac facilisis in
- Morbi leo risus
- Cras justo odio
- Dapibus ac facilisis in
- Morbi leo risus
Ordered
- Cras justo odio
- Dapibus ac facilisis in
- Morbi leo risus
- Cras justo odio
- Dapibus ac facilisis in
- Morbi leo risus
- Cras justo odio
- Dapibus ac facilisis in
- Morbi leo risus
Unstyled
- Cras justo odio
- Dapibus ac facilisis in
- Morbi leo risus
- Cras justo odio
- Dapibus ac facilisis in
- Morbi leo risus
- Cras justo odio
- Dapibus ac facilisis in
- Morbi leo risus
Images
Predefined classes are available for images, just add the relevant class to the image tag <img>. The image element can be "standalone", inside a <picture> element or inside a <figure> element.
Shadowed Image:
'shadowed-img'
Bordered Image:
'bordered-img'
Rounded Image:
'rounded-img'
Tables
Add the 'table' class to all tables, then add the appropriate class for the desired style.
Note: The 'table-shadowed' class works only when the 'table-bordered' class is also applied.
Stripped
Added class: 'table-stripped'
| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Alice | Cooper | |
| 4 | James | Anderson | @ms |
| 5 | Camila | Lynch | @zoo |
| 6 | Lucy | Brown | @w3c |
Stripped, Hover, Bordered & Shadowed
Added classes: 'table-stripped', 'table-hover', 'table-bordered', 'table-shadowed'.
Select a table style| # | First | Last | Handle |
|---|---|---|---|
| 1 | Mark | Otto | @mdo |
| 2 | Jacob | Thornton | @fat |
| 3 | Alice | Cooper | |
| 4 | James | Anderson | @ms |
| 5 | Camila | Lynch | @zoo |
| 6 | Lucy | Brown | @w3c |
Contextual Classes
To apply a contextual style to a table or row, add the appropriate class, such as 'table-primary', to the <table> or <tr> element.
| Context | First | Last | Handle |
|---|---|---|---|
| Primary | Chloe | Brooks | @bank |
| Secondary | Alexa | Grand | @bank |
| Info | Mark | Otto | @ufo |
| Success | Jacob | Thornton | @fat |
| Warning | Alice | Cooper | |
| Danger | James | Anderson | @ms |
| Light | Camila | Lynch | @zoo |
| Dark | Lucy | Brown | @w3c |
Forms
Simple Form
| Classes | |
|---|---|
| input | form-control |
| label | form-label |
| Submit | btn btn-primary |
| Reset | btn btn-light |
Wrap the password input in a <div> element with the 'data-password' attribute to add an emoji to show or hide the password, and add the following JavaScript.
document.querySelectorAll('div[data-password]').forEach(div => {
div.addEventListener('click', event => {
const input = div.querySelector('input');
if (!input) return;
const rect = div.getBoundingClientRect();
if (event.clientX < rect.right - 50) return;
const visible = input.type === 'password';
input.type = visible ? 'text' : 'password';
div.classList.toggle('password-visible', visible);
}); });
Simple form example:
<form>
<div>
<label for="inputEmail1" class="form-label">Email address</label>
<input type="email" class="form-control" id="inputEmail1">
</div>
<div data-password>
<label for="inputPassword1" class="form-label">Password</label>
<input type="password" class="form-control" id="inputPassword1">
</div>
<div>
<button type="submit" class="btn btn-primary">Submit</button>
<button type="reset" class="btn btn-light">Reset</button>
</div>
</form>
Read Only
Input Group
With Text
Grouped elements: span + input + spanWith Button
Grouped elements: input + buttonWith Radio Input
Grouped elements: div.input-group-text.primary-background(input[radio]) + input[text]| Step | Element | Classes |
|---|---|---|
| 1 | Wrap the input and the other grouped element(s) in a <div class="input-group">. | |
| 2 | Add a class to each grouped element: | |
| 3 | span | input-group-text |
| 4 | button | btn btn-primary |
| 5 | radio | form-check-input |
Form using validation with tooltips example:
<form class="needs-validation" action=" " method=" " novalidate>
... ...
<div class="position-relative">
<label for="validation02" class="form-label">First name</label>
<input type="text" class="form-control" id="validation02" value=" " required>
<div class="valid-tooltip">Valid</div>
<div class="invalid-tooltip">Enter a First Name</div>
</div>
... ...
</form>
Validation
With messages (optional)
With Tooltips
(function () { 'use strict';
document.querySelectorAll('.needs-validation').forEach(form => {
const fields = form.querySelectorAll('input, select, textarea'),
messages = ['valid-submit-feedback','invalid-submit-feedback',
'valid-submit-tooltip','invalid-submit-tooltip'].map(c => form.querySelector('.' + c)),
hide = () => messages.forEach(m => { if (m) m.style.display = 'none'; }),
check = f => {
f.classList.toggle('is-valid', f.checkValidity());
f.classList.toggle('is-invalid', !f.checkValidity()); };
fields.forEach(f => {
f.addEventListener('input', () => { check(f); hide(); });
f.addEventListener('change', () => { check(f); hide(); });
f.addEventListener('blur', () => check(f)); });
form.addEventListener('submit', e => {
const valid = form.checkValidity();
if (!valid) { e.preventDefault(); e.stopPropagation(); }
form.classList.add('was-validated');
messages.forEach((m, i) => {
if (m) m.style.display = (i % 2 === (valid ? 0 : 1)) ? 'block' : 'none'; }); });
form.addEventListener('reset', () => {
form.classList.remove('was-validated');
fields.forEach(f => f.classList.remove('is-valid', 'is-invalid'));
hide(); });
}); })();
Form using validation with messages example:
<form class="needs-validation" action=" " method=" " novalidate>
... ...
<div>
<label for="validation01" class="form-label">First name</label>
<input type="text" class="form-control" id="validation01" value=" " required>
<div class="invalid-feedback">Enter a First Name.</div>
</div>
... ...
</form>
Textarea
Setup steps for form validation |
||
|---|---|---|
| 1 | Add the 'novalidate' attribute to the form. | |
| 2 | Add the 'needs-validation' class to the form. | |
| With messages | With tooltips | |
| 3 | For invalid input, add a <div> below the input with the class 'invalid-feedback', containing the warning message. | For invalid input, add a <div> below the input with the class 'invalid-tooltip', containing the warning message. |
| 4 | For valid input add a <div> below the input with the class 'valid-tooltip', containing the confirmation message. | |
| 5 | Add the JavaScript to prevent the form from being submitted when it contains invalid input and also to show or hide the validation feedback. | |
Selection controls
Checkbox
Secondary, info, success, warning, danger, light, dark.
Radio
Secondary, info, success, warning, danger, light, dark.
Range
Setup steps for selection controls (group 1)
| Step | |||
|---|---|---|---|
| 1 | Wrap the input and the label in a <div class="form-check">. | ||
| 2 | Add classes to the input and label | ||
| Tag | Checkboxes & Radios | Ranges | |
| input | form-check-input | form-range | |
| label | form-check-label | form-label | |
| 3 | For contextual controls add one of these classes to the input element, 'secondary', 'info', 'success', warning', 'danger', 'light' & 'black'. | ||
| 4 | Range type | Added class on "input" element | |
| Increase | increase | ||
| Balance | balance | ||
| Scale | scale | ||
| 5 | For a range control of type Scale, add the following JavaScript to display the selected value in a tooltip. | ||
JavaScript to display the scale value
document.querySelectorAll(".form-scale").forEach(function(wrapper) {
var slider = wrapper.querySelector(".scale");
var output = wrapper.querySelector(".range-tooltip");
function updateScale() {
output.textContent = slider.value;
var min = Number(slider.min || 0);
var max = Number(slider.max || 100);
var percent = max === min ? 0 :
(Number(slider.value) - min) / (max - min);
output.style.left = (percent * 100) + "%"; }
slider.addEventListener("input", function() {
updateScale();
output.style.display = "block"; });
slider.addEventListener("pointerdown", function() {
updateScale();
output.style.display = "block"; });
slider.addEventListener("focus", function() {
updateScale();
output.style.display = "block"; });
slider.addEventListener("blur", function() {
output.style.display = "none"; });
});
<div class="form-check">
<input class="form-check-input secondary" type="radio" name="flexRadioDefault" id="flexRadioDefault1">
<label class="form-check-label" for="flexRadioDefault1">Default radio</label>
</div>
Select control
Select a context style ExampleMultiselect control
Select a context style ExampleInline select
Select a context style ExampleSetup steps for selection controls (group 2)
| Step | |||
|---|---|---|---|
| 1 | Add the class 'form-select' to the 'select' element. | ||
| 2 | Add a contextual class 'control-variant' to the 'select' element, where variant is one of the following: secondary, info, success, warning, danger, light, dark. | ||
| 2 | For an Inline Select, add the class 'inline' to the 'select' element and if needed, one of the contextual classes listed above. | ||
| Default select: | | |
| Multiselect: | | |
| Inline select: | |
Toggles (Switches)
Checkbox toggle
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="switch01">
<label class="form-check-label" for="switch01">Unchecked checkbox</label>
</div>
Radio toggle group
<div class="form-check form-switch">
<input id="flexRadio1" class="form-check-input" type="radio" name="radioGroup01">
<label class="form-check-label" for="flexRadio1">Radio One</label>
</div>
<div class="form-check form-switch">
<input id="flexRadio2" class="form-check-input toggle-info" type="radio" name="radioGroup01">
<label class="form-check-label" for="flexRadio2">Radio Two Info</label>
</div>
...
Radio vertical toggle
<div class="radio-toggle">
<div class="form-check">
<input class="form-check-input" type="radio" name="radioVertical" id="radioOne">
<label class="form-check-label" for="radioOne">Radio One</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="radioVertical" id="radioTwo">
<label class="form-check-label" for="radioTwo">Radio Two</label>
</div>
...
</div>
Contextual toggles
Input element contextual classes: 'toggle-variant'.
Buttons
Toggles (Buttons)
Checkbox button
Radio button
Radio vertical group
Wrap the checkbox or radio inputs and their labels in a <div> with the class 'btn-group' for horizontal groups, or 'btn-group-vertical' for vertical groups, also add role="group". Add the class 'btn-check' to each input and the classes 'btn btn-outline-primary' to each label. All inputs within a group must share the same name attribute.
Example of horizontal checkbox button group:
<div class="btn-group" role="group" aria-label="Checkbox button toggle group">
<input type="checkbox" class="btn-check" id="btncheck1" autocomplete="off">
<label class="btn btn-outline-primary" for="btncheck1">One</label>
<input type="checkbox" class="btn-check" id="btncheck2" autocomplete="off">
<label class="btn btn-outline-primary" for="btncheck2">Two</label>
...
</div>
Contextual buttons
Solid background
Outlined
For a contextual solid button, add the classes 'btn btn-variant'. For a contextual outline button, add the classes 'btn btn-outline-variant'. In both cases, replace variant with one of the following: 'primary', 'secondary', 'success', 'info', 'warning', 'danger', 'light' or 'dark'.
Contextual messages
Inline messages (Alerts)
Create inline "contextual messages" by wrapping each message in a <div> with the classes 'alert' and 'alert-variant', where variant is one of the following: 'primary', 'secondary', 'info', 'success', 'warning', 'danger', 'light', or 'dark'.
HTML example for "floated messages"
<!-- the button -->
<button popovertarget="myAlert" class="btn btn-primary">Show toast</button>
<!-- the floated message -->
<div id="myAlert" class="floated-alert" role="alert" popover>
<p class="alert alert-info">Hello! This is a floated alert. <button class="btn-close" popovertarget="myAlert" popovertargetaction="hide" aria-label="Close"></button></p>
</div>
HTML example for "adjacent floated messages"
<!-- the button -->
<button popovertarget="posAlert" class="btn btn-primary" style="--anchor-name: --message-name;">Show toast next to me</button>
<!-- the floated message -->
<div id="posAlert" class="alert-positioned" role="alert" popover>
<p class="alert alert-info">Hello! This is a floated alert. <button class="btn-close" popovertarget="posAlert" popovertargetaction="hide" aria-label="Close"></button></p>
</div>
Floated messages (Toasts)
- Link styled button:
- Use this JavaScript to display an alert by targeting its ID:
document.getElementById('my-alert').showPopover(); - Link styled button:
Hello! This is a floated alert.
Closes by clicking its trigger button again or the close (x) button.
Hello! This is a floated alert.
The "floated messages" are hidden and can be shown using a standard button, a button styled to look like a link (as shown above), or a JavaScript trigger (also shown above) that can be included in any JavaScript script.
There are two types of "floated messages", one that is always displayed in the bottom-right corner of the browser window, and another that is displayed near the triggering button, at the top center by default.
The button that opens the "floated message" must reference the message's id (popovertarget="theID") and have the classes: btn and btn-variant, where variant is one of the following: 'primary', 'secondary', 'info', 'success', 'warning', 'danger', 'light', 'dark' or 'link'.
The button that opens a "floated message" positioned next to the button must also reference the message's id and have the same classes, plus the following style attribute: style="--anchor-name: message-one;". Replace 'message-one' with a unique name, such as message-two, for each additional button.
"Floated messages" must be placed inside a paragraph element, <p class="alert alert-variant">. The paragraph must be wrapped in a <div> with an 'id' that the button will reference. The div must also have the following attributes exactly as shown:
<div id="anyID" class="alert-positioned" role="alert" popover>.
The "close" button (x) at the end of the "floated message" must have the following attributes:
<button class="btn-close" popovertarget="theID" popovertargetaction="hide" aria-label="Close"></button>.
The "floated messages" can be closed by clicking anywhere outside them in the browser window. If this behaviour is not desired, they can be closed only by clicking their own close button or the button that opened them. To achieve this, add the attribute 'popover="manual"' to the popover <div>.
Badges
On headings
A Heading with an Emoji Badge
A Heading with a Text Badge
Example of a heading with a badge
<h4 class="badge-text badge-info" style="--badge-text: 'NEW story';">A Heading with a Text Badge</h4>
Elements with counter
You have new messages
Normally, a counter is updated using JavaScript:
document.getElementById('myID').style.setProperty('--badge-text', `'${counter}'`);
14 emojis to use as badges
Badges are supported on the following elements: heading, button, span, div, a, figure, picture, table, ul, and ol. There are two types of badges text and emoji. To create text badges use the classes 'badge-text', and 'badge-variant' where 'variant' is one of the following: 'primary', 'secondary', 'info', 'success', 'warning', 'danger', 'light' or 'dark'.
To specify the badge text, use the following inline style: style="--badge-text: 'The Text Here';".
To use a text badge (class: badge-text) as a counter, JavaScript or another method is required to update its value dynamically. Use the inline style style="--badge-text: ' ';", where the two non-breaking spaces are a placeholder for the number that will be updated. For an unspecified counter, use the two non-breaking spaces to display an empty badge.
To use one of the 14 emojis as a badge, use the class badge-emoji, where 'emoji' is one of the following: new, cool, free, okay, notice, money, yes, not, star, info, success, warning, danger, or registered.
Disclosure
Accordion
Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec metus quam, rutrum sit amet euismod ac, bibendum ac ligula. Nam sit amet turpis laoreet, suscipit nulla in, convallis erat. Praesent sit amet odio non urna pharetra sagittis eu sed turpis. Praesent pulvinar metus sollicitudin velit aliquam, nec interdum augue tempus. Aliquam a viverra orci. Phasellus a rhoncus elit. Morbi sed sollicitudin mi. Curabitur eleifend auctor justo in blandit.
Maecenas convallis risus
Maecenas convallis risus a eleifend consectetur. Suspendisse sit amet tellus egestas, cursus risus nec, tristique quam. Donec ut ante hendrerit, sodales diam quis, efficitur nisl. Aenean vitae erat augue. Etiam id sapien dignissim, ullamcorper lorem et, rutrum lacus. Ut ut sodales erat. Duis sed faucibus ante. Suspendisse molestie arcu sed nisi condimentum feugiat.
Sed quis hendrerit lorem
Sed quis hendrerit lorem, a iaculis lorem. Etiam dignissim placerat tristique. Curabitur eu mauris gravida, dictum nulla a, feugiat odio. Sed rutrum consequat cursus. Vivamus fermentum orci erat, ut efficitur erat suscipit in. Phasellus tincidunt vel lacus at ullamcorper. Nam in massa tortor. Morbi mattis orci quis viverra volutpat. Proin ac nunc nec dolor rhoncus imperdiet. Proin ornare nibh enim. Pellentesque ornare nunc ac tellus consequat viverra. Nam sollicitudin ex at pretium rutrum.
Disclosure uses the HTML elements <details> and <summary>. To create an accordion, group the 'details' elements inside a <div> with the class 'disclosure', using the same name attribute for all 'details' elements in the group.
Tabs
First
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec metus quam, rutrum sit amet euismod ac, bibendum ac ligula. Nam sit amet turpis laoreet, suscipit nulla in, convallis erat. Praesent sit amet odio non urna pharetra sagittis eu sed turpis. Praesent pulvinar metus sollicitudin velit aliquam, nec interdum augue tempus. Aliquam a viverra orci. Phasellus a rhoncus elit. Morbi sed sollicitudin mi. Curabitur eleifend auctor justo in blandit. Etiam at velit fermentum erat pellentesque accumsan id id diam. Pellentesque tincidunt enim ante. Cras ac leo ex.
Second
Maecenas convallis risus a eleifend consectetur. Suspendisse sit amet tellus egestas, cursus risus nec, tristique quam. Donec ut ante hendrerit, sodales diam quis, efficitur nisl. Aenean vitae erat augue. Etiam id sapien dignissim, ullamcorper lorem et, rutrum lacus. Ut ut sodales erat. Duis sed faucibus ante. Suspendisse molestie arcu sed nisi condimentum feugiat.
Third
Sed quis hendrerit lorem, a iaculis lorem. Etiam dignissim placerat tristique. Curabitur eu mauris gravida, dictum nulla a, feugiat odio. Sed rutrum consequat cursus. Vivamus fermentum orci erat, ut efficitur erat suscipit in. Phasellus tincidunt vel lacus at ullamcorper. Nam in massa tortor. Morbi mattis orci quis viverra volutpat. Proin ac nunc nec dolor rhoncus imperdiet. Proin ornare nibh enim. Pellentesque ornare nunc ac tellus consequat viverra. Nam sollicitudin ex at pretium rutrum.
To create a tabs equivalent using <details> and <summary>, wrap the 'details' elements in a <div> with the class 'disclosure-tabs'. All 'details' elements must have the same name attribute. In addition, the content of each 'details' element must be wrapped in a <div>.
Collapse
Example 1:
Lorem ipsum with INFO style
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec metus quam, rutrum sit amet euismod ac, bibendum ac ligula. Nam sit amet turpis laoreet, suscipit nulla in, convallis erat. Praesent sit amet odio non urna pharetra sagittis eu sed turpis. Praesent pulvinar metus sollicitudin velit aliquam, nec interdum augue tempus. Aliquam a viverra orci. Phasellus a rhoncus elit. Morbi sed sollicitudin mi. Curabitur eleifend auctor justo in blandit. Etiam at velit fermentum erat pellentesque accumsan id id diam. Pellentesque tincidunt enim ante. Cras ac leo ex.
Example 2:
To create a "single" disclosure (collapse), apply the class 'single' to a <details> element and wrap its content in a <div>. To style the <summary> element as a button, apply the class 'with-button' to the 'details' element.
To apply a style to a 'details' content, add the appropriate class to its inner <div>, such as 'variant-background', where 'variant' is one of the following: primary, secondary, success, info, warning, danger, light, or dark.
Example of a single disclosure using a button.
<details class="single with-button">
<summary>Button title</summary>
<div class="info-background">
<p>Content here.</p>
</div>
</details>
Example of the disclosure accordion style, to create the tab style use the "disclosure-tabs" class.
<div class="disclosure">
<details name="group1" open><summary>Title One</summary><p> ... </p></details>
<details name="group1"><summary>Title Two</summary><p> ... </p></details>
</div>
Pagination
Block Pagination
Ut ut sodales erat. Duis sed faucibus ante. Suspendisse molestie arcu sed ...
Previous-Next Pagination
Ut ut sodales erat. Duis sed faucibus ante. Suspendisse molestie arcu sed ...
There are two ways to implement pagination for split pages: manually, which is a good option when there are only a few pages, or automatically, using a server-side language such as PHP or JavaScript. Pagination consists of an unordered list <ul> inside a <nav> element. Each list item contains a link <a>.
Two pagination styles are available:
- Block Pagination: The pagination is centred at the bottom of each page. Developers can specify the number of page numbers displayed using the '--pages-visible' CSS variable in the 'pagination' class. The default is 3.
- Previous-Next Pagination: Only the "Previous" and "Next" buttons are displayed at opposite ends of the page bottom, with the current page number shown between them.
The following classes must be observed:
| Element | Classes | |
|---|---|---|
| Block pagination | Previous-Next pagination | |
| ul | pagination | pagination + previous-next |
| li | page-item + ('active' for the current page, 'disabled' for pages that cannot be visited). | |
| a | page-link | |
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center">
<li class="page-item active"><a class="page-link" href="page1.html">1</a></li>
<li class="page-item"><a class="page-link" href="page2.html">2</a></li>
<li class="page-item disabled"><a class="page-link" href="page3.html">3</a></li>
<li class="page-item"><a class="page-link" href="page4.html">4</a></li>
<li class="page-item"><a class="page-link" href="page5.html">5</a></li>
<li class="page-item"><a class="page-link" href="page6.html">6</a></li>
<li class="page-item"><a class="page-link" href="page7.html">7</a></li>
<li class="page-item"><a class="page-link" href="page8.html">8</a></li>
<li class="page-item"><a class="page-link" href="page9.html">9</a></li>
<li class="page-item"><a class="page-link" href="page10.html">10</a></li>
</ul>
</nav>
The following JavaScript is required to generate the dynamic pagination.
document.querySelectorAll('.pagination').forEach(p => {
const previousNext = p.classList.contains('previous-next');
const prev = document.createElement('li');
prev.className = 'page-item';
prev.innerHTML = `<a class="page-link" href="#" aria-label="Previous">
${previousNext ? 'Previous' : '<span aria-hidden="true">«</span>'} </a>`;
const next = prev.cloneNode(true);
next.querySelector('a').innerHTML = previousNext ? 'Next' : '<span aria-hidden="true">»</span>';
next.querySelector('a').setAttribute('aria-label', 'Next');
if (!previousNext) {
prev.querySelector('a').dataset.pageStep = '-1';
next.querySelector('a').dataset.pageStep = '1'; }
p.prepend(prev);
p.append(next);
const dotsBefore = document.createElement('li');
dotsBefore.className = 'page-item';
dotsBefore.innerHTML = '<span class="page-link">âĻ</span>';
const dotsAfter = dotsBefore.cloneNode(true);
const pages = [...p.querySelectorAll('.page-item')] .filter(li => /^\d+$/.test(li.textContent.trim()));
const count = +getComputedStyle(p) .getPropertyValue('--pages-visible').trim() || 3;
let start = Math.max(0, Math.min(
pages.findIndex(li => li.classList.contains('active')) - Math.floor(count / 2),
pages.length - count ));
function show() {
if (previousNext) {
const items = [...p.querySelectorAll('.page-item')] .filter(li => li !== prev && li !== next);
const current = items.findIndex(li => li.classList.contains('active'));
if (current < 0) return;
const findPage = (step) => {
for (let i = current + step; i >= 0 && i < items.length; i += step) {
const a = items[i].querySelector('a');
if (a && !items[i].classList.contains('disabled')) return a; }
return null; };
const before = findPage(-1);
const after = findPage(1);
const prevLink = prev.querySelector('a');
const nextLink = next.querySelector('a');
prev.classList.toggle('disabled', !before);
next.classList.toggle('disabled', !after);
prevLink.setAttribute('aria-disabled', String(!before));
nextLink.setAttribute('aria-disabled', String(!after));
if (before) prevLink.href = before.href;
if (after) nextLink.href = after.href;
items.forEach(li => {
li.style.display = li === items[current] ? '' : 'none'; });
prev.style.display = '';
next.style.display = '';
} else {
pages.forEach((li, i) =>
li.style.display = i >= start && i < start + count ? '' : 'none' );
dotsBefore.remove();
dotsAfter.remove();
if (start > 0) pages[start].before(dotsBefore);
if (start + count < pages.length)
pages[start + count - 1].after(dotsAfter);
prev.classList.toggle('disabled', start === 0);
next.classList.toggle('disabled', start + count >= pages.length);
prev.querySelector('a').setAttribute('aria-disabled', start === 0);
next.querySelector('a').setAttribute('aria-disabled', start + count >= pages.length); }
p.style.display = 'flex'; }
if (!previousNext) {
p.querySelectorAll('[data-page-step]').forEach(a =>
a.addEventListener('click', e => {
e.preventDefault();
if (a.getAttribute('aria-disabled') === 'true') return;
start = Math.max(0, Math.min(
start + (+a.dataset.pageStep) * count,
pages.length - count ));
show(); })
); }
show();
});
Example of previous-next pagination.
<nav aria-label="Page navigation">
<ul class="pagination previous-next">
<li class="page-item active"><a class="page-link" href="page1.html">1</a></li>
<li class="page-item"><a class="page-link" href="page2.html">2</a></li>
......
Spinners & Progress
| Border Spinner | Alternative Spinner | Windmill Spinner | Spinner Bars |
|---|---|---|---|
|
Loading...
|
Loading...
|
Loading...
|
|
|
|||
| Classes | |||
| spinner-border | alter-spinner | windmill-spinner | spinner-bars |
| 'Border spinner' can also be contextual: Add the class 'variant-border, where 'variant' is one of the following: secondary, success, info, warning, danger, light, dark.
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
| |||
Progress with labels
Default
<div class="progress">
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">25%</div>
</div>
With gradient
Add the class 'gradient' to the <div class="progress">.
With animated stripes
To create an animated stripped progress bar, add the 'progress-bar-striped' and 'progress-bar-animated' classes, to the <div class="progress-bar" ... > element.
Progress bar example with animated stripes.
<div class="progress">
<div id="myID" class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"> </div>
</div>
To update a 'progress bar' dynamically, JavaScript is required, either independently or in communication with another system. Updates can be triggered by events such as user interactions, form submissions, file uploads or downloads, background processes, and responses from a server or API.
Step indicators
Static horizontal stepper
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
To create a "step indicator", wrap the steps in a <div> with the class 'stepper'. Each step should be a <div> with the class 'step' and the attributes 'data-title' and 'data-status'. Inside each step, include a <span> with the class 'step-indicator'. Set 'data-title' to the step's title and 'data-status' to one of the following values:
- "Completed" - add also the 'completed' class to each step that has been completed.
- "In progress" - add also the 'in-progress' class to the step in progress.
- "Pending" - add also the 'pending' class to each step that has not yet been completed.
<div class="stepper">
<div class="step completed" data-title="Title One" data-status="Completed">
<span class="step-indicator"></span>
</div>
<div class="step in-progress" data-title="Title Two" data-status="In progress">
<span class="step-indicator"></span>
</div>
<div class="step pending" data-title="Title Three" data-status="Pending">
<span class="step-indicator"></span>
</div>
</div>
Dynamic horizontal stepper
To create a dynamically updated step indicator, first create the "stepper" in exactly the same way as the static version, and in addition add a unique ID, such as 'dynamic-stepper', and set the first step to 'In progress'.
Use the following JavaScript function and ensure that it is called by the system responsible for managing the workflow.
function updateStepper(currentStep) {
const steps = document.querySelectorAll('#dynamic-stepper .step');
steps.forEach((step, index) => {
step.classList.remove('completed', 'in-progress', 'pending');
if (index + 1 < currentStep) {
step.classList.add('completed');
step.dataset.status = 'Completed';
} else if (index + 1 === currentStep) {
step.classList.add('in-progress');
step.dataset.status = 'In progress';
} else {
step.classList.add('pending');
step.dataset.status = 'Pending'; }
}); }
Interactive vertical stepper
Sequential vertical stepper
Dynamic vertical stepper
To create a "vertical stepper", create a <section> for each segment and wrap all sections in a <div> with the class 'stepper-vertical'. Each 'section' must have the class 'v-step' and contain the individual steps. The steps must be wrapped in a <div> with the class 'v-substeps', and each step must be wrapped in a <div> with the class 'v-substep' and include:
- A checkbox.
- A <span> with the class 'v-substep-indicator.
- A <label> associated with the checkbox using the for and id attributes.
Each section must also include: A "header" <div> with the class 'v-step-header', containing a <span> with the class 'v-step-indicator' and another <span> with the class 'v-step-title'. A "footer" <span> with the class 'v-step-count'.
Accessibility requirements must be observed as demonstrated in the HTML example.
âšī¸ There are four types of "vertical steppers":
- Manual Vertical Stepper
- With the Manual "vertical stepper", the developer must add the checked attribute to a checkbox to mark a step as completed.
- Interactive Vertical Stepper
- Add the class 'interactive' to the stepper. Users can click the round step indicator or its label to complete (check) any step. It is also possible to uncheck a completed step.
- Sequential Vertical Stepper
- Add the class 'sequential' to the stepper. Users can click to complete only the first uncompleted step. It is also possible to uncheck the last completed step.
- Dynamic Vertical Stepper
- Add the class 'dynamic' to the stepper. Developers can call the following JavaScript function from other scripts to update the completed steps dynamically. The stepper must have an ID.
The HTML code for the "Vertical Stepper".
<div class="stepper-vertical">
<section class="v-step" aria-labelledby="section1-title">
<div class="v-step-header">
<span class="v-step-indicator"></span>
<span id="section1-title" class="v-step-title">Section One Title</span>
</div>
<div class="v-substeps">
<div class="v-substep">
<input id="_S1S1" type="checkbox">
<span class="v-substep-indicator"></span>
<label for="_S1S1">Label One</label>
</div>
<div class="v-substep">
<input id="_S1S2" type="checkbox">
<span class="v-substep-indicator"></span>
<label for="_S1S2">Label Two</label>
</div>
<div class="v-substep">
<input id="_S1S3" type="checkbox">
<span class="v-substep-indicator"></span>
<label for="_S1S3">Label Three</label>
</div>
</div>
<span class="v-step-count"></span>
</section>
<!-- more sections here -->
<div>
JavaScript for the "Dynamic Vertical Stepper".
function updateVerticalStepper(verticalStep) {
const checkboxes = document.querySelectorAll(
'#dynamic-vertical-stepper-id .v-substep input[type="checkbox"]'
);
checkboxes.forEach((checkbox, index) => {
checkbox.checked = index < verticalStep;
});
}
Popovers and Tooltips
Text before, text after.
Closes by clicking its trigger button again or the close (x) button.
Instructions
Display a popover preferable using a button with the classes 'btn btn-link'. The button appears inline, making it look like part of the surrounding text. Add the popovertarget attribute to the button, setting its value to the id of the corresponding popover <div>.
To create a popover, use a <div> with the class 'bootcms-popover' and a unique id. Add the popover attribute with the value 'manual', as well as role="popover".
The maximum width can be specified using the inline CSS variable: style="--popover-max-width: 300px". The popover can contain the following optional elements:
- Header: A <div> with the class 'popover-header', which should also contain a close button (class="btn-close").
- Body: A <div> with the class 'popover-body'.
- Footer: A <div> with the class 'popover-footer.
The popover can be closed either by clicking its close button or by clicking its trigger button again.
This is a text to test a tooltip, hover over the word tooltip.
Instructions
To create a tooltip trigger, add the class 'show-tooltip' and the attribute data-tooltip, setting its value to the tooltip text. It is preferable to use a <span> as the trigger, since it is an inline element.
... <span class="show-tooltip" data-tooltip="This is a tooltip example">any text</span> ...
Popover example:
<!-- the trigger -->
... <button popovertarget="thePopover1" class="btn btn-link">BootCMS popover</button> ...
<!-- the popover -->
<div id="thePopover1" class="bootcms-popover" role="popover" style="--popover-max-width: 300px" popover="manual">
<div class="popover-header"><span>Popover title</span><button class="btn-close" popovertarget="thePopover1" popovertargetaction="hide" aria-label="Close"></button></div>
<div class="popover-body">
<p>Paragraphs and small images can also be placed here.</p>
</div>
<div class="popover-footer"><span>Footer</span></div>
</div>
Modal
A modal is a <dialog> element with the 'bootcms-modal' class and which floats above the rest of the page and receives the reader's focus. To trigger a modal, use a button with a small inline JavaScript onclick handler that targets the modal's ID:
<button type="button" class="btn btn-primary" onclick="document.getElementById('exampleModal1').showModal()">
A modal can contain almost any HTML element, including paragraphs, images, forms, tables, etc. It has a header, body, and a footer, the header and the footer should include a close button. Different styles of close buttons can be used in each.
<!-- example modal one -->
<dialog class="bootcms-modal" id="exampleModal1" aria-labelledby="exampleModalLabel1">
<div class="bootcms-modal-content">
<div class="bootcms-modal-header">
<span class="bootcms-modal-title" id="exampleModalLabel1">Modal title</span>
<form method="dialog">
<button type="submit" class="btn-close" aria-label="Close"></button>
</form>
</div>
<div class="bootcms-modal-body">
<img src="an image" width="125" height="125" alt="Sample Image">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec metus quam, rutrum sit amet euismod ac, bibendum ac ligula. Nam sit amet turpis laoreet, suscipit nulla in, convallis erat. Praesent sit amet odio non urna pharetra sagittis eu sed turpis.</p>
<p>Praesent pulvinar metus sollicitudin velit aliquam, nec interdum augue tempus. Aliquam a viverra orci. Phasellus a rhoncus elit.</p>
</div>
<div class="bootcms-modal-footer">
<form method="dialog">
<button type="submit" class="btn btn-primary">Close</button>
</form>
</div>
</div>
</dialog>
Carousel
The carousel is a slideshow for cycling through a series of content, built with CSS and a bit of JavaScript. It works with a series of images, text, or custom markup. It also includes support for previous/next controls and indicators. Holding the mouse button down pauses the slides.
The "carousel" example on this page can be found at the top, in the 'Hero Unit'.
HTML
Wrap everything in a <div> with the 'carousel' and 'slide' classes, and apply a unique ID. Specify the interval between slides using data-bs-interval (e.g. data-bs-interval="5000").
Wrap the carousel content in a <div> with the 'carousel-inner' class. Place the indicator buttons inside a <div> with the 'carousel-indicators' class, followed by the Previous and Next buttons.
All the required classes and the HTML structure are shown in the example below.
<div id="carouselHeroUnit" class="carousel slide" data-bs-ride="carousel" data-bs-interval="5000">
<div class="carousel-inner"><!-- carousel content -->
<div id="carousel-slide-1" class="carousel-item active onpageload">
<h2>First Slide Label</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec metus quam, rutrum sit amet euismod ac, bibendum ac ligula. Nam sit amet turpis laoreet, suscipit nulla in, convallis erat.</p>
</div>
<div id="carousel-slide-2" class="carousel-item">
<h2>Second Slide Label</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec metus quam, rutrum sit amet euismod ac, bibendum ac ligula. Nam sit amet turpis laoreet, suscipit nulla in, convallis erat.</p>
</div>
<div id="carousel-slide-3" class="carousel-item">
<h5>Third slide label</h5>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec metus quam, rutrum sit amet euismod ac, bibendum ac ligula. Nam sit amet turpis laoreet, suscipit nulla in, convallis erat.</p>
</div>
</div><!-- / carousel content -->
<div class="carousel-indicators">
<button type="button" data-bs-target="#carouselHeroUnit" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselHeroUnit" data-bs-slide-to="1" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselHeroUnit" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselHeroUnit" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#carouselHeroUnit" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
Carousel JavaScript
document.querySelectorAll('.carousel').forEach(carousel => {
const slides = [...carousel.querySelectorAll('.carousel-item')];
const dots = [...carousel.querySelectorAll('.carousel-indicators button')];
const interval = Number(carousel.dataset.bsInterval) || 4000;
const autoplay = carousel.dataset.bsRide === 'carousel' && slides.length > 1;
let index = Math.max(0, slides.findIndex(s => s.classList.contains('active')));
let timer;
const show = i => {
index = (i + slides.length) % slides.length;
slides.forEach((s, n) => s.classList.toggle('active', n === index));
dots.forEach((d, n) => {
d.classList.toggle('active', n === index);
n === index ? d.setAttribute('aria-current', 'true') : d.removeAttribute('aria-current');
}); };
const start = () => {
clearInterval(timer);
if (autoplay) timer = setInterval(() => show(index + 1), interval); };
carousel.addEventListener('click', e => {
const c = e.target.closest('.carousel-control-prev, .carousel-control-next, [data-bs-slide-to]');
if (!c || slides.length > 2) return;
show(c.hasAttribute('data-bs-slide-to')
? Number(c.dataset.bsSlideTo)
: index + (c.classList.contains('carousel-control-next') ? 1 : -1));
start(); });
carousel.addEventListener('pointerdown', e => {
if (!e.target.closest('button')) clearInterval(timer); });
['pointerup', 'pointerleave', 'pointercancel'].forEach(ev => carousel.addEventListener(ev, start));
let startX = 0, startY = 0;
carousel.addEventListener('pointerdown', e => { startX = e.clientX; startY = e.clientY; });
carousel.addEventListener('pointerup', e => {
if (e.target.closest('button')) return;
const dx = e.clientX - startX, dy = e.clientY - startY;
if (Math.abs(dx) > 50 && Math.abs(dx) > Math.abs(dy) * 1.5) show(index + (dx < 0 ? 1 : -1));
});
start();
});
Layout Utilities
Since this stylesheet is based on Bootstrap 5, Bootstrap's layout utilities can also be used. However, BootCMS provides a few ready-made classes for more complex layouts.
- Class: bootcms-flex-stretch
- Arranges items horizontally within their container, with additional layout options using the variables and classes below. Items stretch vertically to match the height of the tallest.
Must also include one of the classes below.
Inline variables: --bootcms-flex-gap, --bootcms-flex-size. Set to a value in rem, em, px, etc.
Class equal: Equal distribution, with a minimum width if desired.
Class auto: Uses a preferred starting width, then grows to fill available space or wraps onto additional rows. - Class: bootcms-flex-column
- Arranges items vertically within their container, with additional layout options using the variables and classes below.
Inline variables: --bootcms-flex-gap, --bootcms-flex-size. Set to a value in rem, em, px, etc.
Class start: Align to the start horizontally.
Class center: Centre horizontally.
Class end: Align to the end horizontally.
Class equal: All containers use the width specified by the variable.
Class auto: All containers use the width specified by the variable, with a minimum of half that width and a maximum of 100%.
No added class: Stretching to fill the available width of the container. - Class: bootcms-flex-center
- Centres items horizontally and vertically within their container, with additional layout options using the variables below.
Inline variables: --bootcms-flex-gap, --bootcms-flex-max, --bootcms-flex-min. Set to a value in rem, em, px, etc. - Class: grid-3x2-34
- A grid of four containers arranged in two rows and three columns within a parent container. The third column spans both rows, while the first item in the second row spans two columns. By default, all columns share the available width equally.
Inline variables: --bootcms-grid-gap. Set to a value in rem, em, px, etc. - Class: grid-2x3-12
- A grid of four containers arranged in two rows and three columns within a parent container. The first column spans both rows, while the second item in the first row spans two columns. By default, all columns share the available width equally.
Inline variables: --bootcms-grid-gap. Set to a value in rem, em, px, etc. - Class: grid-3x3-34
- A grid of six containers arranged in three rows and three columns within a parent container. The third column spans all rows, while the fourth item spans column one and two in the second row. By default, all columns share the available width equally.
Inline variables: --bootcms-grid-gap. Set to a value in rem, em, px, etc.