Documentation and examples for Bootstrap’s logo and brand usage guidelines.
-
-
-
-
-
-
-
- On this page
-
-
-
-
-
-
-
-
-
-
-
Have a need for Bootstrap’s brand resources? Great! We have only a few guidelines we follow, and in turn ask you to follow as well.
-
Logo
-
When referencing Bootstrap, use our logo mark. Do not modify our logos in any way. Do not use Bootstrap’s branding for your own open or closed source projects.
Documentation and examples for Bootstrap’s logo and brand usage guidelines.
+
On this page
Have a need for Bootstrap’s brand resources? Great! We have only a few guidelines we follow, and in turn ask you to follow as well.
+
Logo
+
When referencing Bootstrap, use our logo mark. Do not modify our logos in any way. Do not use Bootstrap’s branding for your own open or closed source projects.
+
Our logo mark is also available in black and white. All rules for our primary logo apply to these as well.
-
-
-
-
-
-
-
-
-
Name
+
+
Name
Bootstrap should always be referred to as just Bootstrap. No capital s.
Learn more about the team maintaining Bootstrap, how and why the project started, and how to get involved.
-
-
-
-
-
-
-
-
-
-
Team
-
Bootstrap is maintained by a small team of developers on GitHub. We’re actively looking to grow this team and would love to hear from you if you’re excited about CSS at scale, writing and maintaining vanilla JavaScript plugins, and improving build tooling processes for frontend code.
Learn more about the team maintaining Bootstrap, how and why the project started, and how to get involved.
+
Team
+
Bootstrap is maintained by a small team of developers on GitHub. We’re actively looking to grow this team and would love to hear from you if you’re excited about CSS at scale, writing and maintaining vanilla JavaScript plugins, and improving build tooling processes for frontend code.
+
History
Originally created by a designer and a developer at Twitter, Bootstrap has become one of the most popular front-end frameworks and open source projects in the world.
Bootstrap was created at Twitter in mid-2010 by @mdo and @fat. Prior to being an open-sourced framework, Bootstrap was known as Twitter Blueprint. A few months into development, Twitter held its first Hack Week and the project exploded as developers of all skill levels jumped in without any external guidance. It served as the style guide for internal tools development at the company for over a year before its public release, and continues to do so today.
-
Originally released on , we’ve since had over twenty releases, including two major rewrites with v2 and v3. With Bootstrap 2, we added responsive functionality to the entire framework as an optional stylesheet. Building on that with Bootstrap 3, we rewrote the library once more to make it responsive by default with a mobile first approach.
-
With Bootstrap 4, we once again rewrote the project to account for two key architectural changes: a migration to Sass and the move to CSS’s flexbox. Our intention is to help in a small way to move the web development community forward by pushing for newer CSS properties, fewer dependencies, and new technologies across more modern browsers.
-
Our latest release, Bootstrap 5, focuses on improving v4’s codebase with as few major breaking changes as possible. We improved existing features and components, removed support for older browsers, dropped jQuery for regular JavaScript, and embraced more future-friendly technologies like CSS custom properties as part of our tooling.
-
Get involved
-
Get involved with Bootstrap development by opening an issue or submitting a pull request. Read our contributing guidelines for information on how we develop.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
Originally released on , we’ve since had over twenty releases, including two major rewrites with v2 and v3. With Bootstrap 2, we added responsive functionality to the entire framework as an optional stylesheet. Building on that with Bootstrap 3, we rewrote the library once more to make it responsive by default with a mobile first approach.
+
With Bootstrap 4, we once again rewrote the project to account for two key architectural changes: a migration to Sass and the move to CSS’s flexbox. Our intention is to help in a small way to move the web development community forward by pushing for newer CSS properties, fewer dependencies, and new technologies across more modern browsers.
+
Our latest release, Bootstrap 5, focuses on improving v4’s codebase with as few major breaking changes as possible. We improved existing features and components, removed support for older browsers, dropped jQuery for regular JavaScript, and embraced more future-friendly technologies like CSS custom properties as part of our tooling.
+
Get involved
+
Get involved with Bootstrap development by opening an issue or submitting a pull request. Read our contributing guidelines for information on how we develop.
An overview of the founding team and core contributors to Bootstrap.
-
-
-
-
-
-
-
-
-
-
Bootstrap is maintained by the founding team and a small group of invaluable core contributors, with the massive support and involvement of our community.
Get involved with Bootstrap development by opening an issue or submitting a pull request. Read our contributing guidelines for information on how we develop.
An overview of the founding team and core contributors to Bootstrap.
+
Bootstrap is maintained by the founding team and a small group of invaluable core contributors, with the massive support and involvement of our community.
Get involved with Bootstrap development by opening an issue or submitting a pull request. Read our contributing guidelines for information on how we develop.
Links to community-translated Bootstrap documentation sites.
-
-
-
-
-
-
-
-
-
-
Community members have translated Bootstrap’s documentation into various languages. None are officially supported and they may not always be up-to-date.
Links to community-translated Bootstrap documentation sites.
+
Community members have translated Bootstrap’s documentation into various languages. None are officially supported and they may not always be up-to-date.
Click the accordions below to expand/collapse the accordion content.
-
To render an accordion that’s expanded by default:
+
To render an accordion that’s expanded by default:
add the .show class on the .accordion-collapse element.
drop the .collapsed class from the .accordion-button element and set its aria-expanded attribute to true.
-
-
-
-
+
- This is the first item's accordion body. It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.
+ This is the first item’s accordion body. It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It’s also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.
@@ -604,7 +52,7 @@ The animation effect of this component is dependent on the prefers-reduced
- This is the second item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.
+ This is the second item’s accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It’s also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.
@@ -616,68 +64,51 @@ The animation effect of this component is dependent on the prefers-reduced
- This is the third item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.
+ This is the third item’s accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It’s also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.
-
-
-
- html
-
-
-
-
-
<divclass="accordion"id="accordionExample">
-<divclass="accordion-item">
-<h2class="accordion-header">
-<buttonclass="accordion-button"type="button"data-bs-toggle="collapse"data-bs-target="#collapseOne"aria-expanded="true"aria-controls="collapseOne">
- Accordion Item #1
-</button>
-</h2>
-<divid="collapseOne"class="accordion-collapse collapse show"data-bs-parent="#accordionExample">
-<divclass="accordion-body">
-<strong>This is the first item's accordion body.</strong> It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
-</div>
-</div>
-</div>
-<divclass="accordion-item">
-<h2class="accordion-header">
-<buttonclass="accordion-button collapsed"type="button"data-bs-toggle="collapse"data-bs-target="#collapseTwo"aria-expanded="false"aria-controls="collapseTwo">
- Accordion Item #2
-</button>
-</h2>
-<divid="collapseTwo"class="accordion-collapse collapse"data-bs-parent="#accordionExample">
-<divclass="accordion-body">
-<strong>This is the second item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
-</div>
-</div>
-</div>
-<divclass="accordion-item">
-<h2class="accordion-header">
-<buttonclass="accordion-button collapsed"type="button"data-bs-toggle="collapse"data-bs-target="#collapseThree"aria-expanded="false"aria-controls="collapseThree">
- Accordion Item #3
-</button>
-</h2>
-<divid="collapseThree"class="accordion-collapse collapse"data-bs-parent="#accordionExample">
-<divclass="accordion-body">
-<strong>This is the third item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
-</div>
-</div>
-</div>
-</div>
-
-
-
Flush
+
html
<divclass="accordion"id="accordionExample">
+ <divclass="accordion-item">
+ <h2class="accordion-header">
+ <buttonclass="accordion-button"type="button"data-bs-toggle="collapse"data-bs-target="#collapseOne"aria-expanded="true"aria-controls="collapseOne">
+ Accordion Item #1
+ </button>
+ </h2>
+ <divid="collapseOne"class="accordion-collapse collapse show"data-bs-parent="#accordionExample">
+ <divclass="accordion-body">
+ <strong>This is the first item’s accordion body.</strong> It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It’s also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
+ </div>
+ </div>
+ </div>
+ <divclass="accordion-item">
+ <h2class="accordion-header">
+ <buttonclass="accordion-button collapsed"type="button"data-bs-toggle="collapse"data-bs-target="#collapseTwo"aria-expanded="false"aria-controls="collapseTwo">
+ Accordion Item #2
+ </button>
+ </h2>
+ <divid="collapseTwo"class="accordion-collapse collapse"data-bs-parent="#accordionExample">
+ <divclass="accordion-body">
+ <strong>This is the second item’s accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It’s also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
+ </div>
+ </div>
+ </div>
+ <divclass="accordion-item">
+ <h2class="accordion-header">
+ <buttonclass="accordion-button collapsed"type="button"data-bs-toggle="collapse"data-bs-target="#collapseThree"aria-expanded="false"aria-controls="collapseThree">
+ Accordion Item #3
+ </button>
+ </h2>
+ <divid="collapseThree"class="accordion-collapse collapse"data-bs-parent="#accordionExample">
+ <divclass="accordion-body">
+ <strong>This is the third item’s accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It’s also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
+ </div>
+ </div>
+ </div>
+</div>
+
Flush
Add .accordion-flush to remove some borders and rounded corners to render accordions edge-to-edge with their parent container.
-
-
-
-
+
-
Placeholder content for this accordion, which is intended to demonstrate the .accordion-flush class. This is the first item's accordion body.
+
Placeholder content for this accordion, which is intended to demonstrate the .accordion-flush class. This is the first item’s accordion body.
@@ -695,7 +126,7 @@ The animation effect of this component is dependent on the prefers-reduced
-
Placeholder content for this accordion, which is intended to demonstrate the .accordion-flush class. This is the second item's accordion body. Let's imagine this being filled with some actual content.
+
Placeholder content for this accordion, which is intended to demonstrate the .accordion-flush class. This is the second item’s accordion body. Let’s imagine this being filled with some actual content.
@@ -705,61 +136,44 @@ The animation effect of this component is dependent on the prefers-reduced
-
Placeholder content for this accordion, which is intended to demonstrate the .accordion-flush class. This is the third item's accordion body. Nothing more exciting happening here in terms of content, but just filling up the space to make it look, at least at first glance, a bit more representative of how this would look in a real-world application.
+
Placeholder content for this accordion, which is intended to demonstrate the .accordion-flush class. This is the third item’s accordion body. Nothing more exciting happening here in terms of content, but just filling up the space to make it look, at least at first glance, a bit more representative of how this would look in a real-world application.
-
-
-
- html
-
-
-
-
-
<divclass="accordion accordion-flush"id="accordionFlushExample">
-<divclass="accordion-item">
-<h2class="accordion-header">
-<buttonclass="accordion-button collapsed"type="button"data-bs-toggle="collapse"data-bs-target="#flush-collapseOne"aria-expanded="false"aria-controls="flush-collapseOne">
- Accordion Item #1
-</button>
-</h2>
-<divid="flush-collapseOne"class="accordion-collapse collapse"data-bs-parent="#accordionFlushExample">
-<divclass="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the first item's accordion body.</div>
-</div>
-</div>
-<divclass="accordion-item">
-<h2class="accordion-header">
-<buttonclass="accordion-button collapsed"type="button"data-bs-toggle="collapse"data-bs-target="#flush-collapseTwo"aria-expanded="false"aria-controls="flush-collapseTwo">
- Accordion Item #2
-</button>
-</h2>
-<divid="flush-collapseTwo"class="accordion-collapse collapse"data-bs-parent="#accordionFlushExample">
-<divclass="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the second item's accordion body. Let's imagine this being filled with some actual content.</div>
-</div>
-</div>
-<divclass="accordion-item">
-<h2class="accordion-header">
-<buttonclass="accordion-button collapsed"type="button"data-bs-toggle="collapse"data-bs-target="#flush-collapseThree"aria-expanded="false"aria-controls="flush-collapseThree">
- Accordion Item #3
-</button>
-</h2>
-<divid="flush-collapseThree"class="accordion-collapse collapse"data-bs-parent="#accordionFlushExample">
-<divclass="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the third item's accordion body. Nothing more exciting happening here in terms of content, but just filling up the space to make it look, at least at first glance, a bit more representative of how this would look in a real-world application.</div>
-</div>
-</div>
-</div>
-
-
-
Always open
+
html
<divclass="accordion accordion-flush"id="accordionFlushExample">
+ <divclass="accordion-item">
+ <h2class="accordion-header">
+ <buttonclass="accordion-button collapsed"type="button"data-bs-toggle="collapse"data-bs-target="#flush-collapseOne"aria-expanded="false"aria-controls="flush-collapseOne">
+ Accordion Item #1
+ </button>
+ </h2>
+ <divid="flush-collapseOne"class="accordion-collapse collapse"data-bs-parent="#accordionFlushExample">
+ <divclass="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the first item’s accordion body.</div>
+ </div>
+ </div>
+ <divclass="accordion-item">
+ <h2class="accordion-header">
+ <buttonclass="accordion-button collapsed"type="button"data-bs-toggle="collapse"data-bs-target="#flush-collapseTwo"aria-expanded="false"aria-controls="flush-collapseTwo">
+ Accordion Item #2
+ </button>
+ </h2>
+ <divid="flush-collapseTwo"class="accordion-collapse collapse"data-bs-parent="#accordionFlushExample">
+ <divclass="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the second item’s accordion body. Let’s imagine this being filled with some actual content.</div>
+ </div>
+ </div>
+ <divclass="accordion-item">
+ <h2class="accordion-header">
+ <buttonclass="accordion-button collapsed"type="button"data-bs-toggle="collapse"data-bs-target="#flush-collapseThree"aria-expanded="false"aria-controls="flush-collapseThree">
+ Accordion Item #3
+ </button>
+ </h2>
+ <divid="flush-collapseThree"class="accordion-collapse collapse"data-bs-parent="#accordionFlushExample">
+ <divclass="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the third item’s accordion body. Nothing more exciting happening here in terms of content, but just filling up the space to make it look, at least at first glance, a bit more representative of how this would look in a real-world application.</div>
+ </div>
+ </div>
+</div>
+
Always open
Omit the data-bs-parent attribute on each .accordion-collapse to make accordion items stay open when another item is opened.
-
-
-
-
+
- This is the first item's accordion body. It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.
+ This is the first item’s accordion body. It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It’s also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.
@@ -780,7 +194,7 @@ The animation effect of this component is dependent on the prefers-reduced
- This is the second item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.
+ This is the second item’s accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It’s also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.
@@ -792,215 +206,112 @@ The animation effect of this component is dependent on the prefers-reduced
- This is the third item's accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.
+ This is the third item’s accordion body. It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It’s also worth noting that just about any HTML can go within the .accordion-body, though the transition does limit overflow.
-
-
-
- html
-
-
-
-
-
<divclass="accordion"id="accordionPanelsStayOpenExample">
-<divclass="accordion-item">
-<h2class="accordion-header">
-<buttonclass="accordion-button"type="button"data-bs-toggle="collapse"data-bs-target="#panelsStayOpen-collapseOne"aria-expanded="true"aria-controls="panelsStayOpen-collapseOne">
- Accordion Item #1
-</button>
-</h2>
-<divid="panelsStayOpen-collapseOne"class="accordion-collapse collapse show">
-<divclass="accordion-body">
-<strong>This is the first item's accordion body.</strong> It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
-</div>
-</div>
-</div>
-<divclass="accordion-item">
-<h2class="accordion-header">
-<buttonclass="accordion-button collapsed"type="button"data-bs-toggle="collapse"data-bs-target="#panelsStayOpen-collapseTwo"aria-expanded="false"aria-controls="panelsStayOpen-collapseTwo">
- Accordion Item #2
-</button>
-</h2>
-<divid="panelsStayOpen-collapseTwo"class="accordion-collapse collapse">
-<divclass="accordion-body">
-<strong>This is the second item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
-</div>
-</div>
-</div>
-<divclass="accordion-item">
-<h2class="accordion-header">
-<buttonclass="accordion-button collapsed"type="button"data-bs-toggle="collapse"data-bs-target="#panelsStayOpen-collapseThree"aria-expanded="false"aria-controls="panelsStayOpen-collapseThree">
- Accordion Item #3
-</button>
-</h2>
-<divid="panelsStayOpen-collapseThree"class="accordion-collapse collapse">
-<divclass="accordion-body">
-<strong>This is the third item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
-</div>
-</div>
-</div>
-</div>
<divclass="accordion"id="accordionPanelsStayOpenExample">
+ <divclass="accordion-item">
+ <h2class="accordion-header">
+ <buttonclass="accordion-button"type="button"data-bs-toggle="collapse"data-bs-target="#panelsStayOpen-collapseOne"aria-expanded="true"aria-controls="panelsStayOpen-collapseOne">
+ Accordion Item #1
+ </button>
+ </h2>
+ <divid="panelsStayOpen-collapseOne"class="accordion-collapse collapse show">
+ <divclass="accordion-body">
+ <strong>This is the first item’s accordion body.</strong> It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It’s also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
+ </div>
+ </div>
+ </div>
+ <divclass="accordion-item">
+ <h2class="accordion-header">
+ <buttonclass="accordion-button collapsed"type="button"data-bs-toggle="collapse"data-bs-target="#panelsStayOpen-collapseTwo"aria-expanded="false"aria-controls="panelsStayOpen-collapseTwo">
+ Accordion Item #2
+ </button>
+ </h2>
+ <divid="panelsStayOpen-collapseTwo"class="accordion-collapse collapse">
+ <divclass="accordion-body">
+ <strong>This is the second item’s accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It’s also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
+ </div>
+ </div>
+ </div>
+ <divclass="accordion-item">
+ <h2class="accordion-header">
+ <buttonclass="accordion-button collapsed"type="button"data-bs-toggle="collapse"data-bs-target="#panelsStayOpen-collapseThree"aria-expanded="false"aria-controls="panelsStayOpen-collapseThree">
+ Accordion Item #3
+ </button>
+ </h2>
+ <divid="panelsStayOpen-collapseThree"class="accordion-collapse collapse">
+ <divclass="accordion-body">
+ <strong>This is the third item’s accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It’s also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
+ </div>
+ </div>
+ </div>
+</div>
As part of Bootstrap’s evolving CSS variables approach, accordions now use local CSS variables on .accordion for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
As part of Bootstrap’s evolving CSS variables approach, accordions now use local CSS variables on .accordion for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages.
+
On this page
Examples
Alerts are available for any length of text, as well as an optional close button. For proper styling, use one of the eight required contextual classes (e.g., .alert-success). For inline dismissal, use the alerts JavaScript plugin.
-
-Heads up! As of v5.3.0, the alert-variant() Sass mixin is deprecated. Alert variants now have their CSS variables overridden in a Sass loop.
-
-
-
-
-
-
-
+
Heads up! As of v5.3.0, the alert-variant() Sass mixin is deprecated. Alert variants now have their CSS variables overridden in a Sass loop.
+
A simple primary alert—check it out!
@@ -611,105 +47,60 @@
A simple dark alert—check it out!
-
-
-
- html
-
-
-
-
-
<divclass="alert alert-primary"role="alert">
- A simple primary alert—check it out!
-</div>
-<divclass="alert alert-secondary"role="alert">
- A simple secondary alert—check it out!
-</div>
-<divclass="alert alert-success"role="alert">
- A simple success alert—check it out!
-</div>
-<divclass="alert alert-danger"role="alert">
- A simple danger alert—check it out!
-</div>
-<divclass="alert alert-warning"role="alert">
- A simple warning alert—check it out!
-</div>
-<divclass="alert alert-info"role="alert">
- A simple info alert—check it out!
-</div>
-<divclass="alert alert-light"role="alert">
- A simple light alert—check it out!
-</div>
-<divclass="alert alert-dark"role="alert">
- A simple dark alert—check it out!
-</div>
-
-
-
-Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
-
-
-
Live example
+
html
<divclass="alert alert-primary"role="alert">
+ A simple primary alert—check it out!
+</div>
+<divclass="alert alert-secondary"role="alert">
+ A simple secondary alert—check it out!
+</div>
+<divclass="alert alert-success"role="alert">
+ A simple success alert—check it out!
+</div>
+<divclass="alert alert-danger"role="alert">
+ A simple danger alert—check it out!
+</div>
+<divclass="alert alert-warning"role="alert">
+ A simple warning alert—check it out!
+</div>
+<divclass="alert alert-info"role="alert">
+ A simple info alert—check it out!
+</div>
+<divclass="alert alert-light"role="alert">
+ A simple light alert—check it out!
+</div>
+<divclass="alert alert-dark"role="alert">
+ A simple dark alert—check it out!
+</div>
+
Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
+
Live example
Click the button below to show an alert (hidden with inline styles to start), then dismiss (and destroy) it with the built-in close button.
-
-
-
-
-
-
-
- html
-
-
-
-
-
<divid="liveAlertPlaceholder"></div>
-<buttontype="button"class="btn btn-primary"id="liveAlertBtn">Show live alert</button>
-
-
+
+
html
<divid="liveAlertPlaceholder"></div>
+<buttontype="button"class="btn btn-primary"id="liveAlertBtn">Show live alert</button>
We use the following JavaScript to trigger our live alert demo:
Use the .alert-link utility class to quickly provide matching colored links within any alert.
+
A simple primary alert with an example link. Give it a click if you like.
@@ -732,113 +123,62 @@
A simple dark alert with an example link. Give it a click if you like.
-
-
-
- html
-
-
-
-
-
<divclass="alert alert-primary"role="alert">
- A simple primary alert with <ahref="#"class="alert-link">an example link</a>. Give it a click if you like.
-</div>
-<divclass="alert alert-secondary"role="alert">
- A simple secondary alert with <ahref="#"class="alert-link">an example link</a>. Give it a click if you like.
-</div>
-<divclass="alert alert-success"role="alert">
- A simple success alert with <ahref="#"class="alert-link">an example link</a>. Give it a click if you like.
-</div>
-<divclass="alert alert-danger"role="alert">
- A simple danger alert with <ahref="#"class="alert-link">an example link</a>. Give it a click if you like.
-</div>
-<divclass="alert alert-warning"role="alert">
- A simple warning alert with <ahref="#"class="alert-link">an example link</a>. Give it a click if you like.
-</div>
-<divclass="alert alert-info"role="alert">
- A simple info alert with <ahref="#"class="alert-link">an example link</a>. Give it a click if you like.
-</div>
-<divclass="alert alert-light"role="alert">
- A simple light alert with <ahref="#"class="alert-link">an example link</a>. Give it a click if you like.
-</div>
-<divclass="alert alert-dark"role="alert">
- A simple dark alert with <ahref="#"class="alert-link">an example link</a>. Give it a click if you like.
-</div>
-
-
-
Additional content
+
html
<divclass="alert alert-primary"role="alert">
+ A simple primary alert with <ahref="#"class="alert-link">an example link</a>. Give it a click if you like.
+</div>
+<divclass="alert alert-secondary"role="alert">
+ A simple secondary alert with <ahref="#"class="alert-link">an example link</a>. Give it a click if you like.
+</div>
+<divclass="alert alert-success"role="alert">
+ A simple success alert with <ahref="#"class="alert-link">an example link</a>. Give it a click if you like.
+</div>
+<divclass="alert alert-danger"role="alert">
+ A simple danger alert with <ahref="#"class="alert-link">an example link</a>. Give it a click if you like.
+</div>
+<divclass="alert alert-warning"role="alert">
+ A simple warning alert with <ahref="#"class="alert-link">an example link</a>. Give it a click if you like.
+</div>
+<divclass="alert alert-info"role="alert">
+ A simple info alert with <ahref="#"class="alert-link">an example link</a>. Give it a click if you like.
+</div>
+<divclass="alert alert-light"role="alert">
+ A simple light alert with <ahref="#"class="alert-link">an example link</a>. Give it a click if you like.
+</div>
+<divclass="alert alert-dark"role="alert">
+ A simple dark alert with <ahref="#"class="alert-link">an example link</a>. Give it a click if you like.
+</div>
+
Additional content
Alerts can also contain additional HTML elements like headings, paragraphs and dividers.
-
-
-
-
+
Well done!
Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.
Whenever you need to, be sure to use margin utilities to keep things nice and tidy.
-
-
-
- html
-
-
-
-
-
<divclass="alert alert-success"role="alert">
-<h4class="alert-heading">Well done!</h4>
-<p>Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.</p>
-<hr>
-<pclass="mb-0">Whenever you need to, be sure to use margin utilities to keep things nice and tidy.</p>
-</div>
-
-
-
Icons
-
Similarly, you can use flexbox utilities and Bootstrap Icons to create alerts with icons. Depending on your icons and content, you may want to add more utilities or custom styles.
-
-
-
-
+
html
<divclass="alert alert-success"role="alert">
+ <h4class="alert-heading">Well done!</h4>
+ <p>Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.</p>
+ <hr>
+ <pclass="mb-0">Whenever you need to, be sure to use margin utilities to keep things nice and tidy.</p>
+</div>
+
Icons
+
Similarly, you can use flexbox utilities and Bootstrap Icons to create alerts with icons. Depending on your icons and content, you may want to add more utilities or custom styles.
Need more than one icon for your alerts? Consider using more Bootstrap Icons and making a local SVG sprite like so to easily reference the same icons repeatedly.
Using the alert JavaScript plugin, it’s possible to dismiss any alert inline. Here’s how:
+<divclass="alert alert-primary d-flex align-items-center"role="alert">
+ <svgclass="bi flex-shrink-0 me-2"role="img"aria-label="Info:"><usexlink:href="#info-fill"/></svg>
+ <div>
+ An example alert with an icon
+ </div>
+</div>
+<divclass="alert alert-success d-flex align-items-center"role="alert">
+ <svgclass="bi flex-shrink-0 me-2"role="img"aria-label="Success:"><usexlink:href="#check-circle-fill"/></svg>
+ <div>
+ An example success alert with an icon
+ </div>
+</div>
+<divclass="alert alert-warning d-flex align-items-center"role="alert">
+ <svgclass="bi flex-shrink-0 me-2"role="img"aria-label="Warning:"><usexlink:href="#exclamation-triangle-fill"/></svg>
+ <div>
+ An example warning alert with an icon
+ </div>
+</div>
+<divclass="alert alert-danger d-flex align-items-center"role="alert">
+ <svgclass="bi flex-shrink-0 me-2"role="img"aria-label="Danger:"><usexlink:href="#exclamation-triangle-fill"/></svg>
+ <div>
+ An example danger alert with an icon
+ </div>
+</div>
+
Dismissing
+
Using the alert JavaScript plugin, it’s possible to dismiss any alert inline. Here’s how:
-
Be sure you’ve loaded the alert plugin, or the compiled Bootstrap JavaScript.
-
Add a close button and the .alert-dismissible class, which adds extra padding to the right of the alert and positions the close button.
+
Be sure you’ve loaded the alert plugin, or the compiled Bootstrap JavaScript.
+
Add a close button and the .alert-dismissible class, which adds extra padding to the right of the alert and positions the close button.
On the close button, add the data-bs-dismiss="alert" attribute, which triggers the JavaScript functionality. Be sure to use the <button> element with it for proper behavior across all devices.
To animate alerts when dismissing them, be sure to add the .fade and .show classes.
You can see this in action with a live demo:
-
-
-
-
+
Holy guacamole! You should check in on some of those fields below.
-
-
-
- html
-
-
-
-
-
<divclass="alert alert-warning alert-dismissible fade show"role="alert">
-<strong>Holy guacamole!</strong> You should check in on some of those fields below.
-<buttontype="button"class="btn-close"data-bs-dismiss="alert"aria-label="Close"></button>
-</div>
-
-
-
-When an alert is dismissed, the element is completely removed from the page structure. If a keyboard user dismisses the alert using the close button, their focus will suddenly be lost and, depending on the browser, reset to the start of the page/document. For this reason, we recommend including additional JavaScript that listens for the closed.bs.alert event and programmatically sets focus() to the most appropriate location in the page. If you’re planning to move focus to a non-interactive element that normally does not receive focus, make sure to add tabindex="-1" to the element.
-
-
-
CSS
-
Variables
+
html
<divclass="alert alert-warning alert-dismissible fade show"role="alert">
+ <strong>Holy guacamole!</strong> You should check in on some of those fields below.
+ <buttontype="button"class="btn-close"data-bs-dismiss="alert"aria-label="Close"></button>
+</div>
+
When an alert is dismissed, the element is completely removed from the page structure. If a keyboard user dismisses the alert using the close button, their focus will suddenly be lost and, depending on the browser, reset to the start of the page/document. For this reason, we recommend including additional JavaScript that listens for the closed.bs.alert event and programmatically sets focus() to the most appropriate location in the page. If you’re planning to move focus to a non-interactive element that normally does not receive focus, make sure to add tabindex="-1" to the element.
+
CSS
+
Variables
Added in v5.2.0
+
As part of Bootstrap’s evolving CSS variables approach, alerts now use local CSS variables on .alert for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
$alert-padding-y:$spacer;
+$alert-padding-x:$spacer;
+$alert-margin-bottom: 1rem;
+$alert-border-radius:var(--#{$prefix}border-radius);
+$alert-link-font-weight:$font-weight-bold;
+$alert-border-width:var(--#{$prefix}border-width);
+$alert-dismissible-padding-r:$alert-padding-x* 3;// 3x covers width of x plus default padding on either side
+
As part of Bootstrap’s evolving CSS variables approach, alerts now use local CSS variables on .alert for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
$alert-padding-y:$spacer;
-$alert-padding-x:$spacer;
-$alert-margin-bottom:1rem;
-$alert-border-radius:var(--#{$prefix}border-radius);
-$alert-link-font-weight:$font-weight-bold;
-$alert-border-width:var(--#{$prefix}border-width);
-$alert-dismissible-padding-r:$alert-padding-x*3;// 3x covers width of x plus default padding on either side
-
-
Sass mixins
-Deprecated in v5.3.0
+ @if$enable-gradients{
+ background-image:var(--#{$prefix}gradient);
+ }
-
For the sole purpose of dismissing an alert, it isn’t necessary to initialize the component manually via the JS API. By making use of data-bs-dismiss="alert", the component will be initialized automatically and properly dismissed.
For the sole purpose of dismissing an alert, it isn’t necessary to initialize the component manually via the JS API. By making use of data-bs-dismiss="alert", the component will be initialized automatically and properly dismissed.
Note that closing an alert will remove it from the DOM.
+
Methods
You can create an alert instance with the alert constructor, for example:
-
constbsAlert=newbootstrap.Alert('#myAlert')
-
This makes an alert listen for click events on descendant elements which have the data-bs-dismiss="alert" attribute. (Not necessary when using the data-api’s auto-initialization.)
-
-
-
-
Method
-
Description
-
-
-
-
-
close
-
Closes an alert by removing it from the DOM. If the .fade and .show classes are present on the element, the alert will fade out before it is removed.
-
-
-
dispose
-
Destroys an element’s alert. (Removes stored data on the DOM element)
-
-
-
getInstance
-
Static method which allows you to get the alert instance associated to a DOM element. For example: bootstrap.Alert.getInstance(alert).
-
-
-
getOrCreateInstance
-
Static method which returns an alert instance associated to a DOM element or create a new one in case it wasn’t initialized. You can use it like this: bootstrap.Alert.getOrCreateInstance(element).
-
-
-
+
const bsAlert =newbootstrap.Alert('#myAlert')
+
+
This makes an alert listen for click events on descendant elements which have the data-bs-dismiss="alert" attribute. (Not necessary when using the data-api’s auto-initialization.)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Method
Description
close
Closes an alert by removing it from the DOM. If the .fade and .show classes are present on the element, the alert will fade out before it is removed.
dispose
Destroys an element’s alert. (Removes stored data on the DOM element)
getInstance
Static method which allows you to get the alert instance associated to a DOM element. For example: bootstrap.Alert.getInstance(alert).
getOrCreateInstance
Static method which returns an alert instance associated to a DOM element or create a new one in case it wasn’t initialized. You can use it like this: bootstrap.Alert.getOrCreateInstance(element).
Bootstrap’s alert plugin exposes a few events for hooking into alert functionality.
-
-
-
-
Event
-
Description
-
-
-
-
-
close.bs.alert
-
Fires immediately when the close instance method is called.
-
-
-
closed.bs.alert
-
Fired when the alert has been closed and CSS transitions have completed.
-
-
-
-
-
constmyAlert=document.getElementById('myAlert')
-myAlert.addEventListener('closed.bs.alert',event=>{
-// do something, for instance, explicitly move focus to the most appropriate element,
-// so it doesn't get lost/reset to the start of the page
-// document.getElementById('...').focus()
-})
-
Bootstrap’s alert plugin exposes a few events for hooking into alert functionality.
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
Event
Description
close.bs.alert
Fires immediately when the close instance method is called.
closed.bs.alert
Fired when the alert has been closed and CSS transitions have completed.
+
const myAlert = document.getElementById('myAlert')
+myAlert.addEventListener('closed.bs.alert',event=>{
+ // do something, for instance, explicitly move focus to the most appropriate element,
+ // so it doesn’t get lost/reset to the start of the page
+ // document.getElementById('...').focus()
+})
+
Documentation and examples for badges, our small count and labeling component.
+
On this page
Examples
Badges scale to match the size of the immediate parent element by using relative font sizing and em units. As of v5, badges no longer have focus or hover styles for links.
Note that depending on how they are used, badges may be confusing for users of screen readers and similar assistive technologies. While the styling of badges provides a visual cue as to their purpose, these users will simply be presented with the content of the badge. Depending on the specific situation, these badges may seem like random additional words or numbers at the end of a sentence, link, or button.
-
Unless the context is clear (as with the “Notifications” example, where it is understood that the “4” is the number of notifications), consider including additional context with a visually hidden piece of additional text.
-
Positioned
+
Unless the context is clear (as with the “Notifications” example, where it is understood that the “4” is the number of notifications), consider including additional context with a visually hidden piece of additional text.
+
Positioned
Use utilities to modify a .badge and position it in the corner of a link or button.
Set a background-color with contrasting foreground color with our .text-bg-{color} helpers. Previously it was required to manually pair your choice of .text-{color} and .bg-{color} utilities for styling, which you still may use if you prefer.
-
-
-
-
-Primary
+
Set a background-color with contrasting foreground color with our .text-bg-{color} helpers. Previously it was required to manually pair your choice of .text-{color} and .bg-{color} utilities for styling, which you still may use if you prefer.
-Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
-
Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
+
Pill badges
Use the .rounded-pill utility class to make badges more rounded with a larger border-radius.
As part of Bootstrap’s evolving CSS variables approach, badges now use local CSS variables on .badge for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
As part of Bootstrap’s evolving CSS variables approach, badges now use local CSS variables on .badge for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
Indicate the current page’s location within a navigational hierarchy that automatically adds separators via CSS.
+
+On this page
+On this page
Example
Use an ordered or unordered list with linked list items to create a minimally styled breadcrumb. Use our utilities to add additional styles as desired.
-
-
-
-
+
Dividers
Dividers are automatically added in CSS through ::before and content. They can be changed by modifying a local CSS custom property --bs-breadcrumb-divider, or through the $breadcrumb-divider Sass variable — and $breadcrumb-divider-flipped for its RTL counterpart, if needed. We default to our Sass variable, which is set as a fallback to the custom property. This way, you get a global divider that you can override without recompiling CSS at any time.
When modifying via Sass, the quote function is required to generate the quotes around a string. For example, using > as the divider, you can use this:
-
$breadcrumb-divider:quote(">");
-
It’s also possible to use an embedded SVG icon. Apply it via our CSS custom property, or use the Sass variable.
-
-Inlined SVG requires properly escaped characters. Some reserved characters, such as <, > and #, must be URL-encoded or escaped. We do this with the $breadcrumb-divider variable using our escape-svg() Sass function. When customizing the CSS variable, you must handle this yourself. Read Kevin Weber’s explanations on CodePen for more info.
-
-
-
-
-
-
+
$breadcrumb-divider:quote(">");
+
+
It’s also possible to use an embedded SVG icon. Apply it via our CSS custom property, or use the Sass variable.
+
Inlined SVG requires properly escaped characters. Some reserved characters, such as <, > and #, must be URL-encoded or escaped. We do this with the $breadcrumb-divider variable using our escape-svg() Sass function. When customizing the CSS variable, you must handle this yourself. Read Kevin Weber’s explanations on CodePen for more info.
You can also remove the divider setting --bs-breadcrumb-divider: ''; (empty strings in CSS custom properties counts as a value), or setting the Sass variable to $breadcrumb-divider: none;.
You can also remove the divider setting --bs-breadcrumb-divider: ''; (empty strings in CSS custom properties counts as a value), or setting the Sass variable to $breadcrumb-divider: none;.
Since breadcrumbs provide a navigation, it’s a good idea to add a meaningful label such as aria-label="breadcrumb" to describe the type of navigation provided in the <nav> element, as well as applying an aria-current="page" to the last item of the set to indicate that it represents the current page.
Since breadcrumbs provide a navigation, it’s a good idea to add a meaningful label such as aria-label="breadcrumb" to describe the type of navigation provided in the <nav> element, as well as applying an aria-current="page" to the last item of the set to indicate that it represents the current page.
As part of Bootstrap’s evolving CSS variables approach, breadcrumbs now use local CSS variables on .breadcrumb for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
As part of Bootstrap’s evolving CSS variables approach, breadcrumbs now use local CSS variables on .breadcrumb for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
-Button groups require an appropriate role attribute and explicit label to ensure assistive technologies like screen readers identify buttons as grouped and announce them. Use role="group" for button groups or role="toolbar" for button toolbars. Then use aria-label or aria-labelledby to label them.
-
-
-
These classes can also be added to groups of links, as an alternative to the .nav navigation components.
Button groups require an appropriate role attribute and explicit label to ensure assistive technologies like screen readers identify buttons as grouped and announce them. Use role="group" for button groups or role="toolbar" for button toolbars. Then use aria-label or aria-labelledby to label them.
+
These classes can also be added to groups of links, as an alternative to the .nav navigation components.
Feel free to mix input groups with button groups in your toolbars. Similar to the example above, you’ll likely need some utilities though to space things properly.
Feel free to mix input groups with button groups in your toolbars. Similar to the example above, you’ll likely need some utilities though to space things properly.
+
12
@@ -826,51 +161,34 @@ Button groups require an appropriate role attribute and explicit la
Instead of applying button sizing classes to every button in a group, just add .btn-group-* to each .btn-group, including each one when nesting multiple groups.
-
-
-
-
+
LeftMiddleRight
@@ -886,43 +204,26 @@ Button groups require an appropriate role attribute and explicit la
LeftMiddleRight
-
Bootstrap has a base .btn class that sets up basic styles such as padding and content alignment. By default, .btn controls have a transparent border and background color, and lack any explicit focus and hover styles.
-Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
-
-
-
Disable text wrapping
-
If you don’t want the button text to wrap, you can add the .text-nowrap class to the button. In Sass, you can set $btn-white-space: nowrap to disable text wrapping for each button.
Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
+
Disable text wrapping
+
If you don’t want the button text to wrap, you can add the .text-nowrap class to the button. In Sass, you can set $btn-white-space: nowrap to disable text wrapping for each button.
+
Button tags
The .btn classes are designed to be used with the <button> element. However, you can also use these classes on <a> or <input> elements (though some browsers may apply a slightly different rendering).
When using button classes on <a> elements that are used to trigger in-page functionality (like collapsing content), rather than linking to new pages or sections within the current page, these links should be given a role="button" to appropriately convey their purpose to assistive technologies such as screen readers.
In need of a button, but not the hefty background colors they bring? Replace the default modifier classes with the .btn-outline-* ones to remove all background images and colors on any button.
-Some of the button styles use a relatively light foreground color, and should only be used on a dark background in order to have sufficient contrast.
-
Make buttons look inactive by adding the disabled boolean attribute to any <button> element. Disabled buttons have pointer-events: none applied to, preventing hover and active states from triggering.
To cover cases where you have to keep the href attribute on a disabled link, the .disabled class uses pointer-events: none to try to disable the link functionality of <a>s. Note that this CSS property is not yet standardized for HTML, but all modern browsers support it. In addition, even in browsers that do support pointer-events: none, keyboard navigation remains unaffected, meaning that sighted keyboard users and users of assistive technologies will still be able to activate these links. So to be safe, in addition to aria-disabled="true", also include a tabindex="-1" attribute on these links to prevent them from receiving keyboard focus, and use custom JavaScript to disable their functionality altogether.
Create responsive stacks of full-width, “block buttons” like those in Bootstrap 4 with a mix of our display and gap utilities. By using utilities instead of button-specific classes, we have much greater control over spacing, alignment, and responsive behaviors.
Create responsive stacks of full-width, “block buttons” like those in Bootstrap 4 with a mix of our display and gap utilities. By using utilities instead of button-specific classes, we have much greater control over spacing, alignment, and responsive behaviors.
Here we create a responsive variation, starting with vertically stacked buttons until the md breakpoint, where .d-md-block replaces the .d-grid class, thus nullifying the gap-2 utility. Resize your browser to see them change.
You can adjust the width of your block buttons with grid column width classes. For example, for a half-width “block button”, use .col-6. Center it horizontally with .mx-auto, too.
You can adjust the width of your block buttons with grid column width classes. For example, for a half-width “block button”, use .col-6. Center it horizontally with .mx-auto, too.
Additional utilities can be used to adjust the alignment of buttons when horizontal. Here we’ve taken our previous responsive example and added some flex utilities and a margin utility on the button to right-align the buttons when they’re no longer stacked.
Additional utilities can be used to adjust the alignment of buttons when horizontal. Here we’ve taken our previous responsive example and added some flex utilities and a margin utility on the button to right-align the buttons when they’re no longer stacked.
The button plugin allows you to create simple on/off toggle buttons.
-
-Visually, these toggle buttons are identical to the checkbox toggle buttons. However, they are conveyed differently by assistive technologies: the checkbox toggles will be announced by screen readers as “checked”/“not checked” (since, despite their appearance, they are fundamentally still checkboxes), whereas these toggle buttons will be announced as “button”/“button pressed”. The choice between these two approaches will depend on the type of toggle you are creating, and whether or not the toggle will make sense to users when announced as a checkbox or as an actual button.
-
-
-
Toggle states
-
Add data-bs-toggle="button" to toggle a button’s active state. If you’re pre-toggling a button, you must manually add the .active class andaria-pressed="true" to ensure that it is conveyed appropriately to assistive technologies.
-
-
-
-
+
Visually, these toggle buttons are identical to the checkbox toggle buttons. However, they are conveyed differently by assistive technologies: the checkbox toggles will be announced by screen readers as “checked”/“not checked” (since, despite their appearance, they are fundamentally still checkboxes), whereas these toggle buttons will be announced as “button”/“button pressed”. The choice between these two approaches will depend on the type of toggle you are creating, and whether or not the toggle will make sense to users when announced as a checkbox or as an actual button.
+
Toggle states
+
Add data-bs-toggle="button" to toggle a button’s active state. If you’re pre-toggling a button, you must manually add the .active class andaria-pressed="true" to ensure that it is conveyed appropriately to assistive technologies.
You can create a button instance with the button constructor, for example:
-
constbsButton=newbootstrap.Button('#myButton')
-
-
-
-
Method
-
Description
-
-
-
-
-
dispose
-
Destroys an element’s button. (Removes stored data on the DOM element)
-
-
-
getInstance
-
Static method which allows you to get the button instance associated with a DOM element, you can use it like this: bootstrap.Button.getInstance(element).
-
-
-
getOrCreateInstance
-
Static method which returns a button instance associated with a DOM element or creates a new one in case it wasn’t initialized. You can use it like this: bootstrap.Button.getOrCreateInstance(element).
-
-
-
toggle
-
Toggles push state. Gives the button the appearance that it has been activated.
Destroys an element’s button. (Removes stored data on the DOM element)
getInstance
Static method which allows you to get the button instance associated with a DOM element, you can use it like this: bootstrap.Button.getInstance(element).
getOrCreateInstance
Static method which returns a button instance associated with a DOM element or creates a new one in case it wasn’t initialized. You can use it like this: bootstrap.Button.getOrCreateInstance(element).
toggle
Toggles push state. Gives the button the appearance that it has been activated.
As part of Bootstrap’s evolving CSS variables approach, buttons now use local CSS variables on .btn for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
As part of Bootstrap’s evolving CSS variables approach, buttons now use local CSS variables on .btn for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
Each .btn-* modifier class updates the appropriate CSS variables to minimize additional CSS rules with our button-variant(), button-outline-variant(), and button-size() mixins.
-
Here’s an example of building a custom .btn-* modifier class as we do for the buttons unique to our docs by reassigning Bootstrap’s CSS variables with a mixture of our own CSS and Sass variables.
$btn-color:var(--#{$prefix}body-color);
-$btn-padding-y:$input-btn-padding-y;
-$btn-padding-x:$input-btn-padding-x;
-$btn-font-family:$input-btn-font-family;
-$btn-font-size:$input-btn-font-size;
-$btn-line-height:$input-btn-line-height;
-$btn-white-space:null;// Set to `nowrap` to prevent text wrapping
-
-$btn-padding-y-sm:$input-btn-padding-y-sm;
-$btn-padding-x-sm:$input-btn-padding-x-sm;
-$btn-font-size-sm:$input-btn-font-size-sm;
-
-$btn-padding-y-lg:$input-btn-padding-y-lg;
-$btn-padding-x-lg:$input-btn-padding-x-lg;
-$btn-font-size-lg:$input-btn-font-size-lg;
-
-$btn-border-width:$input-btn-border-width;
-
-$btn-font-weight:$font-weight-normal;
-$btn-box-shadow:inset01px0rgba($white,.15),01px1pxrgba($black,.075);
-$btn-focus-width:$input-btn-focus-width;
-$btn-focus-box-shadow:$input-btn-focus-box-shadow;
-$btn-disabled-opacity:.65;
-$btn-active-box-shadow:inset03px5pxrgba($black,.125);
-
-$btn-link-color:var(--#{$prefix}link-color);
-$btn-link-hover-color:var(--#{$prefix}link-hover-color);
-$btn-link-disabled-color:$gray-600;
-$btn-link-focus-shadow-rgb:to-rgb(mix(color-contrast($link-color),$link-color,15%));
-
-// Allows for customizing button radius independently from global border radius
-$btn-border-radius:var(--#{$prefix}border-radius);
-$btn-border-radius-sm:var(--#{$prefix}border-radius-sm);
-$btn-border-radius-lg:var(--#{$prefix}border-radius-lg);
-
-$btn-transition:color.15sease-in-out,background-color.15sease-in-out,border-color.15sease-in-out,box-shadow.15sease-in-out;
-
-$btn-hover-bg-shade-amount:15%;
-$btn-hover-bg-tint-amount:15%;
-$btn-hover-border-shade-amount:20%;
-$btn-hover-border-tint-amount:10%;
-$btn-active-bg-shade-amount:20%;
-$btn-active-bg-tint-amount:20%;
-$btn-active-border-shade-amount:25%;
-$btn-active-border-tint-amount:10%;
-
-
Sass mixins
+
Here’s an example of building a custom .btn-* modifier class as we do for the buttons unique to our docs by reassigning Bootstrap’s CSS variables with a mixture of our own CSS and Sass variables.
Button variants (for regular and outline buttons) use their respective mixins with our $theme-colors map to generate the modifier classes in scss/_buttons.scss.
A card is a flexible and extensible content container. It includes options for headers and footers, a wide variety of content, contextual background colors, and powerful display options. If you’re familiar with Bootstrap 3, cards replace our old panels, wells, and thumbnails. Similar functionality to those components is available as modifier classes for cards.
-
Example
-
Cards are built with as little markup and styles as possible, but still manage to deliver a ton of control and customization. Built with flexbox, they offer easy alignment and mix well with other Bootstrap components. They have no margin by default, so use spacing utilities as needed.
-
Below is an example of a basic card with mixed content and a fixed width. Cards have no fixed width to start, so they’ll naturally fill the full width of its parent element. This is easily customized with our various sizing options.
A card is a flexible and extensible content container. It includes options for headers and footers, a wide variety of content, contextual background colors, and powerful display options. If you’re familiar with Bootstrap 3, cards replace our old panels, wells, and thumbnails. Similar functionality to those components is available as modifier classes for cards.
+
Example
+
Cards are built with as little markup and styles as possible, but still manage to deliver a ton of control and customization. Built with flexbox, they offer easy alignment and mix well with other Bootstrap components. They have no margin by default, so use spacing utilities as needed.
+
Below is an example of a basic card with mixed content and a fixed width. Cards have no fixed width to start, so they’ll naturally fill the full width of its parent element. This is easily customized with our various sizing options.
+
+ PlaceholderImage cap
Card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
<divclass="card"style="width: 18rem;">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-<ahref="#"class="btn btn-primary">Go somewhere</a>
-</div>
-</div>
-
-
-
Content types
-
Cards support a wide variety of content, including images, text, list groups, links, and more. Below are examples of what’s supported.
-
Body
+
html
<divclass="card"style="width: 18rem;">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ <ahref="#"class="btn btn-primary">Go somewhere</a>
+ </div>
+</div>
+
Content types
+
Cards support a wide variety of content, including images, text, list groups, links, and more. Below are examples of what’s supported.
+
Body
The building block of a card is the .card-body. Use it whenever you need a padded section within a card.
-
-
-
-
+
This is some text within a card body.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="card">
-<divclass="card-body">
- This is some text within a card body.
-</div>
-</div>
-
-
-
Titles, text, and links
+
html
<divclass="card">
+ <divclass="card-body">
+ This is some text within a card body.
+ </div>
+</div>
+
Titles, text, and links
Card titles are used by adding .card-title to a <h*> tag. In the same way, links are added and placed next to each other by adding .card-link to an <a> tag.
Subtitles are used by adding a .card-subtitle to a <h*> tag. If the .card-title and the .card-subtitle items are placed in a .card-body item, the card title and subtitle are aligned nicely.
-
-
-
-
+
Card title
Card subtitle
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
<divclass="card"style="width: 18rem;">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<h6class="card-subtitle mb-2 text-body-secondary">Card subtitle</h6>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-<ahref="#"class="card-link">Card link</a>
-<ahref="#"class="card-link">Another link</a>
-</div>
-</div>
-
-
-
Images
-
.card-img-top and .card-img-bottom respectively set the top and bottom corners rounded to match the card’s borders. With .card-text, text can be added to the card. Text within .card-text can also be styled with the standard HTML tags.
-
-
-
-
- PlaceholderImage cap
+
html
<divclass="card"style="width: 18rem;">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <h6class="card-subtitle mb-2 text-body-secondary">Card subtitle</h6>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ <ahref="#"class="card-link">Card link</a>
+ <ahref="#"class="card-link">Another link</a>
+ </div>
+</div>
+
Images
+
.card-img-top and .card-img-bottom respectively set the top and bottom corners rounded to match the card’s borders. With .card-text, text can be added to the card. Text within .card-text can also be styled with the standard HTML tags.
+
+ PlaceholderImage cap
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="card"style="width: 18rem;">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-</div>
-
-
-
List groups
+
html
<divclass="card"style="width: 18rem;">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+</div>
+
List groups
Create lists of content in a card with a flush list group.
-
-
-
-
+
An item
A second item
A third item
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="card"style="width: 18rem;">
-<ulclass="list-group list-group-flush">
-<liclass="list-group-item">An item</li>
-<liclass="list-group-item">A second item</li>
-<liclass="list-group-item">A third item</li>
-</ul>
-</div>
-
-
-
-
-
-
+
html
<divclass="card"style="width: 18rem;">
+ <ulclass="list-group list-group-flush">
+ <liclass="list-group-item">An item</li>
+ <liclass="list-group-item">A second item</li>
+ <liclass="list-group-item">A third item</li>
+ </ul>
+</div>
+
Featured
@@ -779,34 +111,17 @@
A second item
A third item
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="card"style="width: 18rem;">
-<divclass="card-header">
- Featured
-</div>
-<ulclass="list-group list-group-flush">
-<liclass="list-group-item">An item</li>
-<liclass="list-group-item">A second item</li>
-<liclass="list-group-item">A third item</li>
-</ul>
-</div>
-
-
-
-
-
-
+
html
<divclass="card"style="width: 18rem;">
+ <divclass="card-header">
+ Featured
+ </div>
+ <ulclass="list-group list-group-flush">
+ <liclass="list-group-item">An item</li>
+ <liclass="list-group-item">A second item</li>
+ <liclass="list-group-item">A third item</li>
+ </ul>
+</div>
+
An item
A second item
@@ -815,40 +130,23 @@
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="card"style="width: 18rem;">
-<ulclass="list-group list-group-flush">
-<liclass="list-group-item">An item</li>
-<liclass="list-group-item">A second item</li>
-<liclass="list-group-item">A third item</li>
-</ul>
-<divclass="card-footer">
- Card footer
-</div>
-</div>
Mix and match multiple content types to create the card you need, or throw everything in there. Shown below are image styles, blocks, text styles, and a list group—all wrapped in a fixed-width card.
-
-
-
-
- PlaceholderImage cap
+
+ PlaceholderImage cap
Card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
<divclass="card"style="width: 18rem;">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-<ulclass="list-group list-group-flush">
-<liclass="list-group-item">An item</li>
-<liclass="list-group-item">A second item</li>
-<liclass="list-group-item">A third item</li>
-</ul>
-<divclass="card-body">
-<ahref="#"class="card-link">Card link</a>
-<ahref="#"class="card-link">Another link</a>
-</div>
-</div>
-
-
-
Header and footer
+
html
<divclass="card"style="width: 18rem;">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+ <ulclass="list-group list-group-flush">
+ <liclass="list-group-item">An item</li>
+ <liclass="list-group-item">A second item</li>
+ <liclass="list-group-item">A third item</li>
+ </ul>
+ <divclass="card-body">
+ <ahref="#"class="card-link">Card link</a>
+ <ahref="#"class="card-link">Another link</a>
+ </div>
+</div>
+
Header and footer
Add an optional header and/or footer within a card.
-
-
-
-
+
Featured
@@ -903,105 +184,62 @@
With supporting text below as a natural lead-in to additional content.
<divclass="card">
-<divclass="card-header">
- Featured
-</div>
-<divclass="card-body">
-<h5class="card-title">Special title treatment</h5>
-<pclass="card-text">With supporting text below as a natural lead-in to additional content.</p>
-<ahref="#"class="btn btn-primary">Go somewhere</a>
-</div>
-</div>
-
-
+
html
<divclass="card">
+ <divclass="card-header">
+ Featured
+ </div>
+ <divclass="card-body">
+ <h5class="card-title">Special title treatment</h5>
+ <pclass="card-text">With supporting text below as a natural lead-in to additional content.</p>
+ <ahref="#"class="btn btn-primary">Go somewhere</a>
+ </div>
+</div>
Card headers can be styled by adding .card-header to <h*> elements.
-
-
-
-
+
Featured
Special title treatment
With supporting text below as a natural lead-in to additional content.
<divclass="card">
-<h5class="card-header">Featured</h5>
-<divclass="card-body">
-<h5class="card-title">Special title treatment</h5>
-<pclass="card-text">With supporting text below as a natural lead-in to additional content.</p>
-<ahref="#"class="btn btn-primary">Go somewhere</a>
-</div>
-</div>
-
-
-
-
-
-
+
html
<divclass="card">
+ <h5class="card-header">Featured</h5>
+ <divclass="card-body">
+ <h5class="card-title">Special title treatment</h5>
+ <pclass="card-text">With supporting text below as a natural lead-in to additional content.</p>
+ <ahref="#"class="btn btn-primary">Go somewhere</a>
+ </div>
+</div>
+
Quote
-
-
A well-known quote, contained in a blockquote element.
-
-
+
+
+
A well-known quote, contained in a blockquote element.
+
+
+ Someone famous in Source Title
+
+
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="card">
-<divclass="card-header">
- Quote
-</div>
-<divclass="card-body">
-<blockquoteclass="blockquote mb-0">
-<p>A well-known quote, contained in a blockquote element.</p>
-<footerclass="blockquote-footer">Someone famous in <citetitle="Source Title">Source Title</cite></footer>
-</blockquote>
-</div>
-</div>
-
-
-
-
-
-
+
html
<divclass="card">
+ <divclass="card-header">
+ Quote
+ </div>
+ <divclass="card-body">
+ <figure>
+ <blockquoteclass="blockquote">
+ <p>A well-known quote, contained in a blockquote element.</p>
+ </blockquote>
+ <figcaptionclass="blockquote-footer">
+ Someone famous in <citetitle="Source Title">Source Title</cite>
+ </figcaption>
+ </figure>
+ </div>
+</div>
+
Featured
@@ -1013,41 +251,24 @@
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="card text-center">
-<divclass="card-header">
- Featured
-</div>
-<divclass="card-body">
-<h5class="card-title">Special title treatment</h5>
-<pclass="card-text">With supporting text below as a natural lead-in to additional content.</p>
-<ahref="#"class="btn btn-primary">Go somewhere</a>
-</div>
-<divclass="card-footer text-body-secondary">
- 2 days ago
-</div>
-</div>
-
-
-
Sizing
-
Cards assume no specific width to start, so they’ll be 100% wide unless otherwise stated. You can change this as needed with custom CSS, grid classes, grid Sass mixins, or utilities.
-
Using grid markup
+
html
<divclass="card text-center">
+ <divclass="card-header">
+ Featured
+ </div>
+ <divclass="card-body">
+ <h5class="card-title">Special title treatment</h5>
+ <pclass="card-text">With supporting text below as a natural lead-in to additional content.</p>
+ <ahref="#"class="btn btn-primary">Go somewhere</a>
+ </div>
+ <divclass="card-footer text-body-secondary">
+ 2 days ago
+ </div>
+</div>
+
Sizing
+
Cards assume no specific width to start, so they’ll be 100% wide unless otherwise stated. You can change this as needed with custom CSS, grid classes, grid Sass mixins, or utilities.
+
Using grid markup
Using the grid, wrap cards in columns and rows as needed.
-
-
-
-
+
@@ -1066,46 +287,29 @@
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="row">
-<divclass="col-sm-6 mb-3 mb-sm-0">
-<divclass="card">
-<divclass="card-body">
-<h5class="card-title">Special title treatment</h5>
-<pclass="card-text">With supporting text below as a natural lead-in to additional content.</p>
-<ahref="#"class="btn btn-primary">Go somewhere</a>
-</div>
-</div>
-</div>
-<divclass="col-sm-6">
-<divclass="card">
-<divclass="card-body">
-<h5class="card-title">Special title treatment</h5>
-<pclass="card-text">With supporting text below as a natural lead-in to additional content.</p>
-<ahref="#"class="btn btn-primary">Go somewhere</a>
-</div>
-</div>
-</div>
-</div>
<divclass="card"style="width: 18rem;">
-<divclass="card-body">
-<h5class="card-title">Special title treatment</h5>
-<pclass="card-text">With supporting text below as a natural lead-in to additional content.</p>
-<ahref="#"class="btn btn-primary">Go somewhere</a>
-</div>
-</div>
-
-
-
Text alignment
-
You can quickly change the text alignment of any card—in its entirety or specific parts—with our text align classes.
-
-
-
-
+
html
<divclass="card"style="width: 18rem;">
+ <divclass="card-body">
+ <h5class="card-title">Special title treatment</h5>
+ <pclass="card-text">With supporting text below as a natural lead-in to additional content.</p>
+ <ahref="#"class="btn btn-primary">Go somewhere</a>
+ </div>
+</div>
+
Text alignment
+
You can quickly change the text alignment of any card—in its entirety or specific parts—with our text align classes.
+
Special title treatment
With supporting text below as a natural lead-in to additional content.
@@ -1207,49 +377,32 @@
With supporting text below as a natural lead-in to additional content.
<divclass="card mb-3"style="width: 18rem;">
+ <divclass="card-body">
+ <h5class="card-title">Special title treatment</h5>
+ <pclass="card-text">With supporting text below as a natural lead-in to additional content.</p>
+ <ahref="#"class="btn btn-primary">Go somewhere</a>
+ </div>
+</div>
-
- html
-
-
-
-
-
-
-
-
-
<divclass="card mb-3"style="width: 18rem;">
-<divclass="card-body">
-<h5class="card-title">Special title treatment</h5>
-<pclass="card-text">With supporting text below as a natural lead-in to additional content.</p>
-<ahref="#"class="btn btn-primary">Go somewhere</a>
-</div>
-</div>
-
-<divclass="card text-center mb-3"style="width: 18rem;">
-<divclass="card-body">
-<h5class="card-title">Special title treatment</h5>
-<pclass="card-text">With supporting text below as a natural lead-in to additional content.</p>
-<ahref="#"class="btn btn-primary">Go somewhere</a>
-</div>
-</div>
-
-<divclass="card text-end"style="width: 18rem;">
-<divclass="card-body">
-<h5class="card-title">Special title treatment</h5>
-<pclass="card-text">With supporting text below as a natural lead-in to additional content.</p>
-<ahref="#"class="btn btn-primary">Go somewhere</a>
-</div>
-</div>
-
+<divclass="card text-center mb-3"style="width: 18rem;">
+ <divclass="card-body">
+ <h5class="card-title">Special title treatment</h5>
+ <pclass="card-text">With supporting text below as a natural lead-in to additional content.</p>
+ <ahref="#"class="btn btn-primary">Go somewhere</a>
+ </div>
+</div>
-
Navigation
-
Add some navigation to a card’s header (or block) with Bootstrap’s nav components.
-
-
-
-
+<divclass="card text-end"style="width: 18rem;">
+ <divclass="card-body">
+ <h5class="card-title">Special title treatment</h5>
+ <pclass="card-text">With supporting text below as a natural lead-in to additional content.</p>
+ <ahref="#"class="btn btn-primary">Go somewhere</a>
+ </div>
+</div>
+
Navigation
+
Add some navigation to a card’s header (or block) with Bootstrap’s nav components.
+
@@ -1268,44 +421,27 @@
With supporting text below as a natural lead-in to additional content.
<divclass="card text-center">
-<divclass="card-header">
-<ulclass="nav nav-pills card-header-pills">
-<liclass="nav-item">
-<aclass="nav-link active"href="#">Active</a>
-</li>
-<liclass="nav-item">
-<aclass="nav-link"href="#">Link</a>
-</li>
-<liclass="nav-item">
-<aclass="nav-link disabled"aria-disabled="true">Disabled</a>
-</li>
-</ul>
-</div>
-<divclass="card-body">
-<h5class="card-title">Special title treatment</h5>
-<pclass="card-text">With supporting text below as a natural lead-in to additional content.</p>
-<ahref="#"class="btn btn-primary">Go somewhere</a>
-</div>
-</div>
-
-
-
Images
-
Cards include a few options for working with images. Choose from appending “image caps” at either end of a card, overlaying images with card content, or simply embedding the image in a card.
-
Image caps
-
Similar to headers and footers, cards can include top and bottom “image caps”—images at the top or bottom of a card.
Cards include a few options for working with images. Choose from appending “image caps” at either end of a card, overlaying images with card content, or simply embedding the image in a card.
+
Image caps
+
Similar to headers and footers, cards can include top and bottom “image caps”—images at the top or bottom of a card.
+
+ PlaceholderImage cap
Card title
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
@@ -1379,84 +498,47 @@
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
Last updated 3 mins ago
- PlaceholderImage cap
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="card mb-3">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
-<pclass="card-text"><smallclass="text-body-secondary">Last updated 3 mins ago</small></p>
-</div>
-</div>
-<divclass="card">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
-<pclass="card-text"><smallclass="text-body-secondary">Last updated 3 mins ago</small></p>
-</div>
-<imgsrc="..."class="card-img-bottom"alt="...">
-</div>
-
-
-
Image overlays
-
Turn an image into a card background and overlay your card’s text. Depending on the image, you may or may not need additional styles or utilities.
-
-
-
-
- PlaceholderCard image
+ PlaceholderImage cap
+
html
<divclass="card mb-3">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
+ <pclass="card-text"><smallclass="text-body-secondary">Last updated 3 mins ago</small></p>
+ </div>
+</div>
+<divclass="card">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
+ <pclass="card-text"><smallclass="text-body-secondary">Last updated 3 mins ago</small></p>
+ </div>
+ <imgsrc="..."class="card-img-bottom"alt="...">
+</div>
+
Image overlays
+
Turn an image into a card background and overlay your card’s text. Depending on the image, you may or may not need additional styles or utilities.
+
+ PlaceholderCard image
Card title
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
Last updated 3 mins ago
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="card text-bg-dark">
-<imgsrc="..."class="card-img"alt="...">
-<divclass="card-img-overlay">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
-<pclass="card-text"><small>Last updated 3 mins ago</small></p>
-</div>
-</div>
-
-
-
-Note that content should not be larger than the height of the image. If content is larger than the image the content will be displayed outside the image.
-
-
-
Horizontal
+
html
<divclass="card text-bg-dark">
+ <imgsrc="..."class="card-img"alt="...">
+ <divclass="card-img-overlay">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
+ <pclass="card-text"><small>Last updated 3 mins ago</small></p>
+ </div>
+</div>
+
Note that content should not be larger than the height of the image. If content is larger than the image the content will be displayed outside the image.
+
Horizontal
Using a combination of grid and utility classes, cards can be made horizontal in a mobile-friendly and responsive way. In the example below, we remove the grid gutters with .g-0 and use .col-md-* classes to make the card horizontal at the md breakpoint. Further adjustments may be needed depending on your card content.
-
-
-
-
+
- PlaceholderImage
+ PlaceholderImage
@@ -1466,348 +548,274 @@ Note that content should not be larger than the height of the image. If content
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="card mb-3"style="max-width: 540px;">
-<divclass="row g-0">
-<divclass="col-md-4">
-<imgsrc="..."class="img-fluid rounded-start"alt="...">
-</div>
-<divclass="col-md-8">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
-<pclass="card-text"><smallclass="text-body-secondary">Last updated 3 mins ago</small></p>
-</div>
-</div>
-</div>
-</div>
-
-
-
Card styles
+
html
<divclass="card mb-3"style="max-width: 540px;">
+ <divclass="row g-0">
+ <divclass="col-md-4">
+ <imgsrc="..."class="img-fluid rounded-start"alt="...">
+ </div>
+ <divclass="col-md-8">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
+ <pclass="card-text"><smallclass="text-body-secondary">Last updated 3 mins ago</small></p>
+ </div>
+ </div>
+ </div>
+</div>
+
Card styles
Cards include various options for customizing their backgrounds, borders, and color.
-
Background and color
+
Background and color
Added in v5.2.0
-
-
Set a background-color with contrasting foreground color with our .text-bg-{color} helpers. Previously it was required to manually pair your choice of .text-{color} and .bg-{color} utilities for styling, which you still may use if you prefer.
-
-
-
-
-
+
Set a background-color with contrasting foreground color with our .text-bg-{color} helpers. Previously it was required to manually pair your choice of .text-{color} and .bg-{color} utilities for styling, which you still may use if you prefer.
+
Header
Primary card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
Header
Secondary card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
Header
Success card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
Header
Danger card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
Header
Warning card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
Header
Info card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
Header
Light card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
Header
Dark card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="card text-bg-primary mb-3"style="max-width: 18rem;">
-<divclass="card-header">Header</div>
-<divclass="card-body">
-<h5class="card-title">Primary card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-</div>
-<divclass="card text-bg-secondary mb-3"style="max-width: 18rem;">
-<divclass="card-header">Header</div>
-<divclass="card-body">
-<h5class="card-title">Secondary card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-</div>
-<divclass="card text-bg-success mb-3"style="max-width: 18rem;">
-<divclass="card-header">Header</div>
-<divclass="card-body">
-<h5class="card-title">Success card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-</div>
-<divclass="card text-bg-danger mb-3"style="max-width: 18rem;">
-<divclass="card-header">Header</div>
-<divclass="card-body">
-<h5class="card-title">Danger card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-</div>
-<divclass="card text-bg-warning mb-3"style="max-width: 18rem;">
-<divclass="card-header">Header</div>
-<divclass="card-body">
-<h5class="card-title">Warning card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-</div>
-<divclass="card text-bg-info mb-3"style="max-width: 18rem;">
-<divclass="card-header">Header</div>
-<divclass="card-body">
-<h5class="card-title">Info card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-</div>
-<divclass="card text-bg-light mb-3"style="max-width: 18rem;">
-<divclass="card-header">Header</div>
-<divclass="card-body">
-<h5class="card-title">Light card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-</div>
-<divclass="card text-bg-dark mb-3"style="max-width: 18rem;">
-<divclass="card-header">Header</div>
-<divclass="card-body">
-<h5class="card-title">Dark card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-</div>
-
-
-
-Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
-
-
-
Border
-
Use border utilities to change just the border-color of a card. Note that you can put .text-{color} classes on the parent .card or a subset of the card’s contents as shown below.
-
-
-
-
-
+
html
<divclass="card text-bg-primary mb-3"style="max-width: 18rem;">
+ <divclass="card-header">Header</div>
+ <divclass="card-body">
+ <h5class="card-title">Primary card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+</div>
+<divclass="card text-bg-secondary mb-3"style="max-width: 18rem;">
+ <divclass="card-header">Header</div>
+ <divclass="card-body">
+ <h5class="card-title">Secondary card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+</div>
+<divclass="card text-bg-success mb-3"style="max-width: 18rem;">
+ <divclass="card-header">Header</div>
+ <divclass="card-body">
+ <h5class="card-title">Success card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+</div>
+<divclass="card text-bg-danger mb-3"style="max-width: 18rem;">
+ <divclass="card-header">Header</div>
+ <divclass="card-body">
+ <h5class="card-title">Danger card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+</div>
+<divclass="card text-bg-warning mb-3"style="max-width: 18rem;">
+ <divclass="card-header">Header</div>
+ <divclass="card-body">
+ <h5class="card-title">Warning card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+</div>
+<divclass="card text-bg-info mb-3"style="max-width: 18rem;">
+ <divclass="card-header">Header</div>
+ <divclass="card-body">
+ <h5class="card-title">Info card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+</div>
+<divclass="card text-bg-light mb-3"style="max-width: 18rem;">
+ <divclass="card-header">Header</div>
+ <divclass="card-body">
+ <h5class="card-title">Light card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+</div>
+<divclass="card text-bg-dark mb-3"style="max-width: 18rem;">
+ <divclass="card-header">Header</div>
+ <divclass="card-body">
+ <h5class="card-title">Dark card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+</div>
+
Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
+
Border
+
Use border utilities to change just the border-color of a card. Note that you can put .text-{color} classes on the parent .card or a subset of the card’s contents as shown below.
+
Header
Primary card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
Header
Secondary card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
Header
Success card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
Header
Danger card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
Header
Warning card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
Header
Info card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
Header
Light card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
Header
Dark card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="card border-primary mb-3"style="max-width: 18rem;">
-<divclass="card-header">Header</div>
-<divclass="card-body text-primary">
-<h5class="card-title">Primary card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-</div>
-<divclass="card border-secondary mb-3"style="max-width: 18rem;">
-<divclass="card-header">Header</div>
-<divclass="card-body text-secondary">
-<h5class="card-title">Secondary card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-</div>
-<divclass="card border-success mb-3"style="max-width: 18rem;">
-<divclass="card-header">Header</div>
-<divclass="card-body text-success">
-<h5class="card-title">Success card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-</div>
-<divclass="card border-danger mb-3"style="max-width: 18rem;">
-<divclass="card-header">Header</div>
-<divclass="card-body text-danger">
-<h5class="card-title">Danger card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-</div>
-<divclass="card border-warning mb-3"style="max-width: 18rem;">
-<divclass="card-header">Header</div>
-<divclass="card-body">
-<h5class="card-title">Warning card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-</div>
-<divclass="card border-info mb-3"style="max-width: 18rem;">
-<divclass="card-header">Header</div>
-<divclass="card-body">
-<h5class="card-title">Info card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-</div>
-<divclass="card border-light mb-3"style="max-width: 18rem;">
-<divclass="card-header">Header</div>
-<divclass="card-body">
-<h5class="card-title">Light card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-</div>
-<divclass="card border-dark mb-3"style="max-width: 18rem;">
-<divclass="card-header">Header</div>
-<divclass="card-body">
-<h5class="card-title">Dark card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-</div>
-
-
-
Mixins utilities
+
html
<divclass="card border-primary mb-3"style="max-width: 18rem;">
+ <divclass="card-header">Header</div>
+ <divclass="card-body text-primary">
+ <h5class="card-title">Primary card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+</div>
+<divclass="card border-secondary mb-3"style="max-width: 18rem;">
+ <divclass="card-header">Header</div>
+ <divclass="card-body text-secondary">
+ <h5class="card-title">Secondary card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+</div>
+<divclass="card border-success mb-3"style="max-width: 18rem;">
+ <divclass="card-header">Header</div>
+ <divclass="card-body text-success">
+ <h5class="card-title">Success card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+</div>
+<divclass="card border-danger mb-3"style="max-width: 18rem;">
+ <divclass="card-header">Header</div>
+ <divclass="card-body text-danger">
+ <h5class="card-title">Danger card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+</div>
+<divclass="card border-warning mb-3"style="max-width: 18rem;">
+ <divclass="card-header">Header</div>
+ <divclass="card-body">
+ <h5class="card-title">Warning card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+</div>
+<divclass="card border-info mb-3"style="max-width: 18rem;">
+ <divclass="card-header">Header</div>
+ <divclass="card-body">
+ <h5class="card-title">Info card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+</div>
+<divclass="card border-light mb-3"style="max-width: 18rem;">
+ <divclass="card-header">Header</div>
+ <divclass="card-body">
+ <h5class="card-title">Light card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+</div>
+<divclass="card border-dark mb-3"style="max-width: 18rem;">
+ <divclass="card-header">Header</div>
+ <divclass="card-body">
+ <h5class="card-title">Dark card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+</div>
+
Mixins utilities
You can also change the borders on the card header and footer as needed, and even remove their background-color with .bg-transparent.
-
-
-
-
+
Header
Success card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="card border-success mb-3"style="max-width: 18rem;">
-<divclass="card-header bg-transparent border-success">Header</div>
-<divclass="card-body text-success">
-<h5class="card-title">Success card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-<divclass="card-footer bg-transparent border-success">Footer</div>
-</div>
-
-
-
Card layout
+
html
<divclass="card border-success mb-3"style="max-width: 18rem;">
+ <divclass="card-header bg-transparent border-success">Header</div>
+ <divclass="card-body text-success">
+ <h5class="card-title">Success card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+ <divclass="card-footer bg-transparent border-success">Footer</div>
+</div>
+
Card layout
In addition to styling the content within cards, Bootstrap includes a few options for laying out series of cards. For the time being, these layout options are not yet responsive.
-
Card groups
+
Card groups
Use card groups to render cards as a single, attached element with equal width and height columns. Card groups start off stacked and use display: flex; to become attached with uniform dimensions starting at the sm breakpoint.
-
-
-
-
+
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
@@ -1815,7 +823,7 @@ Note that content should not be larger than the height of the image. If content
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This card has supporting text below as a natural lead-in to additional content.
@@ -1823,60 +831,43 @@ Note that content should not be larger than the height of the image. If content
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.
Last updated 3 mins ago
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="card-group">
-<divclass="card">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
-<pclass="card-text"><smallclass="text-body-secondary">Last updated 3 mins ago</small></p>
-</div>
-</div>
-<divclass="card">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
-<pclass="card-text"><smallclass="text-body-secondary">Last updated 3 mins ago</small></p>
-</div>
-</div>
-<divclass="card">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
-<pclass="card-text"><smallclass="text-body-secondary">Last updated 3 mins ago</small></p>
-</div>
-</div>
-</div>
-
-
+
html
<divclass="card-group">
+ <divclass="card">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
+ <pclass="card-text"><smallclass="text-body-secondary">Last updated 3 mins ago</small></p>
+ </div>
+ </div>
+ <divclass="card">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
+ <pclass="card-text"><smallclass="text-body-secondary">Last updated 3 mins ago</small></p>
+ </div>
+ </div>
+ <divclass="card">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
+ <pclass="card-text"><smallclass="text-body-secondary">Last updated 3 mins ago</small></p>
+ </div>
+ </div>
+</div>
When using card groups with footers, their content will automatically line up.
-
-
-
-
+
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
@@ -1886,7 +877,7 @@ Note that content should not be larger than the height of the image. If content
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This card has supporting text below as a natural lead-in to additional content.
@@ -1896,7 +887,7 @@ Note that content should not be larger than the height of the image. If content
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.
@@ -1905,61 +896,44 @@ Note that content should not be larger than the height of the image. If content
Last updated 3 mins ago
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="card-group">
-<divclass="card">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
-</div>
-<divclass="card-footer">
-<smallclass="text-body-secondary">Last updated 3 mins ago</small>
-</div>
-</div>
-<divclass="card">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
-</div>
-<divclass="card-footer">
-<smallclass="text-body-secondary">Last updated 3 mins ago</small>
-</div>
-</div>
-<divclass="card">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
-</div>
-<divclass="card-footer">
-<smallclass="text-body-secondary">Last updated 3 mins ago</small>
-</div>
-</div>
-</div>
-
-
-
Grid cards
-
Use the Bootstrap grid system and its .row-cols classes to control how many grid columns (wrapped around your cards) you show per row. For example, here’s .row-cols-1 laying out the cards on one column, and .row-cols-md-2 splitting four cards to equal width across multiple rows, from the medium breakpoint up.
-
-
-
-
+
html
<divclass="card-group">
+ <divclass="card">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
+ </div>
+ <divclass="card-footer">
+ <smallclass="text-body-secondary">Last updated 3 mins ago</small>
+ </div>
+ </div>
+ <divclass="card">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
+ </div>
+ <divclass="card-footer">
+ <smallclass="text-body-secondary">Last updated 3 mins ago</small>
+ </div>
+ </div>
+ <divclass="card">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
+ </div>
+ <divclass="card-footer">
+ <smallclass="text-body-secondary">Last updated 3 mins ago</small>
+ </div>
+ </div>
+</div>
+
Grid cards
+
Use the Bootstrap grid system and its .row-cols classes to control how many grid columns (wrapped around your cards) you show per row. For example, here’s .row-cols-1 laying out the cards on one column, and .row-cols-md-2 splitting four cards to equal width across multiple rows, from the medium breakpoint up.
+
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
@@ -1968,7 +942,7 @@ Note that content should not be larger than the height of the image. If content
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
@@ -1977,7 +951,7 @@ Note that content should not be larger than the height of the image. If content
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This is a longer card with supporting text below as a natural lead-in to additional content.
@@ -1986,73 +960,56 @@ Note that content should not be larger than the height of the image. If content
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="row row-cols-1 row-cols-md-2 g-4">
-<divclass="col">
-<divclass="card">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
-</div>
-</div>
-</div>
-<divclass="col">
-<divclass="card">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
-</div>
-</div>
-</div>
-<divclass="col">
-<divclass="card">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content.</p>
-</div>
-</div>
-</div>
-<divclass="col">
-<divclass="card">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
-</div>
-</div>
-</div>
-</div>
-
-
-
Change it to .row-cols-3 and you’ll see the fourth card wrap.
-
-
-
-
+
html
<divclass="row row-cols-1 row-cols-md-2 g-4">
+ <divclass="col">
+ <divclass="card">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
+ </div>
+ </div>
+ </div>
+ <divclass="col">
+ <divclass="card">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
+ </div>
+ </div>
+ </div>
+ <divclass="col">
+ <divclass="card">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content.</p>
+ </div>
+ </div>
+ </div>
+ <divclass="col">
+ <divclass="card">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
+ </div>
+ </div>
+ </div>
+</div>
+
Change it to .row-cols-3 and you’ll see the fourth card wrap.
+
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
@@ -2061,7 +1018,7 @@ Note that content should not be larger than the height of the image. If content
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
@@ -2070,7 +1027,7 @@ Note that content should not be larger than the height of the image. If content
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This is a longer card with supporting text below as a natural lead-in to additional content.
@@ -2079,73 +1036,56 @@ Note that content should not be larger than the height of the image. If content
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="row row-cols-1 row-cols-md-3 g-4">
-<divclass="col">
-<divclass="card">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
-</div>
-</div>
-</div>
-<divclass="col">
-<divclass="card">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
-</div>
-</div>
-</div>
-<divclass="col">
-<divclass="card">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content.</p>
-</div>
-</div>
-</div>
-<divclass="col">
-<divclass="card">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
-</div>
-</div>
-</div>
-</div>
-
-
+
html
<divclass="row row-cols-1 row-cols-md-3 g-4">
+ <divclass="col">
+ <divclass="card">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
+ </div>
+ </div>
+ </div>
+ <divclass="col">
+ <divclass="card">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
+ </div>
+ </div>
+ </div>
+ <divclass="col">
+ <divclass="card">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content.</p>
+ </div>
+ </div>
+ </div>
+ <divclass="col">
+ <divclass="card">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
+ </div>
+ </div>
+ </div>
+</div>
When you need equal height, add .h-100 to the cards. If you want equal heights by default, you can set $card-height: 100% in Sass.
-
-
-
-
+
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
@@ -2154,7 +1094,7 @@ Note that content should not be larger than the height of the image. If content
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This is a short card.
@@ -2163,7 +1103,7 @@ Note that content should not be larger than the height of the image. If content
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This is a longer card with supporting text below as a natural lead-in to additional content.
@@ -2172,73 +1112,56 @@ Note that content should not be larger than the height of the image. If content
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="row row-cols-1 row-cols-md-3 g-4">
-<divclass="col">
-<divclass="card h-100">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
-</div>
-</div>
-</div>
-<divclass="col">
-<divclass="card h-100">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a short card.</p>
-</div>
-</div>
-</div>
-<divclass="col">
-<divclass="card h-100">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content.</p>
-</div>
-</div>
-</div>
-<divclass="col">
-<divclass="card h-100">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
-</div>
-</div>
-</div>
-</div>
-
-
+
html
<divclass="row row-cols-1 row-cols-md-3 g-4">
+ <divclass="col">
+ <divclass="card h-100">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
+ </div>
+ </div>
+ </div>
+ <divclass="col">
+ <divclass="card h-100">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a short card.</p>
+ </div>
+ </div>
+ </div>
+ <divclass="col">
+ <divclass="card h-100">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content.</p>
+ </div>
+ </div>
+ </div>
+ <divclass="col">
+ <divclass="card h-100">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
+ </div>
+ </div>
+ </div>
+</div>
Just like with card groups, card footers will automatically line up.
-
-
-
-
+
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
@@ -2250,7 +1173,7 @@ Note that content should not be larger than the height of the image. If content
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This card has supporting text below as a natural lead-in to additional content.
@@ -2262,7 +1185,7 @@ Note that content should not be larger than the height of the image. If content
- PlaceholderImage cap
+ PlaceholderImage cap
Card title
This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.
@@ -2272,195 +1195,92 @@ Note that content should not be larger than the height of the image. If content
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="row row-cols-1 row-cols-md-3 g-4">
-<divclass="col">
-<divclass="card h-100">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
-</div>
-<divclass="card-footer">
-<smallclass="text-body-secondary">Last updated 3 mins ago</small>
-</div>
-</div>
-</div>
-<divclass="col">
-<divclass="card h-100">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
-</div>
-<divclass="card-footer">
-<smallclass="text-body-secondary">Last updated 3 mins ago</small>
-</div>
-</div>
-</div>
-<divclass="col">
-<divclass="card h-100">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
-</div>
-<divclass="card-footer">
-<smallclass="text-body-secondary">Last updated 3 mins ago</small>
-</div>
-</div>
-</div>
-</div>
-
-
-
Masonry
-
In v4 we used a CSS-only technique to mimic the behavior of Masonry-like columns, but this technique came with lots of unpleasant side effects. If you want to have this type of layout in v5, you can just make use of Masonry plugin. Masonry is not included in Bootstrap, but we’ve made a demo example to help you get started.
-
CSS
-
Variables
+
html
<divclass="row row-cols-1 row-cols-md-3 g-4">
+ <divclass="col">
+ <divclass="card h-100">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
+ </div>
+ <divclass="card-footer">
+ <smallclass="text-body-secondary">Last updated 3 mins ago</small>
+ </div>
+ </div>
+ </div>
+ <divclass="col">
+ <divclass="card h-100">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
+ </div>
+ <divclass="card-footer">
+ <smallclass="text-body-secondary">Last updated 3 mins ago</small>
+ </div>
+ </div>
+ </div>
+ <divclass="col">
+ <divclass="card h-100">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
+ </div>
+ <divclass="card-footer">
+ <smallclass="text-body-secondary">Last updated 3 mins ago</small>
+ </div>
+ </div>
+ </div>
+</div>
+
Masonry
+
In v4 we used a CSS-only technique to mimic the behavior of Masonry-like columns, but this technique came with lots of unpleasant side effects. If you want to have this type of layout in v5, you can just make use of Masonry plugin. Masonry is not included in Bootstrap, but we’ve made a demo example to help you get started.
+
CSS
+
Variables
Added in v5.2.0
-
-
As part of Bootstrap’s evolving CSS variables approach, cards now use local CSS variables on .card for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
As part of Bootstrap’s evolving CSS variables approach, cards now use local CSS variables on .card for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
The carousel is a slideshow for cycling through a series of content, built with CSS 3D transforms 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.
For performance reasons, carousels must be manually initialized using the carousel constructor method. Without initialization, some of the event listeners (specifically, the events needed touch/swipe support) will not be registered until a user has explicitly activated a control or indicator.
-
The only exception are autoplaying carousels with the data-bs-ride="carousel" attribute as these are initialized automatically on page load. If you’re using autoplaying carousels with the data attribute, don’t explicitly initialize the same carousels with the constructor method.
+
The only exception are autoplaying carousels with the data-bs-ride="carousel" attribute as these are initialized automatically on page load. If you’re using autoplaying carousels with the data attribute, don’t explicitly initialize the same carousels with the constructor method.
Nested carousels are not supported. You should also be aware that carousels in general can often cause usability and accessibility challenges.
Here is a basic example of a carousel with three slides. Note the previous/next controls. We recommend using <button> elements, but you can also use <a> elements with role="button".
Carousels don’t automatically normalize slide dimensions. As such, you may need to use additional utilities or custom styles to appropriately size content. While carousels support previous/next controls and indicators, they’re not explicitly required. Add and customize as you see fit.
-
You must add the .active class to one of the slides, otherwise the carousel will not be visible. Also be sure to set a unique id on the .carousel for optional controls, especially if you’re using multiple carousels on a single page. Control and indicator elements must have a data-bs-target attribute (or href for links) that matches the id of the .carousel element.
Carousels don’t automatically normalize slide dimensions. As such, you may need to use additional utilities or custom styles to appropriately size content. While carousels support previous/next controls and indicators, they’re not explicitly required. Add and customize as you see fit.
+
You must add the .active class to one of the slides, otherwise the carousel will not be visible. Also be sure to set a unique id on the .carousel for optional controls, especially if you’re using multiple carousels on a single page. Control and indicator elements must have a data-bs-target attribute (or href for links) that matches the id of the .carousel element.
+
Indicators
You can add indicators to the carousel, alongside the previous/next controls. The indicators let users jump directly to a particular slide.
-
-
-
-
+
@@ -676,13 +90,13 @@ The animation effect of this component is dependent on the prefers-reduced
You can add captions to your slides with the .carousel-caption element within any .carousel-item. They can be easily hidden on smaller viewports, as shown below, with optional display utilities. We hide them initially with .d-none and bring them back on medium-sized devices with .d-md-block.
You can add captions to your slides with the .carousel-caption element within any .carousel-item. They can be easily hidden on smaller viewports, as shown below, with optional display utilities. We hide them initially with .d-none and bring them back on medium-sized devices with .d-md-block.
+
@@ -746,21 +143,21 @@ The animation effect of this component is dependent on the prefers-reduced
- PlaceholderFirst slide
+ PlaceholderFirst slide
First slide label
Some representative placeholder content for the first slide.
Add .carousel-fade to your carousel to animate slides with a fade transition instead of a slide. Depending on your carousel content (e.g., text only slides), you may want to add .bg-body or some custom CSS to the .carousel-items for proper crossfading.
You can make your carousels autoplay on page load by setting the ride option to carousel. Autoplaying carousels automatically pause while hovered with the mouse. This behavior can be controlled with the pause option. In browsers that support the Page Visibility API, the carousel will stop cycling when the webpage is not visible to the user (such as when the browser tab is inactive, or when the browser window is minimized).
-
-
For accessibility reasons, we recommend avoiding the use of autoplaying carousels. If your page does include an autoplaying carousel, we recommend providing an additional button or control to explicitly pause/stop the carousel.
For accessibility reasons, we recommend avoiding the use of autoplaying carousels. If your page does include an autoplaying carousel, we recommend providing an additional button or control to explicitly pause/stop the carousel.
When the ride option is set to true, rather than carousel, the carousel won’t automatically start to cycle on page load. Instead, it will only start after the first user interaction.
When the ride option is set to true, rather than carousel, the carousel won’t automatically start to cycle on page load. Instead, it will only start after the first user interaction.
Add .carousel-dark to the .carousel for darker controls, indicators, and captions. Controls are inverted compared to their default white fill with the filter CSS property. Captions and controls have additional Sass variables that customize the color and background-color.
-
-
- Heads up! Dark variants for components were deprecated in v5.3.0 with the introduction of color modes. Instead of adding .carousel-dark, set data-bs-theme="dark" on the root element, a parent wrapper, or the component itself.
-
-
-
-
-
-
-
+
Heads up! Dark variants for components were deprecated in v5.3.0 with the introduction of color modes.
+ Instead of adding .carousel-dark, set data-bs-theme="dark" on the root element, a parent
+ wrapper, or the component itself.
+
+
@@ -1197,21 +468,21 @@ The animation effect of this component is dependent on the prefers-reduced
- PlaceholderFirst slide
+ PlaceholderFirst slide
First slide label
Some representative placeholder content for the first slide.
Some representative placeholder content for the second slide.
- PlaceholderThird slide
+ PlaceholderThird slide
Third slide label
Some representative placeholder content for the third slide.
@@ -1226,234 +497,200 @@ The animation effect of this component is dependent on the prefers-reduced
Next
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divid="carouselExampleDark"class="carousel carousel-dark slide">
-<divclass="carousel-indicators">
-<buttontype="button"data-bs-target="#carouselExampleDark"data-bs-slide-to="0"class="active"aria-current="true"aria-label="Slide 1"></button>
-<buttontype="button"data-bs-target="#carouselExampleDark"data-bs-slide-to="1"aria-label="Slide 2"></button>
-<buttontype="button"data-bs-target="#carouselExampleDark"data-bs-slide-to="2"aria-label="Slide 3"></button>
-</div>
-<divclass="carousel-inner">
-<divclass="carousel-item active"data-bs-interval="10000">
-<imgsrc="..."class="d-block w-100"alt="...">
-<divclass="carousel-caption d-none d-md-block">
-<h5>First slide label</h5>
-<p>Some representative placeholder content for the first slide.</p>
-</div>
-</div>
-<divclass="carousel-item"data-bs-interval="2000">
-<imgsrc="..."class="d-block w-100"alt="...">
-<divclass="carousel-caption d-none d-md-block">
-<h5>Second slide label</h5>
-<p>Some representative placeholder content for the second slide.</p>
-</div>
-</div>
-<divclass="carousel-item">
-<imgsrc="..."class="d-block w-100"alt="...">
-<divclass="carousel-caption d-none d-md-block">
-<h5>Third slide label</h5>
-<p>Some representative placeholder content for the third slide.</p>
-</div>
-</div>
-</div>
-<buttonclass="carousel-control-prev"type="button"data-bs-target="#carouselExampleDark"data-bs-slide="prev">
-<spanclass="carousel-control-prev-icon"aria-hidden="true"></span>
-<spanclass="visually-hidden">Previous</span>
-</button>
-<buttonclass="carousel-control-next"type="button"data-bs-target="#carouselExampleDark"data-bs-slide="next">
-<spanclass="carousel-control-next-icon"aria-hidden="true"></span>
-<spanclass="visually-hidden">Next</span>
-</button>
-</div>
-
-
-
Custom transition
-
The transition duration of .carousel-item can be changed with the $carousel-transition-duration Sass variable before compiling or custom styles if you’re using the compiled CSS. If multiple transitions are applied, make sure the transform transition is defined first (e.g. transition: transform 2s ease, opacity .5s ease-out).
The transition duration of .carousel-item can be changed with the $carousel-transition-duration Sass variable before compiling or custom styles if you’re using the compiled CSS. If multiple transitions are applied, make sure the transform transition is defined first (e.g. transition: transform 2s ease, opacity .5s ease-out).
$carousel-dark-indicator-active-bg:$black;// Deprecated in v5.3.4
-$carousel-dark-caption-color:$black;// Deprecated in v5.3.4
-$carousel-dark-control-icon-filter:invert(1)grayscale(100);// Deprecated in v5.3.4
-
$carousel-dark-indicator-active-bg:$black;// Deprecated in v5.3.4
+$carousel-dark-caption-color:$black;// Deprecated in v5.3.4
+$carousel-dark-control-icon-filter:invert(1)grayscale(100);// Deprecated in v5.3.4
+
+
Usage
+
Via data attributes
Use data attributes to easily control the position of the carousel. data-bs-slide accepts the keywords prev or next, which alters the slide position relative to its current position. Alternatively, use data-bs-slide-to to pass a raw slide index to the carousel data-bs-slide-to="2", which shifts the slide position to a particular index beginning with 0.
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
-
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
+
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
The final configuration object is the merged result of data-bs-config, data-bs-, and js object where the latest given key-value overrides the others.
+
-
-
-
-
Name
-
Type
-
Default
-
Description
-
-
-
-
-
interval
-
number
-
5000
-
The amount of time to delay between automatically cycling an item.
-
-
-
keyboard
-
boolean
-
true
-
Whether the carousel should react to keyboard events.
-
-
-
pause
-
string, boolean
-
"hover"
-
If set to "hover", pauses the cycling of the carousel on mouseenter and resumes the cycling of the carousel on mouseleave. If set to false, hovering over the carousel won’t pause it. On touch-enabled devices, when set to "hover", cycling will pause on touchend (once the user finished interacting with the carousel) for two intervals, before automatically resuming. This is in addition to the mouse behavior.
-
-
-
ride
-
string, boolean
-
false
-
If set to true, autoplays the carousel after the user manually cycles the first item. If set to "carousel", autoplays the carousel on load.
-
-
-
touch
-
boolean
-
true
-
Whether the carousel should support left/right swipe interactions on touchscreen devices.
-
-
-
wrap
-
boolean
-
true
-
Whether the carousel should cycle continuously or have hard stops.
-
-
-
-
Methods
-
-All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started, but before it ends. In addition, a method call on a transitioning component will be ignored. Learn more in our JavaScript docs.
-
-
You can create a carousel instance with the carousel constructor, and pass on any additional options. For example, to manually initialize an autoplaying carousel (assuming you’re not using the data-bs-ride="carousel" attribute in the markup itself) with a specific interval and with touch support disabled, you can use:
Starts cycling through the carousel items from left to right.
-
-
-
dispose
-
Destroys an element’s carousel. (Removes stored data on the DOM element)
-
-
-
getInstance
-
Static method which allows you to get the carousel instance associated to a DOM element. You can use it like this: bootstrap.Carousel.getInstance(element).
-
-
-
getOrCreateInstance
-
Static method which returns a carousel instance associated to a DOM element, or creates a new one in case it wasn’t initialized. You can use it like this: bootstrap.Carousel.getOrCreateInstance(element).
-
-
-
next
-
Cycles to the next item. Returns to the caller before the next item has been shown (e.g., before the slid.bs.carousel event occurs).
-
-
-
nextWhenVisible
-
Don’t cycle carousel to next when the page, the carousel, or the carousel’s parent aren’t visible. Returns to the caller before the target item has been shown.
-
-
-
pause
-
Stops the carousel from cycling through items.
-
-
-
prev
-
Cycles to the previous item. Returns to the caller before the previous item has been shown (e.g., before the slid.bs.carousel event occurs).
-
-
-
to
-
Cycles the carousel to a particular frame (0 based, similar to an array). Returns to the caller before the target item has been shown (e.g., before the slid.bs.carousel event occurs).
-
-
-
-
Events
-
Bootstrap’s carousel class exposes two events for hooking into carousel functionality. Both events have the following additional properties:
The amount of time to delay between automatically cycling an item.
keyboard
boolean
true
Whether the carousel should react to keyboard events.
pause
string, boolean
"hover"
If set to "hover", pauses the cycling of the carousel on mouseenter and resumes the cycling of the carousel on mouseleave. If set to false, hovering over the carousel won’t pause it. On touch-enabled devices, when set to "hover", cycling will pause on touchend (once the user finished interacting with the carousel) for two intervals, before automatically resuming. This is in addition to the mouse behavior.
ride
string, boolean
false
If set to true, autoplays the carousel after the user manually cycles the first item. If set to "carousel", autoplays the carousel on load.
touch
boolean
true
Whether the carousel should support left/right swipe interactions on touchscreen devices.
wrap
boolean
true
Whether the carousel should cycle continuously or have hard stops.
+
Methods
+
All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started, but before it ends. In addition, a method call on a transitioning component will be ignored. Learn more in our JavaScript docs.
+
You can create a carousel instance with the carousel constructor, and pass on any additional options. For example, to manually initialize an autoplaying carousel (assuming you’re not using the data-bs-ride="carousel" attribute in the markup itself) with a specific interval and with touch support disabled, you can use:
Starts cycling through the carousel items from left to right.
dispose
Destroys an element’s carousel. (Removes stored data on the DOM element)
getInstance
Static method which allows you to get the carousel instance associated to a DOM element. You can use it like this: bootstrap.Carousel.getInstance(element).
getOrCreateInstance
Static method which returns a carousel instance associated to a DOM element, or creates a new one in case it wasn’t initialized. You can use it like this: bootstrap.Carousel.getOrCreateInstance(element).
next
Cycles to the next item. Returns to the caller before the next item has been shown (e.g., before the slid.bs.carousel event occurs).
nextWhenVisible
Don’t cycle carousel to next when the page, the carousel, or the carousel’s parent aren’t visible. Returns to the caller before the target item has been shown.
pause
Stops the carousel from cycling through items.
prev
Cycles to the previous item. Returns to the caller before the previous item has been shown (e.g., before the slid.bs.carousel event occurs).
to
Cycles the carousel to a particular frame (0 based, similar to an array). Returns to the caller before the target item has been shown (e.g., before the slid.bs.carousel event occurs).
+
Events
+
Bootstrap’s carousel class exposes two events for hooking into carousel functionality. Both events have the following additional properties:
direction: The direction in which the carousel is sliding (either "left" or "right").
relatedTarget: The DOM element that is being slid into place as the active item.
@@ -1461,104 +698,31 @@ The animation effect of this component is dependent on the prefers-reduced
to: The index of the next item
All carousel events are fired at the carousel itself (i.e. at the <div class="carousel">).
-
-
-
-
Event type
-
Description
-
-
-
-
-
slid.bs.carousel
-
Fired when the carousel has completed its slide transition.
-
-
-
slide.bs.carousel
-
Fires immediately when the slide instance method is invoked.
-
-
-
-
-
constmyCarousel=document.getElementById('myCarousel')
-
-myCarousel.addEventListener('slide.bs.carousel',event=>{
-// do something...
-})
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
Event type
Description
slid.bs.carousel
Fired when the carousel has completed its slide transition.
slide.bs.carousel
Fires immediately when the slide instance method is invoked.
Provide an option to dismiss or close a component with .btn-close. Default styling is limited, but highly customizable. Modify the Sass variables to replace the default background-image. Be sure to include text for screen readers, as we’ve done with aria-label.
Disabled close buttons change their opacity. We’ve also applied pointer-events: none and user-select: none to preventing hover and active states from triggering.
Provide an option to dismiss or close a component with .btn-close. Default styling is limited, but highly customizable. Modify the Sass variables to replace the default background-image. Be sure to include text for screen readers, as we’ve done with aria-label.
Disabled close buttons change their opacity. We’ve also applied pointer-events: none and user-select: none to preventing hover and active states from triggering.
Heads up! As of v5.3.0, the .btn-close-white class is deprecated. Instead, use data-bs-theme="dark" to change the color mode of the close button.
Add data-bs-theme="dark" to the .btn-close, or to its parent element, to invert the close button. This uses the filter property to invert the background-image without overriding its value.
As part of Bootstrap’s evolving CSS variables approach, close button now uses local CSS variables on .btn-close for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
As part of Bootstrap’s evolving CSS variables approach, close button now uses local CSS variables on .btn-close for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
The collapse JavaScript plugin is used to show and hide content. Buttons or anchors are used as triggers that are mapped to specific elements you toggle. Collapsing an element will animate the height from its current value to 0. Given how CSS handles animations, you cannot use padding on a .collapse element. Instead, use the class as an independent wrapping element.
Click the buttons below to show and hide another element via class changes:
.collapse hides content
@@ -587,10 +32,7 @@ The animation effect of this component is dependent on the prefers-reduced
.collapse.show shows content
Generally, we recommend using a <button> with the data-bs-target attribute. While not recommended from a semantic point of view, you can also use an <a> link with the href attribute (and a role="button"). In both cases, the data-bs-toggle="collapse" is required.
-
-
-
-
+
Link with href
@@ -602,43 +44,23 @@ The animation effect of this component is dependent on the prefers-reduced
Some placeholder content for the collapse component. This panel is hidden by default but revealed when the user activates the relevant trigger.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<pclass="d-inline-flex gap-1">
-<aclass="btn btn-primary"data-bs-toggle="collapse"href="#collapseExample"role="button"aria-expanded="false"aria-controls="collapseExample">
- Link with href
-</a>
-<buttonclass="btn btn-primary"type="button"data-bs-toggle="collapse"data-bs-target="#collapseExample"aria-expanded="false"aria-controls="collapseExample">
- Button with data-bs-target
-</button>
-</p>
-<divclass="collapse"id="collapseExample">
-<divclass="card card-body">
- Some placeholder content for the collapse component. This panel is hidden by default but revealed when the user activates the relevant trigger.
-</div>
-</div>
-
-
-
Horizontal
-
The collapse plugin supports horizontal collapsing. Add the .collapse-horizontal modifier class to transition the width instead of height and set a width on the immediate child element. Feel free to write your own custom Sass, use inline styles, or use our width utilities.
-
-Please note that while the example below has a min-height set to avoid excessive repaints in our docs, this is not explicitly required. Only the width on the child element is required.
-
-
-
-
-
-
+
html
<pclass="d-inline-flex gap-1">
+ <aclass="btn btn-primary"data-bs-toggle="collapse"href="#collapseExample"role="button"aria-expanded="false"aria-controls="collapseExample">
+ Link with href
+ </a>
+ <buttonclass="btn btn-primary"type="button"data-bs-toggle="collapse"data-bs-target="#collapseExample"aria-expanded="false"aria-controls="collapseExample">
+ Button with data-bs-target
+ </button>
+</p>
+<divclass="collapse"id="collapseExample">
+ <divclass="card card-body">
+ Some placeholder content for the collapse component. This panel is hidden by default but revealed when the user activates the relevant trigger.
+ </div>
+</div>
+
Horizontal
+
The collapse plugin supports horizontal collapsing. Add the .collapse-horizontal modifier class to transition the width instead of height and set a width on the immediate child element. Feel free to write your own custom Sass, use inline styles, or use our width utilities.
+
Please note that while the example below has a min-height set to avoid excessive repaints in our docs, this is not explicitly required. Only the width on the child element is required.
+
Toggle width collapse
@@ -646,42 +68,25 @@ Please note that while the example below has a min-height set to av
- This is some placeholder content for a horizontal collapse. It's hidden by default and shown when triggered.
+ This is some placeholder content for a horizontal collapse. It’s hidden by default and shown when triggered.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<p>
-<buttonclass="btn btn-primary"type="button"data-bs-toggle="collapse"data-bs-target="#collapseWidthExample"aria-expanded="false"aria-controls="collapseWidthExample">
- Toggle width collapse
-</button>
-</p>
-<divstyle="min-height: 120px;">
-<divclass="collapse collapse-horizontal"id="collapseWidthExample">
-<divclass="card card-body"style="width: 300px;">
- This is some placeholder content for a horizontal collapse. It's hidden by default and shown when triggered.
-</div>
-</div>
-</div>
-
-
-
Multiple toggles and targets
+
html
<p>
+ <buttonclass="btn btn-primary"type="button"data-bs-toggle="collapse"data-bs-target="#collapseWidthExample"aria-expanded="false"aria-controls="collapseWidthExample">
+ Toggle width collapse
+ </button>
+</p>
+<divstyle="min-height: 120px;">
+ <divclass="collapse collapse-horizontal"id="collapseWidthExample">
+ <divclass="card card-body"style="width: 300px;">
+ This is some placeholder content for a horizontal collapse. It’s hidden by default and shown when triggered.
+ </div>
+ </div>
+</div>
+
Multiple toggles and targets
A <button> or <a> element can show and hide multiple elements by referencing them with a selector in its data-bs-target or href attribute.
Conversely, multiple <button> or <a> elements can show and hide the same element if they each reference it with their data-bs-target or href attribute.
-
-
-
-
+
Toggle first elementToggle second elementToggle both elements
@@ -701,87 +106,57 @@ Conversely, multiple <button> or <a> eleme
-
-
-
- html
-
-
-
-
-
-
-
-
-
<pclass="d-inline-flex gap-1">
-<aclass="btn btn-primary"data-bs-toggle="collapse"href="#multiCollapseExample1"role="button"aria-expanded="false"aria-controls="multiCollapseExample1">Toggle first element</a>
-<buttonclass="btn btn-primary"type="button"data-bs-toggle="collapse"data-bs-target="#multiCollapseExample2"aria-expanded="false"aria-controls="multiCollapseExample2">Toggle second element</button>
-<buttonclass="btn btn-primary"type="button"data-bs-toggle="collapse"data-bs-target=".multi-collapse"aria-expanded="false"aria-controls="multiCollapseExample1 multiCollapseExample2">Toggle both elements</button>
-</p>
-<divclass="row">
-<divclass="col">
-<divclass="collapse multi-collapse"id="multiCollapseExample1">
-<divclass="card card-body">
- Some placeholder content for the first collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.
-</div>
-</div>
-</div>
-<divclass="col">
-<divclass="collapse multi-collapse"id="multiCollapseExample2">
-<divclass="card card-body">
- Some placeholder content for the second collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.
-</div>
-</div>
-</div>
-</div>
-
-
-
Accessibility
-
Be sure to add aria-expanded to the control element. This attribute explicitly conveys the current state of the collapsible element tied to the control to screen readers and similar assistive technologies. If the collapsible element is closed by default, the attribute on the control element should have a value of aria-expanded="false". If you’ve set the collapsible element to be open by default using the show class, set aria-expanded="true" on the control instead. The plugin will automatically toggle this attribute on the control based on whether or not the collapsible element has been opened or closed (via JavaScript, or because the user triggered another control element also tied to the same collapsible element). If the control element’s HTML element is not a button (e.g., an <a> or <div>), the attribute role="button" should be added to the element.
+
html
<pclass="d-inline-flex gap-1">
+ <aclass="btn btn-primary"data-bs-toggle="collapse"href="#multiCollapseExample1"role="button"aria-expanded="false"aria-controls="multiCollapseExample1">Toggle first element</a>
+ <buttonclass="btn btn-primary"type="button"data-bs-toggle="collapse"data-bs-target="#multiCollapseExample2"aria-expanded="false"aria-controls="multiCollapseExample2">Toggle second element</button>
+ <buttonclass="btn btn-primary"type="button"data-bs-toggle="collapse"data-bs-target=".multi-collapse"aria-expanded="false"aria-controls="multiCollapseExample1 multiCollapseExample2">Toggle both elements</button>
+</p>
+<divclass="row">
+ <divclass="col">
+ <divclass="collapse multi-collapse"id="multiCollapseExample1">
+ <divclass="card card-body">
+ Some placeholder content for the first collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.
+ </div>
+ </div>
+ </div>
+ <divclass="col">
+ <divclass="collapse multi-collapse"id="multiCollapseExample2">
+ <divclass="card card-body">
+ Some placeholder content for the second collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.
+ </div>
+ </div>
+ </div>
+</div>
+
Accessibility
+
Be sure to add aria-expanded to the control element. This attribute explicitly conveys the current state of the collapsible element tied to the control to screen readers and similar assistive technologies. If the collapsible element is closed by default, the attribute on the control element should have a value of aria-expanded="false". If you’ve set the collapsible element to be open by default using the show class, set aria-expanded="true" on the control instead. The plugin will automatically toggle this attribute on the control based on whether or not the collapsible element has been opened or closed (via JavaScript, or because the user triggered another control element also tied to the same collapsible element). If the control element’s HTML element is not a button (e.g., an <a> or <div>), the attribute role="button" should be added to the element.
If your control element is targeting a single collapsible element – i.e. the data-bs-target attribute is pointing to an id selector – you should add the aria-controls attribute to the control element, containing the id of the collapsible element. Modern screen readers and similar assistive technologies make use of this attribute to provide users with additional shortcuts to navigate directly to the collapsible element itself.
-
Note that Bootstrap’s current implementation does not cover the various optional keyboard interactions described in the ARIA Authoring Practices Guide accordion pattern - you will need to include these yourself with custom JavaScript.
Note that Bootstrap’s current implementation does not cover the various optional keyboard interactions described in the ARIA Authoring Practices Guide accordion pattern - you will need to include these yourself with custom JavaScript.
The collapse plugin utilizes a few classes to handle the heavy lifting:
.collapse hides the content
@@ -789,195 +164,118 @@ Conversely, multiple <button> or <a> eleme
.collapsing is added when the transition starts, and removed when it finishes
These classes can be found in _transitions.scss.
-
Via data attributes
-
Just add data-bs-toggle="collapse" and a data-bs-target to the element to automatically assign control of one or more collapsible elements. The data-bs-target attribute accepts a CSS selector to apply the collapse to. Be sure to add the class collapse to the collapsible element. If you’d like it to default open, add the additional class show.
-
To add accordion-like group management to a collapsible area, add the data attribute data-bs-parent="#selector". Refer to the accordion page for more information.
-
Via JavaScript
+
Via data attributes
+
Just add data-bs-toggle="collapse" and a data-bs-target to the element to automatically assign control of one or more collapsible elements. The data-bs-target attribute accepts a CSS selector to apply the collapse to. Be sure to add the class collapse to the collapsible element. If you’d like it to default open, add the additional class show.
+
To add accordion-like group management to a collapsible area, add the data attribute data-bs-parent="#selector". Refer to the accordion page for more information.
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
-
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
+
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
The final configuration object is the merged result of data-bs-config, data-bs-, and js object where the latest given key-value overrides the others.
+
-
-
-
-
Name
-
Type
-
Default
-
Description
-
-
-
-
-
parent
-
selector, DOM element
-
null
-
If parent is provided, then all collapsible elements under the specified parent will be closed when this collapsible item is shown. (similar to traditional accordion behavior - this is dependent on the card class). The attribute has to be set on the target collapsible area.
-
-
-
toggle
-
boolean
-
true
-
Toggles the collapsible element on invocation.
-
-
-
-
Methods
-
-All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started, but before it ends. In addition, a method call on a transitioning component will be ignored. Learn more in our JavaScript docs.
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Name
Type
Default
Description
parent
selector, DOM element
null
If parent is provided, then all collapsible elements under the specified parent will be closed when this collapsible item is shown. (similar to traditional accordion behavior - this is dependent on the card class). The attribute has to be set on the target collapsible area.
toggle
boolean
true
Toggles the collapsible element on invocation.
+
Methods
+
All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started, but before it ends. In addition, a method call on a transitioning component will be ignored. Learn more in our JavaScript docs.
Activates your content as a collapsible element. Accepts an optional options object.
You can create a collapse instance with the constructor, for example:
Destroys an element’s collapse. (Removes stored data on the DOM element)
-
-
-
getInstance
-
Static method which allows you to get the collapse instance associated to a DOM element, you can use it like this: bootstrap.Collapse.getInstance(element).
-
-
-
getOrCreateInstance
-
Static method which returns a collapse instance associated to a DOM element or create a new one in case it wasn’t initialized. You can use it like this: bootstrap.Collapse.getOrCreateInstance(element).
-
-
-
hide
-
Hides a collapsible element. Returns to the caller before the collapsible element has actually been hidden (e.g., before the hidden.bs.collapse event occurs).
-
-
-
show
-
Shows a collapsible element. Returns to the caller before the collapsible element has actually been shown (e.g., before the shown.bs.collapse event occurs).
-
-
-
toggle
-
Toggles a collapsible element to shown or hidden. Returns to the caller before the collapsible element has actually been shown or hidden (i.e. before the shown.bs.collapse or hidden.bs.collapse event occurs).
-
-
-
-
-
Events
-
Bootstrap’s collapse class exposes a few events for hooking into collapse functionality.
-
-
-
-
Event type
-
Description
-
-
-
-
-
hide.bs.collapse
-
This event is fired immediately when the hide method has been called.
-
-
-
hidden.bs.collapse
-
This event is fired when a collapse element has been hidden from the user (will wait for CSS transitions to complete).
-
-
-
show.bs.collapse
-
This event fires immediately when the show instance method is called.
-
-
-
shown.bs.collapse
-
This event is fired when a collapse element has been made visible to the user (will wait for CSS transitions to complete).
-
-
-
-
-
constmyCollapsible=document.getElementById('myCollapsible')
-myCollapsible.addEventListener('hidden.bs.collapse',event=>{
-// do something...
-})
-
Destroys an element’s collapse. (Removes stored data on the DOM element)
getInstance
Static method which allows you to get the collapse instance associated to a DOM element, you can use it like this: bootstrap.Collapse.getInstance(element).
getOrCreateInstance
Static method which returns a collapse instance associated to a DOM element or create a new one in case it wasn’t initialized. You can use it like this: bootstrap.Collapse.getOrCreateInstance(element).
hide
Hides a collapsible element. Returns to the caller before the collapsible element has actually been hidden (e.g., before the hidden.bs.collapse event occurs).
show
Shows a collapsible element. Returns to the caller before the collapsible element has actually been shown (e.g., before the shown.bs.collapse event occurs).
toggle
Toggles a collapsible element to shown or hidden. Returns to the caller before the collapsible element has actually been shown or hidden (i.e. before the shown.bs.collapse or hidden.bs.collapse event occurs).
+
Events
+
Bootstrap’s collapse class exposes a few events for hooking into collapse functionality.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Event type
Description
hide.bs.collapse
This event is fired immediately when the hide method has been called.
hidden.bs.collapse
This event is fired when a collapse element has been hidden from the user (will wait for CSS transitions to complete).
show.bs.collapse
This event fires immediately when the show instance method is called.
shown.bs.collapse
This event is fired when a collapse element has been made visible to the user (will wait for CSS transitions to complete).
Dropdowns are toggleable, contextual overlays for displaying lists of links and more. They’re made interactive with the included Bootstrap dropdown JavaScript plugin. They’re toggled by clicking, not by hovering; this is an intentional design decision.
-
Dropdowns are built on a third party library, Popper, which provides dynamic positioning and viewport detection. Be sure to include popper.min.js before Bootstrap’s JavaScript or use bootstrap.bundle.min.js / bootstrap.bundle.js which contains Popper. Popper isn’t used to position dropdowns in navbars though as dynamic positioning isn’t required.
Dropdowns are toggleable, contextual overlays for displaying lists of links and more. They’re made interactive with the included Bootstrap dropdown JavaScript plugin. They’re toggled by clicking, not by hovering; this is an intentional design decision.
+
Dropdowns are built on a third party library, Popper, which provides dynamic positioning and viewport detection. Be sure to include popper.min.js before Bootstrap’s JavaScript or use bootstrap.bundle.min.js / bootstrap.bundle.js which contains Popper. Popper isn’t used to position dropdowns in navbars though as dynamic positioning isn’t required.
+
Accessibility
The WAI ARIA standard defines an actual role="menu" widget, but this is specific to application-like menus which trigger actions or functions. ARIA menus can only contain menu items, checkbox menu items, radio button menu items, radio button groups, and sub-menus.
-
Bootstrap’s dropdowns, on the other hand, are designed to be generic and applicable to a variety of situations and markup structures. For instance, it is possible to create dropdowns that contain additional inputs and form controls, such as search fields or login forms. For this reason, Bootstrap does not expect (nor automatically add) any of the role and aria- attributes required for true ARIA menus. Authors will have to include these more specific attributes themselves.
+
Bootstrap’s dropdowns, on the other hand, are designed to be generic and applicable to a variety of situations and markup structures. For instance, it is possible to create dropdowns that contain additional inputs and form controls, such as search fields or login forms. For this reason, Bootstrap does not expect (nor automatically add) any of the role and aria- attributes required for true ARIA menus. Authors will have to include these more specific attributes themselves.
However, Bootstrap does add built-in support for most standard keyboard menu interactions, such as the ability to move through individual .dropdown-item elements using the cursor keys and close the menu with the Esc key.
-
Examples
-
Wrap the dropdown’s toggle (your button or link) and the dropdown menu within .dropdown, or another element that declares position: relative;. Ideally, you should use a <button> element as the dropdown trigger, but the plugin will work with <a> elements as well. The examples shown here use semantic <ul> elements where appropriate, but custom markup is supported.
-
Single button
-
Any single .btn can be turned into a dropdown toggle with some markup changes. Here’s how you can put them to work with <button> elements:
-
-
-
-
+
Examples
+
Wrap the dropdown’s toggle (your button or link) and the dropdown menu within .dropdown, or another element that declares position: relative;. Ideally, you should use a <button> element as the dropdown trigger, but the plugin will work with <a> elements as well. The examples shown here use semantic <ul> elements where appropriate, but custom markup is supported.
+
Single button
+
Any single .btn can be turned into a dropdown toggle with some markup changes. Here’s how you can put them to work with <button> elements:
While <button> is the recommended control for a dropdown toggle, there might be situations where you have to use an <a> element. If you do, we recommend adding a role="button" attribute to appropriately convey control’s purpose to assistive technologies such as screen readers.
While <button> is the recommended control for a dropdown toggle, there might be situations where you have to use an <a> element. If you do, we recommend adding a role="button" attribute to appropriately convey control’s purpose to assistive technologies such as screen readers.
Similarly, create split button dropdowns with virtually the same markup as single button dropdowns, but with the addition of .dropdown-toggle-split for proper spacing around the dropdown caret.
-
We use this extra class to reduce the horizontal padding on either side of the caret by 25% and remove the margin-left that’s added for regular button dropdowns. Those extra changes keep the caret centered in the split button and provide a more appropriately sized hit area next to the main button.
We use this extra class to reduce the horizontal padding on either side of the caret by 25% and remove the margin-left that’s added for regular button dropdowns. Those extra changes keep the caret centered in the split button and provide a more appropriately sized hit area next to the main button.
Opt into darker dropdowns to match a dark navbar or custom style by adding .dropdown-menu-dark onto an existing .dropdown-menu. No changes are required to the dropdown items.
-
-
- Heads up! Dark variants for components were deprecated in v5.3.0 with the introduction of color modes. Instead of adding .dropdown-menu-dark, set data-bs-theme="dark" on the root element, a parent wrapper, or the component itself.
-
-
-
-
-
-
-
+
Heads up! Dark variants for components were deprecated in v5.3.0 with the introduction of color modes.
+ Instead of adding .dropdown-menu-dark, set data-bs-theme="dark" on the root element, a parent
+ wrapper, or the component itself.
+
Add .active to items in the dropdown to style them as active. To convey the active state to assistive technologies, use the aria-current attribute — using the page value for the current page, or true for the current item in a set.
By default, a dropdown menu is automatically positioned 100% from the top and along the left side of its parent. You can change this with the directional .drop* classes, but you can also control them with additional modifier classes.
Add .dropdown-menu-end to a .dropdown-menu to right align the dropdown menu. Directions are mirrored when using Bootstrap in RTL, meaning .dropdown-menu-end will appear on the left side.
-
-Heads up! Dropdowns are positioned thanks to Popper except when they are contained in a navbar.
-
-
-
-
-
-
+
Heads up! Dropdowns are positioned thanks to Popper except when they are contained in a navbar.
+
Right-aligned menu example
@@ -1464,37 +674,20 @@
Another action
Something else here
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="btn-group">
-<buttontype="button"class="btn btn-secondary dropdown-toggle"data-bs-toggle="dropdown"aria-expanded="false">
- Right-aligned menu example
-</button>
-<ulclass="dropdown-menu dropdown-menu-end">
-<li><buttonclass="dropdown-item"type="button">Action</button></li>
-<li><buttonclass="dropdown-item"type="button">Another action</button></li>
-<li><buttonclass="dropdown-item"type="button">Something else here</button></li>
-</ul>
-</div>
If you want to use responsive alignment, disable dynamic positioning by adding the data-bs-display="static" attribute and use the responsive variation classes.
To align right the dropdown menu with the given breakpoint or larger, add .dropdown-menu{-sm|-md|-lg|-xl|-xxl}-end.
-
-
-
-
+
Left-aligned but right aligned when large screen
@@ -1503,35 +696,18 @@
Another action
Something else here
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="btn-group">
-<buttontype="button"class="btn btn-secondary dropdown-toggle"data-bs-toggle="dropdown"data-bs-display="static"aria-expanded="false">
- Left-aligned but right aligned when large screen
-</button>
-<ulclass="dropdown-menu dropdown-menu-lg-end">
-<li><buttonclass="dropdown-item"type="button">Action</button></li>
-<li><buttonclass="dropdown-item"type="button">Another action</button></li>
-<li><buttonclass="dropdown-item"type="button">Something else here</button></li>
-</ul>
-</div>
-
-
+
html
<divclass="btn-group">
+ <buttontype="button"class="btn btn-secondary dropdown-toggle"data-bs-toggle="dropdown"data-bs-display="static"aria-expanded="false">
+ Left-aligned but right aligned when large screen
+ </button>
+ <ulclass="dropdown-menu dropdown-menu-lg-end">
+ <li><buttonclass="dropdown-item"type="button">Action</button></li>
+ <li><buttonclass="dropdown-item"type="button">Another action</button></li>
+ <li><buttonclass="dropdown-item"type="button">Something else here</button></li>
+ </ul>
+</div>
To align left the dropdown menu with the given breakpoint or larger, add .dropdown-menu-end and .dropdown-menu{-sm|-md|-lg|-xl|-xxl}-start.
-
-
-
-
+
Right-aligned but left aligned when large screen
@@ -1540,37 +716,20 @@
Another action
Something else here
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="btn-group">
-<buttontype="button"class="btn btn-secondary dropdown-toggle"data-bs-toggle="dropdown"data-bs-display="static"aria-expanded="false">
- Right-aligned but left aligned when large screen
-</button>
-<ulclass="dropdown-menu dropdown-menu-end dropdown-menu-lg-start">
-<li><buttonclass="dropdown-item"type="button">Action</button></li>
-<li><buttonclass="dropdown-item"type="button">Another action</button></li>
-<li><buttonclass="dropdown-item"type="button">Something else here</button></li>
-</ul>
-</div>
-
-
-
Note that you don’t need to add a data-bs-display="static" attribute to dropdown buttons in navbars, since Popper isn’t used in navbars.
-
Alignment options
-
Taking most of the options shown above, here’s a small kitchen sink demo of various dropdown alignment options in one place.
-
-
-
-
+
html
<divclass="btn-group">
+ <buttontype="button"class="btn btn-secondary dropdown-toggle"data-bs-toggle="dropdown"data-bs-display="static"aria-expanded="false">
+ Right-aligned but left aligned when large screen
+ </button>
+ <ulclass="dropdown-menu dropdown-menu-end dropdown-menu-lg-start">
+ <li><buttonclass="dropdown-item"type="button">Action</button></li>
+ <li><buttonclass="dropdown-item"type="button">Another action</button></li>
+ <li><buttonclass="dropdown-item"type="button">Something else here</button></li>
+ </ul>
+</div>
+
Note that you don’t need to add a data-bs-display="static" attribute to dropdown buttons in navbars, since Popper isn’t used in navbars.
+
Alignment options
+
Taking most of the options shown above, here’s a small kitchen sink demo of various dropdown alignment options in one place.
Place any freeform text within a dropdown menu with text and use spacing utilities. Note that you’ll likely need additional sizing styles to constrain the menu width.
Place any freeform text within a dropdown menu with text and use spacing utilities. Note that you’ll likely need additional sizing styles to constrain the menu width.
+
- Some example text that's free-flowing within the dropdown menu.
+ Some example text that’s free-flowing within the dropdown menu.
And this is more example text.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="dropdown-menu p-4 text-body-secondary"style="max-width: 200px;">
-<p>
- Some example text that's free-flowing within the dropdown menu.
-</p>
-<pclass="mb-0">
- And this is more example text.
-</p>
-</div>
-
-
-
Forms
-
Put a form within a dropdown menu, or make it into a dropdown menu, and use margin or padding utilities to give it the negative space you require.
-
-
-
-
+
html
<divclass="dropdown-menu p-4 text-body-secondary"style="max-width: 200px;">
+ <p>
+ Some example text that’s free-flowing within the dropdown menu.
+ </p>
+ <pclass="mb-0">
+ And this is more example text.
+ </p>
+</div>
+
Forms
+
Put a form within a dropdown menu, or make it into a dropdown menu, and use margin or padding utilities to give it the negative space you require.
By default, the dropdown menu is closed when clicking inside or outside the dropdown menu. You can use the autoClose option to change this behavior of the dropdown.
As part of Bootstrap’s evolving CSS variables approach, dropdowns now use local CSS variables on .dropdown-menu for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
Dropdown items include at least one variable that is not set on .dropdown. This allows you to provide a new value while Bootstrap defaults to a fallback value.
-
+
As part of Bootstrap’s evolving CSS variables approach, dropdowns now use local CSS variables on .dropdown-menu for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
Dropdown items include at least one variable that is not set on .dropdown. This allows you to provide a new value while Bootstrap defaults to a fallback value.
--bs-dropdown-item-border-radius
-
-
-
+
Customization through CSS variables can be seen on the .dropdown-menu-dark class where we override specific values without adding duplicate CSS selectors.
Via data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) by toggling the .show class on the parent .dropdown-menu. The data-bs-toggle="dropdown" attribute is relied on for closing dropdown menus at an application level, so it’s a good idea to always use it.
-
-On touch-enabled devices, opening a dropdown adds empty mouseover handlers to the immediate children of the <body> element. This admittedly ugly hack is necessary to work around a quirk in iOS’ event delegation, which would otherwise prevent a tap anywhere outside of the dropdown from triggering the code that closes the dropdown. Once the dropdown is closed, these additional empty mouseover handlers are removed.
-
Via data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) by toggling the .show class on the parent .dropdown-menu. The data-bs-toggle="dropdown" attribute is relied on for closing dropdown menus at an application level, so it’s a good idea to always use it.
+
On touch-enabled devices, opening a dropdown adds empty mouseover handlers to the immediate children of the <body> element. This admittedly ugly hack is necessary to work around a quirk in iOs’ event delegation, which would otherwise prevent a tap anywhere outside of the dropdown from triggering the code that closes the dropdown. Once the dropdown is closed, these additional empty mouseover handlers are removed.
+
Via data attributes
Add data-bs-toggle="dropdown" to a link or button to toggle a dropdown.
-Dropdowns must have data-bs-toggle="dropdown" on their trigger element, regardless of whether you call your dropdown via JavaScript or use the data-api.
-
Dropdowns must have data-bs-toggle="dropdown" on their trigger element, regardless of whether you call your dropdown via JavaScript or use the data-api.
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
-
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
+
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
The final configuration object is the merged result of data-bs-config, data-bs-, and js object where the latest given key-value overrides the others.
-
-
-
-
-
Name
-
Type
-
Default
-
Description
-
-
-
-
-
autoClose
-
boolean, string
-
true
-
Configure the auto close behavior of the dropdown:
true - the dropdown will be closed by clicking outside or inside the dropdown menu.
false - the dropdown will be closed by clicking the toggle button and manually calling hide or toggle method. (Also will not be closed by pressing Esc key)
'inside' - the dropdown will be closed (only) by clicking inside the dropdown menu.
'outside' - the dropdown will be closed (only) by clicking outside the dropdown menu.
Note: the dropdown can always be closed with the Esc key.
-
-
-
boundary
-
string, element
-
'clippingParents'
-
Overflow constraint boundary of the dropdown menu (applies only to Popper’s preventOverflow modifier). By default it’s clippingParents and can accept an HTMLElement reference (via JavaScript only). For more information refer to Popper’s detectOverflow docs.
-
-
-
display
-
string
-
'dynamic'
-
By default, we use Popper for dynamic positioning. Disable this with static.
-
-
-
offset
-
array, string, function
-
[0, 2]
-
Offset of the dropdown relative to its target. You can pass a string in data attributes with comma separated values like: data-bs-offset="10,20". When a function is used to determine the offset, it is called with an object containing the popper placement, the reference, and popper rects as its first argument. The triggering element DOM node is passed as the second argument. The function must return an array with two numbers: skidding, distance. For more information refer to Popper’s offset docs.
-
-
-
popperConfig
-
null, object, function
-
null
-
To change Bootstrap’s default Popper config, see Popper’s configuration. When a function is used to create the Popper configuration, it’s called with an object that contains the Bootstrap’s default Popper configuration. It helps you use and merge the default with your own configuration. The function must return a configuration object for Popper.
-
-
-
reference
-
string, element, object
-
'toggle'
-
Reference element of the dropdown menu. Accepts the values of 'toggle', 'parent', an HTMLElement reference or an object providing getBoundingClientRect. For more information refer to Popper’s constructor docs and virtual element docs.
-
-
-
-
-
Using function with popperConfig
-
constdropdown=newbootstrap.Dropdown(element,{
-popperConfig(defaultBsPopperConfig){
-// const newPopperConfig = {...}
-// use defaultBsPopperConfig if needed...
-// return newPopperConfig
-}
-})
-
Methods
-
-
-
-
Method
-
Description
-
-
-
-
-
dispose
-
Destroys an element’s dropdown. (Removes stored data on the DOM element)
-
-
-
getInstance
-
Static method which allows you to get the dropdown instance associated to a DOM element, you can use it like this: bootstrap.Dropdown.getInstance(element).
-
-
-
getOrCreateInstance
-
Static method which returns a dropdown instance associated to a DOM element or create a new one in case it wasn’t initialized. You can use it like this: bootstrap.Dropdown.getOrCreateInstance(element).
-
-
-
hide
-
Hides the dropdown menu of a given navbar or tabbed navigation.
-
-
-
show
-
Shows the dropdown menu of a given navbar or tabbed navigation.
-
-
-
toggle
-
Toggles the dropdown menu of a given navbar or tabbed navigation.
-
-
-
update
-
Updates the position of an element’s dropdown.
-
-
-
-
-
Events
-
All dropdown events are fired at the toggling element and then bubbled up. So you can also add event listeners on the .dropdown-menu’s parent element. hide.bs.dropdown and hidden.bs.dropdown events have a clickEvent property (only when the original Event type is click) that contains an Event Object for the click event.
-
-
-
-
Event type
-
Description
-
-
-
-
-
hide.bs.dropdown
-
Fires immediately when the hide instance method has been called.
-
-
-
hidden.bs.dropdown
-
Fired when the dropdown has finished being hidden from the user and CSS transitions have completed.
-
-
-
show.bs.dropdown
-
Fires immediately when the show instance method is called.
-
-
-
shown.bs.dropdown
-
Fired when the dropdown has been made visible to the user and CSS transitions have completed.
-
-
-
-
-
constmyDropdown=document.getElementById('myDropdown')
-myDropdown.addEventListener('show.bs.dropdown',event=>{
-// do something...
-})
-
Configure the auto close behavior of the dropdown:
true - the dropdown will be closed by clicking outside or inside the dropdown menu.
false - the dropdown will be closed by clicking the toggle button and manually calling hide or toggle method. (Also will not be closed by pressing Esc key)
'inside' - the dropdown will be closed (only) by clicking inside the dropdown menu.
'outside' - the dropdown will be closed (only) by clicking outside the dropdown menu.
Note: the dropdown can always be closed with the Esc key.
boundary
string, element
'clippingParents'
Overflow constraint boundary of the dropdown menu (applies only to Popper’s preventOverflow modifier). By default it’s clippingParents and can accept an HTMLElement reference (via JavaScript only). For more information refer to Popper’s detectOverflow docs.
display
string
'dynamic'
By default, we use Popper for dynamic positioning. Disable this with static.
offset
array, string, function
[0, 2]
Offset of the dropdown relative to its target. You can pass a string in data attributes with comma separated values like: data-bs-offset="10,20". When a function is used to determine the offset, it is called with an object containing the popper placement, the reference, and popper rects as its first argument. The triggering element DOM node is passed as the second argument. The function must return an array with two numbers: skidding, distance. For more information refer to Popper’s offset docs.
popperConfig
null, object, function
null
To change Bootstrap’s default Popper config, see Popper’s configuration. When a function is used to create the Popper configuration, it’s called with an object that contains the Bootstrap’s default Popper configuration. It helps you use and merge the default with your own configuration. The function must return a configuration object for Popper.
reference
string, element, object
'toggle'
Reference element of the dropdown menu. Accepts the values of 'toggle', 'parent', an HTMLElement reference or an object providing getBoundingClientRect. For more information refer to Popper’s constructor docs and virtual element docs.
Destroys an element’s dropdown. (Removes stored data on the DOM element)
getInstance
Static method which allows you to get the dropdown instance associated to a DOM element, you can use it like this: bootstrap.Dropdown.getInstance(element).
getOrCreateInstance
Static method which returns a dropdown instance associated to a DOM element or create a new one in case it wasn’t initialized. You can use it like this: bootstrap.Dropdown.getOrCreateInstance(element).
hide
Hides the dropdown menu of a given navbar or tabbed navigation.
show
Shows the dropdown menu of a given navbar or tabbed navigation.
toggle
Toggles the dropdown menu of a given navbar or tabbed navigation.
update
Updates the position of an element’s dropdown.
+
Events
+
All dropdown events are fired at the toggling element and then bubbled up. So you can also add event listeners on the .dropdown-menu’s parent element. hide.bs.dropdown and hidden.bs.dropdown events have a clickEvent property (only when the original Event type is click) that contains an Event Object for the click event.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Event type
Description
hide.bs.dropdown
Fires immediately when the hide instance method has been called.
hidden.bs.dropdown
Fired when the dropdown has finished being hidden from the user and CSS transitions have completed.
show.bs.dropdown
Fires immediately when the show instance method is called.
shown.bs.dropdown
Fired when the dropdown has been made visible to the user and CSS transitions have completed.
The most basic list group is an unordered list with list items and the proper classes. Build upon it with the options that follow, or with your own CSS as needed.
-
-
-
-
+
An item
A second item
A third item
A fourth item
And a fifth one
-
-
-
- html
-
-
-
-
-
-
-
-
-
<ulclass="list-group">
-<liclass="list-group-item">An item</li>
-<liclass="list-group-item">A second item</li>
-<liclass="list-group-item">A third item</li>
-<liclass="list-group-item">A fourth item</li>
-<liclass="list-group-item">And a fifth one</li>
-</ul>
-
-
-
Active items
+
html
<ulclass="list-group">
+ <liclass="list-group-item">An item</li>
+ <liclass="list-group-item">A second item</li>
+ <liclass="list-group-item">A third item</li>
+ <liclass="list-group-item">A fourth item</li>
+ <liclass="list-group-item">And a fifth one</li>
+</ul>
+
Active items
Add .active to a .list-group-item to indicate the current active selection.
-
-
-
-
+
An active item
A second item
A third item
A fourth item
And a fifth one
-
-
-
- html
-
-
-
-
-
-
-
-
-
<ulclass="list-group">
-<liclass="list-group-item active"aria-current="true">An active item</li>
-<liclass="list-group-item">A second item</li>
-<liclass="list-group-item">A third item</li>
-<liclass="list-group-item">A fourth item</li>
-<liclass="list-group-item">And a fifth one</li>
-</ul>
-
-
-
Disabled items
+
html
<ulclass="list-group">
+ <liclass="list-group-item active"aria-current="true">An active item</li>
+ <liclass="list-group-item">A second item</li>
+ <liclass="list-group-item">A third item</li>
+ <liclass="list-group-item">A fourth item</li>
+ <liclass="list-group-item">And a fifth one</li>
+</ul>
+
Disabled items
Add .disabled to a .list-group-item to make it appear disabled. Note that some elements with .disabled will also require custom JavaScript to fully disable their click events (e.g., links).
-
-
-
-
+
A disabled item
A second item
A third item
A fourth item
And a fifth one
-
-
-
- html
-
-
-
-
-
-
-
-
-
<ulclass="list-group">
-<liclass="list-group-item disabled"aria-disabled="true">A disabled item</li>
-<liclass="list-group-item">A second item</li>
-<liclass="list-group-item">A third item</li>
-<liclass="list-group-item">A fourth item</li>
-<liclass="list-group-item">And a fifth one</li>
-</ul>
-
-
-
Links and buttons
-
Use <a>s or <button>s to create actionable list group items with hover, disabled, and active states by adding .list-group-item-action. We separate these pseudo-classes to ensure list groups made of non-interactive elements (like <li>s or <div>s) don’t provide a click or tap affordance.
+
html
<ulclass="list-group">
+ <liclass="list-group-item disabled"aria-disabled="true">A disabled item</li>
+ <liclass="list-group-item">A second item</li>
+ <liclass="list-group-item">A third item</li>
+ <liclass="list-group-item">A fourth item</li>
+ <liclass="list-group-item">And a fifth one</li>
+</ul>
+
Links and buttons
+
Use <a>s or <button>s to create actionable list group items with hover, disabled, and active states by adding .list-group-item-action. We separate these pseudo-classes to ensure list groups made of non-interactive elements (like <li>s or <div>s) don’t provide a click or tap affordance.
Be sure to not use the standard .btn classes here.
<divclass="list-group">
-<ahref="#"class="list-group-item list-group-item-action active"aria-current="true">
- The current link item
-</a>
-<ahref="#"class="list-group-item list-group-item-action">A second link item</a>
-<ahref="#"class="list-group-item list-group-item-action">A third link item</a>
-<ahref="#"class="list-group-item list-group-item-action">A fourth link item</a>
-<aclass="list-group-item list-group-item-action disabled"aria-disabled="true">A disabled link item</a>
-</div>
-
-
-
With <button>s, you can also make use of the disabled attribute instead of the .disabled class. Sadly, <a>s don’t support the disabled attribute.
-
-
-
-
+
html
<divclass="list-group">
+ <ahref="#"class="list-group-item list-group-item-action active"aria-current="true">
+ The current link item
+ </a>
+ <ahref="#"class="list-group-item list-group-item-action">A second link item</a>
+ <ahref="#"class="list-group-item list-group-item-action">A third link item</a>
+ <ahref="#"class="list-group-item list-group-item-action">A fourth link item</a>
+ <aclass="list-group-item list-group-item-action disabled"aria-disabled="true">A disabled link item</a>
+</div>
+
With <button>s, you can also make use of the disabled attribute instead of the .disabled class. Sadly, <a>s don’t support the disabled attribute.
+
The current button
@@ -730,95 +95,44 @@
A third button itemA fourth button itemA disabled button item
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="list-group">
-<buttontype="button"class="list-group-item list-group-item-action active"aria-current="true">
- The current button
-</button>
-<buttontype="button"class="list-group-item list-group-item-action">A second button item</button>
-<buttontype="button"class="list-group-item list-group-item-action">A third button item</button>
-<buttontype="button"class="list-group-item list-group-item-action">A fourth button item</button>
-<buttontype="button"class="list-group-item list-group-item-action"disabled>A disabled button item</button>
-</div>
-
-
-
Flush
+
html
<divclass="list-group">
+ <buttontype="button"class="list-group-item list-group-item-action active"aria-current="true">
+ The current button
+ </button>
+ <buttontype="button"class="list-group-item list-group-item-action">A second button item</button>
+ <buttontype="button"class="list-group-item list-group-item-action">A third button item</button>
+ <buttontype="button"class="list-group-item list-group-item-action">A fourth button item</button>
+ <buttontype="button"class="list-group-item list-group-item-action"disabled>A disabled button item</button>
+</div>
+
Flush
Add .list-group-flush to remove some borders and rounded corners to render list group items edge-to-edge in a parent container (e.g., cards).
-
-
-
-
+
An item
A second item
A third item
A fourth item
And a fifth one
-
-
-
- html
-
-
-
-
-
-
-
-
-
<ulclass="list-group list-group-flush">
-<liclass="list-group-item">An item</li>
-<liclass="list-group-item">A second item</li>
-<liclass="list-group-item">A third item</li>
-<liclass="list-group-item">A fourth item</li>
-<liclass="list-group-item">And a fifth one</li>
-</ul>
-
-
-
Numbered
+
html
<ulclass="list-group list-group-flush">
+ <liclass="list-group-item">An item</li>
+ <liclass="list-group-item">A second item</li>
+ <liclass="list-group-item">A third item</li>
+ <liclass="list-group-item">A fourth item</li>
+ <liclass="list-group-item">And a fifth one</li>
+</ul>
+
Numbered
Add the .list-group-numbered modifier class (and optionally use an <ol> element) to opt into numbered list group items. Numbers are generated via CSS (as opposed to a <ol>s default browser styling) for better placement inside list group items and to allow for better customization.
Numbers are generated by counter-reset on the <ol>, and then styled and placed with a ::before pseudo-element on the <li> with counter-increment and content.
-
-
-
-
+
A list item
A list item
A list item
-
-
-
- html
-
-
-
-
-
-
-
-
-
<olclass="list-group list-group-numbered">
-<liclass="list-group-item">A list item</li>
-<liclass="list-group-item">A list item</li>
-<liclass="list-group-item">A list item</li>
-</ol>
-
-
+
html
<olclass="list-group list-group-numbered">
+ <liclass="list-group-item">A list item</li>
+ <liclass="list-group-item">A list item</li>
+ <liclass="list-group-item">A list item</li>
+</ol>
These work great with custom content as well.
-
-
-
-
+
Subheading
@@ -840,51 +154,33 @@
14
-
-
-
- html
-
-
-
-
-
-
-
-
-
<olclass="list-group list-group-numbered">
-<liclass="list-group-item d-flex justify-content-between align-items-start">
-<divclass="ms-2 me-auto">
-<divclass="fw-bold">Subheading</div>
- Content for list item
-</div>
-<spanclass="badge text-bg-primary rounded-pill">14</span>
-</li>
-<liclass="list-group-item d-flex justify-content-between align-items-start">
-<divclass="ms-2 me-auto">
-<divclass="fw-bold">Subheading</div>
- Content for list item
-</div>
-<spanclass="badge text-bg-primary rounded-pill">14</span>
-</li>
-<liclass="list-group-item d-flex justify-content-between align-items-start">
-<divclass="ms-2 me-auto">
-<divclass="fw-bold">Subheading</div>
- Content for list item
-</div>
-<spanclass="badge text-bg-primary rounded-pill">14</span>
-</li>
-</ol>
-
-
-
Horizontal
-
Add .list-group-horizontal to change the layout of list group items from vertical to horizontal across all breakpoints. Alternatively, choose a responsive variant .list-group-horizontal-{sm|md|lg|xl|xxl} to make a list group horizontal starting at that breakpoint’s min-width. Currently horizontal list groups cannot be combined with flush list groups.
Add .list-group-horizontal to change the layout of list group items from vertical to horizontal across all breakpoints. Alternatively, choose a responsive variant .list-group-horizontal-{sm|md|lg|xl|xxl} to make a list group horizontal starting at that breakpoint’s min-width. Currently horizontal list groups cannot be combined with flush list groups.
ProTip: Want equal-width list group items when horizontal? Add .flex-fill to each list group item.
-
-
-
-
-
+
An item
A second item
A third item
@@ -913,62 +209,42 @@
An item
A second item
A third item
-
-
-
- html
-
-
-
-
-
-
-
-
-
<ulclass="list-group list-group-horizontal">
-<liclass="list-group-item">An item</li>
-<liclass="list-group-item">A second item</li>
-<liclass="list-group-item">A third item</li>
-</ul>
-<ulclass="list-group list-group-horizontal-sm">
-<liclass="list-group-item">An item</li>
-<liclass="list-group-item">A second item</li>
-<liclass="list-group-item">A third item</li>
-</ul>
-<ulclass="list-group list-group-horizontal-md">
-<liclass="list-group-item">An item</li>
-<liclass="list-group-item">A second item</li>
-<liclass="list-group-item">A third item</li>
-</ul>
-<ulclass="list-group list-group-horizontal-lg">
-<liclass="list-group-item">An item</li>
-<liclass="list-group-item">A second item</li>
-<liclass="list-group-item">A third item</li>
-</ul>
-<ulclass="list-group list-group-horizontal-xl">
-<liclass="list-group-item">An item</li>
-<liclass="list-group-item">A second item</li>
-<liclass="list-group-item">A third item</li>
-</ul>
-<ulclass="list-group list-group-horizontal-xxl">
-<liclass="list-group-item">An item</li>
-<liclass="list-group-item">A second item</li>
-<liclass="list-group-item">A third item</li>
-</ul>
-
-
-
Variants
-
-Heads up! As of v5.3.0, the list-group-item-variant() Sass mixin is deprecated. List group item variants now have their CSS variables overridden in a Sass loop.
-
-
+
html
<ulclass="list-group list-group-horizontal">
+ <liclass="list-group-item">An item</li>
+ <liclass="list-group-item">A second item</li>
+ <liclass="list-group-item">A third item</li>
+</ul>
+<ulclass="list-group list-group-horizontal-sm">
+ <liclass="list-group-item">An item</li>
+ <liclass="list-group-item">A second item</li>
+ <liclass="list-group-item">A third item</li>
+</ul>
+<ulclass="list-group list-group-horizontal-md">
+ <liclass="list-group-item">An item</li>
+ <liclass="list-group-item">A second item</li>
+ <liclass="list-group-item">A third item</li>
+</ul>
+<ulclass="list-group list-group-horizontal-lg">
+ <liclass="list-group-item">An item</li>
+ <liclass="list-group-item">A second item</li>
+ <liclass="list-group-item">A third item</li>
+</ul>
+<ulclass="list-group list-group-horizontal-xl">
+ <liclass="list-group-item">An item</li>
+ <liclass="list-group-item">A second item</li>
+ <liclass="list-group-item">A third item</li>
+</ul>
+<ulclass="list-group list-group-horizontal-xxl">
+ <liclass="list-group-item">An item</li>
+ <liclass="list-group-item">A second item</li>
+ <liclass="list-group-item">A third item</li>
+</ul>
+
Variants
+
Heads up! As of v5.3.0, the list-group-item-variant() Sass mixin is deprecated. List group item variants now have their CSS variables overridden in a Sass loop.
Use contextual classes to style list items with a stateful background and color.
-
-
-
-
+
A simple default list group item
-
+
A simple primary list group item
A simple secondary list group item
A simple success list group item
@@ -977,40 +253,23 @@
A simple info list group item
A simple light list group item
A simple dark list group item
-
-
-
- html
-
-
-
-
-
-
-
-
-
<ulclass="list-group">
-<liclass="list-group-item">A simple default list group item</li>
-
-<liclass="list-group-item list-group-item-primary">A simple primary list group item</li>
-<liclass="list-group-item list-group-item-secondary">A simple secondary list group item</li>
-<liclass="list-group-item list-group-item-success">A simple success list group item</li>
-<liclass="list-group-item list-group-item-danger">A simple danger list group item</li>
-<liclass="list-group-item list-group-item-warning">A simple warning list group item</li>
-<liclass="list-group-item list-group-item-info">A simple info list group item</li>
-<liclass="list-group-item list-group-item-light">A simple light list group item</li>
-<liclass="list-group-item list-group-item-dark">A simple dark list group item</li>
-</ul>
-
-
-
For links and buttons
+
html
<ulclass="list-group">
+ <liclass="list-group-item">A simple default list group item</li>
+
+ <liclass="list-group-item list-group-item-primary">A simple primary list group item</li>
+ <liclass="list-group-item list-group-item-secondary">A simple secondary list group item</li>
+ <liclass="list-group-item list-group-item-success">A simple success list group item</li>
+ <liclass="list-group-item list-group-item-danger">A simple danger list group item</li>
+ <liclass="list-group-item list-group-item-warning">A simple warning list group item</li>
+ <liclass="list-group-item list-group-item-info">A simple info list group item</li>
+ <liclass="list-group-item list-group-item-light">A simple light list group item</li>
+ <liclass="list-group-item list-group-item-dark">A simple dark list group item</li>
+</ul>
+
For links and buttons
Contextual classes also work with .list-group-item-action for <a> and <button> elements. Note the addition of the hover styles here not present in the previous example. Also supported is the .active state; apply it to indicate an active selection on a contextual list group item.
<divclass="list-group">
-<ahref="#"class="list-group-item list-group-item-action">A simple default list group item</a>
-
-<ahref="#"class="list-group-item list-group-item-action list-group-item-primary">A simple primary list group item</a>
-<ahref="#"class="list-group-item list-group-item-action list-group-item-secondary">A simple secondary list group item</a>
-<ahref="#"class="list-group-item list-group-item-action list-group-item-success">A simple success list group item</a>
-<ahref="#"class="list-group-item list-group-item-action list-group-item-danger">A simple danger list group item</a>
-<ahref="#"class="list-group-item list-group-item-action list-group-item-warning">A simple warning list group item</a>
-<ahref="#"class="list-group-item list-group-item-action list-group-item-info">A simple info list group item</a>
-<ahref="#"class="list-group-item list-group-item-action list-group-item-light">A simple light list group item</a>
-<ahref="#"class="list-group-item list-group-item-action list-group-item-dark">A simple dark list group item</a>
-</div>
-
-
-
-Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
-
-
-
With badges
-
Add badges to any list group item to show unread counts, activity, and more with the help of some utilities.
-
-
-
-
+
html
<divclass="list-group">
+ <ahref="#"class="list-group-item list-group-item-action">A simple default list group item</a>
+
+ <ahref="#"class="list-group-item list-group-item-action list-group-item-primary">A simple primary list group item</a>
+ <ahref="#"class="list-group-item list-group-item-action list-group-item-secondary">A simple secondary list group item</a>
+ <ahref="#"class="list-group-item list-group-item-action list-group-item-success">A simple success list group item</a>
+ <ahref="#"class="list-group-item list-group-item-action list-group-item-danger">A simple danger list group item</a>
+ <ahref="#"class="list-group-item list-group-item-action list-group-item-warning">A simple warning list group item</a>
+ <ahref="#"class="list-group-item list-group-item-action list-group-item-info">A simple info list group item</a>
+ <ahref="#"class="list-group-item list-group-item-action list-group-item-light">A simple light list group item</a>
+ <ahref="#"class="list-group-item list-group-item-action list-group-item-dark">A simple dark list group item</a>
+</div>
+
Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
+
With badges
+
Add badges to any list group item to show unread counts, activity, and more with the help of some utilities.
+
A list item
14
@@ -1067,40 +306,23 @@
A third list item
1
-
-
-
- html
-
-
-
-
-
-
-
-
-
<ulclass="list-group">
-<liclass="list-group-item d-flex justify-content-between align-items-center">
- A list item
-<spanclass="badge text-bg-primary rounded-pill">14</span>
-</li>
-<liclass="list-group-item d-flex justify-content-between align-items-center">
- A second list item
-<spanclass="badge text-bg-primary rounded-pill">2</span>
-</li>
-<liclass="list-group-item d-flex justify-content-between align-items-center">
- A third list item
-<spanclass="badge text-bg-primary rounded-pill">1</span>
-</li>
-</ul>
-
-
-
Custom content
-
Add nearly any HTML within, even for linked list groups like the one below, with the help of flexbox utilities.
-
-
-
-
+
html
<ulclass="list-group">
+ <liclass="list-group-item d-flex justify-content-between align-items-center">
+ A list item
+ <spanclass="badge text-bg-primary rounded-pill">14</span>
+ </li>
+ <liclass="list-group-item d-flex justify-content-between align-items-center">
+ A second list item
+ <spanclass="badge text-bg-primary rounded-pill">2</span>
+ </li>
+ <liclass="list-group-item d-flex justify-content-between align-items-center">
+ A third list item
+ <spanclass="badge text-bg-primary rounded-pill">1</span>
+ </li>
+</ul>
+
Custom content
+
Add nearly any HTML within, even for linked list groups like the one below, with the help of flexbox utilities.
<divclass="list-group">
-<ahref="#"class="list-group-item list-group-item-action active"aria-current="true">
-<divclass="d-flex w-100 justify-content-between">
-<h5class="mb-1">List group item heading</h5>
-<small>3 days ago</small>
-</div>
-<pclass="mb-1">Some placeholder content in a paragraph.</p>
-<small>And some small print.</small>
-</a>
-<ahref="#"class="list-group-item list-group-item-action">
-<divclass="d-flex w-100 justify-content-between">
-<h5class="mb-1">List group item heading</h5>
-<smallclass="text-body-secondary">3 days ago</small>
-</div>
-<pclass="mb-1">Some placeholder content in a paragraph.</p>
-<smallclass="text-body-secondary">And some muted small print.</small>
-</a>
-<ahref="#"class="list-group-item list-group-item-action">
-<divclass="d-flex w-100 justify-content-between">
-<h5class="mb-1">List group item heading</h5>
-<smallclass="text-body-secondary">3 days ago</small>
-</div>
-<pclass="mb-1">Some placeholder content in a paragraph.</p>
-<smallclass="text-body-secondary">And some muted small print.</small>
-</a>
-</div>
-
-
-
Checkboxes and radios
-
Place Bootstrap’s checkboxes and radios within list group items and customize as needed. You can use them without <label>s, but please remember to include an aria-label attribute and value for accessibility.
-
-
-
-
+
html
<divclass="list-group">
+ <ahref="#"class="list-group-item list-group-item-action active"aria-current="true">
+ <divclass="d-flex w-100 justify-content-between">
+ <h5class="mb-1">List group item heading</h5>
+ <small>3 days ago</small>
+ </div>
+ <pclass="mb-1">Some placeholder content in a paragraph.</p>
+ <small>And some small print.</small>
+ </a>
+ <ahref="#"class="list-group-item list-group-item-action">
+ <divclass="d-flex w-100 justify-content-between">
+ <h5class="mb-1">List group item heading</h5>
+ <smallclass="text-body-secondary">3 days ago</small>
+ </div>
+ <pclass="mb-1">Some placeholder content in a paragraph.</p>
+ <smallclass="text-body-secondary">And some muted small print.</small>
+ </a>
+ <ahref="#"class="list-group-item list-group-item-action">
+ <divclass="d-flex w-100 justify-content-between">
+ <h5class="mb-1">List group item heading</h5>
+ <smallclass="text-body-secondary">3 days ago</small>
+ </div>
+ <pclass="mb-1">Some placeholder content in a paragraph.</p>
+ <smallclass="text-body-secondary">And some muted small print.</small>
+ </a>
+</div>
+
Checkboxes and radios
+
Place Bootstrap’s checkboxes and radios within list group items and customize as needed. You can use them without <label>s, but please remember to include an aria-label attribute and value for accessibility.
As part of Bootstrap’s evolving CSS variables approach, list groups now use local CSS variables on .list-group for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
As part of Bootstrap’s evolving CSS variables approach, list groups now use local CSS variables on .list-group for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
// List group contextual variants
-//
-// Add modifier classes to change text and background color on individual items.
-// Organizationally, this must come after the `:hover` states.
-
-@each$stateinmap-keys($theme-colors){
-.list-group-item-#{$state}{
---#{$prefix}list-group-color:var(--#{$prefix}#{$state}-text-emphasis);
---#{$prefix}list-group-bg:var(--#{$prefix}#{$state}-bg-subtle);
---#{$prefix}list-group-border-color:var(--#{$prefix}#{$state}-border-subtle);
---#{$prefix}list-group-action-hover-color:var(--#{$prefix}emphasis-color);
---#{$prefix}list-group-action-hover-bg:var(--#{$prefix}#{$state}-border-subtle);
---#{$prefix}list-group-action-active-color:var(--#{$prefix}emphasis-color);
---#{$prefix}list-group-action-active-bg:var(--#{$prefix}#{$state}-border-subtle);
---#{$prefix}list-group-active-color:var(--#{$prefix}#{$state}-bg-subtle);
---#{$prefix}list-group-active-bg:var(--#{$prefix}#{$state}-text-emphasis);
---#{$prefix}list-group-active-border-color:var(--#{$prefix}#{$state}-text-emphasis);
-}
-}
-
-
JavaScript behavior
-
Use the tab JavaScript plugin—include it individually or through the compiled bootstrap.js file—to extend our list group to create tabbable panes of local content.
Some placeholder content in a paragraph relating to "Home". And some more content, used here just to pad out and fill this tab panel. In production, you would obviously have more real content here. And not just text. It could be anything, really. Text, images, forms.
-
-
-
Some placeholder content in a paragraph relating to "Profile". And some more content, used here just to pad out and fill this tab panel. In production, you would obviously have more real content here. And not just text. It could be anything, really. Text, images, forms.
-
-
-
Some placeholder content in a paragraph relating to "Messages". And some more content, used here just to pad out and fill this tab panel. In production, you would obviously have more real content here. And not just text. It could be anything, really. Text, images, forms.
-
-
-
Some placeholder content in a paragraph relating to "Settings". And some more content, used here just to pad out and fill this tab panel. In production, you would obviously have more real content here. And not just text. It could be anything, really. Text, images, forms.
You can activate a list group navigation without writing any JavaScript by simply specifying data-bs-toggle="list" or on an element. Use these data attributes on .list-group-item.
-All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started, but before it ends. In addition, a method call on a transitioning component will be ignored. Learn more in our JavaScript docs.
-
// List group contextual variants
+//
+// Add modifier classes to change text and background color on individual items.
+// Organizationally, this must come after the `:hover` states.
+@each$state in map-keys($theme-colors){
+ .list-group-item-#{$state}{
+ --#{$prefix}list-group-color:var(--#{$prefix}#{$state}-text-emphasis);
+ --#{$prefix}list-group-bg:var(--#{$prefix}#{$state}-bg-subtle);
+ --#{$prefix}list-group-border-color:var(--#{$prefix}#{$state}-border-subtle);
+ --#{$prefix}list-group-action-hover-color:var(--#{$prefix}emphasis-color);
+ --#{$prefix}list-group-action-hover-bg:var(--#{$prefix}#{$state}-border-subtle);
+ --#{$prefix}list-group-action-active-color:var(--#{$prefix}emphasis-color);
+ --#{$prefix}list-group-action-active-bg:var(--#{$prefix}#{$state}-border-subtle);
+ --#{$prefix}list-group-active-color:var(--#{$prefix}#{$state}-bg-subtle);
+ --#{$prefix}list-group-active-bg:var(--#{$prefix}#{$state}-text-emphasis);
+ --#{$prefix}list-group-active-border-color:var(--#{$prefix}#{$state}-text-emphasis);
+ }
+}
+
+
JavaScript behavior
+
Use the tab JavaScript plugin—include it individually or through the compiled bootstrap.js file—to extend our list group to create tabbable panes of local content.
Some placeholder content in a paragraph relating to "Home". And some more content, used here just to pad out and fill this tab panel. In production, you would obviously have more real content here. And not just text. It could be anything, really. Text, images, forms.
Some placeholder content in a paragraph relating to "Profile". And some more content, used here just to pad out and fill this tab panel. In production, you would obviously have more real content here. And not just text. It could be anything, really. Text, images, forms.
Some placeholder content in a paragraph relating to "Messages". And some more content, used here just to pad out and fill this tab panel. In production, you would obviously have more real content here. And not just text. It could be anything, really. Text, images, forms.
Some placeholder content in a paragraph relating to "Settings". And some more content, used here just to pad out and fill this tab panel. In production, you would obviously have more real content here. And not just text. It could be anything, really. Text, images, forms.
You can activate a list group navigation without writing any JavaScript by simply specifying data-bs-toggle="list" or on an element. Use these data attributes on .list-group-item.
All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started, but before it ends. In addition, a method call on a transitioning component will be ignored. Learn more in our JavaScript docs.
Activates your content as a tab element.
You can create a tab instance with the constructor, for example:
-
constbsTab=newbootstrap.Tab('#myTab')
-
-
-
-
Method
-
Description
-
-
-
-
-
dispose
-
Destroys an element’s tab.
-
-
-
getInstance
-
Static method which allows you to get the tab instance associated with a DOM element, you can use it like this: bootstrap.Tab.getInstance(element).
-
-
-
getOrCreateInstance
-
Static method which returns a tab instance associated to a DOM element or create a new one in case it wasn’t initialized. You can use it like this: bootstrap.Tab.getOrCreateInstance(element).
-
-
-
show
-
Selects the given tab and shows its associated pane. Any other tab that was previously selected becomes unselected and its associated pane is hidden. Returns to the caller before the tab pane has actually been shown (i.e. before the shown.bs.tab event occurs).
-
-
-
+
const bsTab =newbootstrap.Tab('#myTab')
+
+
-
Events
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Method
Description
dispose
Destroys an element’s tab.
getInstance
Static method which allows you to get the tab instance associated with a DOM element, you can use it like this: bootstrap.Tab.getInstance(element).
getOrCreateInstance
Static method which returns a tab instance associated to a DOM element or create a new one in case it wasn’t initialized. You can use it like this: bootstrap.Tab.getOrCreateInstance(element).
show
Selects the given tab and shows its associated pane. Any other tab that was previously selected becomes unselected and its associated pane is hidden. Returns to the caller before the tab pane has actually been shown (i.e. before the shown.bs.tab event occurs).
+
Events
When showing a new tab, the events fire in the following order:
hide.bs.tab (on the current active tab)
@@ -1564,114 +664,41 @@
shown.bs.tab (on the newly-active just-shown tab, the same one as for the show.bs.tab event)
If no tab was already active, then the hide.bs.tab and hidden.bs.tab events will not be fired.
-
-
-
-
Event type
-
Description
-
-
-
-
-
hide.bs.tab
-
This event fires when a new tab is to be shown (and thus the previous active tab is to be hidden). Use event.target and event.relatedTarget to target the current active tab and the new soon-to-be-active tab, respectively.
-
-
-
hidden.bs.tab
-
This event fires after a new tab is shown (and thus the previous active tab is hidden). Use event.target and event.relatedTarget to target the previous active tab and the new active tab, respectively.
-
-
-
show.bs.tab
-
This event fires on tab show, but before the new tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively.
-
-
-
shown.bs.tab
-
This event fires on tab show after a tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively.
This event fires when a new tab is to be shown (and thus the previous active tab is to be hidden). Use event.target and event.relatedTarget to target the current active tab and the new soon-to-be-active tab, respectively.
hidden.bs.tab
This event fires after a new tab is shown (and thus the previous active tab is hidden). Use event.target and event.relatedTarget to target the previous active tab and the new active tab, respectively.
show.bs.tab
This event fires on tab show, but before the new tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively.
shown.bs.tab
This event fires on tab show after a tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively.
Before getting started with Bootstrap’s modal component, be sure to read the following as our menu options have recently changed.
-
Modals are built with HTML, CSS, and JavaScript. They’re positioned over everything else in the document and remove scroll from the <body> so that modal content scrolls instead.
-
Clicking on the modal “backdrop” will automatically close the modal.
-
Bootstrap only supports one modal window at a time. Nested modals aren’t supported as we believe them to be poor user experiences.
-
Modals use position: fixed, which can sometimes be a bit particular about its rendering. Whenever possible, place your modal HTML in a top-level position to avoid potential interference from other elements. You’ll likely run into issues when nesting a .modal within another fixed element.
-
Once again, due to position: fixed, there are some caveats with using modals on mobile devices. See our browser support docs for details.
+
Modals are built with HTML, CSS, and JavaScript. They’re positioned over everything else in the document and remove scroll from the <body> so that modal content scrolls instead.
+
Clicking on the modal “backdrop” will automatically close the modal.
+
Bootstrap only supports one modal window at a time. Nested modals aren’t supported as we believe them to be poor user experiences.
+
Modals use position: fixed, which can sometimes be a bit particular about its rendering. Whenever possible, place your modal HTML in a top-level position to avoid potential interference from other elements. You’ll likely run into issues when nesting a .modal within another fixed element.
+
Once again, due to position: fixed, there are some caveats with using modals on mobile devices. See our browser support docs for details.
Due to how HTML5 defines its semantics, the autofocus HTML attribute has no effect in Bootstrap modals. To achieve the same effect, use some custom JavaScript:
Below is a static modal example (meaning its position and display have been overridden). Included are the modal header, modal body (required for padding), and modal footer (optional). We ask that you include modal headers with dismiss actions whenever possible, or provide another explicit dismiss action.
-In the above static example, we use <h5>, to avoid issues with the heading hierarchy in the documentation page. Structurally, however, a modal dialog represents its own separate document/context, so the .modal-title should ideally be an <h1>. If necessary, you can use the font size utilities to control the heading’s appearance. All the following live examples use this approach.
-
In the above static example, we use <h5>, to avoid issues with the heading hierarchy in the documentation page. Structurally, however, a modal dialog represents its own separate document/context, so the .modal-title should ideally be an <h1>. If necessary, you can use the font size utilities to control the heading’s appearance. All the following live examples use this approach.
+
Live demo
Toggle a working modal demo by clicking the button below. It will slide down and fade in from the top of the page.
When modals become too long for the user’s viewport or device, they scroll independent of the page itself. Try the demo below to see what we mean.
-
-
-
-
-
Modal title
-
-
-
-
This is some placeholder content to show the scrolling behavior for modals. Instead of repeating the text in the modal, we use an inline style to set a minimum height, thereby extending the length of the overall modal and demonstrating the overflow scrolling. When content becomes longer than the height of the viewport, scrolling will move the modal as needed.
-
-
-
-
-
-
-
- Launch demo modal
-
-
+
Modal title
I will not close if you click outside of me. Don’t even try to press escape key.
When modals become too long for the user’s viewport or device, they scroll independent of the page itself. Try the demo below to see what we mean.
+
Modal title
This is some placeholder content to show the scrolling behavior for modals. Instead of repeating the text in the modal, we use an inline style to set a minimum height, thereby extending the length of the overall modal and demonstrating the overflow scrolling. When content becomes longer than the height of the viewport, scrolling will move the modal as needed.
+
Launch demo modal
You can also create a scrollable modal that allows scrolling the modal body by adding .modal-dialog-scrollable to .modal-dialog.
-
-
-
-
-
Modal title
-
-
-
-
This is some placeholder content to show the scrolling behavior for modals. We use repeated line breaks to demonstrate how content can exceed minimum inner height, thereby showing inner scrolling. When content becomes longer than the predefined max-height of modal, content will be cropped and scrollable within the modal.
-
-
This content should appear at the bottom after you scroll.
This is some placeholder content to show the scrolling behavior for modals. We use repeated line breaks to demonstrate how content can exceed minimum inner height, thereby showing inner scrolling. When content becomes longer than the predefined max-height of modal, content will be cropped and scrollable within the modal.
This content should appear at the bottom after you scroll.
Add .modal-dialog-centered to .modal-dialog to vertically center the modal.
-
+
@@ -829,6 +150,7 @@ In the above static example, we use <h5>, to avoid issues wit
+
@@ -837,8 +159,8 @@ In the above static example, we use <h5>, to avoid issues wit
-
This is some placeholder content to show a vertically centered modal. We've added some extra copy here to show how vertically centering the modal works when combined with scrollable modals. We also use some repeated line breaks to quickly extend the height of the content, thereby triggering the scrolling. When content becomes longer than the predefined max-height of modal, content will be cropped and scrollable within the modal.
-
+
This is some placeholder content to show a vertically centered modal. We’ve added some extra copy here to show how vertically centering the modal works when combined with scrollable modals. We also use some repeated line breaks to quickly extend the height of the content, thereby triggering the scrolling. When content becomes longer than the predefined max-height of modal, content will be cropped and scrollable within the modal.
Tooltips and popovers can be placed within modals as needed. When modals are closed, any tooltips and popovers within are also automatically dismissed.
Tooltips and popovers can be placed within modals as needed. When modals are closed, any tooltips and popovers within are also automatically dismissed.
+
@@ -888,102 +206,53 @@ In the above static example, we use <h5>, to avoid issues wit
-
-
- Launch demo modal
-
-
-
<divclass="modal-body">
-<h2class="fs-5">Popover in a modal</h2>
-<p>This <buttonclass="btn btn-secondary"data-bs-toggle="popover"title="Popover title"data-bs-content="Popover body content is set in this attribute.">button</button> triggers a popover on click.</p>
-<hr>
-<h2class="fs-5">Tooltips in a modal</h2>
-<p><ahref="#"data-bs-toggle="tooltip"title="Tooltip">This link</a> and <ahref="#"data-bs-toggle="tooltip"title="Tooltip">that link</a> have tooltips on hover.</p>
-</div>
-
Using the grid
+
+Launch demo modal
+
<divclass="modal-body">
+ <h2class="fs-5">Popover in a modal</h2>
+ <p>This <buttonclass="btn btn-secondary"data-bs-toggle="popover"title="Popover title"data-bs-content="Popover body content is set in this attribute.">button</button> triggers a popover on click.</p>
+ <hr>
+ <h2class="fs-5">Tooltips in a modal</h2>
+ <p><ahref="#"data-bs-toggle="tooltip"title="Tooltip">This link</a> and <ahref="#"data-bs-toggle="tooltip"title="Tooltip">that link</a> have tooltips on hover.</p>
+</div>
+
+
Using the grid
Utilize the Bootstrap grid system within a modal by nesting .container-fluid within the .modal-body. Then, use the normal grid system classes as you would anywhere else.
Have a bunch of buttons that all trigger the same modal with slightly different contents? Use event.relatedTarget and HTML data-bs-* attributes to vary the contents of the modal depending on which button was clicked.
Below is a live demo followed by example HTML and JavaScript. For more information, read the modal events docs for details on relatedTarget.
-
-
-
-Open modal for @mdo
+
Open modal for @mdoOpen modal for @fatOpen modal for @getbootstrap
@@ -1012,82 +281,58 @@ In the above static example, we use <h5>, to avoid issues wit
-
+
html
<buttontype="button"class="btn btn-primary"data-bs-toggle="modal"data-bs-target="#exampleModal"data-bs-whatever="@mdo">Open modal for @mdo</button>
+<buttontype="button"class="btn btn-primary"data-bs-toggle="modal"data-bs-target="#exampleModal"data-bs-whatever="@fat">Open modal for @fat</button>
+<buttontype="button"class="btn btn-primary"data-bs-toggle="modal"data-bs-target="#exampleModal"data-bs-whatever="@getbootstrap">Open modal for @getbootstrap</button>
-
const exampleModal = document.getElementById('exampleModal')
+if(exampleModal){
+ exampleModal.addEventListener('show.bs.modal',event=>{
+ // Button that triggered the modal
+ const button = event.relatedTarget
+ // Extract info from data-bs-* attributes
+ const recipient = button.getAttribute('data-bs-whatever')
+ // If necessary, you could initiate an Ajax request here
+ // and then do the updating in a callback.
-
constexampleModal=document.getElementById('exampleModal')
-if(exampleModal){
-exampleModal.addEventListener('show.bs.modal',event=>{
-// Button that triggered the modal
-constbutton=event.relatedTarget
-// Extract info from data-bs-* attributes
-constrecipient=button.getAttribute('data-bs-whatever')
-// If necessary, you could initiate an Ajax request here
-// and then do the updating in a callback.
-
-// Update the modal's content.
-constmodalTitle=exampleModal.querySelector('.modal-title')
-constmodalBodyInput=exampleModal.querySelector('.modal-body input')
-
-modalTitle.textContent=`New message to ${recipient}`
-modalBodyInput.value=recipient
-})
-}
Toggle between multiple modals with some clever placement of the data-bs-target and data-bs-toggle attributes. For example, you could toggle a password reset modal from within an already open sign in modal. Please note multiple modals cannot be open at the same time—this method simply toggles between two separate modals.
-
-
-
-
+
@@ -1119,644 +364,392 @@ In the above static example, we use <h5>, to avoid issues wit
-Open first modal
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="modal fade"id="exampleModalToggle"aria-hidden="true"aria-labelledby="exampleModalToggleLabel"tabindex="-1">
-<divclass="modal-dialog modal-dialog-centered">
-<divclass="modal-content">
-<divclass="modal-header">
-<h1class="modal-title fs-5"id="exampleModalToggleLabel">Modal 1</h1>
-<buttontype="button"class="btn-close"data-bs-dismiss="modal"aria-label="Close"></button>
-</div>
-<divclass="modal-body">
- Show a second modal and hide this one with the button below.
-</div>
-<divclass="modal-footer">
-<buttonclass="btn btn-primary"data-bs-target="#exampleModalToggle2"data-bs-toggle="modal">Open second modal</button>
-</div>
-</div>
-</div>
-</div>
-<divclass="modal fade"id="exampleModalToggle2"aria-hidden="true"aria-labelledby="exampleModalToggleLabel2"tabindex="-1">
-<divclass="modal-dialog modal-dialog-centered">
-<divclass="modal-content">
-<divclass="modal-header">
-<h1class="modal-title fs-5"id="exampleModalToggleLabel2">Modal 2</h1>
-<buttontype="button"class="btn-close"data-bs-dismiss="modal"aria-label="Close"></button>
-</div>
-<divclass="modal-body">
- Hide this modal and show the first with the button below.
-</div>
-<divclass="modal-footer">
-<buttonclass="btn btn-primary"data-bs-target="#exampleModalToggle"data-bs-toggle="modal">Back to first</button>
-</div>
-</div>
-</div>
-</div>
-<buttonclass="btn btn-primary"data-bs-target="#exampleModalToggle"data-bs-toggle="modal">Open first modal</button>
-
-
-
Change animation
+Open first modal
html
<divclass="modal fade"id="exampleModalToggle"aria-hidden="true"aria-labelledby="exampleModalToggleLabel"tabindex="-1">
+ <divclass="modal-dialog modal-dialog-centered">
+ <divclass="modal-content">
+ <divclass="modal-header">
+ <h1class="modal-title fs-5"id="exampleModalToggleLabel">Modal 1</h1>
+ <buttontype="button"class="btn-close"data-bs-dismiss="modal"aria-label="Close"></button>
+ </div>
+ <divclass="modal-body">
+ Show a second modal and hide this one with the button below.
+ </div>
+ <divclass="modal-footer">
+ <buttonclass="btn btn-primary"data-bs-target="#exampleModalToggle2"data-bs-toggle="modal">Open second modal</button>
+ </div>
+ </div>
+ </div>
+</div>
+<divclass="modal fade"id="exampleModalToggle2"aria-hidden="true"aria-labelledby="exampleModalToggleLabel2"tabindex="-1">
+ <divclass="modal-dialog modal-dialog-centered">
+ <divclass="modal-content">
+ <divclass="modal-header">
+ <h1class="modal-title fs-5"id="exampleModalToggleLabel2">Modal 2</h1>
+ <buttontype="button"class="btn-close"data-bs-dismiss="modal"aria-label="Close"></button>
+ </div>
+ <divclass="modal-body">
+ Hide this modal and show the first with the button below.
+ </div>
+ <divclass="modal-footer">
+ <buttonclass="btn btn-primary"data-bs-target="#exampleModalToggle"data-bs-toggle="modal">Back to first</button>
+ </div>
+ </div>
+ </div>
+</div>
+<buttonclass="btn btn-primary"data-bs-target="#exampleModalToggle"data-bs-toggle="modal">Open first modal</button>
+
Change animation
The $modal-fade-transform variable determines the transform state of .modal-dialog before the modal fade-in animation, the $modal-show-transform variable determines the transform of .modal-dialog at the end of the modal fade-in animation.
If you want for example a zoom-in animation, you can set $modal-fade-transform: scale(.8).
-
Remove animation
+
Remove animation
For modals that simply appear rather than fade in to view, remove the .fade class from your modal markup.
If the height of a modal changes while it is open, you should call myModal.handleUpdate() to readjust the modal’s position in case a scrollbar appears.
-
Accessibility
-
Be sure to add aria-labelledby="...", referencing the modal title, to .modal. Additionally, you may give a description of your modal dialog with aria-describedby on .modal. Note that you don’t need to add role="dialog" since we already add it via JavaScript.
If the height of a modal changes while it is open, you should call myModal.handleUpdate() to readjust the modal’s position in case a scrollbar appears.
+
Accessibility
+
Be sure to add aria-labelledby="...", referencing the modal title, to .modal. Additionally, you may give a description of your modal dialog with aria-describedby on .modal. Note that you don’t need to add role="dialog" since we already add it via JavaScript.
+
Embedding YouTube videos
Embedding YouTube videos in modals requires additional JavaScript not in Bootstrap to automatically stop playback and more. See this helpful Stack Overflow post for more information.
-
Optional sizes
+
Optional sizes
Modals have three optional sizes, available via modifier classes to be placed on a .modal-dialog. These sizes kick in at certain breakpoints to avoid horizontal scrollbars on narrower viewports.
-
-
-
-
Size
-
Class
-
Modal max-width
-
-
-
-
-
Small
-
.modal-sm
-
300px
-
-
-
Default
-
None
-
500px
-
-
-
Large
-
.modal-lg
-
800px
-
-
-
Extra large
-
.modal-xl
-
1140px
-
-
-
+
-
Our default modal without modifier class constitutes the “medium” size modal.
As part of Bootstrap’s evolving CSS variables approach, modals now use local CSS variables on .modal and .modal-backdrop for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
--#{$prefix}modal-zindex:#{$zindex-modal};
+--#{$prefix}modal-width:#{$modal-md};
+--#{$prefix}modal-padding:#{$modal-inner-padding};
+--#{$prefix}modal-margin:#{$modal-dialog-margin};
+--#{$prefix}modal-color:#{$modal-content-color};
+--#{$prefix}modal-bg:#{$modal-content-bg};
+--#{$prefix}modal-border-color:#{$modal-content-border-color};
+--#{$prefix}modal-border-width:#{$modal-content-border-width};
+--#{$prefix}modal-border-radius:#{$modal-content-border-radius};
+--#{$prefix}modal-box-shadow:#{$modal-content-box-shadow-xs};
+--#{$prefix}modal-inner-border-radius:#{$modal-content-inner-border-radius};
+--#{$prefix}modal-header-padding-x:#{$modal-header-padding-x};
+--#{$prefix}modal-header-padding-y:#{$modal-header-padding-y};
+--#{$prefix}modal-header-padding:#{$modal-header-padding};// Todo in v6: Split this padding into x and y
+--#{$prefix}modal-header-border-color:#{$modal-header-border-color};
+--#{$prefix}modal-header-border-width:#{$modal-header-border-width};
+--#{$prefix}modal-title-line-height:#{$modal-title-line-height};
+--#{$prefix}modal-footer-gap:#{$modal-footer-margin-between};
+--#{$prefix}modal-footer-bg:#{$modal-footer-bg};
+--#{$prefix}modal-footer-border-color:#{$modal-footer-border-color};
+--#{$prefix}modal-footer-border-width:#{$modal-footer-border-width};
+
As part of Bootstrap’s evolving CSS variables approach, modals now use local CSS variables on .modal and .modal-backdrop for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
--#{$prefix}modal-zindex:#{$zindex-modal};
---#{$prefix}modal-width:#{$modal-md};
---#{$prefix}modal-padding:#{$modal-inner-padding};
---#{$prefix}modal-margin:#{$modal-dialog-margin};
---#{$prefix}modal-color:#{$modal-content-color};
---#{$prefix}modal-bg:#{$modal-content-bg};
---#{$prefix}modal-border-color:#{$modal-content-border-color};
---#{$prefix}modal-border-width:#{$modal-content-border-width};
---#{$prefix}modal-border-radius:#{$modal-content-border-radius};
---#{$prefix}modal-box-shadow:#{$modal-content-box-shadow-xs};
---#{$prefix}modal-inner-border-radius:#{$modal-content-inner-border-radius};
---#{$prefix}modal-header-padding-x:#{$modal-header-padding-x};
---#{$prefix}modal-header-padding-y:#{$modal-header-padding-y};
---#{$prefix}modal-header-padding:#{$modal-header-padding};// Todo in v6: Split this padding into x and y
---#{$prefix}modal-header-border-color:#{$modal-header-border-color};
---#{$prefix}modal-header-border-width:#{$modal-header-border-width};
---#{$prefix}modal-title-line-height:#{$modal-title-line-height};
---#{$prefix}modal-footer-gap:#{$modal-footer-margin-between};
---#{$prefix}modal-footer-bg:#{$modal-footer-bg};
---#{$prefix}modal-footer-border-color:#{$modal-footer-border-color};
---#{$prefix}modal-footer-border-width:#{$modal-footer-border-width};
The modal plugin toggles your hidden content on demand, via data attributes or JavaScript. It also overrides default scrolling behavior and generates a .modal-backdrop to provide a click area for dismissing shown modals when clicking outside the modal.
-
Via data attributes
-
Toggle
+
Via data attributes
+
Toggle
Activate a modal without writing JavaScript. Set data-bs-toggle="modal" on a controller element, like a button, along with a data-bs-target="#foo" or href="#foo" to target a specific modal to toggle.
constmyModal=newbootstrap.Modal(document.getElementById('myModal'),options)
-// or
-constmyModalAlternative=newbootstrap.Modal('#myModal',options)
-
Options
-
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
-
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
+
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
The final configuration object is the merged result of data-bs-config, data-bs-, and js object where the latest given key-value overrides the others.
+
-
-
-
-
Name
-
Type
-
Default
-
Description
-
-
-
-
-
backdrop
-
boolean, 'static'
-
true
-
Includes a modal-backdrop element. Alternatively, specify static for a backdrop which doesn’t close the modal when clicked.
-
-
-
focus
-
boolean
-
true
-
Puts the focus on the modal when initialized.
-
-
-
keyboard
-
boolean
-
true
-
Closes the modal when escape key is pressed.
-
-
-
-
Methods
-
-All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started, but before it ends. In addition, a method call on a transitioning component will be ignored. Learn more in our JavaScript docs.
-
Includes a modal-backdrop element. Alternatively, specify static for a backdrop which doesn’t close the modal when clicked.
focus
boolean
true
Puts the focus on the modal when initialized.
keyboard
boolean
true
Closes the modal when escape key is pressed.
+
Methods
+
All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started, but before it ends. In addition, a method call on a transitioning component will be ignored. Learn more in our JavaScript docs.
+
Passing options
Activates your content as a modal. Accepts an optional options object.
Destroys an element’s modal. (Removes stored data on the DOM element)
-
-
-
getInstance
-
Static method which allows you to get the modal instance associated with a DOM element.
-
-
-
getOrCreateInstance
-
Static method which allows you to get the modal instance associated with a DOM element, or create a new one in case it wasn’t initialized.
-
-
-
handleUpdate
-
Manually readjust the modal’s position if the height of a modal changes while it is open (i.e. in case a scrollbar appears).
-
-
-
hide
-
Manually hides a modal. Returns to the caller before the modal has actually been hidden (i.e. before the hidden.bs.modal event occurs).
-
-
-
show
-
Manually opens a modal. Returns to the caller before the modal has actually been shown (i.e. before the shown.bs.modal event occurs). Also, you can pass a DOM element as an argument that can be received in the modal events (as the relatedTarget property). (i.e. const modalToggle = document.getElementById('toggleMyModal'); myModal.show(modalToggle).
-
-
-
toggle
-
Manually toggles a modal. Returns to the caller before the modal has actually been shown or hidden (i.e. before the shown.bs.modal or hidden.bs.modal event occurs).
-
-
-
-
-
Events
-
Bootstrap’s modal class exposes a few events for hooking into modal functionality. All modal events are fired at the modal itself (i.e. at the <div class="modal">).
-
-
-
-
Event
-
Description
-
-
-
-
-
hide.bs.modal
-
This event is fired immediately when the hide instance method has been called. Can be prevented by calling event.preventDefault(). See JavaScript events documentation for more details on event prevention.
-
-
-
hidden.bs.modal
-
This event is fired when the modal has finished being hidden from the user (will wait for CSS transitions to complete).
-
-
-
hidePrevented.bs.modal
-
This event is fired when the modal is shown, its backdrop is static and a click outside of the modal is performed. The event is also fired when the escape key is pressed and the keyboard option is set to false.
-
-
-
show.bs.modal
-
This event fires immediately when the show instance method is called. If caused by a click, the clicked element is available as the relatedTarget property of the event.
-
-
-
shown.bs.modal
-
This event is fired when the modal has been made visible to the user (will wait for CSS transitions to complete). If caused by a click, the clicked element is available as the relatedTarget property of the event.
-
-
-
-
-
constmyModalEl=document.getElementById('myModal')
-myModalEl.addEventListener('hidden.bs.modal',event=>{
-// do something...
-})
-
Destroys an element’s modal. (Removes stored data on the DOM element)
getInstance
Static method which allows you to get the modal instance associated with a DOM element.
getOrCreateInstance
Static method which allows you to get the modal instance associated with a DOM element, or create a new one in case it wasn’t initialized.
handleUpdate
Manually readjust the modal’s position if the height of a modal changes while it is open (i.e. in case a scrollbar appears).
hide
Manually hides a modal. Returns to the caller before the modal has actually been hidden (i.e. before the hidden.bs.modal event occurs).
show
Manually opens a modal. Returns to the caller before the modal has actually been shown (i.e. before the shown.bs.modal event occurs). Also, you can pass a DOM element as an argument that can be received in the modal events (as the relatedTarget property). (i.e. const modalToggle = document.getElementById('toggleMyModal'); myModal.show(modalToggle).
toggle
Manually toggles a modal. Returns to the caller before the modal has actually been shown or hidden (i.e. before the shown.bs.modal or hidden.bs.modal event occurs).
+
Events
+
Bootstrap’s modal class exposes a few events for hooking into modal functionality. All modal events are fired at the modal itself (i.e. at the <div class="modal">).
This event is fired immediately when the hide instance method has been called. Can be prevented by calling event.preventDefault(). See JavaScript events documentation for more details on event prevention.
hidden.bs.modal
This event is fired when the modal has finished being hidden from the user (will wait for CSS transitions to complete).
hidePrevented.bs.modal
This event is fired when the modal is shown, its backdrop is static and a click outside of the modal is performed. The event is also fired when the escape key is pressed and the keyboard option is set to false.
show.bs.modal
This event fires immediately when the show instance method is called. If caused by a click, the clicked element is available as the relatedTarget property of the event.
shown.bs.modal
This event is fired when the modal has been made visible to the user (will wait for CSS transitions to complete). If caused by a click, the clicked element is available as the relatedTarget property of the event.
Documentation and examples for Bootstrap’s powerful, responsive navigation header, the navbar. Includes support for branding, navigation, and more, including support for our collapse plugin.
Documentation and examples for Bootstrap’s powerful, responsive navigation header, the navbar. Includes support for branding, navigation, and more, including support for our collapse plugin.
Here’s what you need to know before getting started with the navbar:
Navbars require a wrapping .navbar with .navbar-expand{-sm|-md|-lg|-xl|-xxl} for responsive collapsing and color scheme classes.
Navbars and their contents are fluid by default. Change the container to limit their horizontal width in different ways.
-
Use our spacing and flex utility classes for controlling spacing and alignment within navbars.
+
Use our spacing and flex utility classes for controlling spacing and alignment within navbars.
Navbars are responsive by default, but you can easily modify them to change that. Responsive behavior depends on our Collapse JavaScript plugin.
Ensure accessibility by using a <nav> element or, if using a more generic element such as a <div>, add a role="navigation" to every navbar to explicitly identify it as a landmark region for users of assistive technologies.
Indicate the current item by using aria-current="page" for the current page or aria-current="true" for the current item in a set.
New in v5.2.0: Navbars can be themed with CSS variables that are scoped to the .navbar base class. .navbar-light has been deprecated and .navbar-dark has been rewritten to override CSS variables instead of adding additional styles.
This example uses background (bg-body-tertiary) and spacing (me-auto, mb-2, mb-lg-0, me-2) utility classes.
+
Brand
The .navbar-brand can be applied to most elements, but an anchor works best, as some elements might require utility classes or custom styles.
-
Text
+
Text
Add your text within an element with the .navbar-brand class.
-
-
-
-
+
Navbar
@@ -721,107 +133,56 @@ The animation effect of this component is dependent on the prefers-reduced
Navbar
-
+
html
<!-- As a link -->
+<navclass="navbar bg-body-tertiary">
+ <divclass="container-fluid">
+ <aclass="navbar-brand"href="#">Navbar</a>
+ </div>
+</nav>
-
- html
-
-
-
-
-
-
-
-
-
<!-- As a link -->
-<navclass="navbar bg-body-tertiary">
-<divclass="container-fluid">
-<aclass="navbar-brand"href="#">Navbar</a>
-</div>
-</nav>
-
-<!-- As a heading -->
-<navclass="navbar bg-body-tertiary">
-<divclass="container-fluid">
-<spanclass="navbar-brand mb-0 h1">Navbar</span>
-</div>
-</nav>
-
-
-
Image
+<!-- As a heading -->
+<navclass="navbar bg-body-tertiary">
+ <divclass="container-fluid">
+ <spanclass="navbar-brand mb-0 h1">Navbar</span>
+ </div>
+</nav>
+
Image
You can replace the text within the .navbar-brand with an <img>.
You can also make use of some additional utilities to add an image and text at the same time. Note the addition of .d-inline-block and .align-text-top on the <img>.
Navbar navigation links build on our .nav options with their own modifier class and require the use of toggler classes for proper responsive styling. Navigation in navbars will also grow to occupy as much horizontal space as possible to keep your navbar contents securely aligned.
Add the .active class on .nav-link to indicate the current page.
Please note that you should also add the aria-current attribute on the active .nav-link.
-
-
-
-
+
Navbar
@@ -844,49 +205,32 @@ The animation effect of this component is dependent on the prefers-reduced
You can also use dropdowns in your navbar. Dropdown menus require a wrapping element for positioning, so be sure to use separate and nested elements for .nav-item and .nav-link as shown below.
-
-
-
-
+
Navbar
@@ -965,219 +292,117 @@ The animation effect of this component is dependent on the prefers-reduced
Immediate child elements of .navbar use flex layout and will default to justify-content: space-between. Use additional flex utilities as needed to adjust this behavior.
Immediate child elements of .navbar use flex layout and will default to justify-content: space-between. Use additional flex utilities as needed to adjust this behavior.
Various buttons are supported as part of these navbar forms, too. This is also a great reminder that vertical alignment utilities can be used to align different sized elements.
Navbars may contain bits of text with the help of .navbar-text. This class adjusts vertical alignment and horizontal spacing for strings of text.
-
-
-
-
+
Navbar text with an inline element
-
-
-
- html
-
-
-
-
-
-
-
-
-
<navclass="navbar bg-body-tertiary">
-<divclass="container-fluid">
-<spanclass="navbar-text">
- Navbar text with an inline element
-</span>
-</div>
-</nav>
-
-
+
html
<navclass="navbar bg-body-tertiary">
+ <divclass="container-fluid">
+ <spanclass="navbar-text">
+ Navbar text with an inline element
+ </span>
+ </div>
+</nav>
Mix and match with other components and utilities as needed.
-
-
-
-
+
Navbar w/ text
@@ -1200,350 +425,124 @@ The animation effect of this component is dependent on the prefers-reduced
New dark navbars in v5.3.0 — We’ve deprecated .navbar-dark in favor of the new data-bs-theme="dark". Add data-bs-theme="dark" to the .navbar to enable a component-specific color mode. Learn more about our color modes.
New in v5.2.0 — Navbar theming is now powered by CSS variables and .navbar-light has been deprecated. CSS variables are applied to .navbar, defaulting to the “light” appearance, and can be overridden with .navbar-dark.
+
Navbar themes are easier than ever thanks to Bootstrap’s combination of Sass and CSS variables. The default is our “light navbar” for use with light background colors, but you can also apply data-bs-theme="dark" to the .navbar parent for dark background colors. Then, customize with .bg-* and additional utilities.
New dark navbars in v5.3.0 — We’ve deprecated .navbar-dark in favor of the new data-bs-theme="dark". Add data-bs-theme="dark" to the .navbar to enable a component-specific color mode. Learn more about our color modes.
-
-
New in v5.2.0 — Navbar theming is now powered by CSS variables and .navbar-light has been deprecated. CSS variables are applied to .navbar, defaulting to the “light” appearance, and can be overridden with .navbar-dark.
-
-
-
-
Navbar themes are easier than ever thanks to Bootstrap’s combination of Sass and CSS variables. The default is our “light navbar” for use with light background colors, but you can also apply data-bs-theme="dark" to the .navbar parent for dark background colors. Then, customize with .bg-* and additional utilities.
Although it’s not required, you can wrap a navbar in a .container to center it on a page–though note that an inner container is still required. Or you can add a container inside the .navbar to only center the contents of a fixed or static top navbar.
Although it’s not required, you can wrap a navbar in a .container to center it on a page–though note that an inner container is still required. Or you can add a container inside the .navbar to only center the contents of a fixed or static top navbar.
Use our position utilities to place navbars in non-static positions. Choose from fixed to the top, fixed to the bottom, stickied to the top (scrolls with the page until it reaches the top, then stays there), or stickied to the bottom (scrolls with the page until it reaches the bottom, then stays there).
-
Fixed navbars use position: fixed, meaning they’re pulled from the normal flow of the DOM and may require custom CSS (e.g., padding-top on the <body>) to prevent overlap with other elements.
Use our position utilities to place navbars in non-static positions. Choose from fixed to the top, fixed to the bottom, stickied to the top (scrolls with the page until it reaches the top, then stays there), or stickied to the bottom (scrolls with the page until it reaches the bottom, then stays there).
+
Fixed navbars use position: fixed, meaning they’re pulled from the normal flow of the DOM and may require custom CSS (e.g., padding-top on the <body>) to prevent overlap with other elements.
Add .navbar-nav-scroll to a .navbar-nav (or other navbar sub-component) to enable vertical scrolling within the toggleable contents of a collapsed navbar. By default, scrolling kicks in at 75vh (or 75% of the viewport height), but you can override that with the local CSS custom property --bs-navbar-height or custom styles. At larger viewports when the navbar is expanded, content will appear as it does in a default navbar.
Please note that this behavior comes with a potential drawback of overflow—when setting overflow-y: auto (required to scroll the content here), overflow-x is the equivalent of auto, which will crop some horizontal content.
-
Here’s an example navbar using .navbar-nav-scroll with style="--bs-scroll-height: 100px;", with some extra margin utilities for optimum spacing.
-
-
-
-
+
Here’s an example navbar using .navbar-nav-scroll with style="--bs-scroll-height: 100px;", with some extra margin utilities for optimum spacing.
+
Navbar scroll
@@ -1573,71 +572,54 @@ The animation effect of this component is dependent on the prefers-reduced
Navbars can use .navbar-toggler, .navbar-collapse, and .navbar-expand{-sm|-md|-lg|-xl|-xxl} classes to determine when their content collapses behind a button. In combination with other utilities, you can easily choose when to show or hide particular elements.
-
For navbars that never collapse, add the .navbar-expand class on the navbar. For navbars that always collapse, don’t add any .navbar-expand class.
-
Toggler
-
Navbar togglers are left-aligned by default, but should they follow a sibling element like a .navbar-brand, they’ll automatically be aligned to the far right. Reversing your markup will reverse the placement of the toggler. Below are examples of different toggle styles.
+
For navbars that never collapse, add the .navbar-expand class on the navbar. For navbars that always collapse, don’t add any .navbar-expand class.
+
Toggler
+
Navbar togglers are left-aligned by default, but should they follow a sibling element like a .navbar-brand, they’ll automatically be aligned to the far right. Reversing your markup will reverse the placement of the toggler. Below are examples of different toggle styles.
With no .navbar-brand shown at the smallest breakpoint:
-
-
-
-
+
@@ -1656,55 +638,38 @@ The animation effect of this component is dependent on the prefers-reduced
Sometimes you want to use the collapse plugin to trigger a container element for content that structurally sits outside of the .navbar . Because our plugin works on the id and data-bs-target matching, that’s easily done!
Sometimes you want to use the collapse plugin to trigger a container element for content that structurally sits outside of the .navbar . Because our plugin works on the id and data-bs-target matching, that’s easily done!
+
Collapsed content
Toggleable via the navbar brand.
@@ -1851,41 +782,24 @@ The animation effect of this component is dependent on the prefers-reduced
When you do this, we recommend including additional JavaScript to move the focus programmatically to the container when it is opened. Otherwise, keyboard users and users of assistive technologies will likely have a hard time finding the newly revealed content - particularly if the container that was opened comes before the toggler in the document’s structure. We also recommend making sure that the toggler has the aria-controls attribute, pointing to the id of the content container. In theory, this allows assistive technology users to jump directly from the toggler to the container it controls–but support for this is currently quite patchy.
-
Offcanvas
-
Transform your expanding and collapsing navbar into an offcanvas drawer with the offcanvas component. We extend both the offcanvas default styles and use our .navbar-expand-* classes to create a dynamic and flexible navigation sidebar.
When you do this, we recommend including additional JavaScript to move the focus programmatically to the container when it is opened. Otherwise, keyboard users and users of assistive technologies will likely have a hard time finding the newly revealed content - particularly if the container that was opened comes before the toggler in the document’s structure. We also recommend making sure that the toggler has the aria-controls attribute, pointing to the id of the content container. In theory, this allows assistive technology users to jump directly from the toggler to the container it controls–but support for this is currently quite patchy.
+
Offcanvas
+
Transform your expanding and collapsing navbar into an offcanvas drawer with the offcanvas component. We extend both the offcanvas default styles and use our .navbar-expand-* classes to create a dynamic and flexible navigation sidebar.
In the example below, to create an offcanvas navbar that is always collapsed across all breakpoints, omit the .navbar-expand-* class entirely.
-
-
-
-
+
Offcanvas navbar
@@ -1919,82 +833,66 @@ The animation effect of this component is dependent on the prefers-reduced
When using offcanvas in a dark navbar, be aware that you may need to have a dark background on the offcanvas content to avoid the text becoming illegible. In the example below, we add .navbar-dark and .bg-dark to the .navbar, .text-bg-dark to the .offcanvas, .dropdown-menu-dark to .dropdown-menu, and .btn-close-white to .btn-close for proper styling with a dark offcanvas.
When using offcanvas in a dark navbar, be aware that you may need to have a dark background on the offcanvas content to avoid the text becoming illegible. In the example below, we add .navbar-dark and .bg-dark to the .navbar, .text-bg-dark to the .offcanvas, .dropdown-menu-dark to .dropdown-menu, and .btn-close-white to .btn-close for proper styling with a dark offcanvas.
+
Offcanvas dark navbar
@@ -2028,345 +926,212 @@ The animation effect of this component is dependent on the prefers-reduced
As part of Bootstrap’s evolving CSS variables approach, navbars now use local CSS variables on .navbar for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
As part of Bootstrap’s evolving CSS variables approach, navbars now use local CSS variables on .navbar for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
// Generate series of `.navbar-expand-*` responsive classes for configuring
+// where your navbar collapses.
+.navbar-expand {
+ @each$breakpoint in map-keys($grid-breakpoints){
+ $next:breakpoint-next($breakpoint,$grid-breakpoints);
+ $infix:breakpoint-infix($next,$grid-breakpoints);
-
Navigation available in Bootstrap share general markup and styles, from the base .nav class to the active and disabled states. Swap modifier classes to switch between each style.
The base .nav component is built with flexbox and provide a strong foundation for building all types of navigation components. It includes some style overrides (for working with lists), some link padding for larger hit areas, and basic disabled styling.
-
-
The base .nav component does not include any .active state. The following examples include the class, mainly to demonstrate that this particular class does not trigger any special styling.
-
To convey the active state to assistive technologies, use the aria-current attribute — using the page value for current page, or true for the current item in a set.
-
-
-
-
-
-
-
+
The base .nav component does not include any .active state. The following examples include the class, mainly to demonstrate that this particular class does not trigger any special styling.
To convey the active state to assistive technologies, use the aria-current attribute — using the page value for current page, or true for the current item in a set.
Classes are used throughout, so your markup can be super flexible. Use <ul>s like above, <ol> if the order of your items is important, or roll your own with a <nav> element. Because the .nav uses display: flex, the nav links behave the same as nav items would, but without the extra markup.
Change the style of .navs component with modifiers and utilities. Mix and match as needed, or build your own.
-
Horizontal alignment
-
Change the horizontal alignment of your nav with flexbox utilities. By default, navs are left-aligned, but you can easily change them to center or right-aligned.
+
Horizontal alignment
+
Change the horizontal alignment of your nav with flexbox utilities. By default, navs are left-aligned, but you can easily change them to center or right-aligned.
Stack your navigation by changing the flex item direction with the .flex-column utility. Need to stack them on some viewports but not others? Use the responsive versions (e.g., .flex-sm-column).
Takes the basic nav from above and adds the .nav-tabs class to generate a tabbed interface. Use them to create tabbable regions with our tab JavaScript plugin.
Force your .nav’s contents to extend the full available width with one of two modifier classes. To proportionately fill all available space with your .nav-items, use .nav-fill. Notice that all horizontal space is occupied, but not every nav item has the same width.
Force your .nav’s contents to extend the full available width with one of two modifier classes. To proportionately fill all available space with your .nav-items, use .nav-fill. Notice that all horizontal space is occupied, but not every nav item has the same width.
For equal-width elements, use .nav-justified. All horizontal space will be occupied by nav links, but unlike the .nav-fill above, every nav item will be the same width.
If you need responsive nav variations, consider using a series of flexbox utilities. While more verbose, these utilities offer greater customization across responsive breakpoints. In the example below, our nav will be stacked on the lowest breakpoint, then adapt to a horizontal layout that fills the available width starting from the small breakpoint.
If you need responsive nav variations, consider using a series of flexbox utilities. While more verbose, these utilities offer greater customization across responsive breakpoints. In the example below, our nav will be stacked on the lowest breakpoint, then adapt to a horizontal layout that fills the available width starting from the small breakpoint.
If you’re using navs to provide a navigation bar, be sure to add a role="navigation" to the most logical parent container of the <ul>, or wrap a <nav> element around the whole navigation. Do not add the role to the <ul> itself, as this would prevent it from being announced as an actual list by assistive technologies.
If you’re using navs to provide a navigation bar, be sure to add a role="navigation" to the most logical parent container of the <ul>, or wrap a <nav> element around the whole navigation. Do not add the role to the <ul> itself, as this would prevent it from being announced as an actual list by assistive technologies.
Note that navigation bars, even if visually styled as tabs with the .nav-tabs class, should not be given role="tablist", role="tab" or role="tabpanel" attributes. These are only appropriate for dynamic tabbed interfaces, as described in the ARIA Authoring Practices Guide tabs pattern. See JavaScript behavior for dynamic tabbed interfaces in this section for an example. The aria-current attribute is not necessary on dynamic tabbed interfaces since our JavaScript handles the selected state by adding aria-selected="true" on the active tab.
As part of Bootstrap’s evolving CSS variables approach, navs now use local CSS variables on .nav, .nav-tabs, and .nav-pills for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
+
As part of Bootstrap’s evolving CSS variables approach, navs now use local CSS variables on .nav, .nav-tabs, and .nav-pills for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
Use the tab JavaScript plugin—include it individually or through the compiled bootstrap.js file—to extend our navigational tabs and pills to create tabbable panes of local content.
-
-
-
- Home
-
-
- Profile
-
-
- Contact
-
-
- Disabled
-
-
-
-
-
This is some placeholder content the Home tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
-
-
-
This is some placeholder content the Profile tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
-
-
-
This is some placeholder content the Contact tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
-
-
-
This is some placeholder content the Disabled tab's associated content.
To help fit your needs, this works with <ul>-based markup, as shown above, or with any arbitrary “roll your own” markup. Note that if you’re using <nav>, you shouldn’t add role="tablist" directly to it, as this would override the element’s native role as a navigation landmark. Instead, switch to an alternative element (in the example below, a simple <div>) and wrap the <nav> around it.
-
-
-
- Home
- Profile
- Contact
- Disabled
-
-
-
-
-
This is some placeholder content the Home tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
-
-
-
This is some placeholder content the Profile tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
-
-
-
This is some placeholder content the Contact tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
-
-
-
This is some placeholder content the Disabled tab's associated content.
This is some placeholder content the Home tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
-
-
-
This is some placeholder content the Profile tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
-
-
-
This is some placeholder content the Contact tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
-
-
-
This is some placeholder content the Disabled tab's associated content.
This is some placeholder content the Home tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
-
-
-
This is some placeholder content the Profile tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
-
-
-
This is some placeholder content the Disabled tab's associated content.
-
-
-
This is some placeholder content the Messages tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
-
-
-
This is some placeholder content the Settings tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
This is some placeholder content the Home tab’s associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
This is some placeholder content the Profile tab’s associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
This is some placeholder content the Contact tab’s associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
This is some placeholder content the Disabled tab’s associated content.
To help fit your needs, this works with <ul>-based markup, as shown above, or with any arbitrary “roll your own” markup. Note that if you’re using <nav>, you shouldn’t add role="tablist" directly to it, as this would override the element’s native role as a navigation landmark. Instead, switch to an alternative element (in the example below, a simple <div>) and wrap the <nav> around it.
+
HomeProfileContactDisabled
This is some placeholder content the Home tab’s associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
This is some placeholder content the Profile tab’s associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
This is some placeholder content the Contact tab’s associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
This is some placeholder content the Disabled tab’s associated content.
This is some placeholder content the Home tab’s associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
This is some placeholder content the Profile tab’s associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
This is some placeholder content the Contact tab’s associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
This is some placeholder content the Disabled tab’s associated content.
And with vertical pills. Ideally, for vertical tabs, you should also add aria-orientation="vertical" to the tab list container.
+
HomeProfileDisabledMessagesSettings
This is some placeholder content the Home tab’s associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
This is some placeholder content the Profile tab’s associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
This is some placeholder content the Disabled tab’s associated content.
This is some placeholder content the Messages tab’s associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
This is some placeholder content the Settings tab’s associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
Dynamic tabbed interfaces, as described in the ARIA Authoring Practices Guide tabs pattern, require role="tablist", role="tab", role="tabpanel", and additional aria- attributes in order to convey their structure, functionality, and current state to users of assistive technologies (such as screen readers). As a best practice, we recommend using <button> elements for the tabs, as these are controls that trigger a dynamic change, rather than links that navigate to a new page or location.
-
In line with the ARIA Authoring Practices pattern, only the currently active tab receives keyboard focus. When the JavaScript plugin is initialized, it will set tabindex="-1" on all inactive tab controls. Once the currently active tab has focus, the cursor keys activate the previous/next tab. The Home and End keys activate the first and last tabs, respectively. The plugin will change the roving tabindex accordingly. However, note that the JavaScript plugin does not distinguish between horizontal and vertical tab lists when it comes to cursor key interactions: regardless of the tab list’s orientation, both the up and left cursor go to the previous tab, and down and right cursor go to the next tab.
-
-In general, to facilitate keyboard navigation, it’s recommended to make the tab panels themselves focusable as well, unless the first element containing meaningful content inside the tab panel is already focusable. The JavaScript plugin does not try to handle this aspect—where appropriate, you’ll need to explicitly make your tab panels focusable by adding tabindex="0" in your markup.
-
-
-
-The tab JavaScript plugin does not support tabbed interfaces that contain dropdown menus, as these cause both usability and accessibility issues. From a usability perspective, the fact that the currently displayed tab’s trigger element is not immediately visible (as it’s inside the closed dropdown menu) can cause confusion. From an accessibility point of view, there is currently no sensible way to map this sort of construct to a standard WAI ARIA pattern, meaning that it cannot be easily made understandable to users of assistive technologies.
-
-
-
Using data attributes
+
In line with the ARIA Authoring Practices pattern, only the currently active tab receives keyboard focus. When the JavaScript plugin is initialized, it will set tabindex="-1" on all inactive tab controls. Once the currently active tab has focus, the cursor keys activate the previous/next tab. The Home and End keys activate the first and last tabs, respectively. The plugin will change the roving tabindex accordingly. However, note that the JavaScript plugin does not distinguish between horizontal and vertical tab lists when it comes to cursor key interactions: regardless of the tab list’s orientation, both the up and left cursor go to the previous tab, and down and right cursor go to the next tab.
+
In general, to facilitate keyboard navigation, it’s recommended to make the tab panels themselves focusable as well, unless the first element containing meaningful content inside the tab panel is already focusable. The JavaScript plugin does not try to handle this aspect—where appropriate, you’ll need to explicitly make your tab panels focusable by adding tabindex="0" in your markup.
+
The tab JavaScript plugin does not support tabbed interfaces that contain dropdown menus, as these cause both usability and accessibility issues. From a usability perspective, the fact that the currently displayed tab’s trigger element is not immediately visible (as it’s inside the closed dropdown menu) can cause confusion. From an accessibility point of view, there is currently no sensible way to map this sort of construct to a standard WAI ARIA pattern, meaning that it cannot be easily made understandable to users of assistive technologies.
+
Using data attributes
You can activate a tab or pill navigation without writing any JavaScript by simply specifying data-bs-toggle="tab" or data-bs-toggle="pill" on an element. Use these data attributes on .nav-tabs or .nav-pills.
-All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started, but before it ends. In addition, a method call on a transitioning component will be ignored. Learn more in our JavaScript docs.
-
All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started, but before it ends. In addition, a method call on a transitioning component will be ignored. Learn more in our JavaScript docs.
Activates your content as a tab element.
You can create a tab instance with the constructor, for example:
-
constbsTab=newbootstrap.Tab('#myTab')
-
-
-
-
Method
-
Description
-
-
-
-
-
dispose
-
Destroys an element’s tab.
-
-
-
getInstance
-
Static method which allows you to get the tab instance associated with a DOM element, you can use it like this: bootstrap.Tab.getInstance(element).
-
-
-
getOrCreateInstance
-
Static method which returns a tab instance associated to a DOM element or create a new one in case it wasn’t initialized. You can use it like this: bootstrap.Tab.getOrCreateInstance(element).
-
-
-
show
-
Selects the given tab and shows its associated pane. Any other tab that was previously selected becomes unselected and its associated pane is hidden. Returns to the caller before the tab pane has actually been shown (i.e. before the shown.bs.tab event occurs).
-
-
-
+
const bsTab =newbootstrap.Tab('#myTab')
+
+
-
Events
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Method
Description
dispose
Destroys an element’s tab.
getInstance
Static method which allows you to get the tab instance associated with a DOM element, you can use it like this: bootstrap.Tab.getInstance(element).
getOrCreateInstance
Static method which returns a tab instance associated to a DOM element or create a new one in case it wasn’t initialized. You can use it like this: bootstrap.Tab.getOrCreateInstance(element).
show
Selects the given tab and shows its associated pane. Any other tab that was previously selected becomes unselected and its associated pane is hidden. Returns to the caller before the tab pane has actually been shown (i.e. before the shown.bs.tab event occurs).
+
Events
When showing a new tab, the events fire in the following order:
hide.bs.tab (on the current active tab)
@@ -1670,112 +678,39 @@ The tab JavaScript plugin does not support tabbed interfaces th
shown.bs.tab (on the newly-active just-shown tab, the same one as for the show.bs.tab event)
If no tab was already active, then the hide.bs.tab and hidden.bs.tab events will not be fired.
-
-
-
-
Event type
-
Description
-
-
-
-
-
hide.bs.tab
-
This event fires when a new tab is to be shown (and thus the previous active tab is to be hidden). Use event.target and event.relatedTarget to target the current active tab and the new soon-to-be-active tab, respectively.
-
-
-
hidden.bs.tab
-
This event fires after a new tab is shown (and thus the previous active tab is hidden). Use event.target and event.relatedTarget to target the previous active tab and the new active tab, respectively.
-
-
-
show.bs.tab
-
This event fires on tab show, but before the new tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively.
-
-
-
shown.bs.tab
-
This event fires on tab show after a tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively.
This event fires when a new tab is to be shown (and thus the previous active tab is to be hidden). Use event.target and event.relatedTarget to target the current active tab and the new soon-to-be-active tab, respectively.
hidden.bs.tab
This event fires after a new tab is shown (and thus the previous active tab is hidden). Use event.target and event.relatedTarget to target the previous active tab and the new active tab, respectively.
show.bs.tab
This event fires on tab show, but before the new tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively.
shown.bs.tab
This event fires on tab show after a tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively.
Offcanvas is a sidebar component that can be toggled via JavaScript to appear from the left, right, top, or bottom edge of the viewport. Buttons or anchors are used as triggers that are attached to specific elements you toggle, and data attributes are used to invoke our JavaScript.
Offcanvas shares some of the same JavaScript code as modals. Conceptually, they are quite similar, but they are separate plugins.
-
Similarly, some source Sass variables for offcanvas’s styles and dimensions are inherited from the modal’s variables.
+
Similarly, some source Sass variables for offcanvas’s styles and dimensions are inherited from the modal’s variables.
When shown, offcanvas includes a default backdrop that can be clicked to hide the offcanvas.
Similar to modals, only one offcanvas can be shown at a time.
Heads up! Given how CSS handles animations, you cannot use margin or translate on an .offcanvas element. Instead, use the class as an independent wrapping element.
Below is an offcanvas example that is shown by default (via .show on .offcanvas). Offcanvas includes support for a header with a close button and an optional body class for some initial padding. We suggest that you include offcanvas headers with dismiss actions whenever possible, or provide an explicit dismiss action.
-
-
-
-
+
Offcanvas
@@ -614,40 +42,23 @@ The animation effect of this component is dependent on the prefers-reduced
Content for the offcanvas goes here. You can place just about any Bootstrap component or custom elements here.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="offcanvas offcanvas-start show"tabindex="-1"id="offcanvas"aria-labelledby="offcanvasLabel">
-<divclass="offcanvas-header">
-<h5class="offcanvas-title"id="offcanvasLabel">Offcanvas</h5>
-<buttontype="button"class="btn-close"data-bs-dismiss="offcanvas"aria-label="Close"></button>
-</div>
-<divclass="offcanvas-body">
- Content for the offcanvas goes here. You can place just about any Bootstrap component or custom elements here.
-</div>
-</div>
-
-
-
Live demo
+
html
<divclass="offcanvas offcanvas-start show"tabindex="-1"id="offcanvas"aria-labelledby="offcanvasLabel">
+ <divclass="offcanvas-header">
+ <h5class="offcanvas-title"id="offcanvasLabel">Offcanvas</h5>
+ <buttontype="button"class="btn-close"data-bs-dismiss="offcanvas"aria-label="Close"></button>
+ </div>
+ <divclass="offcanvas-body">
+ Content for the offcanvas goes here. You can place just about any Bootstrap component or custom elements here.
+ </div>
+</div>
+
Live demo
Use the buttons below to show and hide an offcanvas element via JavaScript that toggles the .show class on an element with the .offcanvas class.
.offcanvas hides content (default)
.offcanvas.show shows content
You can use a link with the href attribute, or a button with the data-bs-target attribute. In both cases, the data-bs-toggle="offcanvas" is required.
Link with href
@@ -660,7 +71,7 @@ The animation effect of this component is dependent on the prefers-reduced
-
+
Some text as placeholder. In real life you can have the elements you have chosen. Like, text, images, lists, etc.
@@ -674,54 +85,37 @@ The animation effect of this component is dependent on the prefers-reduced
-
+
html
<aclass="btn btn-primary"data-bs-toggle="offcanvas"href="#offcanvasExample"role="button"aria-controls="offcanvasExample">
+ Link with href
+</a>
+<buttonclass="btn btn-primary"type="button"data-bs-toggle="offcanvas"data-bs-target="#offcanvasExample"aria-controls="offcanvasExample">
+ Button with data-bs-target
+</button>
-
- html
-
-
-
-
-
-
-
-
-
<aclass="btn btn-primary"data-bs-toggle="offcanvas"href="#offcanvasExample"role="button"aria-controls="offcanvasExample">
- Link with href
-</a>
-<buttonclass="btn btn-primary"type="button"data-bs-toggle="offcanvas"data-bs-target="#offcanvasExample"aria-controls="offcanvasExample">
- Button with data-bs-target
-</button>
-
-<divclass="offcanvas offcanvas-start"tabindex="-1"id="offcanvasExample"aria-labelledby="offcanvasExampleLabel">
-<divclass="offcanvas-header">
-<h5class="offcanvas-title"id="offcanvasExampleLabel">Offcanvas</h5>
-<buttontype="button"class="btn-close"data-bs-dismiss="offcanvas"aria-label="Close"></button>
-</div>
-<divclass="offcanvas-body">
-<div>
- Some text as placeholder. In real life you can have the elements you have chosen. Like, text, images, lists, etc.
-</div>
-<divclass="dropdown mt-3">
-<buttonclass="btn btn-secondary dropdown-toggle"type="button"data-bs-toggle="dropdown">
- Dropdown button
-</button>
-<ulclass="dropdown-menu">
-<li><aclass="dropdown-item"href="#">Action</a></li>
-<li><aclass="dropdown-item"href="#">Another action</a></li>
-<li><aclass="dropdown-item"href="#">Something else here</a></li>
-</ul>
-</div>
-</div>
-</div>
-
-
-
Body scrolling
+<divclass="offcanvas offcanvas-start"tabindex="-1"id="offcanvasExample"aria-labelledby="offcanvasExampleLabel">
+ <divclass="offcanvas-header">
+ <h5class="offcanvas-title"id="offcanvasExampleLabel">Offcanvas</h5>
+ <buttontype="button"class="btn-close"data-bs-dismiss="offcanvas"aria-label="Close"></button>
+ </div>
+ <divclass="offcanvas-body">
+ <div>
+ Some text as placeholder. In real life you can have the elements you have chosen. Like, text, images, lists, etc.
+ </div>
+ <divclass="dropdown mt-3">
+ <buttonclass="btn btn-secondary dropdown-toggle"type="button"data-bs-toggle="dropdown">
+ Dropdown button
+ </button>
+ <ulclass="dropdown-menu">
+ <li><aclass="dropdown-item"href="#">Action</a></li>
+ <li><aclass="dropdown-item"href="#">Another action</a></li>
+ <li><aclass="dropdown-item"href="#">Something else here</a></li>
+ </ul>
+ </div>
+ </div>
+</div>
+
Body scrolling
Scrolling the <body> element is disabled when an offcanvas and its backdrop are visible. Use the data-bs-scroll attribute to enable <body> scrolling.
-
-
-
-Enable body scrolling
+
Enable body scrolling
@@ -731,37 +125,20 @@ The animation effect of this component is dependent on the prefers-reduced
Try scrolling the rest of the page to see this option in action.
-
+
html
<buttonclass="btn btn-primary"type="button"data-bs-toggle="offcanvas"data-bs-target="#offcanvasScrolling"aria-controls="offcanvasScrolling">Enable body scrolling</button>
-
- html
-
-
-
-
-
-
-
-
-
<buttonclass="btn btn-primary"type="button"data-bs-toggle="offcanvas"data-bs-target="#offcanvasScrolling"aria-controls="offcanvasScrolling">Enable body scrolling</button>
-
-<divclass="offcanvas offcanvas-start"data-bs-scroll="true"data-bs-backdrop="false"tabindex="-1"id="offcanvasScrolling"aria-labelledby="offcanvasScrollingLabel">
-<divclass="offcanvas-header">
-<h5class="offcanvas-title"id="offcanvasScrollingLabel">Offcanvas with body scrolling</h5>
-<buttontype="button"class="btn-close"data-bs-dismiss="offcanvas"aria-label="Close"></button>
-</div>
-<divclass="offcanvas-body">
-<p>Try scrolling the rest of the page to see this option in action.</p>
-</div>
-</div>
-
-
-
Body scrolling and backdrop
+<divclass="offcanvas offcanvas-start"data-bs-scroll="true"data-bs-backdrop="false"tabindex="-1"id="offcanvasScrolling"aria-labelledby="offcanvasScrollingLabel">
+ <divclass="offcanvas-header">
+ <h5class="offcanvas-title"id="offcanvasScrollingLabel">Offcanvas with body scrolling</h5>
+ <buttontype="button"class="btn-close"data-bs-dismiss="offcanvas"aria-label="Close"></button>
+ </div>
+ <divclass="offcanvas-body">
+ <p>Try scrolling the rest of the page to see this option in action.</p>
+ </div>
+</div>
+
Body scrolling and backdrop
You can also enable <body> scrolling with a visible backdrop.
-
-
-
-Enable both scrolling & backdrop
+
Enable both scrolling & backdrop
@@ -771,37 +148,20 @@ The animation effect of this component is dependent on the prefers-reduced
Try scrolling the rest of the page to see this option in action.
-
+
html
<buttonclass="btn btn-primary"type="button"data-bs-toggle="offcanvas"data-bs-target="#offcanvasWithBothOptions"aria-controls="offcanvasWithBothOptions">Enable both scrolling & backdrop</button>
-
- html
-
-
-
-
-
-
-
-
-
<buttonclass="btn btn-primary"type="button"data-bs-toggle="offcanvas"data-bs-target="#offcanvasWithBothOptions"aria-controls="offcanvasWithBothOptions">Enable both scrolling & backdrop</button>
-
-<divclass="offcanvas offcanvas-start"data-bs-scroll="true"tabindex="-1"id="offcanvasWithBothOptions"aria-labelledby="offcanvasWithBothOptionsLabel">
-<divclass="offcanvas-header">
-<h5class="offcanvas-title"id="offcanvasWithBothOptionsLabel">Backdrop with scrolling</h5>
-<buttontype="button"class="btn-close"data-bs-dismiss="offcanvas"aria-label="Close"></button>
-</div>
-<divclass="offcanvas-body">
-<p>Try scrolling the rest of the page to see this option in action.</p>
-</div>
-</div>
-
-
-
Static backdrop
+<divclass="offcanvas offcanvas-start"data-bs-scroll="true"tabindex="-1"id="offcanvasWithBothOptions"aria-labelledby="offcanvasWithBothOptionsLabel">
+ <divclass="offcanvas-header">
+ <h5class="offcanvas-title"id="offcanvasWithBothOptionsLabel">Backdrop with scrolling</h5>
+ <buttontype="button"class="btn-close"data-bs-dismiss="offcanvas"aria-label="Close"></button>
+ </div>
+ <divclass="offcanvas-body">
+ <p>Try scrolling the rest of the page to see this option in action.</p>
+ </div>
+</div>
+
Static backdrop
When backdrop is set to static, the offcanvas will not close when clicking outside of it.
-
-
-
-
+
Toggle static offcanvas
@@ -815,48 +175,28 @@ The animation effect of this component is dependent on the prefers-reduced
I will not close if you click outside of me.
<buttonclass="btn btn-primary"type="button"data-bs-toggle="offcanvas"data-bs-target="#staticBackdrop"aria-controls="staticBackdrop">
- Toggle static offcanvas
-</button>
-
-<divclass="offcanvas offcanvas-start"data-bs-backdrop="static"tabindex="-1"id="staticBackdrop"aria-labelledby="staticBackdropLabel">
-<divclass="offcanvas-header">
-<h5class="offcanvas-title"id="staticBackdropLabel">Offcanvas</h5>
-<buttontype="button"class="btn-close"data-bs-dismiss="offcanvas"aria-label="Close"></button>
-</div>
-<divclass="offcanvas-body">
-<div>
- I will not close if you click outside of me.
-</div>
-</div>
-</div>
-
-
-
Dark offcanvas
-
Deprecated in v5.3.0
- Added in v5.2.0
-
+<divclass="offcanvas offcanvas-start"data-bs-backdrop="static"tabindex="-1"id="staticBackdrop"aria-labelledby="staticBackdropLabel">
+ <divclass="offcanvas-header">
+ <h5class="offcanvas-title"id="staticBackdropLabel">Offcanvas</h5>
+ <buttontype="button"class="btn-close"data-bs-dismiss="offcanvas"aria-label="Close"></button>
+ </div>
+ <divclass="offcanvas-body">
+ <div>
+ I will not close if you click outside of me.
+ </div>
+ </div>
+</div>
+
Dark offcanvas
+
+Deprecated in v5.3.0
+Added in v5.2.0
Change the appearance of offcanvases with utilities to better match them to different contexts like dark navbars. Here we add .text-bg-dark to the .offcanvas and .btn-close-white to .btn-close for proper styling with a dark offcanvas. If you have dropdowns within, consider also adding .dropdown-menu-dark to .dropdown-menu.
-
-Heads up! Dark variants for components were deprecated in v5.3.0 with the introduction of color modes. Instead of manually adding classes mentioned above, set data-bs-theme="dark" on the root element, a parent wrapper, or the component itself.
-
-
-
-
-
-
+
Heads up! Dark variants for components were deprecated in v5.3.0 with the introduction of color modes. Instead of manually adding classes mentioned above, set data-bs-theme="dark" on the root element, a parent wrapper, or the component itself.
+
Offcanvas
@@ -864,37 +204,28 @@ The animation effect of this component is dependent on the prefers-reduced
Responsive offcanvas classes hide content outside the viewport from a specified breakpoint and down. Above that breakpoint, the contents within will behave as usual. For example, .offcanvas-lg hides content in an offcanvas below the lg breakpoint, but shows the content above the lg breakpoint.
-
-
-
-Toggle offcanvas
+
Responsive offcanvas classes hide content outside the viewport from a specified breakpoint and down. Above that breakpoint, the contents within will behave as usual. For example, .offcanvas-lg hides content in an offcanvas below the lg breakpoint, but shows the content above the lg breakpoint. Responsive offcanvas classes are available for each breakpoint.
+
+
.offcanvas
+
.offcanvas-sm
+
.offcanvas-md
+
.offcanvas-lg
+
.offcanvas-xl
+
.offcanvas-xxl
+
+
To make a responsive offcanvas, replace the .offcanvas base class with a responsive variant and ensure your close button has an explicit data-bs-target.
+
Toggle offcanvas
Resize your browser to show the responsive offcanvas toggle.
@@ -906,44 +237,21 @@ The animation effect of this component is dependent on the prefers-reduced
<buttonclass="btn btn-primary d-lg-none"type="button"data-bs-toggle="offcanvas"data-bs-target="#offcanvasResponsive"aria-controls="offcanvasResponsive">Toggle offcanvas</button>
-
-<divclass="alert alert-info d-none d-lg-block">Resize your browser to show the responsive offcanvas toggle.</div>
-
-<divclass="offcanvas-lg offcanvas-end"tabindex="-1"id="offcanvasResponsive"aria-labelledby="offcanvasResponsiveLabel">
-<divclass="offcanvas-header">
-<h5class="offcanvas-title"id="offcanvasResponsiveLabel">Responsive offcanvas</h5>
-<buttontype="button"class="btn-close"data-bs-dismiss="offcanvas"data-bs-target="#offcanvasResponsive"aria-label="Close"></button>
-</div>
-<divclass="offcanvas-body">
-<pclass="mb-0">This is content within an <code>.offcanvas-lg</code>.</p>
-</div>
-</div>
-
+<divclass="alert alert-info d-none d-lg-block">Resize your browser to show the responsive offcanvas toggle.</div>
-
Responsive offcanvas classes are available across for each breakpoint.
-
-
.offcanvas
-
.offcanvas-sm
-
.offcanvas-md
-
.offcanvas-lg
-
.offcanvas-xl
-
.offcanvas-xxl
-
-
Placement
-
There’s no default placement for offcanvas components, so you must add one of the modifier classes below.
+<divclass="offcanvas-lg offcanvas-end"tabindex="-1"id="offcanvasResponsive"aria-labelledby="offcanvasResponsiveLabel">
+ <divclass="offcanvas-header">
+ <h5class="offcanvas-title"id="offcanvasResponsiveLabel">Responsive offcanvas</h5>
+ <buttontype="button"class="btn-close"data-bs-dismiss="offcanvas"data-bs-target="#offcanvasResponsive"aria-label="Close"></button>
+ </div>
+ <divclass="offcanvas-body">
+ <pclass="mb-0">This is content within an <code>.offcanvas-lg</code>.</p>
+ </div>
+</div>
+
Placement
+
There’s no default placement for offcanvas components, so you must add one of the modifier classes below.
.offcanvas-start places offcanvas on the left of the viewport (shown above)
.offcanvas-end places offcanvas on the right of the viewport
@@ -951,10 +259,7 @@ The animation effect of this component is dependent on the prefers-reduced
.offcanvas-bottom places offcanvas on the bottom of the viewport
Try the top, right, and bottom examples out below.
-
-
-
-Toggle top offcanvas
+
Toggle top offcanvas
@@ -964,35 +269,18 @@ The animation effect of this component is dependent on the prefers-reduced
...
-
+
html
<buttonclass="btn btn-primary"type="button"data-bs-toggle="offcanvas"data-bs-target="#offcanvasTop"aria-controls="offcanvasTop">Toggle top offcanvas</button>
-
@@ -1002,35 +290,18 @@ The animation effect of this component is dependent on the prefers-reduced
...
-
+
html
<buttonclass="btn btn-primary"type="button"data-bs-toggle="offcanvas"data-bs-target="#offcanvasRight"aria-controls="offcanvasRight">Toggle right offcanvas</button>
-
Since the offcanvas panel is conceptually a modal dialog, be sure to add aria-labelledby="..."—referencing the offcanvas title—to .offcanvas. Note that you don’t need to add role="dialog" since we already add it via JavaScript.
-
CSS
-
Variables
+
CSS
+
Variables
Added in v5.2.0
-
-
As part of Bootstrap’s evolving CSS variables approach, offcanvas now uses local CSS variables on .offcanvas for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
As part of Bootstrap’s evolving CSS variables approach, offcanvas now uses local CSS variables on .offcanvas for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
The offcanvas plugin utilizes a few classes and attributes to handle the heavy lifting:
.offcanvas hides the content
@@ -1126,212 +367,133 @@ The animation effect of this component is dependent on the prefers-reduced
.offcanvas-bottom hides the offcanvas on the bottom
Add a dismiss button with the data-bs-dismiss="offcanvas" attribute, which triggers the JavaScript functionality. Be sure to use the <button> element with it for proper behavior across all devices.
-
Via data attributes
-
Toggle
-
Add data-bs-toggle="offcanvas" and a data-bs-target or href to the element to automatically assign control of one offcanvas element. The data-bs-target attribute accepts a CSS selector to apply the offcanvas to. Be sure to add the class offcanvas to the offcanvas element. If you’d like it to default open, add the additional class show.
-
Dismiss
-
Dismissal can be achieved with the data-bs-dismiss attribute on a button within the offcanvas as demonstrated below:
-While both ways to dismiss an offcanvas are supported, keep in mind that dismissing from outside an offcanvas does not match the ARIA Authoring Practices Guide dialog (modal) pattern. Do this at your own risk.
-
-
-
Via JavaScript
+
Via data attributes
+
Toggle
+
Add data-bs-toggle="offcanvas" and a data-bs-target or href to the element to automatically assign control of one offcanvas element. The data-bs-target attribute accepts a CSS selector to apply the offcanvas to. Be sure to add the class offcanvas to the offcanvas element. If you’d like it to default open, add the additional class show.
+
Dismiss
+
+Dismissal can be achieved with the data-bs-dismiss attribute on a button within the offcanvas as demonstrated below:
+
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
-
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
+
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
The final configuration object is the merged result of data-bs-config, data-bs-, and js object where the latest given key-value overrides the others.
+
-
-
-
-
Name
-
Type
-
Default
-
Description
-
-
-
-
-
backdrop
-
boolean or the string static
-
true
-
Apply a backdrop on body while offcanvas is open. Alternatively, specify static for a backdrop which doesn’t close the offcanvas when clicked.
-
-
-
keyboard
-
boolean
-
true
-
Closes the offcanvas when escape key is pressed.
-
-
-
scroll
-
boolean
-
false
-
Allow body scrolling while offcanvas is open.
-
-
-
-
Methods
-
-All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started, but before it ends. In addition, a method call on a transitioning component will be ignored. Learn more in our JavaScript docs.
-
Apply a backdrop on body while offcanvas is open. Alternatively, specify static for a backdrop which doesn’t close the offcanvas when clicked.
keyboard
boolean
true
Closes the offcanvas when escape key is pressed.
scroll
boolean
false
Allow body scrolling while offcanvas is open.
+
Methods
+
All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started, but before it ends. In addition, a method call on a transitioning component will be ignored. Learn more in our JavaScript docs.
Activates your content as an offcanvas element. Accepts an optional options object.
You can create an offcanvas instance with the constructor, for example:
Static method which allows you to get the offcanvas instance associated with a DOM element.
-
-
-
getOrCreateInstance
-
Static method which allows you to get the offcanvas instance associated with a DOM element, or create a new one in case it wasn’t initialized.
-
-
-
hide
-
Hides an offcanvas element. Returns to the caller before the offcanvas element has actually been hidden (i.e. before the hidden.bs.offcanvas event occurs).
-
-
-
show
-
Shows an offcanvas element. Returns to the caller before the offcanvas element has actually been shown (i.e. before the shown.bs.offcanvas event occurs).
-
-
-
toggle
-
Toggles an offcanvas element to shown or hidden. Returns to the caller before the offcanvas element has actually been shown or hidden (i.e. before the shown.bs.offcanvas or hidden.bs.offcanvas event occurs).
-
-
-
-
-
Events
-
Bootstrap’s offcanvas class exposes a few events for hooking into offcanvas functionality.
-
-
-
-
Event type
-
Description
-
-
-
-
-
hide.bs.offcanvas
-
This event is fired immediately when the hide method has been called.
-
-
-
hidden.bs.offcanvas
-
This event is fired when an offcanvas element has been hidden from the user (will wait for CSS transitions to complete).
-
-
-
hidePrevented.bs.offcanvas
-
This event is fired when the offcanvas is shown, its backdrop is static and a click outside of the offcanvas is performed. The event is also fired when the escape key is pressed and the keyboard option is set to false.
-
-
-
show.bs.offcanvas
-
This event fires immediately when the show instance method is called.
-
-
-
shown.bs.offcanvas
-
This event is fired when an offcanvas element has been made visible to the user (will wait for CSS transitions to complete).
-
-
-
-
-
constmyOffcanvas=document.getElementById('myOffcanvas')
-myOffcanvas.addEventListener('hidden.bs.offcanvas',event=>{
-// do something...
-})
-
Static method which allows you to get the offcanvas instance associated with a DOM element.
getOrCreateInstance
Static method which allows you to get the offcanvas instance associated with a DOM element, or create a new one in case it wasn’t initialized.
hide
Hides an offcanvas element. Returns to the caller before the offcanvas element has actually been hidden (i.e. before the hidden.bs.offcanvas event occurs).
show
Shows an offcanvas element. Returns to the caller before the offcanvas element has actually been shown (i.e. before the shown.bs.offcanvas event occurs).
toggle
Toggles an offcanvas element to shown or hidden. Returns to the caller before the offcanvas element has actually been shown or hidden (i.e. before the shown.bs.offcanvas or hidden.bs.offcanvas event occurs).
+
Events
+
Bootstrap’s offcanvas class exposes a few events for hooking into offcanvas functionality.
This event is fired immediately when the hide method has been called.
hidden.bs.offcanvas
This event is fired when an offcanvas element has been hidden from the user (will wait for CSS transitions to complete).
hidePrevented.bs.offcanvas
This event is fired when the offcanvas is shown, its backdrop is static and a click outside of the offcanvas is performed. The event is also fired when the escape key is pressed and the keyboard option is set to false.
show.bs.offcanvas
This event fires immediately when the show instance method is called.
shown.bs.offcanvas
This event is fired when an offcanvas element has been made visible to the user (will wait for CSS transitions to complete).
We use a large block of connected links for our pagination, making links hard to miss and easily scalable—all while providing large hit areas. Pagination is built with list HTML elements so screen readers can announce the number of available links. Use a wrapping <nav> element to identify it as a navigation section to screen readers and other assistive technologies.
-
In addition, as pages likely have more than one such navigation section, it’s advisable to provide a descriptive aria-label for the <nav> to reflect its purpose. For example, if the pagination component is used to navigate between a set of search results, an appropriate label could be aria-label="Search results pages".
-
-
-
-
+
In addition, as pages likely have more than one such navigation section, it’s advisable to provide a descriptive aria-label for the <nav> to reflect its purpose. For example, if the pagination component is used to navigate between a set of search results, an appropriate label could be aria-label="Search results pages".
Pagination links are customizable for different circumstances. Use .disabled for links that appear un-clickable and .active to indicate the current page.
-
While the .disabled class uses pointer-events: none to try to disable the link functionality of <a>s, that CSS property is not yet standardized and doesn’t account for keyboard navigation. As such, you should always add tabindex="-1" on disabled links and use custom JavaScript to fully disable their functionality.
-
-
-
-
+
While the .disabled class uses pointer-events: none to try to disable the link functionality of <a>s, that CSS property is not yet standardized and doesn’t account for keyboard navigation. As such, you should always add tabindex="-1" on disabled links and use custom JavaScript to fully disable their functionality.
You can optionally swap out active or disabled anchors for <span>, or omit the anchor in the case of the prev/next arrows, to remove click functionality and prevent keyboard focus while retaining intended styles.
As part of Bootstrap’s evolving CSS variables approach, pagination now uses local CSS variables on .pagination for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
As part of Bootstrap’s evolving CSS variables approach, pagination now uses local CSS variables on .pagination for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
Placeholders can be used to enhance the experience of your application. They’re built only with HTML and CSS, meaning you don’t need any JavaScript to create them. You will, however, need some custom JavaScript to toggle their visibility. Their appearance, color, and sizing can be easily customized with our utility classes.
-
Example
-
In the example below, we take a typical card component and recreate it with placeholders applied to create a “loading card”. Size and proportions are the same between the two.
Placeholders can be used to enhance the experience of your application. They’re built only with HTML and CSS, meaning you don’t need any JavaScript to create them. You will, however, need some custom JavaScript to toggle their visibility. Their appearance, color, and sizing can be easily customized with our utility classes.
+
Example
+
In the example below, we take a typical card component and recreate it with placeholders applied to create a “loading card”. Size and proportions are the same between the two.
+
+ Placeholder
Card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
<divclass="card">
-<imgsrc="..."class="card-img-top"alt="...">
-
-<divclass="card-body">
-<h5class="card-title">Card title</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-<ahref="#"class="btn btn-primary">Go somewhere</a>
-</div>
-</div>
-
-<divclass="card"aria-hidden="true">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title placeholder-glow">
-<spanclass="placeholder col-6"></span>
-</h5>
-<pclass="card-text placeholder-glow">
-<spanclass="placeholder col-7"></span>
-<spanclass="placeholder col-4"></span>
-<spanclass="placeholder col-4"></span>
-<spanclass="placeholder col-6"></span>
-<spanclass="placeholder col-8"></span>
-</p>
-<aclass="btn btn-primary disabled placeholder col-6"aria-disabled="true"></a>
-</div>
-</div>
-
How it works
+
+
<divclass="card">
+ <imgsrc="..."class="card-img-top"alt="...">
+
+ <divclass="card-body">
+ <h5class="card-title">Card title</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ <ahref="#"class="btn btn-primary">Go somewhere</a>
+ </div>
+</div>
+
+<divclass="card"aria-hidden="true">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title placeholder-glow">
+ <spanclass="placeholder col-6"></span>
+ </h5>
+ <pclass="card-text placeholder-glow">
+ <spanclass="placeholder col-7"></span>
+ <spanclass="placeholder col-4"></span>
+ <spanclass="placeholder col-4"></span>
+ <spanclass="placeholder col-6"></span>
+ <spanclass="placeholder col-8"></span>
+ </p>
+ <aclass="btn btn-primary disabled placeholder col-6"aria-disabled="true"></a>
+ </div>
+</div>
+
+
How it works
Create placeholders with the .placeholder class and a grid column class (e.g., .col-6) to set the width. They can replace the text inside an element or be added as a modifier class to an existing component.
We apply additional styling to .btns via ::before to ensure the height is respected. You may extend this pattern for other situations as needed, or add a within the element to reflect the height when actual text is rendered in its place.
-The use of aria-hidden="true" only indicates that the element should be hidden to screen readers. The loading behavior of the placeholder depends on how authors will actually use the placeholder styles, how they plan to update things, etc. Some JavaScript code may be needed to swap the state of the placeholder and inform AT users of the update.
-
The use of aria-hidden="true" only indicates that the element should be hidden to screen readers. The loading behavior of the placeholder depends on how authors will actually use the placeholder styles, how they plan to update things, etc. Some JavaScript code may be needed to swap the state of the placeholder and inform AT users of the update.
+
Width
You can change the width through grid column classes, width utilities, or inline styles.
The size of .placeholders are based on the typographic style of the parent element. Customize them with sizing modifiers: .placeholder-lg, .placeholder-sm, or .placeholder-xs.
Popovers rely on the third party library Popper for positioning. You must include popper.min.js before bootstrap.js, or use one bootstrap.bundle.min.js which contains Popper.
Popovers are opt-in for performance reasons, so you must initialize them yourself.
Zero-length title and content values will never show a popover.
-
Specify container: 'body' to avoid rendering problems in more complex components (like our input groups, button groups, etc).
+
Specify container: 'body' to avoid rendering problems in more complex components (like our input groups, button groups, etc).
Triggering popovers on hidden elements will not work.
Popovers for .disabled or disabled elements must be triggered on a wrapper element.
-
When triggered from anchors that wrap across multiple lines, popovers will be centered between the anchors’ overall width. Use .text-nowrap on your <a>s to avoid this behavior.
+
When triggered from anchors that wrap across multiple lines, popovers will be centered between the anchors’ overall width. Use .text-nowrap on your <a>s to avoid this behavior.
Popovers must be hidden before their corresponding elements have been removed from the DOM.
Popovers can be triggered thanks to an element inside a shadow DOM.
-
-By default, this component uses the built-in content sanitizer, which strips out any HTML elements that are not explicitly allowed. See the sanitizer section in our JavaScript documentation for more details.
-
By default, this component uses the built-in content sanitizer, which strips out any HTML elements that are not explicitly allowed. See the sanitizer section in our JavaScript documentation for more details.
Keep reading to see how popovers work with some examples.
-
Examples
-
Enable popovers
+
Examples
+
Enable popovers
As mentioned above, you must initialize popovers before they can be used. One way to initialize all popovers on a page would be to select them by their data-bs-toggle attribute, like so:
We use JavaScript similar to the snippet above to render the following live popover. Titles are set via data-bs-title and body content is set via data-bs-content.
-
-Feel free to use either title or data-bs-title in your HTML. When title is used, Popper will replace it automatically with data-bs-title when the element is rendered.
-
-
-
-
-
-Click to toggle popover
-
-
- html
-
-
-
-
-
-
-
-
-
<buttontype="button"class="btn btn-lg btn-danger"data-bs-toggle="popover"data-bs-title="Popover title"data-bs-content="And here's some amazing content. It's very engaging. Right?">Click to toggle popover</button>
-
-
-
Four directions
+
Feel free to use either title or data-bs-title in your HTML. When title is used, Popper will replace it automatically with data-bs-title when the element is rendered.
+
Click to toggle popover
html
<buttontype="button"class="btn btn-lg btn-danger"data-bs-toggle="popover"data-bs-title="Popover title"data-bs-content="And here’s some amazing content. It’s very engaging. Right?">Click to toggle popover</button>
+
Four directions
Four options are available: top, right, bottom, and left. Directions are mirrored when using Bootstrap in RTL. Set data-bs-placement to change the direction.
-
-
-
-
+
Popover on top
@@ -650,544 +61,362 @@ Feel free to use either title or data-bs-title in your
Popover on left
-
-
-
- html
-
-
-
-
-
-
-
-
-
<buttontype="button"class="btn btn-secondary"data-bs-container="body"data-bs-toggle="popover"data-bs-placement="top"data-bs-content="Top popover">
- Popover on top
-</button>
-<buttontype="button"class="btn btn-secondary"data-bs-container="body"data-bs-toggle="popover"data-bs-placement="right"data-bs-content="Right popover">
- Popover on right
-</button>
-<buttontype="button"class="btn btn-secondary"data-bs-container="body"data-bs-toggle="popover"data-bs-placement="bottom"data-bs-content="Bottom popover">
- Popover on bottom
-</button>
-<buttontype="button"class="btn btn-secondary"data-bs-container="body"data-bs-toggle="popover"data-bs-placement="left"data-bs-content="Left popover">
- Popover on left
-</button>
-
-
-
Custom container
-
When you have some styles on a parent element that interfere with a popover, you’ll want to specify a custom container so that the popover’s HTML appears within that element instead. This is common in responsive tables, input groups, and the like.
Another situation where you’ll want to set an explicit custom container are popovers inside a modal dialog, to make sure that the popover itself is appended to the modal. This is particularly important for popovers that contain interactive elements – modal dialogs will trap focus, so unless the popover is a child element of the modal, users won’t be able to focus or activate these interactive elements.
<buttontype="button"class="btn btn-secondary"data-bs-container="body"data-bs-toggle="popover"data-bs-placement="top"data-bs-content="Top popover">
+ Popover on top
+</button>
+<buttontype="button"class="btn btn-secondary"data-bs-container="body"data-bs-toggle="popover"data-bs-placement="right"data-bs-content="Right popover">
+ Popover on right
+</button>
+<buttontype="button"class="btn btn-secondary"data-bs-container="body"data-bs-toggle="popover"data-bs-placement="bottom"data-bs-content="Bottom popover">
+ Popover on bottom
+</button>
+<buttontype="button"class="btn btn-secondary"data-bs-container="body"data-bs-toggle="popover"data-bs-placement="left"data-bs-content="Left popover">
+ Popover on left
+</button>
+
Custom container
+
When you have some styles on a parent element that interfere with a popover, you’ll want to specify a custom container so that the popover’s HTML appears within that element instead. This is common in responsive tables, input groups, and the like.
Another situation where you’ll want to set an explicit custom container are popovers inside a modal dialog, to make sure that the popover itself is appended to the modal. This is particularly important for popovers that contain interactive elements – modal dialogs will trap focus, so unless the popover is a child element of the modal, users won’t be able to focus or activate these interactive elements.
You can customize the appearance of popovers using CSS variables. We set a custom class with data-bs-custom-class="custom-popover" to scope our custom appearance and use it to override some of the local CSS variables.
<buttontype="button"class="btn btn-secondary"
-data-bs-toggle="popover"data-bs-placement="right"
-data-bs-custom-class="custom-popover"
-data-bs-title="Custom popover"
-data-bs-content="This popover is themed via CSS variables.">
- Custom popover
-</button>
-
-
-
Dismiss on next click
-
Use the focus trigger to dismiss popovers on the user’s next click of an element other than the toggle element.
-
-Dismissing on next click requires specific HTML for proper cross-browser and cross-platform behavior. You can only use <a> elements, not <button>s, and you must include a tabindex.
-
Elements with the disabled attribute aren’t interactive, meaning users cannot hover or click them to trigger a popover (or tooltip). As a workaround, you’ll want to trigger the popover from a wrapper <div> or <span>, ideally made keyboard-focusable using tabindex="0".
Use the focus trigger to dismiss popovers on the user’s next click of an element other than the toggle element.
+
Dismissing on next click requires specific HTML for proper cross-browser and cross-platform behavior. You can only use <a> elements, not <button>s, and you must include a tabindex.
Elements with the disabled attribute aren’t interactive, meaning users cannot hover or click them to trigger a popover (or tooltip). As a workaround, you’ll want to trigger the popover from a wrapper <div> or <span>, ideally made keyboard-focusable using tabindex="0".
For disabled popover triggers, you may also prefer data-bs-trigger="hover focus" so that the popover appears as immediate visual feedback to your users as they may not expect to click on a disabled element.
As part of Bootstrap’s evolving CSS variables approach, popovers now use local CSS variables on .popover for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
Keep popovers accessible to keyboard and assistive technology users by only adding them to HTML elements that are traditionally keyboard-focusable and interactive (such as links or form controls). While other HTML elements can be made focusable by adding tabindex="0", this can create annoying and confusing tab stops on non-interactive elements for keyboard users, and most assistive technologies currently do not announce popovers in this situation. Additionally, do not rely solely on hover as the trigger for your popovers as this will make them impossible to trigger for keyboard users.
-
Avoid adding an excessive amount of content in popovers with the html option. Once popovers are displayed, their content is tied to the trigger element with the aria-describedby attribute, causing all of the popover’s content to be announced to assistive technology users as one long, uninterrupted stream.
-
Popovers do not manage keyboard focus order, and their placement can be random in the DOM, so be careful when adding interactive elements (like forms or links), as it may lead to an illogical focus order or make the popover content itself completely unreachable for keyboard users. In cases where you must use these elements, consider using a modal dialog instead.
-
-
-
-
Options
-
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
-
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
Keep popovers accessible to keyboard and assistive technology users by only adding them to HTML elements that are traditionally keyboard-focusable and interactive (such as links or form controls). While other HTML elements can be made focusable by adding tabindex="0", this can create annoying and confusing tab stops on non-interactive elements for keyboard users, and most assistive technologies currently do not announce popovers in this situation. Additionally, do not rely solely on hover as the trigger for your popovers as this will make them impossible to trigger for keyboard users.
Avoid adding an excessive amount of content in popovers with the html option. Once popovers are displayed, their content is tied to the trigger element with the aria-describedby attribute, causing all of the popover’s content to be announced to assistive technology users as one long, uninterrupted stream.
Popovers do not manage keyboard focus order, and their placement can be random in the DOM, so be careful when adding interactive elements (like forms or links), as it may lead to an illogical focus order or make the popover content itself completely unreachable for keyboard users. In cases where you must use these elements, consider using a modal dialog instead.
+
Options
+
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
+
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
The final configuration object is the merged result of data-bs-config, data-bs-, and js object where the latest given key-value overrides the others.
-
-
-Note that for security reasons the sanitize, sanitizeFn, and allowList options cannot be supplied using data attributes.
-
Object which contains allowed attributes and tags.
-
-
-
animation
-
boolean
-
true
-
Apply a CSS fade transition to the popover.
-
-
-
boundary
-
string, element
-
'clippingParents'
-
Overflow constraint boundary of the popover (applies only to Popper’s preventOverflow modifier). By default, it’s 'clippingParents' and can accept an HTMLElement reference (via JavaScript only). For more information refer to Popper’s detectOverflow docs.
-
-
-
container
-
string, element, false
-
false
-
Appends the popover to a specific element. Example: container: 'body'. This option is particularly useful in that it allows you to position the popover in the flow of the document near the triggering element - which will prevent the popover from floating away from the triggering element during a window resize.
-
-
-
content
-
string, element, function
-
''
-
The popover’s text content. If a function is given, it will be called with its this reference set to the element that the popover is attached to.
-
-
-
customClass
-
string, function
-
''
-
Add classes to the popover when it is shown. Note that these classes will be added in addition to any classes specified in the template. To add multiple classes, separate them with spaces: 'class-1 class-2'. You can also pass a function that should return a single string containing additional class names.
-
-
-
delay
-
number, object
-
0
-
Delay showing and hiding the popover (ms)—doesn’t apply to manual trigger type. If a number is supplied, delay is applied to both hide/show. Object structure is: delay: { "show": 500, "hide": 100 }.
-
-
-
fallbackPlacements
-
string, array
-
['top', 'right', 'bottom', 'left']
-
Define fallback placements by providing a list of placements in array (in order of preference). For more information refer to Popper’s behavior docs.
-
-
-
html
-
boolean
-
false
-
Allow HTML in the popover. If true, HTML tags in the popover’s title will be rendered in the popover. If false, innerText property will be used to insert content into the DOM. Use text if you’re worried about XSS attacks.
-
-
-
offset
-
number, string, function
-
[0, 8]
-
Offset of the popover relative to its target. You can pass a string in data attributes with comma separated values like: data-bs-offset="10,20". When a function is used to determine the offset, it is called with an object containing the popper placement, the reference, and popper rects as its first argument. The triggering element DOM node is passed as the second argument. The function must return an array with two numbers: skidding, distance. For more information refer to Popper’s offset docs.
-
-
-
placement
-
string, function
-
'right'
-
How to position the popover: auto, top, bottom, left, right. When auto is specified, it will dynamically reorient the popover. When a function is used to determine the placement, it is called with the popover DOM node as its first argument and the triggering element DOM node as its second. The this context is set to the popover instance.
-
-
-
popperConfig
-
null, object, function
-
null
-
To change Bootstrap’s default Popper config, see Popper’s configuration. When a function is used to create the Popper configuration, it’s called with an object that contains the Bootstrap’s default Popper configuration. It helps you use and merge the default with your own configuration. The function must return a configuration object for Popper.
-
-
-
sanitize
-
boolean
-
true
-
Enable or disable the sanitization. If activated 'template', 'content' and 'title' options will be sanitized.
-
-
-
sanitizeFn
-
null, function
-
null
-
Here you can supply your own sanitize function. This can be useful if you prefer to use a dedicated library to perform sanitization.
-
-
-
selector
-
string, false
-
false
-
If a selector is provided, popover objects will be delegated to the specified targets. In practice, this is used to also apply popovers to dynamically added DOM elements (jQuery.on support). See this issue and an informative example. Note: title attribute must not be used as a selector.
Base HTML to use when creating the popover. The popover’s title will be injected into the .popover-header. The popover’s content will be injected into the .popover-body. .popover-arrow will become the popover’s arrow. The outermost wrapper element should have the .popover class and role="tooltip".
-
-
-
title
-
string, element, function
-
''
-
The popover title. If a function is given, it will be called with its this reference set to the element that the popover is attached to.
-
-
-
trigger
-
string
-
'click'
-
How popover is triggered: click, hover, focus, manual. You may pass multiple triggers; separate them with a space. 'manual' indicates that the popover will be triggered programmatically via the .popover('show'), .popover('hide') and .popover('toggle') methods; this value cannot be combined with any other trigger. 'hover' on its own will result in popovers that cannot be triggered via the keyboard, and should only be used if alternative methods for conveying the same information for keyboard users is present.
-
-
-
-
-
-
Data attributes for individual popovers
-
Options for individual popovers can alternatively be specified through the use of data attributes, as explained above.
-
-
-
Using function with popperConfig
-
constpopover=newbootstrap.Popover(element,{
-popperConfig(defaultBsPopperConfig){
-// const newPopperConfig = {...}
-// use defaultBsPopperConfig if needed...
-// return newPopperConfig
-}
-})
-
Methods
-
-All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started, but before it ends. In addition, a method call on a transitioning component will be ignored. Learn more in our JavaScript docs.
-
-
-
-
-
-
Method
-
Description
-
-
-
-
-
disable
-
Removes the ability for an element’s popover to be shown. The popover will only be able to be shown if it is re-enabled.
-
-
-
dispose
-
Hides and destroys an element’s popover (Removes stored data on the DOM element). Popovers that use delegation (which are created using the selector option) cannot be individually destroyed on descendant trigger elements.
-
-
-
enable
-
Gives an element’s popover the ability to be shown. Popovers are enabled by default.
-
-
-
getInstance
-
Static method which allows you to get the popover instance associated with a DOM element.
-
-
-
getOrCreateInstance
-
Static method which allows you to get the popover instance associated with a DOM element, or create a new one in case it wasn’t initialized.
-
-
-
hide
-
Hides an element’s popover. Returns to the caller before the popover has actually been hidden (i.e. before the hidden.bs.popover event occurs). This is considered a “manual” triggering of the popover.
-
-
-
setContent
-
Gives a way to change the popover’s content after its initialization.
-
-
-
show
-
Reveals an element’s popover. Returns to the caller before the popover has actually been shown (i.e. before the shown.bs.popover event occurs). This is considered a “manual” triggering of the popover. Popovers whose title and content are both zero-length are never displayed.
-
-
-
toggle
-
Toggles an element’s popover. Returns to the caller before the popover has actually been shown or hidden (i.e. before the shown.bs.popover or hidden.bs.popover event occurs). This is considered a “manual” triggering of the popover.
-
-
-
toggleEnabled
-
Toggles the ability for an element’s popover to be shown or hidden.
-
-
-
update
-
Updates the position of an element’s popover.
-
-
-
-
-
// getOrCreateInstance example
-constpopover=bootstrap.Popover.getOrCreateInstance('#example')// Returns a Bootstrap popover instance
-
-// setContent example
-popover.setContent({
-'.popover-header':'another title',
-'.popover-body':'another content'
-})
-
-The setContent method accepts an object argument, where each property-key is a valid string selector within the popover template, and each related property-value can be string | element | function | null
-
-
-
Events
-
-
-
-
Event
-
Description
-
-
-
-
-
hide.bs.popover
-
This event is fired immediately when the hide instance method has been called.
-
-
-
hidden.bs.popover
-
This event is fired when the popover has finished being hidden from the user (will wait for CSS transitions to complete).
-
-
-
inserted.bs.popover
-
This event is fired after the show.bs.popover event when the popover template has been added to the DOM.
-
-
-
show.bs.popover
-
This event fires immediately when the show instance method is called.
-
-
-
shown.bs.popover
-
This event is fired when the popover has been made visible to the user (will wait for CSS transitions to complete).
-
-
-
-
-
constmyPopoverTrigger=document.getElementById('myPopover')
-myPopoverTrigger.addEventListener('hidden.bs.popover',()=>{
-// do something...
-})
-
-
-
-
+
Note that for security reasons the sanitize, sanitizeFn, and allowList options cannot be supplied using data attributes.
Object which contains allowed attributes and tags.
animation
boolean
true
Apply a CSS fade transition to the popover.
boundary
string, element
'clippingParents'
Overflow constraint boundary of the popover (applies only to Popper’s preventOverflow modifier). By default, it’s 'clippingParents' and can accept an HTMLElement reference (via JavaScript only). For more information refer to Popper’s detectOverflow docs.
container
string, element, false
false
Appends the popover to a specific element. Example: container: 'body'. This option is particularly useful in that it allows you to position the popover in the flow of the document near the triggering element - which will prevent the popover from floating away from the triggering element during a window resize.
content
string, element, function
''
The popover’s text content. If a function is given, it will be called with its this reference set to the element that the popover is attached to.
customClass
string, function
''
Add classes to the popover when it is shown. Note that these classes will be added in addition to any classes specified in the template. To add multiple classes, separate them with spaces: 'class-1 class-2'. You can also pass a function that should return a single string containing additional class names.
delay
number, object
0
Delay showing and hiding the popover (ms)—doesn’t apply to manual trigger type. If a number is supplied, delay is applied to both hide/show. Object structure is: delay: { "show": 500, "hide": 100 }.
fallbackPlacements
string, array
['top', 'right', 'bottom', 'left']
Define fallback placements by providing a list of placements in array (in order of preference). For more information refer to Popper’s behavior docs.
html
boolean
false
Allow HTML in the popover. If true, HTML tags in the popover’s title will be rendered in the popover. If false, innerText property will be used to insert content into the DOM. Use text if you’re worried about XSS attacks.
offset
number, string, function
[0, 8]
Offset of the popover relative to its target. You can pass a string in data attributes with comma separated values like: data-bs-offset="10,20". When a function is used to determine the offset, it is called with an object containing the popper placement, the reference, and popper rects as its first argument. The triggering element DOM node is passed as the second argument. The function must return an array with two numbers: skidding, distance. For more information refer to Popper’s offset docs.
placement
string, function
'right'
How to position the popover: auto, top, bottom, left, right. When auto is specified, it will dynamically reorient the popover. When a function is used to determine the placement, it is called with the popover DOM node as its first argument and the triggering element DOM node as its second. The this context is set to the popover instance.
popperConfig
null, object, function
null
To change Bootstrap’s default Popper config, see Popper’s configuration. When a function is used to create the Popper configuration, it’s called with an object that contains the Bootstrap’s default Popper configuration. It helps you use and merge the default with your own configuration. The function must return a configuration object for Popper.
sanitize
boolean
true
Enable or disable the sanitization. If activated 'template', 'content' and 'title' options will be sanitized.
sanitizeFn
null, function
null
Here you can supply your own sanitize function. This can be useful if you prefer to use a dedicated library to perform sanitization.
selector
string, false
false
If a selector is provided, popover objects will be delegated to the specified targets. In practice, this is used to also apply popovers to dynamically added DOM elements (jQuery.on support). See this issue and an informative example. Note: title attribute must not be used as a selector.
Base HTML to use when creating the popover. The popover’s title will be injected into the .popover-header. The popover’s content will be injected into the .popover-body. .popover-arrow will become the popover’s arrow. The outermost wrapper element should have the .popover class and role="tooltip".
title
string, element, function
''
The popover title. If a function is given, it will be called with its this reference set to the element that the popover is attached to.
trigger
string
'click'
How popover is triggered: click, hover, focus, manual. You may pass multiple triggers; separate them with a space. 'manual' indicates that the popover will be triggered programmatically via the .popover('show'), .popover('hide') and .popover('toggle') methods; this value cannot be combined with any other trigger. 'hover' on its own will result in popovers that cannot be triggered via the keyboard, and should only be used if alternative methods for conveying the same information for keyboard users is present.
+
Data attributes for individual popovers
Options for individual popovers can alternatively be specified through the use of data attributes, as explained above.
All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started, but before it ends. In addition, a method call on a transitioning component will be ignored. Learn more in our JavaScript docs.
Removes the ability for an element’s popover to be shown. The popover will only be able to be shown if it is re-enabled.
dispose
Hides and destroys an element’s popover (Removes stored data on the DOM element). Popovers that use delegation (which are created using the selector option) cannot be individually destroyed on descendant trigger elements.
enable
Gives an element’s popover the ability to be shown. Popovers are enabled by default.
getInstance
Static method which allows you to get the popover instance associated with a DOM element.
getOrCreateInstance
Static method which allows you to get the popover instance associated with a DOM element, or create a new one in case it wasn’t initialized.
hide
Hides an element’s popover. Returns to the caller before the popover has actually been hidden (i.e. before the hidden.bs.popover event occurs). This is considered a “manual” triggering of the popover.
setContent
Gives a way to change the popover’s content after its initialization.
show
Reveals an element’s popover. Returns to the caller before the popover has actually been shown (i.e. before the shown.bs.popover event occurs). This is considered a “manual” triggering of the popover. Popovers whose title and content are both zero-length are never displayed.
toggle
Toggles an element’s popover. Returns to the caller before the popover has actually been shown or hidden (i.e. before the shown.bs.popover or hidden.bs.popover event occurs). This is considered a “manual” triggering of the popover.
toggleEnabled
Toggles the ability for an element’s popover to be shown or hidden.
update
Updates the position of an element’s popover.
+
// getOrCreateInstance example
+const popover = bootstrap.Popover.getOrCreateInstance('#example')// Returns a Bootstrap popover instance
+
+// setContent example
+popover.setContent({
+ '.popover-header':'another title',
+ '.popover-body':'another content'
+})
+
+
The setContent method accepts an object argument, where each property-key is a valid string selector within the popover template, and each related property-value can be string | element | function | null
-New markup in v5.3.0 — We’ve deprecated the previous HTML structure for progress bars and replaced it with a more accessible one. The previous structure will continue to work until v6. See what’s changed in our migration guide.
-
-
-
How it works
-
Progress components are built with two HTML elements, some CSS to set the width, and a few attributes. We don’t use the HTML5 <progress> element, ensuring you can stack progress bars, animate them, and place text labels over them.
New markup in v5.3.0 — We’ve deprecated the previous HTML structure for progress bars and replaced it with a more accessible one. The previous structure will continue to work until v6. See what’s changed in our migration guide.
+
How it works
+
Progress components are built with two HTML elements, some CSS to set the width, and a few attributes. We don’t use the HTML5 <progress> element, ensuring you can stack progress bars, animate them, and place text labels over them.
We use the .progress as a wrapper to indicate the max value of the progress bar.
The .progress wrapper also requires a role="progressbar" and aria attributes to make it accessible, including an accessible name (using aria-label, aria-labelledby, or similar).
@@ -590,10 +32,7 @@
We provide a special .progress-stacked class to create multiple/stacked progress bars.
Put that all together, and you have the following examples.
Bootstrap provides a handful of utilities for setting width. Depending on your needs, these may help with quickly configuring the width of the .progress-bar.
Bootstrap provides a handful of utilities for setting width. Depending on your needs, these may help with quickly configuring the width of the .progress-bar.
Add labels to your progress bars by placing text within the .progress-bar.
-
-
-
-
+
25%
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="progress"role="progressbar"aria-label="Example with label"aria-valuenow="25"aria-valuemin="0"aria-valuemax="100">
-<divclass="progress-bar"style="width: 25%">25%</div>
-</div>
-
-
-
Long labels
-
Note that by default, the content inside the .progress-bar is controlled with overflow: hidden, so it doesn’t bleed out of the bar. If your progress bar is shorter than its label, the content will be capped and may become unreadable. To change this behavior, you can use .overflow-visible from the overflow utilities.
-
-
Labels longer than the progress bar within may not be fully accessible using this method because it relies on the text color having the correct contrast ratio with both the .progress and .progress-bar background colors. Use caution when implementing this example.
-
If the text can overlap the progress bar, we often recommend displaying the label outside of the progress bar for better accessibility.
-
-
-
-
Backgrounds
+
html
<divclass="progress"role="progressbar"aria-label="Example with label"aria-valuenow="25"aria-valuemin="0"aria-valuemax="100">
+ <divclass="progress-bar"style="width: 25%">25%</div>
+</div>
+
Long labels
+
Note that by default, the content inside the .progress-bar is controlled with overflow: hidden, so it doesn’t bleed out of the bar. If your progress bar is shorter than its label, the content will be capped and may become unreadable. To change this behavior, you can use .overflow-visible from the overflow utilities.
+
Labels longer than the progress bar within may not be fully accessible using this method because it relies on the text color having the correct contrast ratio with both the .progress and .progress-bar background colors. Use caution when implementing this example.
If the text can overlap the progress bar, we often recommend displaying the label outside of the progress bar for better accessibility.
+
Backgrounds
Use background utility classes to change the appearance of individual progress bars.
-Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
-
-
-
If you’re adding labels to progress bars with a custom background color, make sure to also set an appropriate text color, so the labels remain readable and have sufficient contrast. We recommend using the color and background helper classes.
Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
+
If you’re adding labels to progress bars with a custom background color, make sure to also set an appropriate text color, so the labels remain readable and have sufficient contrast. We recommend using the color and background helper classes.
You can include multiple progress components inside a container with .progress-stacked to create a single stacked progress bar. Note that in this case, the styling to set the visual width of the progress bar must be applied to the .progress elements, rather than the .progress-bars.
As part of Bootstrap’s evolving CSS variables approach, progress bars now use local CSS variables on .progress for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
As part of Bootstrap’s evolving CSS variables approach, progress bars now use local CSS variables on .progress for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
Automatically update Bootstrap navigation or list group components based on scroll position to indicate which link is currently active in the viewport.
Scrollspy toggles the .active class on anchor (<a>) elements when the element with the id referenced by the anchor’s href is scrolled into view. Scrollspy is best used in conjunction with a Bootstrap nav component or list group, but it will also work with any anchor elements in the current page. Here’s how it works.
Automatically update Bootstrap navigation or list group components based on scroll position to indicate which link is currently active in the viewport.
Scrollspy toggles the .active class on anchor (<a>) elements when the element with the id referenced by the anchor’s href is scrolled into view. Scrollspy is best used in conjunction with a Bootstrap nav component or list group, but it will also work with any anchor elements in the current page. Here’s how it works.
To start, scrollspy requires two things: a navigation, list group, or a simple set of links, plus a scrollable container. The scrollable container can be the <body> or a custom element with a set height and overflow-y: scroll.
@@ -582,498 +31,315 @@
On the scrollable container, add data-bs-spy="scroll" and data-bs-target="#navId" where navId is the unique id of the associated navigation. If there is no focusable element inside the element, be sure to also include a tabindex="0" to ensure keyboard access.
-
As you scroll the “spied” container, an .active class is added and removed from anchor links within the associated navigation. Links must have resolvable id targets, otherwise they’re ignored. For example, a <a href="#home">home</a> must correspond to something in the DOM like <div id="home"></div>
+
As you scroll the “spied” container, an .active class is added and removed from anchor links within the associated navigation. Links must have resolvable id targets, otherwise they’re ignored. For example, a <a href="#home">home</a> must correspond to something in the DOM like <div id="home"></div>
Target elements that are not visible will be ignored. See the Non-visible elements section below.
-
Examples
-
Navbar
+
Examples
+
Navbar
Scroll the area below the navbar and watch the active class change. Open the dropdown menu and watch the dropdown items be highlighted as well.
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Second heading
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Third heading
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Fourth heading
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Fifth heading
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
+
Second heading
+
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
+
Third heading
+
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
+
Fourth heading
+
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
+
Fifth heading
+
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Scrollspy also works with nested .navs. If a nested .nav is .active, its parents will also be .active. Scroll the area next to the navbar and watch the active class change.
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Keep in mind that the JavaScript plugin tries to pick the right element among all that may be visible. Multiple visible scrollspy targets at the same time may cause some issues.
-
-
-
Item 1-1
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Keep in mind that the JavaScript plugin tries to pick the right element among all that may be visible. Multiple visible scrollspy targets at the same time may cause some issues.
-
-
-
Item 1-2
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Keep in mind that the JavaScript plugin tries to pick the right element among all that may be visible. Multiple visible scrollspy targets at the same time may cause some issues.
-
-
-
Item 2
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Keep in mind that the JavaScript plugin tries to pick the right element among all that may be visible. Multiple visible scrollspy targets at the same time may cause some issues.
-
-
-
Item 3
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Keep in mind that the JavaScript plugin tries to pick the right element among all that may be visible. Multiple visible scrollspy targets at the same time may cause some issues.
-
-
-
Item 3-1
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Keep in mind that the JavaScript plugin tries to pick the right element among all that may be visible. Multiple visible scrollspy targets at the same time may cause some issues.
-
-
-
Item 3-2
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Keep in mind that the JavaScript plugin tries to pick the right element among all that may be visible. Multiple visible scrollspy targets at the same time may cause some issues.
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Keep in mind that the JavaScript plugin tries to pick the right element among all that may be visible. Multiple visible scrollspy targets at the same time may cause some issues.
Item 1-1
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Keep in mind that the JavaScript plugin tries to pick the right element among all that may be visible. Multiple visible scrollspy targets at the same time may cause some issues.
Item 1-2
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Keep in mind that the JavaScript plugin tries to pick the right element among all that may be visible. Multiple visible scrollspy targets at the same time may cause some issues.
Item 2
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Keep in mind that the JavaScript plugin tries to pick the right element among all that may be visible. Multiple visible scrollspy targets at the same time may cause some issues.
Item 3
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Keep in mind that the JavaScript plugin tries to pick the right element among all that may be visible. Multiple visible scrollspy targets at the same time may cause some issues.
Item 3-1
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Keep in mind that the JavaScript plugin tries to pick the right element among all that may be visible. Multiple visible scrollspy targets at the same time may cause some issues.
Item 3-2
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Keep in mind that the JavaScript plugin tries to pick the right element among all that may be visible. Multiple visible scrollspy targets at the same time may cause some issues.
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Item 2
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Item 3
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Item 4
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Item 2
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Item 3
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Item 4
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Scrollspy is not limited to nav components and list groups, so it will work on any <a> anchor elements in the current document. Scroll the area and watch the .active class change.
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Item 2
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Item 3
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Item 4
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Item 5
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Target elements that aren’t visible will be ignored and their corresponding nav items won’t receive an .active class. Scrollspy instances initialized in a non-visible wrapper will ignore all target elements. Use the refresh method to check for observable elements once the wrapper becomes visible.
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Item 2
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Item 3
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Item 4
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Item 5
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It’s repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Target elements that aren’t visible will be ignored and their corresponding nav items won’t receive an .active class. Scrollspy instances initialized in a non-visible wrapper will ignore all target elements. Use the refresh method to check for observable elements once the wrapper becomes visible.
To easily add scrollspy behavior to your topbar navigation, add data-bs-spy="scroll" to the element you want to spy on (most typically this would be the <body>). Then add the data-bs-target attribute with the id or class name of the parent element of any Bootstrap .nav component.
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
-
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
+
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
The final configuration object is the merged result of data-bs-config, data-bs-, and js object where the latest given key-value overrides the others.
-
-
-
-
-
Name
-
Type
-
Default
-
Description
-
-
-
-
-
rootMargin
-
string
-
0px 0px -25%
-
Intersection Observer rootMargin valid units, when calculating scroll position.
-
-
-
smoothScroll
-
boolean
-
false
-
Enables smooth scrolling when a user clicks on a link that refers to ScrollSpy observables.
-
-
-
target
-
string, DOM element
-
null
-
Specifies element to apply Scrollspy plugin.
-
-
-
threshold
-
array
-
[0.1, 0.5, 1]
-
IntersectionObserverthreshold valid input, when calculating scroll position.
-
-
-
-
-
-
Deprecated Options
-
Up until v5.1.3 we were using offset & method options, which are now deprecated and replaced by rootMargin.
-To keep backwards compatibility, we will continue to parse a given offset to rootMargin, but this feature will be removed in v6.
-
-
-
-
Methods
-
-
-
-
Method
-
Description
-
-
-
-
-
dispose
-
Destroys an element’s scrollspy. (Removes stored data on the DOM element)
-
-
-
getInstance
-
Static method to get the scrollspy instance associated with a DOM element.
-
-
-
getOrCreateInstance
-
Static method to get the scrollspy instance associated with a DOM element, or to create a new one in case it wasn’t initialized.
-
-
-
refresh
-
When adding or removing elements in the DOM, you’ll need to call the refresh method.
Intersection Observer rootMargin valid units, when calculating scroll position.
smoothScroll
boolean
false
Enables smooth scrolling when a user clicks on a link that refers to ScrollSpy observables.
target
string, DOM element
null
Specifies element to apply Scrollspy plugin.
threshold
array
[0.1, 0.5, 1]
IntersectionObserverthreshold valid input, when calculating scroll position.
+
Deprecated Options
Up until v5.1.3 we were using offset & method options, which are now deprecated and replaced by rootMargin.
+To keep backwards compatibility, we will continue to parse a given offset to rootMargin, but this feature will be removed in v6.
+
Methods
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Method
Description
dispose
Destroys an element’s scrollspy. (Removes stored data on the DOM element)
getInstance
Static method to get the scrollspy instance associated with a DOM element.
getOrCreateInstance
Static method to get the scrollspy instance associated with a DOM element, or to create a new one in case it wasn’t initialized.
refresh
When adding or removing elements in the DOM, you’ll need to call the refresh method.
Bootstrap “spinners” can be used to show the loading state in your projects. They’re built only with HTML and CSS, meaning you don’t need any JavaScript to create them. You will, however, need some custom JavaScript to toggle their visibility. Their appearance, alignment, and sizing can be easily customized with our amazing utility classes.
Bootstrap “spinners” can be used to show the loading state in your projects. They’re built only with HTML and CSS, meaning you don’t need any JavaScript to create them. You will, however, need some custom JavaScript to toggle their visibility. Their appearance, alignment, and sizing can be easily customized with our amazing utility classes.
For accessibility purposes, each loader here includes role="status" and a nested <span class="visually-hidden">Loading...</span>.
The border spinner uses currentColor for its border-color, meaning you can customize the color with text color utilities. You can use any of our text color utilities on the standard spinner.
The border spinner uses currentColor for its border-color, meaning you can customize the color with text color utilities. You can use any of our text color utilities on the standard spinner.
+
Loading...
@@ -641,78 +57,40 @@ The animation effect of this component is dependent on the prefers-reduced
-Why not use border-color utilities? Each border spinner specifies a transparent border for at least one side, so .border-{color} utilities would override that.
-
-
-
Growing spinner
-
If you don’t fancy a border spinner, switch to the grow spinner. While it doesn’t technically spin, it does repeatedly grow!
Why not use border-color utilities? Each border spinner specifies a transparent border for at least one side, so .border-{color} utilities would override that.
+
Growing spinner
+
If you don’t fancy a border spinner, switch to the grow spinner. While it doesn’t technically spin, it does repeatedly grow!
Once again, this spinner is built with currentColor, so you can easily change its appearance with text color utilities. Here it is in blue, along with the supported variants.
Once again, this spinner is built with currentColor, so you can easily change its appearance with text color utilities. Here it is in blue, along with the supported variants.
+
Loading...
@@ -735,473 +113,187 @@ The animation effect of this component is dependent on the prefers-reduced
Spinners in Bootstrap are built with rems, currentColor, and display: inline-flex. This means they can easily be resized, recolored, and quickly aligned.
Use spinners within buttons to indicate an action is currently processing or taking place. You may also swap the text out of the spinner element and utilize button text as needed.
As part of Bootstrap’s evolving CSS variables approach, spinners now use local CSS variables on .spinner-border and .spinner-grow for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
+
As part of Bootstrap’s evolving CSS variables approach, spinners now use local CSS variables on .spinner-border and .spinner-grow for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
For both spinners, small spinner modifier classes are used to update the values of these CSS variables as needed. For example, the .spinner-border-sm class does the following:
Toasts are lightweight notifications designed to mimic the push notifications that have been popularized by mobile and desktop operating systems. They’re built with flexbox, so they’re easy to align and position.
Toasts are lightweight notifications designed to mimic the push notifications that have been popularized by mobile and desktop operating systems. They’re built with flexbox, so they’re easy to align and position.
+
Overview
Things to know when using the toast plugin:
Toasts are opt-in for performance reasons, so you must initialize them yourself.
Toasts will automatically hide if you do not specify autohide: false.
To encourage extensible and predictable toasts, we recommend a header and body. Toast headers use display: flex, allowing easy alignment of content thanks to our margin and flexbox utilities.
-
Toasts are as flexible as you need and have very little required markup. At a minimum, we require a single element to contain your “toasted” content and strongly encourage a dismiss button.
-
-
-
-
+
Toasts are as flexible as you need and have very little required markup. At a minimum, we require a single element to contain your “toasted” content and strongly encourage a dismiss button.
+
-
+ Bootstrap
11 mins ago
@@ -608,94 +43,54 @@ The animation effect of this component is dependent on the prefers-reduced
Hello, world! This is a toast message.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="toast"role="alert"aria-live="assertive"aria-atomic="true">
-<divclass="toast-header">
-<imgsrc="..."class="rounded me-2"alt="...">
-<strongclass="me-auto">Bootstrap</strong>
-<small>11 mins ago</small>
-<buttontype="button"class="btn-close"data-bs-dismiss="toast"aria-label="Close"></button>
-</div>
-<divclass="toast-body">
- Hello, world! This is a toast message.
-</div>
-</div>
-
-
-
-Previously, our scripts dynamically added the .hide class to completely hide a toast (with display:none, rather than just with opacity:0). This is now not necessary anymore. However, for backwards compatibility, our script will continue to toggle the class (even though there is no practical need for it) until the next major version.
-
-
-
Live example
+
html
<divclass="toast"role="alert"aria-live="assertive"aria-atomic="true">
+ <divclass="toast-header">
+ <imgsrc="..."class="rounded me-2"alt="...">
+ <strongclass="me-auto">Bootstrap</strong>
+ <small>11 mins ago</small>
+ <buttontype="button"class="btn-close"data-bs-dismiss="toast"aria-label="Close"></button>
+ </div>
+ <divclass="toast-body">
+ Hello, world! This is a toast message.
+ </div>
+</div>
+
Previously, our scripts dynamically added the .hide class to completely hide a toast (with display:none, rather than just with opacity:0). This is now not necessary anymore. However, for backwards compatibility, our script will continue to toggle the class (even though there is no practical need for it) until the next major version.
+
Live example
Click the button below to show a toast (positioned with our utilities in the lower right corner) that has been hidden by default.
-
-
-
-
- Bootstrap
- 11 mins ago
-
-
-
+
Bootstrap11 mins ago
Hello, world! This is a toast message.
+
Show live toast
+
<buttontype="button"class="btn btn-primary"id="liveToastBtn">Show live toast</button>
+
+<divclass="toast-container position-fixed bottom-0 end-0 p-3">
+ <divid="liveToast"class="toast"role="alert"aria-live="assertive"aria-atomic="true">
+ <divclass="toast-header">
+ <imgsrc="..."class="rounded me-2"alt="...">
+ <strongclass="me-auto">Bootstrap</strong>
+ <small>11 mins ago</small>
+ <buttontype="button"class="btn-close"data-bs-dismiss="toast"aria-label="Close"></button>
+ </div>
+ <divclass="toast-body">
Hello, world! This is a toast message.
-
-
-
-
- Show live toast
-
-
<buttontype="button"class="btn btn-primary"id="liveToastBtn">Show live toast</button>
-
-<divclass="toast-container position-fixed bottom-0 end-0 p-3">
-<divid="liveToast"class="toast"role="alert"aria-live="assertive"aria-atomic="true">
-<divclass="toast-header">
-<imgsrc="..."class="rounded me-2"alt="...">
-<strongclass="me-auto">Bootstrap</strong>
-<small>11 mins ago</small>
-<buttontype="button"class="btn-close"data-bs-dismiss="toast"aria-label="Close"></button>
-</div>
-<divclass="toast-body">
- Hello, world! This is a toast message.
-</div>
-</div>
-</div>
-
We use the following JavaScript to trigger our live toast demo:
Customize your toasts by removing sub-components, tweaking them with utilities, or by adding your own markup. Here we’ve created a simpler toast by removing the default .toast-header, adding a custom hide icon from Bootstrap Icons, and using some flexbox utilities to adjust the layout.
Customize your toasts by removing sub-components, tweaking them with utilities, or by adding your own markup. Here we’ve created a simpler toast by removing the default .toast-header, adding a custom hide icon from Bootstrap Icons, and using some flexbox utilities to adjust the layout.
+
Hello, world! This is a toast message.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="toast align-items-center"role="alert"aria-live="assertive"aria-atomic="true">
-<divclass="d-flex">
-<divclass="toast-body">
- Hello, world! This is a toast message.
-</div>
-<buttontype="button"class="btn-close me-2 m-auto"data-bs-dismiss="toast"aria-label="Close"></button>
-</div>
-</div>
-
-
+
html
<divclass="toast align-items-center"role="alert"aria-live="assertive"aria-atomic="true">
+ <divclass="d-flex">
+ <divclass="toast-body">
+ Hello, world! This is a toast message.
+ </div>
+ <buttontype="button"class="btn-close me-2 m-auto"data-bs-dismiss="toast"aria-label="Close"></button>
+ </div>
+</div>
Alternatively, you can also add additional controls and components to toasts.
-
-
-
-
+
Hello, world! This is a toast message.
@@ -842,69 +186,35 @@ Previously, our scripts dynamically added the .hide class to comple
Close
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="toast"role="alert"aria-live="assertive"aria-atomic="true">
-<divclass="toast-body">
- Hello, world! This is a toast message.
-<divclass="mt-2 pt-2 border-top">
-<buttontype="button"class="btn btn-primary btn-sm">Take action</button>
-<buttontype="button"class="btn btn-secondary btn-sm"data-bs-dismiss="toast">Close</button>
-</div>
-</div>
-</div>
-
-
-
Color schemes
-
Building on the above example, you can create different toast color schemes with our color and background utilities. Here we’ve added .text-bg-primary to the .toast, and then added .btn-close-white to our close button. For a crisp edge, we remove the default border with .border-0.
-
-
-
-
+
html
<divclass="toast"role="alert"aria-live="assertive"aria-atomic="true">
+ <divclass="toast-body">
+ Hello, world! This is a toast message.
+ <divclass="mt-2 pt-2 border-top">
+ <buttontype="button"class="btn btn-primary btn-sm">Take action</button>
+ <buttontype="button"class="btn btn-secondary btn-sm"data-bs-dismiss="toast">Close</button>
+ </div>
+ </div>
+</div>
+
Color schemes
+
Building on the above example, you can create different toast color schemes with our color and background utilities. Here we’ve added .text-bg-primary to the .toast, and then added .btn-close-white to our close button. For a crisp edge, we remove the default border with .border-0.
+
Hello, world! This is a toast message.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="toast align-items-center text-bg-primary border-0"role="alert"aria-live="assertive"aria-atomic="true">
-<divclass="d-flex">
-<divclass="toast-body">
- Hello, world! This is a toast message.
-</div>
-<buttontype="button"class="btn-close btn-close-white me-2 m-auto"data-bs-dismiss="toast"aria-label="Close"></button>
-</div>
-</div>
-
-
-
Placement
-
Place toasts with custom CSS as you need them. The top right is often used for notifications, as is the top middle. If you’re only ever going to show one toast at a time, put the positioning styles right on the .toast.
-
-
-
-
html
<divclass="toast align-items-center text-bg-primary border-0"role="alert"aria-live="assertive"aria-atomic="true">
+ <divclass="d-flex">
+ <divclass="toast-body">
+ Hello, world! This is a toast message.
+ </div>
+ <buttontype="button"class="btn-close btn-close-white me-2 m-auto"data-bs-dismiss="toast"aria-label="Close"></button>
+ </div>
+</div>
+
Placement
+
Place toasts with custom CSS as you need them. The top right is often used for notifications, as is the top middle. If you’re only ever going to show one toast at a time, put the positioning styles right on the .toast.
For systems that generate more notifications, consider using a wrapping element so they can easily stack.
-
-
-
-
+
@@ -993,7 +286,7 @@ Previously, our scripts dynamically added the .hide class to comple
-
+ Bootstrap
just now
@@ -1005,7 +298,7 @@ Previously, our scripts dynamically added the .hide class to comple
-
+ Bootstrap
2 seconds ago
@@ -1015,64 +308,47 @@ Previously, our scripts dynamically added the .hide class to comple
-
+
html
<divaria-live="polite"aria-atomic="true"class="position-relative">
+ <!-- Position it: -->
+ <!-- - `.toast-container` for spacing between toasts -->
+ <!-- - `top-0` & `end-0` to position the toasts in the upper right corner -->
+ <!-- - `.p-3` to prevent the toasts from sticking to the edge of the container -->
+ <divclass="toast-container top-0 end-0 p-3">
-
- html
-
-
-
-
-
-
-
-
-
<divaria-live="polite"aria-atomic="true"class="position-relative">
-<!-- Position it: -->
-<!-- - `.toast-container` for spacing between toasts -->
-<!-- - `top-0` & `end-0` to position the toasts in the upper right corner -->
-<!-- - `.p-3` to prevent the toasts from sticking to the edge of the container -->
-<divclass="toast-container top-0 end-0 p-3">
-
-<!-- Then put toasts within -->
-<divclass="toast"role="alert"aria-live="assertive"aria-atomic="true">
-<divclass="toast-header">
-<imgsrc="..."class="rounded me-2"alt="...">
-<strongclass="me-auto">Bootstrap</strong>
-<smallclass="text-body-secondary">just now</small>
-<buttontype="button"class="btn-close"data-bs-dismiss="toast"aria-label="Close"></button>
-</div>
-<divclass="toast-body">
- See? Just like this.
-</div>
-</div>
-
-<divclass="toast"role="alert"aria-live="assertive"aria-atomic="true">
-<divclass="toast-header">
-<imgsrc="..."class="rounded me-2"alt="...">
-<strongclass="me-auto">Bootstrap</strong>
-<smallclass="text-body-secondary">2 seconds ago</small>
-<buttontype="button"class="btn-close"data-bs-dismiss="toast"aria-label="Close"></button>
-</div>
-<divclass="toast-body">
- Heads up, toasts will stack automatically
-</div>
-</div>
-</div>
-</div>
You can also get fancy with flexbox utilities to align toasts horizontally and/or vertically.
-
-
-
-
+
-
+ Bootstrap
11 mins ago
@@ -1081,51 +357,35 @@ Previously, our scripts dynamically added the .hide class to comple
Hello, world! This is a toast message.
-
+
html
<!-- Flexbox container for aligning the toasts -->
+<divaria-live="polite"aria-atomic="true"class="d-flex justify-content-center align-items-center w-100">
-
- html
-
-
-
-
-
-
-
-
-
<!-- Flexbox container for aligning the toasts -->
-<divaria-live="polite"aria-atomic="true"class="d-flex justify-content-center align-items-center w-100">
-
-<!-- Then put toasts within -->
-<divclass="toast"role="alert"aria-live="assertive"aria-atomic="true">
-<divclass="toast-header">
-<imgsrc="..."class="rounded me-2"alt="...">
-<strongclass="me-auto">Bootstrap</strong>
-<small>11 mins ago</small>
-<buttontype="button"class="btn-close"data-bs-dismiss="toast"aria-label="Close"></button>
-</div>
-<divclass="toast-body">
- Hello, world! This is a toast message.
-</div>
-</div>
-</div>
-
-
-
Accessibility
-
Toasts are intended to be small interruptions to your visitors or users, so to help those with screen readers and similar assistive technologies, you should wrap your toasts in an aria-live region. Changes to live regions (such as injecting/updating a toast component) are automatically announced by screen readers without needing to move the user’s focus or otherwise interrupt the user. Additionally, include aria-atomic="true" to ensure that the entire toast is always announced as a single (atomic) unit, rather than just announcing what was changed (which could lead to problems if you only update part of the toast’s content, or if displaying the same toast content at a later point in time). If the information needed is important for the process, e.g. for a list of errors in a form, then use the alert component instead of toast.
+ <!-- Then put toasts within -->
+ <divclass="toast"role="alert"aria-live="assertive"aria-atomic="true">
+ <divclass="toast-header">
+ <imgsrc="..."class="rounded me-2"alt="...">
+ <strongclass="me-auto">Bootstrap</strong>
+ <small>11 mins ago</small>
+ <buttontype="button"class="btn-close"data-bs-dismiss="toast"aria-label="Close"></button>
+ </div>
+ <divclass="toast-body">
+ Hello, world! This is a toast message.
+ </div>
+ </div>
+</div>
+
Accessibility
+
Toasts are intended to be small interruptions to your visitors or users, so to help those with screen readers and similar assistive technologies, you should wrap your toasts in an aria-live region. Changes to live regions (such as injecting/updating a toast component) are automatically announced by screen readers without needing to move the user’s focus or otherwise interrupt the user. Additionally, include aria-atomic="true" to ensure that the entire toast is always announced as a single (atomic) unit, rather than just announcing what was changed (which could lead to problems if you only update part of the toast’s content, or if displaying the same toast content at a later point in time). If the information needed is important for the process, e.g. for a list of errors in a form, then use the alert component instead of toast.
Note that the live region needs to be present in the markup before the toast is generated or updated. If you dynamically generate both at the same time and inject them into the page, they will generally not be announced by assistive technologies.
-
You also need to adapt the role and aria-live level depending on the content. If it’s an important message like an error, use role="alert" aria-live="assertive", otherwise use role="status" aria-live="polite" attributes.
-
As the content you’re displaying changes, be sure to update the delay timeout so that users have enough time to read the toast.
When using autohide: false, you must add a close button to allow users to dismiss the toast.
-
-
-
-
+
You also need to adapt the role and aria-live level depending on the content. If it’s an important message like an error, use role="alert" aria-live="assertive", otherwise use role="status" aria-live="polite" attributes.
+
As the content you’re displaying changes, be sure to update the delay timeout so that users have enough time to read the toast.
When using autohide: false, you must add a close button to allow users to dismiss the toast.
+
-
+ Bootstrap
11 mins ago
@@ -1133,276 +393,169 @@ Previously, our scripts dynamically added the .hide class to comple
Hello, world! This is a toast message.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divrole="alert"aria-live="assertive"aria-atomic="true"class="toast"data-bs-autohide="false">
-<divclass="toast-header">
-<imgsrc="..."class="rounded me-2"alt="...">
-<strongclass="me-auto">Bootstrap</strong>
-<small>11 mins ago</small>
-<buttontype="button"class="btn-close"data-bs-dismiss="toast"aria-label="Close"></button>
-</div>
-<divclass="toast-body">
- Hello, world! This is a toast message.
-</div>
-</div>
-
-
-
While technically it’s possible to add focusable/actionable controls (such as additional buttons or links) in your toast, you should avoid doing this for autohiding toasts. Even if you give the toast a long delay timeout, keyboard and assistive technology users may find it difficult to reach the toast in time to take action (since toasts don’t receive focus when they are displayed). If you absolutely must have further controls, we recommend using a toast with autohide: false.
-
CSS
-
Variables
+
html
<divrole="alert"aria-live="assertive"aria-atomic="true"class="toast"data-bs-autohide="false">
+ <divclass="toast-header">
+ <imgsrc="..."class="rounded me-2"alt="...">
+ <strongclass="me-auto">Bootstrap</strong>
+ <small>11 mins ago</small>
+ <buttontype="button"class="btn-close"data-bs-dismiss="toast"aria-label="Close"></button>
+ </div>
+ <divclass="toast-body">
+ Hello, world! This is a toast message.
+ </div>
+</div>
+
While technically it’s possible to add focusable/actionable controls (such as additional buttons or links) in your toast, you should avoid doing this for autohiding toasts. Even if you give the toast a long delay timeout, keyboard and assistive technology users may find it difficult to reach the toast in time to take action (since toasts don’t receive focus when they are displayed). If you absolutely must have further controls, we recommend using a toast with autohide: false.
+
CSS
+
Variables
Added in v5.2.0
+
As part of Bootstrap’s evolving CSS variables approach, toasts now use local CSS variables on .toast for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
As part of Bootstrap’s evolving CSS variables approach, toasts now use local CSS variables on .toast for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
-
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
+
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
The final configuration object is the merged result of data-bs-config, data-bs-, and js object where the latest given key-value overrides the others.
-
-
-
-
-
Name
-
Type
-
Default
-
Description
-
-
-
-
-
animation
-
boolean
-
true
-
Apply a CSS fade transition to the toast.
-
-
-
autohide
-
boolean
-
true
-
Automatically hide the toast after the delay.
-
-
-
delay
-
number
-
5000
-
Delay in milliseconds before hiding the toast.
-
-
-
-
-
Methods
-
-All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started, but before it ends. In addition, a method call on a transitioning component will be ignored. Learn more in our JavaScript docs.
-
-
-
-
-
-
Method
-
Description
-
-
-
-
-
dispose
-
Hides an element’s toast. Your toast will remain on the DOM but won’t show anymore.
-
-
-
getInstance
-
Static method which allows you to get the toast instance associated with a DOM element. For example: const myToastEl = document.getElementById('myToastEl')const myToast = bootstrap.Toast.getInstance(myToastEl) Returns a Bootstrap toast instance.
-
-
-
getOrCreateInstance
-
Static method which allows you to get the toast instance associated with a DOM element, or create a new one, in case it wasn’t initialized. const myToastEl = document.getElementById('myToastEl')const myToast = bootstrap.Toast.getOrCreateInstance(myToastEl) Returns a Bootstrap toast instance.
-
-
-
hide
-
Hides an element’s toast. Returns to the caller before the toast has actually been hidden (i.e. before the hidden.bs.toast event occurs). You have to manually call this method if you made autohide to false.
-
-
-
isShown
-
Returns a boolean according to toast’s visibility state.
-
-
-
show
-
Reveals an element’s toast. Returns to the caller before the toast has actually been shown (i.e. before the shown.bs.toast event occurs). You have to manually call this method, instead your toast won’t show.
-
-
-
-
-
Events
-
-
-
-
Event
-
Description
-
-
-
-
-
hide.bs.toast
-
This event is fired immediately when the hide instance method has been called.
-
-
-
hidden.bs.toast
-
This event is fired when the toast has finished being hidden from the user.
-
-
-
show.bs.toast
-
This event fires immediately when the show instance method is called.
-
-
-
shown.bs.toast
-
This event is fired when the toast has been made visible to the user.
-
-
-
-
-
constmyToastEl=document.getElementById('myToast')
-myToastEl.addEventListener('hidden.bs.toast',()=>{
-// do something...
-})
-
All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started, but before it ends. In addition, a method call on a transitioning component will be ignored. Learn more in our JavaScript docs.
Hides an element’s toast. Your toast will remain on the DOM but won’t show anymore.
getInstance
Static method which allows you to get the toast instance associated with a DOM element. For example: const myToastEl = document.getElementById('myToastEl')const myToast = bootstrap.Toast.getInstance(myToastEl) Returns a Bootstrap toast instance.
getOrCreateInstance
Static method which allows you to get the toast instance associated with a DOM element, or create a new one, in case it wasn’t initialized. const myToastEl = document.getElementById('myToastEl')const myToast = bootstrap.Toast.getOrCreateInstance(myToastEl) Returns a Bootstrap toast instance.
hide
Hides an element’s toast. Returns to the caller before the toast has actually been hidden (i.e. before the hidden.bs.toast event occurs). You have to manually call this method if you made autohide to false.
isShown
Returns a boolean according to toast’s visibility state.
show
Reveals an element’s toast. Returns to the caller before the toast has actually been shown (i.e. before the shown.bs.toast event occurs). You have to manually call this method, instead your toast won’t show.
+
Events
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Event
Description
hide.bs.toast
This event is fired immediately when the hide instance method has been called.
hidden.bs.toast
This event is fired when the toast has finished being hidden from the user.
show.bs.toast
This event fires immediately when the show instance method is called.
shown.bs.toast
This event is fired when the toast has been made visible to the user.
Documentation and examples for adding custom Bootstrap tooltips with CSS and JavaScript using CSS3 for animations and data-bs-attributes for local title storage.
Documentation and examples for adding custom Bootstrap tooltips with CSS and JavaScript using CSS3 for animations and data-bs-attributes for local title storage.
Tooltips rely on the third party library Popper for positioning. You must include popper.min.js before bootstrap.js, or use one bootstrap.bundle.min.js which contains Popper.
Tooltips are opt-in for performance reasons, so you must initialize them yourself.
Tooltips with zero-length titles are never displayed.
-
Specify container: 'body' to avoid rendering problems in more complex components (like our input groups, button groups, etc).
+
Specify container: 'body' to avoid rendering problems in more complex components (like our input groups, button groups, etc).
Triggering tooltips on hidden elements will not work.
Tooltips for .disabled or disabled elements must be triggered on a wrapper element.
When triggered from hyperlinks that span multiple lines, tooltips will be centered. Use white-space: nowrap; on your <a>s to avoid this behavior.
Tooltips must be hidden before their corresponding elements have been removed from the DOM.
Tooltips can be triggered thanks to an element inside a shadow DOM.
-
Got all that? Great, let’s see how they work with some examples.
-
-By default, this component uses the built-in content sanitizer, which strips out any HTML elements that are not explicitly allowed. See the sanitizer section in our JavaScript documentation for more details.
-
Got all that? Great, let’s see how they work with some examples.
+
By default, this component uses the built-in content sanitizer, which strips out any HTML elements that are not explicitly allowed. See the sanitizer section in our JavaScript documentation for more details.
As mentioned above, you must initialize tooltips before they can be used. One way to initialize all tooltips on a page would be to select them by their data-bs-toggle attribute, like so:
Placeholder text to demonstrate some inline links with tooltips. This is now just filler, no killer. Content placed here just to mimic the presence of real text. And all that just to give you an idea of how tooltips would look when used in real-world situations. So hopefully you've now seen how these tooltips on links can work in practice, once you use them on your own site or project.
-
-
- html
-
-
-
-
-
-
-
-
-
<pclass="muted">Placeholder text to demonstrate some <ahref="#"data-bs-toggle="tooltip"data-bs-title="Default tooltip">inline links</a> with tooltips. This is now just filler, no killer. Content placed here just to mimic the presence of <ahref="#"data-bs-toggle="tooltip"data-bs-title="Another tooltip">real text</a>. And all that just to give you an idea of how tooltips would look when used in real-world situations. So hopefully you've now seen how <ahref="#"data-bs-toggle="tooltip"data-bs-title="Another one here too">these tooltips on links</a> can work in practice, once you use them on <ahref="#"data-bs-toggle="tooltip"data-bs-title="The last tip!">your own</a> site or project.</p>
-
-
-
-Feel free to use either title or data-bs-title in your HTML. When title is used, Popper will replace it automatically with data-bs-title when the element is rendered.
-
-
-
Custom tooltips
+
Placeholder text to demonstrate some inline links with tooltips. This is now just filler, no killer. Content placed here just to mimic the presence of real text. And all that just to give you an idea of how tooltips would look when used in real-world situations. So hopefully you’ve now seen how these tooltips on links can work in practice, once you use them on your own site or project.
html
<pclass="muted">Placeholder text to demonstrate some <ahref="#"data-bs-toggle="tooltip"data-bs-title="Default tooltip">inline links</a> with tooltips. This is now just filler, no killer. Content placed here just to mimic the presence of <ahref="#"data-bs-toggle="tooltip"data-bs-title="Another tooltip">real text</a>. And all that just to give you an idea of how tooltips would look when used in real-world situations. So hopefully you’ve now seen how <ahref="#"data-bs-toggle="tooltip"data-bs-title="Another one here too">these tooltips on links</a> can work in practice, once you use them on <ahref="#"data-bs-toggle="tooltip"data-bs-title="The last tip!">your own</a> site or project.</p>
+
Feel free to use either title or data-bs-title in your HTML. When title is used, Popper will replace it automatically with data-bs-title when the element is rendered.
+
Custom tooltips
Added in v5.2.0
-
You can customize the appearance of tooltips using CSS variables. We set a custom class with data-bs-custom-class="custom-tooltip" to scope our custom appearance and use it to override a local CSS variable.
<buttontype="button"class="btn btn-secondary"
-data-bs-toggle="tooltip"data-bs-placement="top"
-data-bs-custom-class="custom-tooltip"
-data-bs-title="This top tooltip is themed via CSS variables.">
- Custom tooltip
-</button>
-
-
-
Directions
+
html
<buttontype="button"class="btn btn-secondary"
+ data-bs-toggle="tooltip"data-bs-placement="top"
+ data-bs-custom-class="custom-tooltip"
+ data-bs-title="This top tooltip is themed via CSS variables.">
+ Custom tooltip
+</button>
+
Directions
Hover over the buttons below to see the four tooltips directions: top, right, bottom, and left. Directions are mirrored when using Bootstrap in RTL.
-
-
- Tooltip on top
- Tooltip on right
- Tooltip on bottom
- Tooltip on left
- Tooltip with HTML
-
-
-
<buttontype="button"class="btn btn-secondary"data-bs-toggle="tooltip"data-bs-placement="top"data-bs-title="Tooltip on top">
- Tooltip on top
-</button>
-<buttontype="button"class="btn btn-secondary"data-bs-toggle="tooltip"data-bs-placement="right"data-bs-title="Tooltip on right">
- Tooltip on right
-</button>
-<buttontype="button"class="btn btn-secondary"data-bs-toggle="tooltip"data-bs-placement="bottom"data-bs-title="Tooltip on bottom">
- Tooltip on bottom
-</button>
-<buttontype="button"class="btn btn-secondary"data-bs-toggle="tooltip"data-bs-placement="left"data-bs-title="Tooltip on left">
- Tooltip on left
-</button>
-
And with custom HTML added:
-
<buttontype="button"class="btn btn-secondary"data-bs-toggle="tooltip"data-bs-html="true"data-bs-title="<em>Tooltip</em> <u>with</u> <b>HTML</b>">
- Tooltip with HTML
-</button>
-
+ Tooltip on top
+ Tooltip on right
+ Tooltip on bottom
+ Tooltip on left
+ Tooltip with HTML
+
+
<buttontype="button"class="btn btn-secondary"data-bs-toggle="tooltip"data-bs-placement="top"data-bs-title="Tooltip on top">
+ Tooltip on top
+</button>
+<buttontype="button"class="btn btn-secondary"data-bs-toggle="tooltip"data-bs-placement="right"data-bs-title="Tooltip on right">
+ Tooltip on right
+</button>
+<buttontype="button"class="btn btn-secondary"data-bs-toggle="tooltip"data-bs-placement="bottom"data-bs-title="Tooltip on bottom">
+ Tooltip on bottom
+</button>
+<buttontype="button"class="btn btn-secondary"data-bs-toggle="tooltip"data-bs-placement="left"data-bs-title="Tooltip on left">
+ Tooltip on left
+</button>
+
+
And with custom HTML added:
+
<buttontype="button"class="btn btn-secondary"data-bs-toggle="tooltip"data-bs-html="true"data-bs-title="<em>Tooltip</em> <u>with</u> <b>HTML</b>">
+ Tooltip with HTML
+</button>
+
+
With an SVG:
+
+
CSS
+
Variables
Added in v5.2.0
-
As part of Bootstrap’s evolving CSS variables approach, tooltips now use local CSS variables on .tooltip for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
$tooltip-font-size:$font-size-sm;
+$tooltip-max-width: 200px;
+$tooltip-color:var(--#{$prefix}body-bg);
+$tooltip-bg:var(--#{$prefix}emphasis-color);
+$tooltip-border-radius:var(--#{$prefix}border-radius);
+$tooltip-opacity: .9;
+$tooltip-padding-y:$spacer* .25;
+$tooltip-padding-x:$spacer* .5;
+$tooltip-margin:null;// TODO: remove this in v6
+
+$tooltip-arrow-width: .8rem;
+$tooltip-arrow-height: .4rem;
+// fusv-disable
+$tooltip-arrow-color:null;// Deprecated in Bootstrap 5.2.0 for CSS variables
+// fusv-enable
+
+
Usage
The tooltip plugin generates content and markup on demand, and by default places tooltips after their trigger element. Trigger the tooltip via JavaScript:
Tooltips automatically attempt to change positions when a parent container has overflow: auto or overflow: scroll, but still keeps the original placement’s positioning. Set the boundary option (for the flip modifier using the popperConfig option) to any HTMLElement to override the default value, 'clippingParents', such as document.body:
-
consttooltip=newbootstrap.Tooltip('#example',{
-boundary:document.body// or document.querySelector('#boundary')
-})
-
Tooltips automatically attempt to change positions when a parent container has overflow: auto or overflow: scroll, but still keeps the original placement’s positioning. Set the boundary option (for the flip modifier using the popperConfig option) to any HTMLElement to override the default value, 'clippingParents', such as document.body:
The required markup for a tooltip is only a data attribute and title on the HTML element you wish to have a tooltip. The generated markup of a tooltip is rather simple, though it does require a position (by default, set to top by the plugin).
-
-Keep tooltips accessible to keyboard and assistive technology users by only adding them to HTML elements that are traditionally keyboard-focusable and interactive (such as links or form controls). While other HTML elements can be made focusable by adding tabindex="0", this can create annoying and confusing tab stops on non-interactive elements for keyboard users, and most assistive technologies currently do not announce tooltips in this situation. Additionally, do not rely solely on hover as the trigger for your tooltips as this will make them impossible to trigger for keyboard users.
-
+
Keep tooltips accessible to keyboard and assistive technology users by only adding them to HTML elements that are traditionally keyboard-focusable and interactive (such as links or form controls). While other HTML elements can be made focusable by adding tabindex="0", this can create annoying and confusing tab stops on non-interactive elements for keyboard users, and most assistive technologies currently do not announce tooltips in this situation. Additionally, do not rely solely on hover as the trigger for your tooltips as this will make them impossible to trigger for keyboard users.
+
<!-- HTML to write -->
+<ahref="#"data-bs-toggle="tooltip"data-bs-title="Some tooltip text!">Hover over me</a>
-
<!-- HTML to write -->
-<ahref="#"data-bs-toggle="tooltip"data-bs-title="Some tooltip text!">Hover over me</a>
-
-<!-- Generated markup by the plugin -->
-<divclass="tooltip bs-tooltip-auto"role="tooltip">
-<divclass="tooltip-arrow"></div>
-<divclass="tooltip-inner">
- Some tooltip text!
-</div>
-</div>
-
Disabled elements
-
Elements with the disabled attribute aren’t interactive, meaning users cannot focus, hover, or click them to trigger a tooltip (or popover). As a workaround, you’ll want to trigger the tooltip from a wrapper <div> or <span>, ideally made keyboard-focusable using tabindex="0".
-
-
-
-
+<!-- Generated markup by the plugin -->
+<divclass="tooltip bs-tooltip-auto"role="tooltip">
+ <divclass="tooltip-arrow"></div>
+ <divclass="tooltip-inner">
+ Some tooltip text!
+ </div>
+</div>
+
+
Disabled elements
+
Elements with the disabled attribute aren’t interactive, meaning users cannot focus, hover, or click them to trigger a tooltip (or popover). As a workaround, you’ll want to trigger the tooltip from a wrapper <div> or <span>, ideally made keyboard-focusable using tabindex="0".
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
-
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
+
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
The final configuration object is the merged result of data-bs-config, data-bs-, and js object where the latest given key-value overrides the others.
-
-
-Note that for security reasons the sanitize, sanitizeFn, and allowList options cannot be supplied using data attributes.
-
Object which contains allowed attributes and tags.
-
-
-
animation
-
boolean
-
true
-
Apply a CSS fade transition to the tooltip.
-
-
-
boundary
-
string, element
-
'clippingParents'
-
Overflow constraint boundary of the tooltip (applies only to Popper’s preventOverflow modifier). By default, it’s 'clippingParents' and can accept an HTMLElement reference (via JavaScript only). For more information refer to Popper’s detectOverflow docs.
-
-
-
container
-
string, element, false
-
false
-
Appends the tooltip to a specific element. Example: container: 'body'. This option is particularly useful in that it allows you to position the tooltip in the flow of the document near the triggering element - which will prevent the tooltip from floating away from the triggering element during a window resize.
-
-
-
customClass
-
string, function
-
''
-
Add classes to the tooltip when it is shown. Note that these classes will be added in addition to any classes specified in the template. To add multiple classes, separate them with spaces: 'class-1 class-2'. You can also pass a function that should return a single string containing additional class names.
-
-
-
delay
-
number, object
-
0
-
Delay showing and hiding the tooltip (ms)—doesn’t apply to manual trigger type. If a number is supplied, delay is applied to both hide/show. Object structure is: delay: { "show": 500, "hide": 100 }.
-
-
-
fallbackPlacements
-
array
-
['top', 'right', 'bottom', 'left']
-
Define fallback placements by providing a list of placements in array (in order of preference). For more information refer to Popper’s behavior docs.
-
-
-
html
-
boolean
-
false
-
Allow HTML in the tooltip. If true, HTML tags in the tooltip’s title will be rendered in the tooltip. If false, innerText property will be used to insert content into the DOM. Use text if you’re worried about XSS attacks.
-
-
-
offset
-
array, string, function
-
[0, 6]
-
Offset of the tooltip relative to its target. You can pass a string in data attributes with comma separated values like: data-bs-offset="10,20". When a function is used to determine the offset, it is called with an object containing the popper placement, the reference, and popper rects as its first argument. The triggering element DOM node is passed as the second argument. The function must return an array with two numbers: skidding, distance. For more information refer to Popper’s offset docs.
-
-
-
placement
-
string, function
-
'top'
-
How to position the tooltip: auto, top, bottom, left, right. When auto is specified, it will dynamically reorient the tooltip. When a function is used to determine the placement, it is called with the tooltip DOM node as its first argument and the triggering element DOM node as its second. The this context is set to the tooltip instance.
-
-
-
popperConfig
-
null, object, function
-
null
-
To change Bootstrap’s default Popper config, see Popper’s configuration. When a function is used to create the Popper configuration, it’s called with an object that contains the Bootstrap’s default Popper configuration. It helps you use and merge the default with your own configuration. The function must return a configuration object for Popper.
-
-
-
sanitize
-
boolean
-
true
-
Enable or disable the sanitization. If activated 'template', 'content' and 'title' options will be sanitized.
-
-
-
sanitizeFn
-
null, function
-
null
-
Here you can supply your own sanitize function. This can be useful if you prefer to use a dedicated library to perform sanitization.
-
-
-
selector
-
string, false
-
false
-
If a selector is provided, tooltip objects will be delegated to the specified targets. In practice, this is used to also apply tooltips to dynamically added DOM elements (jQuery.on support). See this issue and an informative example. Note: title attribute must not be used as a selector.
Base HTML to use when creating the tooltip. The tooltip’s title will be injected into the .tooltip-inner. .tooltip-arrow will become the tooltip’s arrow. The outermost wrapper element should have the .tooltip class and role="tooltip".
-
-
-
title
-
string, element, function
-
''
-
The tooltip title. If a function is given, it will be called with its this reference set to the element that the popover is attached to.
-
-
-
trigger
-
string
-
'hover focus'
-
How tooltip is triggered: click, hover, focus, manual. You may pass multiple triggers; separate them with a space. 'manual' indicates that the tooltip will be triggered programmatically via the .tooltip('show'), .tooltip('hide') and .tooltip('toggle') methods; this value cannot be combined with any other trigger. 'hover' on its own will result in tooltips that cannot be triggered via the keyboard, and should only be used if alternative methods for conveying the same information for keyboard users is present.
-
-
-
-
-
-
Data attributes for individual tooltips
-
Options for individual tooltips can alternatively be specified through the use of data attributes, as explained above.
-
-
-
Using function with popperConfig
-
consttooltip=newbootstrap.Tooltip(element,{
-popperConfig(defaultBsPopperConfig){
-// const newPopperConfig = {...}
-// use defaultBsPopperConfig if needed...
-// return newPopperConfig
-}
-})
-
Methods
-
-All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started, but before it ends. In addition, a method call on a transitioning component will be ignored. Learn more in our JavaScript docs.
-
-
-
-
-
-
Method
-
Description
-
-
-
-
-
disable
-
Removes the ability for an element’s tooltip to be shown. The tooltip will only be able to be shown if it is re-enabled.
-
-
-
dispose
-
Hides and destroys an element’s tooltip (Removes stored data on the DOM element). Tooltips that use delegation (which are created using the selector option) cannot be individually destroyed on descendant trigger elements.
-
-
-
enable
-
Gives an element’s tooltip the ability to be shown. Tooltips are enabled by default.
-
-
-
getInstance
-
Static method which allows you to get the tooltip instance associated with a DOM element, or create a new one in case it wasn’t initialized.
-
-
-
getOrCreateInstance
-
Static method which allows you to get the tooltip instance associated with a DOM element, or create a new one in case it wasn’t initialized.
-
-
-
hide
-
Hides an element’s tooltip. Returns to the caller before the tooltip has actually been hidden (i.e. before the hidden.bs.tooltip event occurs). This is considered a “manual” triggering of the tooltip.
-
-
-
setContent
-
Gives a way to change the tooltip’s content after its initialization.
-
-
-
show
-
Reveals an element’s tooltip. Returns to the caller before the tooltip has actually been shown (i.e. before the shown.bs.tooltip event occurs). This is considered a “manual” triggering of the tooltip. Tooltips with zero-length titles are never displayed.
-
-
-
toggle
-
Toggles an element’s tooltip. Returns to the caller before the tooltip has actually been shown or hidden (i.e. before the shown.bs.tooltip or hidden.bs.tooltip event occurs). This is considered a “manual” triggering of the tooltip.
-
-
-
toggleEnabled
-
Toggles the ability for an element’s tooltip to be shown or hidden.
-
-
-
update
-
Updates the position of an element’s tooltip.
-
-
-
-
-
consttooltip=bootstrap.Tooltip.getInstance('#example')// Returns a Bootstrap tooltip instance
-
-// setContent example
-tooltip.setContent({'.tooltip-inner':'another title'})
-
-The setContent method accepts an object argument, where each property-key is a valid string selector within the tooltip template, and each related property-value can be string | element | function | null
-
-
-
Events
-
-
-
-
Event
-
Description
-
-
-
-
-
hide.bs.tooltip
-
This event is fired immediately when the hide instance method has been called.
-
-
-
hidden.bs.tooltip
-
This event is fired when the tooltip has finished being hidden from the user (will wait for CSS transitions to complete).
-
-
-
inserted.bs.tooltip
-
This event is fired after the show.bs.tooltip event when the tooltip template has been added to the DOM.
-
-
-
show.bs.tooltip
-
This event fires immediately when the show instance method is called.
-
-
-
shown.bs.tooltip
-
This event is fired when the tooltip has been made visible to the user (will wait for CSS transitions to complete).
Object which contains allowed attributes and tags.
animation
boolean
true
Apply a CSS fade transition to the tooltip.
boundary
string, element
'clippingParents'
Overflow constraint boundary of the tooltip (applies only to Popper’s preventOverflow modifier). By default, it’s 'clippingParents' and can accept an HTMLElement reference (via JavaScript only). For more information refer to Popper’s detectOverflow docs.
container
string, element, false
false
Appends the tooltip to a specific element. Example: container: 'body'. This option is particularly useful in that it allows you to position the tooltip in the flow of the document near the triggering element - which will prevent the tooltip from floating away from the triggering element during a window resize.
customClass
string, function
''
Add classes to the tooltip when it is shown. Note that these classes will be added in addition to any classes specified in the template. To add multiple classes, separate them with spaces: 'class-1 class-2'. You can also pass a function that should return a single string containing additional class names.
delay
number, object
0
Delay showing and hiding the tooltip (ms)—doesn’t apply to manual trigger type. If a number is supplied, delay is applied to both hide/show. Object structure is: delay: { "show": 500, "hide": 100 }.
fallbackPlacements
array
['top', 'right', 'bottom', 'left']
Define fallback placements by providing a list of placements in array (in order of preference). For more information refer to Popper’s behavior docs.
html
boolean
false
Allow HTML in the tooltip. If true, HTML tags in the tooltip’s title will be rendered in the tooltip. If false, innerText property will be used to insert content into the DOM. Use text if you’re worried about XSS attacks.
offset
array, string, function
[0, 6]
Offset of the tooltip relative to its target. You can pass a string in data attributes with comma separated values like: data-bs-offset="10,20". When a function is used to determine the offset, it is called with an object containing the popper placement, the reference, and popper rects as its first argument. The triggering element DOM node is passed as the second argument. The function must return an array with two numbers: skidding, distance. For more information refer to Popper’s offset docs.
placement
string, function
'top'
How to position the tooltip: auto, top, bottom, left, right. When auto is specified, it will dynamically reorient the tooltip. When a function is used to determine the placement, it is called with the tooltip DOM node as its first argument and the triggering element DOM node as its second. The this context is set to the tooltip instance.
popperConfig
null, object, function
null
To change Bootstrap’s default Popper config, see Popper’s configuration. When a function is used to create the Popper configuration, it’s called with an object that contains the Bootstrap’s default Popper configuration. It helps you use and merge the default with your own configuration. The function must return a configuration object for Popper.
sanitize
boolean
true
Enable or disable the sanitization. If activated 'template', 'content' and 'title' options will be sanitized.
sanitizeFn
null, function
null
Here you can supply your own sanitize function. This can be useful if you prefer to use a dedicated library to perform sanitization.
selector
string, false
false
If a selector is provided, tooltip objects will be delegated to the specified targets. In practice, this is used to also apply tooltips to dynamically added DOM elements (jQuery.on support). See this issue and an informative example. Note: title attribute must not be used as a selector.
Base HTML to use when creating the tooltip. The tooltip’s title will be injected into the .tooltip-inner. .tooltip-arrow will become the tooltip’s arrow. The outermost wrapper element should have the .tooltip class and role="tooltip".
title
string, element, function
''
The tooltip title. If a function is given, it will be called with its this reference set to the element that the popover is attached to.
trigger
string
'hover focus'
How tooltip is triggered: click, hover, focus, manual. You may pass multiple triggers; separate them with a space. 'manual' indicates that the tooltip will be triggered programmatically via the .tooltip('show'), .tooltip('hide') and .tooltip('toggle') methods; this value cannot be combined with any other trigger. 'hover' on its own will result in tooltips that cannot be triggered via the keyboard, and should only be used if alternative methods for conveying the same information for keyboard users is present.
+
Data attributes for individual tooltips
Options for individual tooltips can alternatively be specified through the use of data attributes, as explained above.
All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started, but before it ends. In addition, a method call on a transitioning component will be ignored. Learn more in our JavaScript docs.
Removes the ability for an element’s tooltip to be shown. The tooltip will only be able to be shown if it is re-enabled.
dispose
Hides and destroys an element’s tooltip (Removes stored data on the DOM element). Tooltips that use delegation (which are created using the selector option) cannot be individually destroyed on descendant trigger elements.
enable
Gives an element’s tooltip the ability to be shown. Tooltips are enabled by default.
getInstance
Static method which allows you to get the tooltip instance associated with a DOM element.
getOrCreateInstance
Static method which allows you to get the tooltip instance associated with a DOM element, or create a new one in case it wasn’t initialized.
hide
Hides an element’s tooltip. Returns to the caller before the tooltip has actually been hidden (i.e. before the hidden.bs.tooltip event occurs). This is considered a “manual” triggering of the tooltip.
setContent
Gives a way to change the tooltip’s content after its initialization.
show
Reveals an element’s tooltip. Returns to the caller before the tooltip has actually been shown (i.e. before the shown.bs.tooltip event occurs). This is considered a “manual” triggering of the tooltip. Tooltips with zero-length titles are never displayed.
toggle
Toggles an element’s tooltip. Returns to the caller before the tooltip has actually been shown or hidden (i.e. before the shown.bs.tooltip or hidden.bs.tooltip event occurs). This is considered a “manual” triggering of the tooltip.
toggleEnabled
Toggles the ability for an element’s tooltip to be shown or hidden.
update
Updates the position of an element’s tooltip.
+
const tooltip = bootstrap.Tooltip.getInstance('#example')// Returns a Bootstrap tooltip instance
+
+// setContent example
+tooltip.setContent({'.tooltip-inner':'another title'})
+
+
The setContent method accepts an object argument, where each property-key is a valid string selector within the tooltip template, and each related property-value can be string | element | function | null
Anytime you need to display a piece of content—like an image with an optional caption, consider using a <figure>.
Use the included .figure, .figure-img and .figure-caption classes to provide some baseline styles for the HTML5 <figure> and <figcaption> elements. Images in figures have no explicit size, so be sure to add the .img-fluid class to your <img> to make it responsive.
-
-
-
-
- Placeholder400x300
+
+ Placeholder400x300A caption for the above image.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<figureclass="figure">
-<imgsrc="..."class="figure-img img-fluid rounded"alt="...">
-<figcaptionclass="figure-caption">A caption for the above image.</figcaption>
-</figure>
-
-
-
Aligning the figure’s caption is easy with our text utilities.
-
-
-
-
- Placeholder400x300
+
html
<figureclass="figure">
+ <imgsrc="..."class="figure-img img-fluid rounded"alt="...">
+ <figcaptionclass="figure-caption">A caption for the above image.</figcaption>
+</figure>
+
Aligning the figure’s caption is easy with our text utilities.
+
+ Placeholder400x300A caption for the above image.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<figureclass="figure">
-<imgsrc="..."class="figure-img img-fluid rounded"alt="...">
-<figcaptionclass="figure-caption text-end">A caption for the above image.</figcaption>
-</figure>
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.
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.
Images in Bootstrap 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.
-
-
-
-PlaceholderResponsive image
-
-
- html
-
-
-
-
-
-
-
-
-
<imgsrc="..."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.
-
-
-
-A generic square placeholder image with a white border around it, making it resemble a photograph taken with an old instant camera200x200
-
-
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.
Reboot, a collection of element-specific CSS changes in a single file, kickstart Bootstrap to provide an elegant, consistent, and simple baseline to build upon.
Reboot, a collection of element-specific CSS changes in a single file, kickstart Bootstrap to provide an elegant, consistent, and simple baseline to build upon.
Reboot builds upon Normalize, providing many HTML elements with somewhat opinionated styles using only element selectors. Additional styling is done only with classes. For example, we reboot some <table> styles for a simpler baseline and later provide .table, .table-bordered, and more.
Here are our guidelines and reasons for choosing what to override in Reboot:
@@ -591,74 +30,59 @@
For easier scaling across device sizes, block elements should use rems for margins.
Keep declarations of font-related properties to a minimum, using inherit whenever possible.
-
CSS variables
+
CSS variables
Added in v5.2.0
-
-
With v5.1.1, we standardized our required @imports across all our CSS bundles (including bootstrap.css, bootstrap-reboot.css, and bootstrap-grid.css) to include _root.scss. This adds :root level CSS variables to all bundles, regardless of how many of them are used in that bundle. Ultimately Bootstrap 5 will continue to see more CSS variables added over time, in order to provide more real-time customization without the need to always recompile Sass. Our approach is to take our source Sass variables and transform them into CSS variables. That way, even if you don’t use CSS variables, you still have all the power of Sass. This is still in-progress and will take time to fully implement.
+
With v5.1.1, we standardized our required @imports across all our CSS bundles (including bootstrap.css, bootstrap-reboot.css, and bootstrap-grid.css) to include _root.scss. This adds :root level CSS variables to all bundles, regardless of how many of them are used in that bundle. Ultimately Bootstrap 5 will continue to see more CSS variables added over time, in order to provide more real-time customization without the need to always recompile Sass. Our approach is to take our source Sass variables and transform them into CSS variables. That way, even if you don’t use CSS variables, you still have all the power of Sass. This is still in-progress and will take time to fully implement.
For example, consider these :root CSS variables for common <body> styles:
The <html> and <body> elements are updated to provide better page-wide defaults. More specifically:
The box-sizing is globally set on every element—including *::before and *::after, to border-box. This ensures that the declared width of element is never exceeded due to padding or border.
@@ -669,183 +93,97 @@
The <body> also sets a global font-family, font-weight, line-height, and color. This is inherited later by some form elements to prevent font inconsistencies.
For safety, the <body> has a declared background-color, defaulting to #fff.
-
Native font stack
-
Bootstrap utilizes a “native font stack” or “system font stack” for optimum text rendering on every device and OS. These system fonts have been designed specifically with today’s devices in mind, with improved rendering on screens, variable font support, and more. Read more about native font stacks in this Smashing Magazine article.
-
$font-family-sans-serif:
-// Cross-platform generic font family (default user interface font)
-system-ui,
-// Safari for macOS and iOS (San Francisco)
--apple-system,
-// Windows
-"Segoe UI",
-// Android
-Roboto,
-// older macOS and iOS
-"Helvetica Neue",
-// Linux
-"Noto Sans",
-"Liberation Sans",
-// Basic web fallback
-Arial,
-// Sans serif fallback
-sans-serif,
-// Emoji fonts
-"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"!default;
-
Note that because the font stack includes emoji fonts, many common symbol/dingbat Unicode characters will be rendered as multicolored pictographs. Their appearance will vary, depending on the style used in the browser/platform’s native emoji font, and they won’t be affected by any CSS color styles.
+
Native font stack
+
Bootstrap utilizes a “native font stack” or “system font stack” for optimum text rendering on every device and OS. These system fonts have been designed specifically with today’s devices in mind, with improved rendering on screens, variable font support, and more. Read more about native font stacks in this Smashing Magazine article.
+
$font-family-sans-serif:
+ // Cross-platform generic font family (default user interface font)
+ system-ui,
+ // Safari for macOS and iOS (San Francisco)
+ -apple-system,
+ // Windows
+ "Segoe UI",
+ // Android
+ Roboto,
+ // older macOS and iOS
+ "Helvetica Neue",
+ // Linux
+ "Noto Sans",
+ "Liberation Sans",
+ // Basic web fallback
+ Arial,
+ // Sans serif fallback
+ sans-serif,
+ // Emoji fonts
+ "Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"!default;
+
+
Note that because the font stack includes emoji fonts, many common symbol/dingbat Unicode characters will be rendered as multicolored pictographs. Their appearance will vary, depending on the style used in the browser/platform’s native emoji font, and they won’t be affected by any CSS color styles.
This font-family is applied to the <body> and automatically inherited globally throughout Bootstrap. To switch the global font-family, update $font-family-base and recompile Bootstrap.
-
Headings
+
Headings
All heading elements—<h1>—<h6> have their margin-top removed, margin-bottom: .5rem set, and line-height tightened. While headings inherit their color by default, you can also override it via optional CSS variable, --bs-heading-color.
All <p> elements have their margin-top removed and margin-bottom: 1rem set for easy spacing.
-
-
-
-
This is an example paragraph.
-
-
- html
-
-
-
-
-
-
-
-
-
<p>This is an example paragraph.</p>
-
-
-
Links
-
Links have a default color and underline applied. While links change on :hover, they don’t change based on whether someone :visited the link. They also receive no special :focus styles.
Links have a default color and underline applied. While links change on :hover, they don’t change based on whether someone :visited the link. They also receive no special :focus styles.
As of v5.3.x, link color is set using rgba() and new -rgb CSS variables, allowing for easy customization of link color opacity. Change the link color opacity with the --bs-link-opacity CSS variable:
<ahref="#"style="--bs-link-opacity: .5">This is an example link</a>
Placeholder links—those without an href—are targeted with a more specific selector and have their color and text-decoration reset to their default values.
The <hr> element has been simplified. Similar to browser defaults, <hr>s are styled via border-top, have a default opacity: .25, and automatically inherit their border-color via color, including when color is set via the parent. They can be modified with text, border, and opacity utilities.
All lists—<ul>, <ol>, and <dl>—have their margin-top removed and a margin-bottom: 1rem. Nested lists have no margin-bottom. We’ve also reset the padding-left on <ul> and <ol> elements.
All lists—<ul>, <ol>, and <dl>—have their margin-top removed and a margin-bottom: 1rem. Nested lists have no margin-bottom. We’ve also reset the padding-left on <ul> and <ol> elements.
+
All lists have their top margin removed
And their bottom margin normalized
Nested lists have no bottom margin
@@ -855,139 +193,38 @@
The left padding has also been reset
-
-
-
Here’s an ordered list
+
+
Here’s an ordered list
With a few list items
It has the same overall look
As the previous unordered list
-
-
-
+
For simpler styling, clear hierarchy, and better spacing, description lists have updated margins. <dd>s reset margin-left to 0 and add margin-bottom: .5rem. <dt>s are bolded.
-
-
-
Description lists
-
A description list is perfect for defining terms.
-
Term
-
Definition for the term.
-
A second definition for the same term.
-
Another term
-
Definition for this other term.
-
-
-
Inline code
+
Description lists
A description list is perfect for defining terms.
Term
Definition for the term.
A second definition for the same term.
Another term
Definition for this other term.
+
Inline code
Wrap inline snippets of code with <code>. Be sure to escape HTML angle brackets.
-
-
-
-For example, <section> should be wrapped as inline.
-
-
- html
-
-
-
-
-
-
-
-
-
For example, <code><section></code> should be wrapped as inline.
-
-
-
Code blocks
+
For example, <section> should be wrapped as inline.
html
For example, <code><section></code> should be wrapped as inline.
+
Code blocks
Use <pre>s for multiple lines of code. Once again, be sure to escape any angle brackets in the code for proper rendering. The <pre> element is reset to remove its margin-top and use rem units for its margin-bottom.
-
-
-
-
<p>Sample text here...</p>
+
<p>Sample text here...</p>
<p>And another line of sample text here...</p>
-
-
-
- html
-
-
-
-
-
-
-
-
-
<pre><code><p>Sample text here...</p>
-<p>And another line of sample text here...</p>
-</code></pre>
-
-
-
Variables
+
html
<pre><code><p>Sample text here...</p>
+<p>And another line of sample text here...</p>
+</code></pre>
Use the <kbd> to indicate input that is typically entered via keyboard.
-
-
-
-To switch directories, type cd followed by the name of the directory.
-To edit settings, press Ctrl + ,
-
-
- html
-
-
-
-
-
-
-
-
-
To switch directories, type <kbd>cd</kbd> followed by the name of the directory.<br>
-To edit settings, press <kbd><kbd>Ctrl</kbd> + <kbd>,</kbd></kbd>
-
-
-
Sample output
+
To switch directories, type cd followed by the name of the directory.
+To edit settings, press Ctrl + ,
html
To switch directories, type <kbd>cd</kbd> followed by the name of the directory.<br>
+To edit settings, press <kbd><kbd>Ctrl</kbd> + <kbd>,</kbd></kbd>
+
Sample output
For indicating sample output from a program use the <samp> tag.
-
-
-
-This text is meant to be treated as sample output from a computer program.
-
-
- html
-
-
-
-
-
-
-
-
-
<samp>This text is meant to be treated as sample output from a computer program.</samp>
-
-
-
Tables
-
Tables are slightly adjusted to style <caption>s, collapse borders, and ensure consistent text-align throughout. Additional changes for borders, padding, and more come with the .table class.
-
-
-
-
+
This text is meant to be treated as sample output from a computer program.
html
<samp>This text is meant to be treated as sample output from a computer program.</samp>
+
Tables
+
Tables are slightly adjusted to style <caption>s, collapse borders, and ensure consistent text-align throughout. Additional changes for borders, padding, and more come with the .table class.
+
This is an example table, and this is its caption to describe the contents.
<table>
-<caption>
- This is an example table, and this is its caption to describe the contents.
-</caption>
-<thead>
-<tr>
-<th>Table heading</th>
-<th>Table heading</th>
-<th>Table heading</th>
-<th>Table heading</th>
-</tr>
-</thead>
-<tbody>
-<tr>
-<td>Table cell</td>
-<td>Table cell</td>
-<td>Table cell</td>
-<td>Table cell</td>
-</tr>
-<tr>
-<td>Table cell</td>
-<td>Table cell</td>
-<td>Table cell</td>
-<td>Table cell</td>
-</tr>
-<tr>
-<td>Table cell</td>
-<td>Table cell</td>
-<td>Table cell</td>
-<td>Table cell</td>
-</tr>
-</tbody>
-</table>
-
-
-
Forms
+
html
<table>
+ <caption>
+ This is an example table, and this is its caption to describe the contents.
+ </caption>
+ <thead>
+ <tr>
+ <th>Table heading</th>
+ <th>Table heading</th>
+ <th>Table heading</th>
+ <th>Table heading</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>Table cell</td>
+ <td>Table cell</td>
+ <td>Table cell</td>
+ <td>Table cell</td>
+ </tr>
+ <tr>
+ <td>Table cell</td>
+ <td>Table cell</td>
+ <td>Table cell</td>
+ <td>Table cell</td>
+ </tr>
+ <tr>
+ <td>Table cell</td>
+ <td>Table cell</td>
+ <td>Table cell</td>
+ <td>Table cell</td>
+ </tr>
+ </tbody>
+</table>
+
Forms
Various form elements have been rebooted for simpler base styles. Here are some of the most notable changes:
<fieldset>s have no borders, padding, or margin so they can be easily used as wrappers for individual inputs or groups of inputs.
<legend>s, like fieldsets, have also been restyled to be displayed as a heading of sorts.
<label>s are set to display: inline-block to allow margin to be applied.
<input>s, <select>s, <textarea>s, and <button>s are mostly addressed by Normalize, but Reboot removes their margin and sets line-height: inherit, too.
-
<textarea>s are modified to only be resizable vertically as horizontal resizing often “breaks” page layout.
+
<textarea>s are modified to only be resizable vertically as horizontal resizing often “breaks” page layout.
<button>s and <input> button elements have cursor: pointer when :not(:disabled).
These changes, and more, are demonstrated below.
-
-Some date inputs types are not fully supported by the latest versions of Safari and Firefox.
-
-
-
-
Pointers on buttons
-
Reboot includes an enhancement for role="button" to change the default cursor to pointer. Add this attribute to elements to help indicate elements are interactive. This role isn’t necessary for <button> elements, which get their own cursor change.
-
-
-
-Non-button element button
-
-
- html
-
-
-
-
-
-
-
-
-
<spanrole="button"tabindex="0">Non-button element button</span>
-
-
-
Misc elements
-
Address
+
Some date inputs types are not fully supported by the latest versions of Safari and Firefox.
+
+
Pointers on buttons
+
Reboot includes an enhancement for role="button" to change the default cursor to pointer. Add this attribute to elements to help indicate elements are interactive. This role isn’t necessary for <button> elements, which get their own cursor change.
+
Non-button element button
html
<spanrole="button"tabindex="0">Non-button element button</span>
+
Misc elements
+
Address
The <address> element is updated to reset the browser default font-style from italic to normal. line-height is also now inherited, and margin-bottom: 1rem has been added. <address>s are for presenting contact information for the nearest ancestor (or an entire body of work). Preserve formatting by ending lines with <br>.
-
-
- ACME Corporation
- 1123 Fictional St,
- San Francisco, CA 94103
- P: (123) 456-7890
-
-
- Full Name
- first.last@example.com
-
-
-
Blockquote
+
+ ACME Corporation
+ 1123 Fictional St,
+ San Francisco, CA 94103
+ P: (123) 456-7890
+
+
+
+ Full Name
+ first.last@example.com
+
+
Blockquote
The default margin on blockquotes is 1em 40px, so we reset that to 0 0 1rem for something more consistent with other elements.
-
+
A well-known quote, contained in a blockquote element.
-
Someone famous in Source Title
-
-
Inline elements
+
+ Someone famous in Source Title
+
+
+
Inline elements
The <abbr> element receives basic styling to make it stand out amongst paragraph text.
-
- The HTML abbreviation element.
-
-
Summary
+
The HTML abbreviation element.
+
Summary
The default cursor on summary is text, so we reset that to pointer to convey that the element can be interacted with by clicking on it.
-
-
- Some details
-
More info about the details.
-
-
- Even more details
-
Here are even more details about the details.
-
-
-
HTML5 [hidden] attribute
+
Some details
More info about the details.
Even more details
Here are even more details about the details.
+
HTML5 [hidden] attribute
HTML5 adds a new global attribute named [hidden], which is styled as display: none by default. Borrowing an idea from PureCSS, we improve upon this default by making [hidden] { display: none !important; } to help prevent its display from getting accidentally overridden.
-
<inputtype="text"hidden>
-
-Since [hidden] is not compatible with jQuery’s $(...).hide() and $(...).show() methods, we don’t specifically endorse [hidden] over other techniques for managing the display of elements.
-
-
-
To merely toggle the visibility of an element, meaning its display is not modified and the element can still affect the flow of the document, use the .invisible class instead.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
<inputtype="text"hidden>
+
+
Since [hidden] is not compatible with jQuery’s $(...).hide() and $(...).show() methods, we don’t specifically endorse [hidden] over other techniques for managing the display of elements.
+
To merely toggle the visibility of an element, meaning its display is not modified and the element can still affect the flow of the document, use the .invisible class instead.
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 .table 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.
-
Using the most basic table markup, here’s how .table-based tables look in Bootstrap.
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 .table 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.
+
Using the most basic table markup, here’s how .table-based tables look in Bootstrap.
-Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
-
Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
+
Accented tables
+
Striped rows
Use .table-striped to add zebra-striping to any table row within the <tbody>.
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.
+
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.
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).
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).
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.
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.
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
+
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.
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.
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.
Responsive tables allow tables to be scrolled horizontally with ease. Make any table responsive across all viewports by wrapping a .table with .table-responsive. Or, pick a maximum breakpoint with which to have a responsive table up to by using .table-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
+
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 .table-responsive for horizontally scrolling tables.
Use .table-responsive{-sm|-md|-lg|-xl|-xxl} as needed to create responsive tables up to a particular breakpoint. 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.
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.
Bootstrap 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 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
+
Headings
All HTML headings, <h1> through <h6>, are available.
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.
This is a lead paragraph. It stands out from regular paragraphs.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<pclass="lead">
- This is a lead paragraph. It stands out from regular paragraphs.
-</p>
-
-
-
Inline text elements
+
html
<pclass="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.
+
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>
-
-
+
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.
@@ -805,165 +160,77 @@
.text-decoration-line-through will apply the same styles as <s>.
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.
+
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.
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
-
-
-
-
-
-
-
-
-
<blockquoteclass="blockquote">
-<p>A well-known quote, contained in a blockquote element.</p>
-</blockquote>
-
-
-
Naming a source
+
html
<blockquoteclass="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.
Someone famous in Source Title
-
-
-
- html
-
-
-
-
-
-
-
-
-
<figure>
-<blockquoteclass="blockquote">
-<p>A well-known quote, contained in a blockquote element.</p>
-</blockquote>
-<figcaptionclass="blockquote-footer">
- Someone famous in <citetitle="Source Title">Source Title</cite>
-</figcaption>
-</figure>
-
-
-
Alignment
+
html
<figure>
+ <blockquoteclass="blockquote">
+ <p>A well-known quote, contained in a blockquote element.</p>
+ </blockquote>
+ <figcaptionclass="blockquote-footer">
+ Someone famous in <citetitle="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.
Someone famous in Source Title
-
-
-
- html
-
-
-
-
-
-
-
-
-
<figureclass="text-center">
-<blockquoteclass="blockquote">
-<p>A well-known quote, contained in a blockquote element.</p>
-</blockquote>
-<figcaptionclass="blockquote-footer">
- Someone famous in <citetitle="Source Title">Source Title</cite>
-</figcaption>
-</figure>
-
-
-
-
-
-
+
html
<figureclass="text-center">
+ <blockquoteclass="blockquote">
+ <p>A well-known quote, contained in a blockquote element.</p>
+ </blockquote>
+ <figcaptionclass="blockquote-footer">
+ Someone famous in <citetitle="Source Title">Source Title</cite>
+ </figcaption>
+</figure>
+
A well-known quote, contained in a blockquote element.
Someone famous in Source Title
-
-
-
- html
-
-
-
-
-
-
-
-
-
<figureclass="text-end">
-<blockquoteclass="blockquote">
-<p>A well-known quote, contained in a blockquote element.</p>
-</blockquote>
-<figcaptionclass="blockquote-footer">
- Someone famous in <citetitle="Source Title">Source Title</cite>
-</figcaption>
-</figure>
-
-
-
Lists
-
Unstyled
+
html
<figureclass="text-end">
+ <blockquoteclass="blockquote">
+ <p>A well-known quote, contained in a blockquote element.</p>
+ </blockquote>
+ <figcaptionclass="blockquote-footer">
+ Someone famous in <citetitle="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.
+
Structurally, it’s still a list.
However, this style only applies to immediate child elements.
Nested lists:
@@ -973,68 +240,34 @@
This may still come in handy in some situations.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<ulclass="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.
-
-
-
-
+
html
<ulclass="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
-
-
-
-
-
-
-
-
-
<ulclass="list-inline">
-<liclass="list-inline-item">This is a list item.</li>
-<liclass="list-inline-item">And another one.</li>
-<liclass="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.
-
-
-
-
+
But they’re displayed inline.
+
html
<ulclass="list-inline">
+ <liclass="list-inline-item">This is a list item.</li>
+ <liclass="list-inline-item">And another one.</li>
+ <liclass="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.
@@ -1057,193 +290,92 @@
I heard you like definition lists. Let me put a definition list inside your definition list.
-
+
html
<dlclass="row">
+ <dtclass="col-sm-3">Description lists</dt>
+ <ddclass="col-sm-9">A description list is perfect for defining terms.</dd>
-
- html
-
-
-
-
-
-
-
-
-
<dlclass="row">
-<dtclass="col-sm-3">Description lists</dt>
-<ddclass="col-sm-9">A description list is perfect for defining terms.</dd>
-
-<dtclass="col-sm-3">Term</dt>
-<ddclass="col-sm-9">
-<p>Definition for the term.</p>
-<p>And some more placeholder definition text.</p>
-</dd>
-
-<dtclass="col-sm-3">Another term</dt>
-<ddclass="col-sm-9">This definition is short, so no extra paragraphs or anything.</dd>
-
-<dtclass="col-sm-3 text-truncate">Truncated term is truncated</dt>
-<ddclass="col-sm-9">This can be useful when space is tight. Adds an ellipsis at the end.</dd>
-
-<dtclass="col-sm-3">Nesting</dt>
-<ddclass="col-sm-9">
-<dlclass="row">
-<dtclass="col-sm-4">Nested definition list</dt>
-<ddclass="col-sm-8">I heard you like definition lists. Let me put a definition list inside your definition list.</dd>
-</dl>
-</dd>
-</dl>
-
+ <dtclass="col-sm-3">Term</dt>
+ <ddclass="col-sm-9">
+ <p>Definition for the term.</p>
+ <p>And some more placeholder definition text.</p>
+ </dd>
-
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
+ <dtclass="col-sm-3">Another term</dt>
+ <ddclass="col-sm-9">This definition is short, so no extra paragraphs or anything.</dd>
+
+ <dtclass="col-sm-3 text-truncate">Truncated term is truncated</dt>
+ <ddclass="col-sm-9">This can be useful when space is tight. Adds an ellipsis at the end.</dd>
+
+ <dtclass="col-sm-3">Nesting</dt>
+ <ddclass="col-sm-9">
+ <dlclass="row">
+ <dtclass="col-sm-4">Nested definition list</dt>
+ <ddclass="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.
Bootstrap now supports color modes, or themes, as of v5.3.0. Explore our default light color mode and the new dark mode, or create your own using our styles as your template.
Bootstrap now supports color modes, starting with dark mode! With v5.3.0 you can implement your own color mode toggler (see below for an example from Bootstrap’s docs) and apply the different color modes as you see fit. We support a light mode (default) and now dark mode. Color modes can be toggled globally on the <html> element, or on specific components and elements, thanks to the data-bs-theme attribute.
Bootstrap now supports color modes, or themes, as of v5.3.0. Explore our default light color mode and the new dark mode, or create your own using our styles as your template.
Bootstrap now supports color modes, starting with dark mode! With v5.3.0 you can implement your own color mode toggler (see below for an example from Bootstrap’s docs) and apply the different color modes as you see fit. We support a light mode (default) and now dark mode. Color modes can be toggled globally on the <html> element, or on specific components and elements, thanks to the data-bs-theme attribute.
Alternatively, you can also switch to a media query implementation thanks to our color mode mixin—see the usage section for details. Heads up though—this eliminates your ability to change themes on a per-component basis as shown below.
-
Example
+
Example
For example, to change the color mode of a dropdown menu, add data-bs-theme="light" or data-bs-theme="dark" to the parent .dropdown. Now, no matter the global color mode, these dropdowns will display with the specified theme value.
As shown above, color mode styles are controlled by the data-bs-theme attribute. This attribute can be applied to the <html> element, or to any other element or Bootstrap component. If applied to the <html> element, it will apply to everything. If applied to a component or element, it will be scoped to that specific component or element.
-
For each color mode you wish to support, you’ll need to add new overrides for the shared global CSS variables. We do this already in our _root.scss stylesheet for dark mode, with light mode being the default values. In writing color mode specific styles, use the mixin:
-
// Color mode variables in _root.scss
-@include color-mode(dark){
-// CSS variable overrides here...
-}
-
+
For each color mode you wish to support, you’ll need to add new overrides for the shared global CSS variables. We do this already in our _root.scss stylesheet for dark mode, with light mode being the default values. In writing color mode specific styles, use the mixin:
+
// Color mode variables in _root.scss
+@includecolor-mode(dark){
+ // CSS variable overrides here...
+}
+
+
-
We use a custom _variables-dark.scss to power those shared global CSS variable overrides for dark mode. This file isn’t required for your own custom color modes, but it’s required for our dark mode for two reasons. First, it’s better to have a single place to reset global colors. Second, some Sass variables had to be overridden for background images embedded in our CSS for accordions, form components, and more.
+
We use a custom _variables-dark.scss to power those shared global CSS variable overrides for dark mode. This file isn’t required for your own custom color modes, but it’s required for our dark mode for two reasons. First, it’s better to have a single place to reset global colors. Second, some Sass variables had to be overridden for background images embedded in our CSS for accordions, form components, and more.
-
Usage
-
Enable dark mode
-
Enable the built in dark color mode across your entire project by adding the data-bs-theme="dark" attribute to the <html> element. This will apply the dark color mode to all components and elements, other than those with a specific data-bs-theme attribute applied. Building on the quick start template:
Bootstrap does not yet ship with a built-in color mode picker, but you can use the one from our own documentation if you like. Learn more in the JavaScript section.
-
Building with Sass
-
Our new dark mode option is available to use for all users of Bootstrap, but it’s controlled via data attributes instead of media queries and does not automatically toggle your project’s color mode. You can disable our dark mode entirely via Sass by changing $enable-dark-mode to false.
+
Usage
+
Enable dark mode
+
Enable the built in dark color mode across your entire project by adding the data-bs-theme="dark" attribute to the <html> element. This will apply the dark color mode to all components and elements, other than those with a specific data-bs-theme attribute applied. Building on the quick start template:
Bootstrap does not yet ship with a built-in color mode picker, but you can use the one from our own documentation if you like. Learn more in the JavaScript section.
+
Building with Sass
+
Our new dark mode option is available to use for all users of Bootstrap, but it’s controlled via data attributes instead of media queries and does not automatically toggle your project’s color mode. You can disable our dark mode entirely via Sass by changing $enable-dark-mode to false.
We use a custom Sass mixin, color-mode(), to help you control how color modes are applied. By default, we use a data attribute approach, allowing you to create more user-friendly experiences where your visitors can choose to have an automatic dark mode or control their preference (like in our own docs here). This is also an easy and scalable way to add different themes and more custom color modes beyond light and dark.
-
In case you want to use media queries and only make color modes automatic, you can change the mixin’s default type via Sass variable. Consider the following snippet and its compiled CSS output.
While the primary use case for color modes is light and dark mode, custom color modes are also possible. Create your own data-bs-theme selector with a custom value as the name of your color mode, then modify our Sass and CSS variables as needed. We opted to create a separate _variables-dark.scss stylesheet to house Bootstrap’s dark mode specific Sass variables, but that’s not required for you.
-
For example, you can create a “blue theme” with the selector data-bs-theme="blue". In your custom Sass or CSS file, add the new selector and override any global or component CSS variables as needed. If you’re using Sass, you can also use Sass’s functions within your CSS variable overrides.
To allow visitors or users to toggle color modes, you’ll need to create a toggle element to control the data-bs-theme attribute on the root element, <html>. We’ve built a toggler in our documentation that initially defers to a user’s current system color mode, but provides an option to override that and pick a specific color mode.
-
Here’s a look at the JavaScript that powers it. Feel free to inspect our own documentation navbar to see how it’s implemented using HTML and CSS from our own components. It is suggested to include the JavaScript at the top of your page to reduce potential screen flickering during reloading of your site. Note that if you decide to use media queries for your color modes, your JavaScript may need to be modified or removed if you prefer an implicit control.
In case you want to use media queries and only make color modes automatic, you can change the mixin’s default type via Sass variable. Consider the following snippet and its compiled CSS output.
+
$color-mode-type: data;
-
Adding theme colors
-
Adding a new color in $theme-colors is not enough for some of our components like alerts and list groups. New colors must also be defined in $theme-colors-text, $theme-colors-bg-subtle, and $theme-colors-border-subtle for light theme; but also in $theme-colors-text-dark, $theme-colors-bg-subtle-dark, and $theme-colors-border-subtle-dark for dark theme.
-
This is a manual process because Sass cannot generate its own Sass variables from an existing variable or map. In future versions of Bootstrap, we’ll revisit this setup to reduce the duplication.
-
// Required
-@import"functions";
-@import"variables";
-@import"variables-dark";
-
-// Add a custom color to $theme-colors
-$custom-colors:(
-"custom-color":#712cf9
-);
-$theme-colors:map-merge($theme-colors,$custom-colors);
-
-@import"maps";
-@import"mixins";
-@import"utilities";
-
-// Add a custom color to new theme maps
-
-// Light mode
-$custom-colors-text:("custom-color":#712cf9);
-$custom-colors-bg-subtle:("custom-color":#e1d2fe);
-$custom-colors-border-subtle:("custom-color":#bfa1fc);
-
-$theme-colors-text:map-merge($theme-colors-text,$custom-colors-text);
-$theme-colors-bg-subtle:map-merge($theme-colors-bg-subtle,$custom-colors-bg-subtle);
-$theme-colors-border-subtle:map-merge($theme-colors-border-subtle,$custom-colors-border-subtle);
-
-// Dark mode
-$custom-colors-text-dark:("custom-color":#e1d2f2);
-$custom-colors-bg-subtle-dark:("custom-color":#8951fa);
-$custom-colors-border-subtle-dark:("custom-color":#e1d2f2);
-
-$theme-colors-text-dark:map-merge($theme-colors-text-dark,$custom-colors-text-dark);
-$theme-colors-bg-subtle-dark:map-merge($theme-colors-bg-subtle-dark,$custom-colors-bg-subtle-dark);
-$theme-colors-border-subtle-dark:map-merge($theme-colors-border-subtle-dark,$custom-colors-border-subtle-dark);
-
-// Remainder of Bootstrap imports
-@import"root";
-@import"reboot";
-// etc
-
While the primary use case for color modes is light and dark mode, custom color modes are also possible. Create your own data-bs-theme selector with a custom value as the name of your color mode, then modify our Sass and CSS variables as needed. We opted to create a separate _variables-dark.scss stylesheet to house Bootstrap’s dark mode specific Sass variables, but that’s not required for you.
+
For example, you can create a “blue theme” with the selector data-bs-theme="blue". In your custom Sass or CSS file, add the new selector and override any global or component CSS variables as needed. If you’re using Sass, you can also use Sass’s functions within your CSS variable overrides.
To allow visitors or users to toggle color modes, you’ll need to create a toggle element to control the data-bs-theme attribute on the root element, <html>. We’ve built a toggler in our documentation that initially defers to a user’s current system color mode, but provides an option to override that and pick a specific color mode.
+
Here’s a look at the JavaScript that powers it. Feel free to inspect our own documentation navbar to see how it’s implemented using HTML and CSS from our own components. It is suggested to include the JavaScript at the top of your page to reduce potential screen flickering during reloading of your site. Note that if you decide to use media queries for your color modes, your JavaScript may need to be modified or removed if you prefer an implicit control.
Adding a new color in $theme-colors is not enough for some of our components like alerts and list groups. New colors must also be defined in $theme-colors-text, $theme-colors-bg-subtle, and $theme-colors-border-subtle for light theme; but also in $theme-colors-text-dark, $theme-colors-bg-subtle-dark, and $theme-colors-border-subtle-dark for dark theme.
+
This is a manual process because Sass cannot generate its own Sass variables from an existing variable or map. In future versions of Bootstrap, we'll revisit this setup to reduce the duplication.
+
// Required
+@import"functions";
+@import"variables";
+@import"variables-dark";
+
+// Add a custom color to $theme-colors
+$custom-colors:(
+ "custom-color": #712cf9
+);
+$theme-colors:map-merge($theme-colors,$custom-colors);
+
+@import"maps";
+@import"mixins";
+@import"utilities";
+
+// Add a custom color to new theme maps
+
+// Light mode
+$custom-colors-text:("custom-color": #712cf9);
+$custom-colors-bg-subtle:("custom-color": #e1d2fe);
+$custom-colors-border-subtle:("custom-color": #bfa1fc);
+
+$theme-colors-text:map-merge($theme-colors-text,$custom-colors-text);
+$theme-colors-bg-subtle:map-merge($theme-colors-bg-subtle,$custom-colors-bg-subtle);
+$theme-colors-border-subtle:map-merge($theme-colors-border-subtle,$custom-colors-border-subtle);
+
+// Dark mode
+$custom-colors-text-dark:("custom-color": #e1d2f2);
+$custom-colors-bg-subtle-dark:("custom-color": #8951fa);
+$custom-colors-border-subtle-dark:("custom-color": #e1d2f2);
+
+$theme-colors-text-dark:map-merge($theme-colors-text-dark,$custom-colors-text-dark);
+$theme-colors-bg-subtle-dark:map-merge($theme-colors-bg-subtle-dark,$custom-colors-bg-subtle-dark);
+$theme-colors-border-subtle-dark:map-merge($theme-colors-border-subtle-dark,$custom-colors-border-subtle-dark);
+
+// Remainder of Bootstrap imports
+@import"root";
+@import"reboot";
+// etc
+
+
CSS
+
Variables
Dozens of root level CSS variables are repeated as overrides for dark mode. These are scoped to the color mode selector, which defaults to data-bs-theme but can be configured to use a prefers-color-scheme media query. Use these variables as a guideline for generating your own new color modes.
CSS variables for our dark color mode are partially generated from dark mode specific Sass variables in _variables-dark.scss. This also includes some custom overrides for changing the colors of embedded SVGs used throughout our components.
Styles for dark mode, and any custom color modes you create, can be scoped appropriately to the data-bs-theme attribute selector or media query with the customizable color-mode() mixin. See the Sass usage section for more details.
Bootstrap is supported by an extensive color system that themes our styles and components. This enables more comprehensive customization and extension for any project.
Bootstrap is supported by an extensive color system that themes our styles and components. This enables more comprehensive customization and extension for any project.
Bootstrap’s color palette has continued to expand and become more nuanced in v5.3.0. We’ve added new variables for secondary and tertiary text and background colors, plus {color}-bg-subtle, {color}-border-subtle, and {color}-text-emphasis for our theme colors. These new colors are available through Sass and CSS variables (but not our color maps or utility classes) with the express goal of making it easier to customize across multiple colors modes like light and dark. These new variables are globally set on :root and are adapted for our new dark color mode while our original theme colors remain unchanged.
+
Bootstrap’s color palette has continued to expand and become more nuanced in v5.3.0. We’ve added new variables for secondary and tertiary text and background colors, plus {color}-bg-subtle, {color}-border-subtle, and {color}-text-emphasis for our theme colors. These new colors are available through Sass and CSS variables (but not our color maps or utility classes) with the express goal of making it easier to customize across multiple colors modes like light and dark. These new variables are globally set on :root and are adapted for our new dark color mode while our original theme colors remain unchanged.
Colors ending in -rgb provide the red, green, blue values for use in rgb() and rgba() color modes. For example, rgba(var(--bs-secondary-bg-rgb), .5).
-
-Heads up! There’s some potential confusion with our new secondary and tertiary colors, and our existing secondary theme color, as well as our light and dark theme colors. Expect this to be ironed out in v6.
-
-
-
-
-
-
-
Description
-
Swatch
-
Variables
-
-
-
-
-
- Body — Default foreground (color) and background, including components.
-
-
-
-
-
- --bs-body-color --bs-body-color-rgb
-
-
-
-
-
-
-
- --bs-body-bg --bs-body-bg-rgb
-
-
-
-
- Secondary — Use the color option for lighter text. Use the bg option for dividers and to indicate disabled component states.
-
-
-
-
-
- --bs-secondary-color --bs-secondary-color-rgb
-
-
-
-
-
-
-
- --bs-secondary-bg --bs-secondary-bg-rgb
-
-
-
-
- Tertiary — Use the color option for even lighter text. Use the bg option to style backgrounds for hover states, accents, and wells.
-
-
-
-
-
- --bs-tertiary-color --bs-tertiary-color-rgb
-
-
-
-
-
-
-
- --bs-tertiary-bg --bs-tertiary-bg-rgb
-
-
-
-
- Emphasis — For higher contrast text. Not applicable for backgrounds.
-
-
-
-
-
- --bs-emphasis-color --bs-emphasis-color-rgb
-
-
-
-
- Border — For component borders, dividers, and rules. Use --bs-border-color-translucent to blend with backgrounds with an rgba() value.
-
-
-
-
-
- --bs-border-color --bs-border-color-rgb
-
-
-
-
- Primary — Main theme color, used for hyperlinks, focus styles, and component and form active states.
-
-
-
-
-
- --bs-primary --bs-primary-rgb
-
-
-
-
-
-
-
- --bs-primary-bg-subtle
-
-
-
-
-
-
-
- --bs-primary-border-subtle
-
-
-
-
-
Text
-
-
- --bs-primary-text-emphasis
-
-
-
-
- Success — Theme color used for positive or successful actions and information.
-
-
-
-
-
- --bs-success --bs-success-rgb
-
-
-
-
-
-
-
- --bs-success-bg-subtle
-
-
-
-
-
-
-
- --bs-success-border-subtle
-
-
-
-
-
Text
-
-
- --bs-success-text-emphasis
-
-
-
-
- Danger — Theme color used for errors and dangerous actions.
-
-
-
-
-
- --bs-danger --bs-danger-rgb
-
-
-
-
-
-
-
- --bs-danger-bg-subtle
-
-
-
-
-
-
-
- --bs-danger-border-subtle
-
-
-
-
-
Text
-
-
- --bs-danger-text-emphasis
-
-
-
-
- Warning — Theme color used for non-destructive warning messages.
-
-
-
-
-
- --bs-warning --bs-warning-rgb
-
-
-
-
-
-
-
- --bs-warning-bg-subtle
-
-
-
-
-
-
-
- --bs-warning-border-subtle
-
-
-
-
-
Text
-
-
- --bs-warning-text-emphasis
-
-
-
-
- Info — Theme color used for neutral and informative content.
-
-
-
-
-
- --bs-info --bs-info-rgb
-
-
-
-
-
-
-
- --bs-info-bg-subtle
-
-
-
-
-
-
-
- --bs-info-border-subtle
-
-
-
-
-
Text
-
-
- --bs-info-text-emphasis
-
-
-
-
- Light — Additional theme option for less contrasting colors.
-
-
-
-
-
- --bs-light --bs-light-rgb
-
-
-
-
-
-
-
- --bs-light-bg-subtle
-
-
-
-
-
-
-
- --bs-light-border-subtle
-
-
-
-
-
Text
-
-
- --bs-light-text-emphasis
-
-
-
-
- Dark — Additional theme option for higher contrasting colors.
-
-
-
-
-
- --bs-dark --bs-dark-rgb
-
-
-
-
-
-
-
- --bs-dark-bg-subtle
-
-
-
-
-
-
-
- --bs-dark-border-subtle
-
-
-
-
-
Text
-
-
- --bs-dark-text-emphasis
-
-
-
-
-
-
Using the new colors
-
These new colors are accessible via CSS variables and utility classes—like --bs-primary-bg-subtle and .bg-primary-subtle—allowing you to compose your own CSS rules with the variables, or to quickly apply styles via classes. The utilities are built with the color’s associated CSS variables, and since we customize those CSS variables for dark mode, they are also adaptive to color mode by default.
-
-
-
-
+
Heads up! There’s some potential confusion with our new secondary and tertiary colors, and our existing secondary theme color, as well as our light and dark theme colors. Expect this to be ironed out in v6.
+
Description
Swatch
Variables
Body — Default foreground (color) and background, including components.
--bs-body-color --bs-body-color-rgb
--bs-body-bg --bs-body-bg-rgb
Secondary — Use the color option for lighter text. Use the bg option for dividers and to indicate disabled component states.
--bs-secondary-color --bs-secondary-color-rgb
--bs-secondary-bg --bs-secondary-bg-rgb
Tertiary — Use the color option for even lighter text. Use the bg option to style backgrounds for hover states, accents, and wells.
--bs-tertiary-color --bs-tertiary-color-rgb
--bs-tertiary-bg --bs-tertiary-bg-rgb
Emphasis — For higher contrast text. Not applicable for backgrounds.
--bs-emphasis-color --bs-emphasis-color-rgb
Border — For component borders, dividers, and rules. Use --bs-border-color-translucent to blend with backgrounds with an rgba() value.
--bs-border-color --bs-border-color-rgb
Primary — Main theme color, used for hyperlinks, focus styles, and component and form active states.
--bs-primary --bs-primary-rgb
--bs-primary-bg-subtle
--bs-primary-border-subtle
Text
--bs-primary-text-emphasis
Success — Theme color used for positive or successful actions and information.
--bs-success --bs-success-rgb
--bs-success-bg-subtle
--bs-success-border-subtle
Text
--bs-success-text-emphasis
Danger — Theme color used for errors and dangerous actions.
--bs-danger --bs-danger-rgb
--bs-danger-bg-subtle
--bs-danger-border-subtle
Text
--bs-danger-text-emphasis
Warning — Theme color used for non-destructive warning messages.
--bs-warning --bs-warning-rgb
--bs-warning-bg-subtle
--bs-warning-border-subtle
Text
--bs-warning-text-emphasis
Info — Theme color used for neutral and informative content.
--bs-info --bs-info-rgb
--bs-info-bg-subtle
--bs-info-border-subtle
Text
--bs-info-text-emphasis
Light — Additional theme option for less contrasting colors.
--bs-light --bs-light-rgb
--bs-light-bg-subtle
--bs-light-border-subtle
Text
--bs-light-text-emphasis
Dark — Additional theme option for higher contrasting colors.
--bs-dark --bs-dark-rgb
--bs-dark-bg-subtle
--bs-dark-border-subtle
Text
--bs-dark-text-emphasis
+
Using the new colors
+
These new colors are accessible via CSS variables and utility classes—like --bs-primary-bg-subtle and .bg-primary-subtle—allowing you to compose your own CSS rules with the variables, or to quickly apply styles via classes. The utilities are built with the color’s associated CSS variables, and since we customize those CSS variables for dark mode, they are also adaptive to color mode by default.
+
Example element with utilities
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="p-3 text-primary-emphasis bg-primary-subtle border border-primary-subtle rounded-3">
- Example element with utilities
-</div>
-
-
-
Theme colors
-
We use a subset of all colors to create a smaller color palette for generating color schemes, also available as Sass variables and a Sass map in Bootstrap’s scss/_variables.scss file.
-
-
-
-
Primary
-
-
-
-
Secondary
-
-
-
-
Success
-
-
-
-
Danger
-
-
-
-
Warning
-
-
-
-
Info
-
-
-
-
Light
-
-
-
-
Dark
-
-
-
+
html
<divclass="p-3 text-primary-emphasis bg-primary-subtle border border-primary-subtle rounded-3">
+ Example element with utilities
+</div>
+
Theme colors
+
We use a subset of all colors to create a smaller color palette for generating color schemes, also available as Sass variables and a Sass map in Bootstrap’s scss/_variables.scss file.
+
Primary
Secondary
Success
Danger
Warning
Info
Light
Dark
All these colors are available as a Sass map, $theme-colors.
All Bootstrap colors are available as Sass variables and a Sass map in scss/_variables.scss file. To avoid increased file sizes, we don’t create text or background color classes for each of these variables. Instead, we choose a subset of these colors for a theme palette.
-
Be sure to monitor contrast ratios as you customize colors. As shown below, we’ve added three contrast ratios to each of the main colors—one for the swatch’s current colors, one for against white, and one for against black.
-
-
-
-
- $blue
- #0d6efd
-
-
-
$blue-100
-
-
$blue-200
-
-
$blue-300
-
-
$blue-400
-
-
$blue-500
-
-
$blue-600
-
-
$blue-700
-
-
$blue-800
-
-
$blue-900
-
-
-
-
-
- $indigo
- #6610f2
-
-
-
$indigo-100
-
-
$indigo-200
-
-
$indigo-300
-
-
$indigo-400
-
-
$indigo-500
-
-
$indigo-600
-
-
$indigo-700
-
-
$indigo-800
-
-
$indigo-900
-
-
-
-
-
- $purple
- #6f42c1
-
-
-
$purple-100
-
-
$purple-200
-
-
$purple-300
-
-
$purple-400
-
-
$purple-500
-
-
$purple-600
-
-
$purple-700
-
-
$purple-800
-
-
$purple-900
-
-
-
-
-
- $pink
- #d63384
-
-
-
$pink-100
-
-
$pink-200
-
-
$pink-300
-
-
$pink-400
-
-
$pink-500
-
-
$pink-600
-
-
$pink-700
-
-
$pink-800
-
-
$pink-900
-
-
-
-
-
- $red
- #dc3545
-
-
-
$red-100
-
-
$red-200
-
-
$red-300
-
-
$red-400
-
-
$red-500
-
-
$red-600
-
-
$red-700
-
-
$red-800
-
-
$red-900
-
-
-
-
-
- $orange
- #fd7e14
-
-
-
$orange-100
-
-
$orange-200
-
-
$orange-300
-
-
$orange-400
-
-
$orange-500
-
-
$orange-600
-
-
$orange-700
-
-
$orange-800
-
-
$orange-900
-
-
-
-
-
- $yellow
- #ffc107
-
-
-
$yellow-100
-
-
$yellow-200
-
-
$yellow-300
-
-
$yellow-400
-
-
$yellow-500
-
-
$yellow-600
-
-
$yellow-700
-
-
$yellow-800
-
-
$yellow-900
-
-
-
-
-
- $green
- #198754
-
-
-
$green-100
-
-
$green-200
-
-
$green-300
-
-
$green-400
-
-
$green-500
-
-
$green-600
-
-
$green-700
-
-
$green-800
-
-
$green-900
-
-
-
-
-
- $teal
- #20c997
-
-
-
$teal-100
-
-
$teal-200
-
-
$teal-300
-
-
$teal-400
-
-
$teal-500
-
-
$teal-600
-
-
$teal-700
-
-
$teal-800
-
-
$teal-900
-
-
-
-
-
- $cyan
- #0dcaf0
-
-
-
$cyan-100
-
-
$cyan-200
-
-
$cyan-300
-
-
$cyan-400
-
-
$cyan-500
-
-
$cyan-600
-
-
$cyan-700
-
-
$cyan-800
-
-
$cyan-900
-
-
-
-
- $gray-500
- #adb5bd
-
-
$gray-100
-
-
$gray-200
-
-
$gray-300
-
-
$gray-400
-
-
$gray-500
-
-
$gray-600
-
-
$gray-700
-
-
$gray-800
-
-
$gray-900
-
-
-
-
- $black
- #000
-
-
- $white
- #fff
-
-
-
-
Notes on Sass
-
Sass cannot programmatically generate variables, so we manually created variables for every tint and shade ourselves. We specify the midpoint value (e.g., $blue-500) and use custom color functions to tint (lighten) or shade (darken) our colors via Sass’s mix() color function.
All Bootstrap colors are available as Sass variables and a Sass map in scss/_variables.scss file. To avoid increased file sizes, we don’t create text or background color classes for each of these variables. Instead, we choose a subset of these colors for a theme palette.
+
Be sure to monitor contrast ratios as you customize colors. As shown below, we’ve added three contrast ratios to each of the main colors—one for the swatch’s current colors, one for against white, and one for against black.
+
$blue#0d6efd
$blue-100
$blue-200
$blue-300
$blue-400
$blue-500
$blue-600
$blue-700
$blue-800
$blue-900
$indigo#6610f2
$indigo-100
$indigo-200
$indigo-300
$indigo-400
$indigo-500
$indigo-600
$indigo-700
$indigo-800
$indigo-900
$purple#6f42c1
$purple-100
$purple-200
$purple-300
$purple-400
$purple-500
$purple-600
$purple-700
$purple-800
$purple-900
$pink#d63384
$pink-100
$pink-200
$pink-300
$pink-400
$pink-500
$pink-600
$pink-700
$pink-800
$pink-900
$red#dc3545
$red-100
$red-200
$red-300
$red-400
$red-500
$red-600
$red-700
$red-800
$red-900
$orange#fd7e14
$orange-100
$orange-200
$orange-300
$orange-400
$orange-500
$orange-600
$orange-700
$orange-800
$orange-900
$yellow#ffc107
$yellow-100
$yellow-200
$yellow-300
$yellow-400
$yellow-500
$yellow-600
$yellow-700
$yellow-800
$yellow-900
$green#198754
$green-100
$green-200
$green-300
$green-400
$green-500
$green-600
$green-700
$green-800
$green-900
$teal#20c997
$teal-100
$teal-200
$teal-300
$teal-400
$teal-500
$teal-600
$teal-700
$teal-800
$teal-900
$cyan#0dcaf0
$cyan-100
$cyan-200
$cyan-300
$cyan-400
$cyan-500
$cyan-600
$cyan-700
$cyan-800
$cyan-900
$gray-500#adb5bd
$gray-100
$gray-200
$gray-300
$gray-400
$gray-500
$gray-600
$gray-700
$gray-800
$gray-900
$black
+#000
$white
+#fff
+
Notes on Sass
+
Sass cannot programmatically generate variables, so we manually created variables for every tint and shade ourselves. We specify the midpoint value (e.g., $blue-500) and use custom color functions to tint (lighten) or shade (darken) our colors via Sass’s mix() color function.
Using mix() is not the same as lighten() and darken()—the former blends the specified color with white or black, while the latter only adjusts the lightness value of each color. The result is a much more complete suite of colors, as shown in this CodePen demo.
Our tint-color() and shade-color() functions use mix() alongside our $theme-color-interval variable, which specifies a stepped percentage value for each mixed color we produce. See the scss/_functions.scss and scss/_variables.scss files for the full source code.
-
Color Sass maps
-
Bootstrap’s source Sass files include three maps to help you quickly and easily loop over a list of colors and their hex values.
+
Color Sass maps
+
Bootstrap’s source Sass files include three maps to help you quickly and easily loop over a list of colors and their hex values.
$colors lists all our available base (500) colors
$theme-colors lists all semantically named theme colors (shown below)
$grays lists all tints and shades of gray
-
Within scss/_variables.scss, you’ll find Bootstrap’s color variables and Sass map. Here’s an example of the $colors Sass map:
Add, remove, or modify values within the map to update how they’re used in many other components. Unfortunately at this time, not every component utilizes this Sass map. Future updates will strive to improve upon this. Until then, plan on making use of the ${color} variables and this Sass map.
Add, remove, or modify values within the map to update how they’re used in many other components. Unfortunately at this time, not every component utilizes this Sass map. Future updates will strive to improve upon this. Until then, plan on making use of the ${color} variables and this Sass map.
Color and background utility classes are also available for setting color and background-color using the 500 color values.
+
Generating utilities
Added in v5.1.0
-
-
Bootstrap doesn’t include color and background-color utilities for every color variable, but you can generate these yourself with our utility API and our extended Sass maps added in v5.1.0.
+
Bootstrap doesn’t include color and background-color utilities for every color variable, but you can generate these yourself with our utility API and our extended Sass maps added in v5.1.0.
-
To start, make sure you’ve imported our functions, variables, mixins, and utilities.
+
To start, make sure you’ve imported our functions, variables, mixins, and utilities.
Use our map-merge-multiple() function to quickly merge multiple Sass maps together in a new map.
Merge this new combined map to extend any utility with a {color}-{level} class name.
-
Here’s an example that generates text color utilities (e.g., .text-purple-500) using the above steps.
Bootstrap’s components are largely built with a base-modifier nomenclature. We group as many shared properties as possible into a base class, like .btn, and then group individual styles for each variant into modifier classes, like .btn-primary or .btn-success.
-
To build our modifier classes, we use Sass’s @each loops to iterate over a Sass map. This is especially helpful for generating variants of a component by our $theme-colors and creating responsive variants for each breakpoint. As you customize these Sass maps and recompile, you’ll automatically see your changes reflected in these loops.
-
Check out our Sass maps and loops docs for how to customize these loops and extend Bootstrap’s base-modifier approach to your own code.
-
Modifiers
-
Many of Bootstrap’s components are built with a base-modifier class approach. This means the bulk of the styling is contained to a base class (e.g., .btn) while style variations are confined to modifier classes (e.g., .btn-danger). These modifier classes are built from the $theme-colors map to make customizing the number and name of our modifier classes.
Bootstrap’s components are largely built with a base-modifier nomenclature. We group as many shared properties as possible into a base class, like .btn, and then group individual styles for each variant into modifier classes, like .btn-primary or .btn-success.
+
To build our modifier classes, we use Sass’s @each loops to iterate over a Sass map. This is especially helpful for generating variants of a component by our $theme-colors and creating responsive variants for each breakpoint. As you customize these Sass maps and recompile, you’ll automatically see your changes reflected in these loops.
+
Check out our Sass maps and loops docs for how to customize these loops and extend Bootstrap’s base-modifier approach to your own code.
+
Modifiers
+
Many of Bootstrap’s components are built with a base-modifier class approach. This means the bulk of the styling is contained to a base class (e.g., .btn) while style variations are confined to modifier classes (e.g., .btn-danger). These modifier classes are built from the $theme-colors map to make customizing the number and name of our modifier classes.
Here are two examples of how we loop over the $theme-colors map to generate modifiers to the .alert and .list-group components.
// List group contextual variants
-//
-// Add modifier classes to change text and background color on individual items.
-// Organizationally, this must come after the `:hover` states.
-
-@each$stateinmap-keys($theme-colors){
-.list-group-item-#{$state}{
---#{$prefix}list-group-color:var(--#{$prefix}#{$state}-text-emphasis);
---#{$prefix}list-group-bg:var(--#{$prefix}#{$state}-bg-subtle);
---#{$prefix}list-group-border-color:var(--#{$prefix}#{$state}-border-subtle);
---#{$prefix}list-group-action-hover-color:var(--#{$prefix}emphasis-color);
---#{$prefix}list-group-action-hover-bg:var(--#{$prefix}#{$state}-border-subtle);
---#{$prefix}list-group-action-active-color:var(--#{$prefix}emphasis-color);
---#{$prefix}list-group-action-active-bg:var(--#{$prefix}#{$state}-border-subtle);
---#{$prefix}list-group-active-color:var(--#{$prefix}#{$state}-bg-subtle);
---#{$prefix}list-group-active-bg:var(--#{$prefix}#{$state}-text-emphasis);
---#{$prefix}list-group-active-border-color:var(--#{$prefix}#{$state}-text-emphasis);
-}
-}
-
-
Responsive
-
These Sass loops aren’t limited to color maps, either. You can also generate responsive variations of your components. Take for example our responsive alignment of the dropdowns where we mix an @each loop for the $grid-breakpoints Sass map with a media query include.
// List group contextual variants
+//
+// Add modifier classes to change text and background color on individual items.
+// Organizationally, this must come after the `:hover` states.
+
+@each$state in map-keys($theme-colors){
+ .list-group-item-#{$state}{
+ --#{$prefix}list-group-color:var(--#{$prefix}#{$state}-text-emphasis);
+ --#{$prefix}list-group-bg:var(--#{$prefix}#{$state}-bg-subtle);
+ --#{$prefix}list-group-border-color:var(--#{$prefix}#{$state}-border-subtle);
+ --#{$prefix}list-group-action-hover-color:var(--#{$prefix}emphasis-color);
+ --#{$prefix}list-group-action-hover-bg:var(--#{$prefix}#{$state}-border-subtle);
+ --#{$prefix}list-group-action-active-color:var(--#{$prefix}emphasis-color);
+ --#{$prefix}list-group-action-active-bg:var(--#{$prefix}#{$state}-border-subtle);
+ --#{$prefix}list-group-active-color:var(--#{$prefix}#{$state}-bg-subtle);
+ --#{$prefix}list-group-active-bg:var(--#{$prefix}#{$state}-text-emphasis);
+ --#{$prefix}list-group-active-border-color:var(--#{$prefix}#{$state}-text-emphasis);
+ }
+}
+
+
Responsive
+
These Sass loops aren’t limited to color maps, either. You can also generate responsive variations of your components. Take for example our responsive alignment of the dropdowns where we mix an @each loop for the $grid-breakpoints Sass map with a media query include.
We encourage you to adopt these guidelines when building with Bootstrap to create your own components. We’ve extended this approach ourselves to the custom components in our documentation and examples. Components like our callouts are built just like our provided components with base and modifier classes.
-
-
- This is a callout. We built it custom for our docs so our messages to you stand out. It has three variants via modifier classes.
-
-
-
<divclass="callout">...</div>
-
In your CSS, you’d have something like the following where the bulk of the styling is done via .callout. Then, the unique styles between each variant is controlled via modifier class.
-
// Base class
-.callout{}
-
-// Modifier classes
-.callout-info{}
-.callout-warning{}
-.callout-danger{}
-
For the callouts, that unique styling is just a border-left-color. When you combine that base class with one of those modifier classes, you get your complete component family:
-
-This is an info callout. Example text to show it in action.
-
We encourage you to adopt these guidelines when building with Bootstrap to create your own components. We’ve extended this approach ourselves to the custom components in our documentation and examples. Components like our callouts are built just like our provided components with base and modifier classes.
+
This is a callout. We built it custom for our docs so our messages to you stand out. It has three variants via modifier classes.
+
<divclass="callout">...</div>
+
+
In your CSS, you’d have something like the following where the bulk of the styling is done via .callout. Then, the unique styles between each variant is controlled via modifier class.
+
// Base class
+.callout {}
-
-This is a warning callout. Example text to show it in action.
-
-
-
-This is a danger callout. Example text to show it in action.
-
For the callouts, that unique styling is just a border-left-color. When you combine that base class with one of those modifier classes, you get your complete component family:
+
This is an info callout. Example text to show it in action.
+
This is a warning callout. Example text to show it in action.
+
This is a danger callout. Example text to show it in action.
Bootstrap includes many CSS custom properties (variables) in its compiled CSS for real-time customization without the need to recompile Sass. These provide easy access to commonly used values like our theme colors, breakpoints, and primary font stacks when working in your browser’s inspector, a code sandbox, or general prototyping.
Bootstrap includes many CSS custom properties (variables) in its compiled CSS for real-time customization without the need to recompile Sass. These provide easy access to commonly used values like our theme colors, breakpoints, and primary font stacks when working in your browser’s inspector, a code sandbox, or general prototyping.
All our custom properties are prefixed with bs- to avoid conflicts with third party CSS.
-
Root variables
-
Here are the variables we include (note that the :root is required) that can be accessed anywhere Bootstrap’s CSS is loaded. They’re located in our _root.scss file and included in our compiled dist files.
-
Default
+
Root variables
+
Here are the variables we include (note that the :root is required) that can be accessed anywhere Bootstrap’s CSS is loaded. They’re located in our _root.scss file and included in our compiled dist files.
+
Default
These CSS variables are available everywhere, regardless of color mode.
Bootstrap 5 is increasingly making use of custom properties as local variables for various components. This way we reduce our compiled CSS, ensure styles aren’t inherited in places like nested tables, and allow some basic restyling and extending of Bootstrap components after Sass compilation.
Whenever possible, we’ll assign CSS variables at the base component level (e.g., .navbar for navbar and its sub-components). This reduces guessing on where and how to customize, and allows for easy modifications by our team in future updates.
-
Prefix
-
Most CSS variables use a prefix to avoid collisions with your own codebase. This prefix is in addition to the -- that’s required on every CSS variable.
-
Customize the prefix via the $prefix Sass variable. By default, it’s set to bs- (note the trailing dash).
-
Examples
-
CSS variables offer similar flexibility to Sass’s variables, but without the need for compilation before being served to the browser. For example, here we’re resetting our page’s font and link styles with CSS variables.
Bootstrap 5 is increasingly making use of custom properties as local variables for various components. This way we reduce our compiled CSS, ensure styles aren’t inherited in places like nested tables, and allow some basic restyling and extending of Bootstrap components after Sass compilation.
Whenever possible, we'll assign CSS variables at the base component level (e.g., .navbar for navbar and its sub-components). This reduces guessing on where and how to customize, and allows for easy modifications by our team in future updates.
+
Prefix
+
Most CSS variables use a prefix to avoid collisions with your own codebase. This prefix is in addition to the -- that’s required on every CSS variable.
+
Customize the prefix via the $prefix Sass variable. By default, it’s set to bs- (note the trailing dash).
+
Examples
+
CSS variables offer similar flexibility to Sass’s variables, but without the need for compilation before being served to the browser. For example, here we’re resetting our page’s font and link styles with CSS variables.
Bootstrap provides custom :focus styles using a combination of Sass and CSS variables that can be optionally added to specific components and elements. We do not yet globally override all :focus styles.
In our Sass, we set default values that can be customized before compiling.
Those variables are then reassigned to :root level CSS variables that can be customized in real-time, including with options for x and y offsets (which default to their fallback value of 0).
While we include our grid breakpoints as CSS variables (except for xs), be aware that CSS variables do not work in media queries. This is by design in the CSS spec for variables, but may change in coming years with support for env() variables. Check out this Stack Overflow answer for some helpful links. In the meantime, you can use these variables in other CSS situations, as well as in your JavaScript.
While we include our grid breakpoints as CSS variables (except for xs), be aware that CSS variables do not work in media queries. This is by design in the CSS spec for variables, but may change in coming years with support for env() variables. Check out this Stack Overflow answer for some helpful links. In the meantime, you can use these variables in other CSS situations, as well as in your JavaScript.
When using Sass in your asset pipeline, make sure you optimize Bootstrap by only @importing the components you need. Your largest optimizations will likely come from the Layout & Components section of our bootstrap.scss.
If you’re not using a component, comment it out or delete it entirely. For example, if you’re not using the carousel, remove that import to save some file size in your compiled CSS. Keep in mind there are some dependencies across Sass imports that may make it more difficult to omit a file.
-
Lean JavaScript
-
Bootstrap’s JavaScript includes every component in our primary dist files (bootstrap.js and bootstrap.min.js), and even our primary dependency (Popper) with our bundle files (bootstrap.bundle.js and bootstrap.bundle.min.js). While you’re customizing via Sass, be sure to remove related JavaScript.
-
For instance, assuming you’re using your own JavaScript bundler like Webpack, Parcel, or Vite, you’d only import the JavaScript you plan on using. In the example below, we show how to just include our modal JavaScript:
This way, you’re not including any JavaScript you don’t intend to use for components like buttons, carousels, and tooltips. If you’re importing dropdowns, tooltips or popovers, be sure to list the Popper dependency in your package.json file.
-
-
Heads up! Files in bootstrap/js/dist use the default export. To use them, do the following:
If you’re not using a component, comment it out or delete it entirely. For example, if you’re not using the carousel, remove that import to save some file size in your compiled CSS. Keep in mind there are some dependencies across Sass imports that may make it more difficult to omit a file.
+
Lean JavaScript
+
Bootstrap’s JavaScript includes every component in our primary dist files (bootstrap.js and bootstrap.min.js), and even our primary dependency (Popper) with our bundle files (bootstrap.bundle.js and bootstrap.bundle.min.js). While you’re customizing via Sass, be sure to remove related JavaScript.
+
For instance, assuming you’re using your own JavaScript bundler like Webpack, Parcel, or Vite, you’d only import the JavaScript you plan on using. In the example below, we show how to just include our modal JavaScript:
This way, you’re not including any JavaScript you don’t intend to use for components like buttons, carousels, and tooltips. If you’re importing dropdowns, tooltips or popovers, be sure to list the Popper dependency in your package.json file.
+
Heads up! Files in bootstrap/js/dist use the default export. To use them, do the following:
Bootstrap depends on Autoprefixer to automatically add browser prefixes to certain CSS properties. Prefixes are dictated by our .browserslistrc file, found in the root of the Bootstrap repo. Customizing this list of browsers and recompiling the Sass will automatically remove some CSS from your compiled CSS, if there are vendor prefixes unique to that browser or version.
-
Unused CSS
+
Unused CSS
Help wanted with this section, please consider opening a PR. Thanks!
-
While we don’t have a prebuilt example for using PurgeCSS with Bootstrap, there are some helpful articles and walkthroughs that the community has written. Here are some options:
+
While we don’t have a prebuilt example for using PurgeCSS with Bootstrap, there are some helpful articles and walkthroughs that the community has written. Here are some options:
Whenever possible, be sure to compress all the code you serve to your visitors. If you’re using Bootstrap dist files, try to stick to the minified versions (indicated by the .min.css and .min.js extensions). If you’re building Bootstrap from the source with your own build system, be sure to implement your own minifiers for HTML, CSS, and JS.
-
Non-blocking files
+
Minify and gzip
+
Whenever possible, be sure to compress all the code you serve to your visitors. If you’re using Bootstrap dist files, try to stick to the minified versions (indicated by the .min.css and .min.js extensions). If you’re building Bootstrap from the source with your own build system, be sure to implement your own minifiers for HTML, CSS, and JS.
+
Non-blocking files
While minifying and using compression might seem like enough, making your files non-blocking ones is also a big step in making your site well-optimized and fast enough.
-
If you are using a Lighthouse plugin in Google Chrome, you may have stumbled over FCP. The First Contentful Paint metric measures the time from when the page starts loading to when any part of the page’s content is rendered on the screen.
-
You can improve FCP by deferring non-critical JavaScript or CSS. What does that mean? Simply, JavaScript or stylesheets that don’t need to be present on the first paint of your page should be marked with async or defer attributes.
+
If you are using a Lighthouse plugin in Google Chrome, you may have stumbled over FCP. The First Contentful Paint metric measures the time from when the page starts loading to when any part of the page’s content is rendered on the screen.
+
You can improve FCP by deferring non-critical JavaScript or CSS. What does that mean? Simply, JavaScript or stylesheets that don’t need to be present on the first paint of your page should be marked with async or defer attributes.
This ensures that the less important resources are loaded later and not blocking the first paint. On the other hand, critical resources can be included as inline scripts or styles.
If you want to learn more about this, there are already a lot of great articles about it:
Your website should only be available over HTTPS connections in production. HTTPS improves the security, privacy, and availability of all sites, and there is no such thing as non-sensitive web traffic. The steps to configure your website to be served exclusively over HTTPS vary widely depending on your architecture and web hosting provider, and thus are beyond the scope of these docs.
-
Sites served over HTTPS should also access all stylesheets, scripts, and other assets over HTTPS connections. Otherwise, you’ll be sending users mixed active content, leading to potential vulnerabilities where a site can be compromised by altering a dependency. This can lead to security issues and in-browser warnings displayed to users. Whether you’re getting Bootstrap from a CDN or serving it yourself, ensure that you only access it over HTTPS connections.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
Sites served over HTTPS should also access all stylesheets, scripts, and other assets over HTTPS connections. Otherwise, you’ll be sending users mixed active content, leading to potential vulnerabilities where a site can be compromised by altering a dependency. This can lead to security issues and in-browser warnings displayed to users. Whether you’re getting Bootstrap from a CDN or serving it yourself, ensure that you only access it over HTTPS connections.
Quickly customize Bootstrap with built-in variables to easily toggle global CSS preferences for controlling style and behavior.
+
Customize Bootstrap with our built-in custom variables file and easily toggle global CSS preferences with new $enable-* Sass variables. Override a variable’s value and recompile with npm run test as needed.
+
You can find and customize these variables for key global options in Bootstrap’s scss/_variables.scss file.
Quickly customize Bootstrap with built-in variables to easily toggle global CSS preferences for controlling style and behavior.
-
-
-
-
-
-
-
-
-
-
Customize Bootstrap with our built-in custom variables file and easily toggle global CSS preferences with new $enable-* Sass variables. Override a variable’s value and recompile with npm run test as needed.
-
You can find and customize these variables for key global options in Bootstrap’s scss/_variables.scss file.
-
-
-
-
Variable
-
Values
-
Description
-
-
-
-
-
$spacer
-
1rem (default), or any value > 0
-
Specifies the default spacer value to programmatically generate our spacer utilities.
-
-
-
$enable-dark-mode
-
true (default) or false
-
Enables built-in dark mode support across the project and its components.
-
-
-
$enable-rounded
-
true (default) or false
-
Enables predefined border-radius styles on various components.
-
-
-
$enable-shadows
-
true or false (default)
-
Enables predefined decorative box-shadow styles on various components. Does not affect box-shadows used for focus states.
-
-
-
$enable-gradients
-
true or false (default)
-
Enables predefined gradients via background-image styles on various components.
-
-
-
$enable-transitions
-
true (default) or false
-
Enables predefined transitions on various components.
-
-
-
$enable-reduced-motion
-
true (default) or false
-
Enables the prefers-reduced-motion media query, which suppresses certain animations/transitions based on the users’ browser/operating system preferences.
-
-
-
$enable-grid-classes
-
true (default) or false
-
Enables the generation of CSS classes for the grid system (e.g. .row, .col-md-1, etc.).
-
-
-
$enable-cssgrid
-
true or false (default)
-
Enables the experimental CSS Grid system (e.g. .grid, .g-col-md-1, etc.).
-
-
-
$enable-container-classes
-
true (default) or false
-
Enables the generation of CSS classes for layout containers. (New in v5.2.0)
-
-
-
$enable-caret
-
true (default) or false
-
Enables pseudo element caret on .dropdown-toggle.
-
-
-
$enable-button-pointers
-
true (default) or false
-
Add “hand” cursor to non-disabled button elements.
Specifies the default spacer value to programmatically generate our spacer utilities.
$enable-dark-mode
true (default) or false
Enables built-in dark mode support across the project and its components.
$enable-rounded
true (default) or false
Enables predefined border-radius styles on various components.
$enable-shadows
true or false (default)
Enables predefined decorative box-shadow styles on various components. Does not affect box-shadows used for focus states.
$enable-gradients
true or false (default)
Enables predefined gradients via background-image styles on various components.
$enable-transitions
true (default) or false
Enables predefined transitions on various components.
$enable-reduced-motion
true (default) or false
Enables the prefers-reduced-motion media query, which suppresses certain animations/transitions based on the users’ browser/operating system preferences.
$enable-grid-classes
true (default) or false
Enables the generation of CSS classes for the grid system (e.g. .row, .col-md-1, etc.).
$enable-cssgrid
true or false (default)
Enables the experimental CSS Grid system (e.g. .grid, .g-col-md-1, etc.).
$enable-container-classes
true (default) or false
Enables the generation of CSS classes for layout containers. (New in v5.2.0)
$enable-caret
true (default) or false
Enables pseudo element caret on .dropdown-toggle.
$enable-button-pointers
true (default) or false
Add “hand” cursor to non-disabled button elements.
There are multiple ways to customize Bootstrap. Your best path can depend on your project, the complexity of your build tools, the version of Bootstrap you’re using, browser support, and more.
There are multiple ways to customize Bootstrap. Your best path can depend on your project, the complexity of your build tools, the version of Bootstrap you’re using, browser support, and more.
Our two preferred methods are:
-
Using Bootstrap via package manager so you can use and extend our source files.
-
Using Bootstrap’s compiled distribution files or jsDelivr so you can add onto or override Bootstrap’s styles.
+
Using Bootstrap via package manager so you can use and extend our source files.
+
Using Bootstrap’s compiled distribution files or jsDelivr so you can add onto or override Bootstrap’s styles.
For those who want to use the distribution files, review the getting started page for how to include those files and an example HTML page. From there, consult the docs for the layout, components, and behaviors you’d like to use.
For those who want to use the distribution files, review the getting started page for how to include those files and an example HTML page. From there, consult the docs for the layout, components, and behaviors you’d like to use.
As you familiarize yourself with Bootstrap, continue exploring this section for more details on how to utilize our global options, making use of and changing our color system, how we build our components, how to use our growing list of CSS custom properties, and how to optimize your code when building with Bootstrap.
-
CSPs and embedded SVGs
-
Several Bootstrap components include embedded SVGs in our CSS to style components consistently and easily across browsers and devices. For organizations with more strict CSP configurations, we’ve documented all instances of our embedded SVGs (all of which are applied via background-image) so you can more thoroughly review your options.
+
CSPs and embedded SVGs
+
Several Bootstrap components include embedded SVGs in our CSS to style components consistently and easily across browsers and devices. For organizations with more strict CSP configurations, we’ve documented all instances of our embedded SVGs (all of which are applied via background-image) so you can more thoroughly review your options.
Based on community conversation, some options for addressing this in your own codebase include replacing the URLs with locally hosted assets, removing the images and using inline images (not possible in all components), and modifying your CSP. Our recommendation is to carefully review your own security policies and decide on the best path forward, if necessary.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
Based on community conversation, some options for addressing this in your own codebase include replacing the URLs with locally hosted assets, removing the images and using inline images (not possible in all components), and modifying your CSP. Our recommendation is to carefully review your own security policies and decide on the best path forward, if necessary.
\ No newline at end of file
diff --git a/docs/5.3/customize/sass/index.html b/docs/5.3/customize/sass/index.html
index 1997d1506d..75974aeb3b 100644
--- a/docs/5.3/customize/sass/index.html
+++ b/docs/5.3/customize/sass/index.html
@@ -1,935 +1,303 @@
-
-
-
-
-
-
-
-
+ Sass · Bootstrap v5.3
Utilize our source Sass files to take advantage of variables, maps, mixins, and more.
+
Sass deprecation warnings are shown when compiling source Sass files with the latest versions of Dart Sass. This does not prevent compilation or usage of Bootstrap. We’re working on a long-term fix, but in the meantime these deprecation notices can be ignored.
+
File structure
+
Whenever possible, avoid modifying Bootstrap’s core files. For Sass, that means creating your own stylesheet that imports Bootstrap so you can modify and extend it. Assuming you’re using a package manager like npm, you’ll have a file structure that looks like this:
If you’ve downloaded our source files and aren’t using a package manager, you’ll want to manually create something similar to that structure, keeping Bootstrap’s source files separate from your own.
In your custom.scss, you’ll import Bootstrap’s source Sass files. You have two options: include all of Bootstrap, or pick the parts you need. We encourage the latter, though be aware there are some requirements and dependencies across our components. You also will need to include some JavaScript for our plugins.
+
// Custom.scss
+// Option A: Include all of Bootstrap
-
-
+// Include any default variable overrides here (though functions won’t be available)
-
+@import"../node_modules/bootstrap/scss/bootstrap";
-
+// Then add additional custom code here
+
+
// Custom.scss
+// Option B: Include parts of Bootstrap
-Sass · Bootstrap v5.3
+// 1. Include functions first (so you can manipulate colors, SVGs, calc, etc)
+@import"../node_modules/bootstrap/scss/functions";
-
+// 2. Include any default variable overrides here
-
-
+// 3. Include remainder of required Bootstrap stylesheets (including any separate color mode stylesheets)
+@import"../node_modules/bootstrap/scss/variables";
+@import"../node_modules/bootstrap/scss/variables-dark";
-
-
-
-
-
-
-
+// 4. Include any default map overrides here
-
-
-
-
-
-
+// 5. Include remainder of required parts
+@import"../node_modules/bootstrap/scss/maps";
+@import"../node_modules/bootstrap/scss/mixins";
+@import"../node_modules/bootstrap/scss/root";
-
-
-
-
-
-
-
-
+// 6. Include any other optional stylesheet partials as desired; list below is not inclusive of all available stylesheets
+@import"../node_modules/bootstrap/scss/utilities";
+@import"../node_modules/bootstrap/scss/reboot";
+@import"../node_modules/bootstrap/scss/type";
+@import"../node_modules/bootstrap/scss/images";
+@import"../node_modules/bootstrap/scss/containers";
+@import"../node_modules/bootstrap/scss/grid";
+@import"../node_modules/bootstrap/scss/helpers";
+// ...
-
+// 7. Optionally include utilities API last to generate classes based on the Sass map in `_utilities.scss`
+@import"../node_modules/bootstrap/scss/utilities/api";
-
-
-
-
Utilize our source Sass files to take advantage of variables, maps, mixins, and more.
-
File structure
-
Whenever possible, avoid modifying Bootstrap’s core files. For Sass, that means creating your own stylesheet that imports Bootstrap so you can modify and extend it. Assuming you’re using a package manager like npm, you’ll have a file structure that looks like this:
If you’ve downloaded our source files and aren’t using a package manager, you’ll want to manually create something similar to that structure, keeping Bootstrap’s source files separate from your own.
In your custom.scss, you’ll import Bootstrap’s source Sass files. You have two options: include all of Bootstrap, or pick the parts you need. We encourage the latter, though be aware there are some requirements and dependencies across our components. You also will need to include some JavaScript for our plugins.
-
// Custom.scss
-// Option A: Include all of Bootstrap
-
-// Include any default variable overrides here (though functions won't be available)
-
-@import"../node_modules/bootstrap/scss/bootstrap";
-
-// Then add additional custom code here
-
// Custom.scss
-// Option B: Include parts of Bootstrap
-
-// 1. Include functions first (so you can manipulate colors, SVGs, calc, etc)
-@import"../node_modules/bootstrap/scss/functions";
-
-// 2. Include any default variable overrides here
-
-// 3. Include remainder of required Bootstrap stylesheets (including any separate color mode stylesheets)
-@import"../node_modules/bootstrap/scss/variables";
-@import"../node_modules/bootstrap/scss/variables-dark";
-
-// 4. Include any default map overrides here
-
-// 5. Include remainder of required parts
-@import"../node_modules/bootstrap/scss/maps";
-@import"../node_modules/bootstrap/scss/mixins";
-@import"../node_modules/bootstrap/scss/root";
-
-// 6. Optionally include any other parts as needed
-@import"../node_modules/bootstrap/scss/utilities";
-@import"../node_modules/bootstrap/scss/reboot";
-@import"../node_modules/bootstrap/scss/type";
-@import"../node_modules/bootstrap/scss/images";
-@import"../node_modules/bootstrap/scss/containers";
-@import"../node_modules/bootstrap/scss/grid";
-@import"../node_modules/bootstrap/scss/helpers";
-
-// 7. Optionally include utilities API last to generate classes based on the Sass map in `_utilities.scss`
-@import"../node_modules/bootstrap/scss/utilities/api";
-
-// 8. Add additional custom code here
-
With that setup in place, you can begin to modify any of the Sass variables and maps in your custom.scss. You can also start to add parts of Bootstrap under the // Optional section as needed. We suggest using the full import stack from our bootstrap.scss file as your starting point.
-
Compiling
+// 8. Add additional custom code here
+
+
With that setup in place, you can begin to modify any of the Sass variables and maps in your custom.scss. You can also start to add parts of Bootstrap under the // Optional section as needed. We suggest using the full import stack from our bootstrap.scss file as your starting point.
+
Compiling
In order to use your custom Sass code as CSS in the browser, you need a Sass compiler. Sass ships as a CLI package, but you can also compile it with other build tools like Gulp or Webpack, or with GUI applications. Some IDEs also have Sass compilers built in or as downloadable extensions.
We like to use the CLI to compile our Sass, but you can use whichever method you prefer. From the command line, run the following:
-
# Install Sass globally
-npm install -g sass
-
-# Watch your custom Sass for changes and compile it to CSS
-sass --watch ./scss/custom.scss ./css/custom.css
-
Once your CSS is compiled, you can include it in your HTML files. Inside your index.html you’ll want to include your compiled CSS file. Be sure to update the path to your compiled CSS file if you’ve changed it.
Every Sass variable in Bootstrap includes the !default flag allowing you to override the variable’s default value in your own Sass without modifying Bootstrap’s source code. Copy and paste variables as needed, modify their values, and remove the !default flag. If a variable has already been assigned, then it won’t be re-assigned by the default values in Bootstrap.
-
You will find the complete list of Bootstrap’s variables in scss/_variables.scss. Some variables are set to null, these variables don’t output the property unless they are overridden in your configuration.
+
# Install Sass globally
+npminstall-g sass
+
+# Watch your custom Sass for changes and compile it to CSS
+sass --watch ./scss/custom.scss ./css/custom.css
+
Once your CSS is compiled, you can include it in your HTML files. Inside your index.html you’ll want to include your compiled CSS file. Be sure to update the path to your compiled CSS file if you’ve changed it.
Every Sass variable in Bootstrap includes the !default flag allowing you to override the variable’s default value in your own Sass without modifying Bootstrap’s source code. Copy and paste variables as needed, modify their values, and remove the !default flag. If a variable has already been assigned, then it won’t be re-assigned by the default values in Bootstrap.
+
You will find the complete list of Bootstrap’s variables in scss/_variables.scss. Some variables are set to null, these variables don’t output the property unless they are overridden in your configuration.
Variable overrides must come after our functions are imported, but before the rest of the imports.
-
Here’s an example that changes the background-color and color for the <body> when importing and compiling Bootstrap via npm:
Repeat as necessary for any variable in Bootstrap, including the global options below.
-
-Get started with Bootstrap via npm with our starter project! Head to the Sass & JS example template repository to see how to build and customize Bootstrap in your own npm project. Includes Sass compiler, Autoprefixer, Stylelint, PurgeCSS, and Bootstrap Icons.
-
+
Here’s an example that changes the background-color and color for the <body> when importing and compiling Bootstrap via npm:
Repeat as necessary for any variable in Bootstrap, including the global options below.
+
Get started with Bootstrap via npm with our starter project! Head to the Sass & JS example template repository to see how to build and customize Bootstrap in your own npm project. Includes Sass compiler, Autoprefixer, Stylelint, PurgeCSS, and Bootstrap Icons.
+
Maps and loops
Bootstrap includes a handful of Sass maps, key value pairs that make it easier to generate families of related CSS. We use Sass maps for our colors, grid breakpoints, and more. Just like Sass variables, all Sass maps include the !default flag and can be overridden and extended.
Some of our Sass maps are merged into empty ones by default. This is done to allow easy expansion of a given Sass map, but comes at the cost of making removing items from a map slightly more difficult.
-
Modify map
+
Modify map
All variables in the $theme-colors map are defined as standalone variables. To modify an existing color in our $theme-colors map, add the following to your custom Sass file:
-
$primary:#0074d9;
-$danger:#ff4136;
-
Later on, these variables are set in Bootstrap’s $theme-colors map:
Add new colors to $theme-colors, or any other map, by creating a new Sass map with your custom values and merging it with the original map. In this case, we’ll create a new $custom-colors map and merge it with $theme-colors.
-
// Create your own map
-$custom-colors:(
-"custom-color":#900
-);
-
-// Merge the maps
-$theme-colors:map-merge($theme-colors,$custom-colors);
-
Remove from map
+
$primary: #0074d9;
+$danger: #ff4136;
+
+
Later on, these variables are set in Bootstrap’s $theme-colors map:
Add new colors to $theme-colors, or any other map, by creating a new Sass map with your custom values and merging it with the original map. In this case, we'll create a new $custom-colors map and merge it with $theme-colors.
+
// Create your own map
+$custom-colors:(
+ "custom-color": #900
+);
+
+// Merge the maps
+$theme-colors:map-merge($theme-colors,$custom-colors);
+
+
Remove from map
To remove colors from $theme-colors, or any other map, use map-remove. Be aware you must insert $theme-colors between our requirements just after its definition in variables and before its usage in maps:
Bootstrap assumes the presence of some specific keys within Sass maps as we used and extend these ourselves. As you customize the included maps, you may encounter errors where a specific Sass map’s key is being used.
-
For example, we use the primary, success, and danger keys from $theme-colors for links, buttons, and form states. Replacing the values of these keys should present no issues, but removing them may cause Sass compilation issues. In these instances, you’ll need to modify the Sass code that makes use of those values.
-
Functions
-
Colors
-
Next to the Sass maps we have, theme colors can also be used as standalone variables, like $primary.
You can lighten or darken colors with Bootstrap’s tint-color() and shade-color() functions. These functions will mix colors with black or white, unlike Sass’ native lighten() and darken() functions which will change the lightness by a fixed amount, which often doesn’t lead to the desired effect.
Bootstrap assumes the presence of some specific keys within Sass maps as we used and extend these ourselves. As you customize the included maps, you may encounter errors where a specific Sass map’s key is being used.
+
For example, we use the primary, success, and danger keys from $theme-colors for links, buttons, and form states. Replacing the values of these keys should present no issues, but removing them may cause Sass compilation issues. In these instances, you’ll need to modify the Sass code that makes use of those values.
+
Functions
+
Colors
+
Next to the Sass maps we have, theme colors can also be used as standalone variables, like $primary.
You can lighten or darken colors with Bootstrap’s tint-color() and shade-color() functions. These functions will mix colors with black or white, unlike Sass’ native lighten() and darken() functions which will change the lightness by a fixed amount, which often doesn’t lead to the desired effect.
shift-color() combines these two functions by shading the color if the weight is positive and tinting the color if the weight is negative.
// Tint a color: mix a color with white
-@function tint-color($color,$weight){
-@returnmix(white,$color,$weight);
-}
-
-// Shade a color: mix a color with black
-@function shade-color($color,$weight){
-@returnmix(black,$color,$weight);
-}
-
-// Shade the color if the weight is positive, else tint it
-@function shift-color($color,$weight){
-@returnif($weight>0,shade-color($color,$weight),tint-color($color,-$weight));
-}
-
-
In practice, you’d call the function and pass in the color and weight parameters.
// Tint a color: mix a color with white
+@functiontint-color($color,$weight){
+ @returnmix(white,$color,$weight);
+}
+
+// Shade a color: mix a color with black
+@functionshade-color($color,$weight){
+ @returnmix(black,$color,$weight);
+}
+
+// Shade the color if the weight is positive, else tint it
+@functionshift-color($color,$weight){
+ @returnif($weight> 0,shade-color($color,$weight),tint-color($color, -$weight));
+}
+
+
In practice, you’d call the function and pass in the color and weight parameters.
To help with this, we included the color-contrast function in Bootstrap. It uses the WCAG contrast ratio algorithm for calculating contrast thresholds based on relative luminance in an sRGB color space to automatically return a light (#fff), dark (#212529) or black (#000) contrast color based on the specified base color. This function is especially useful for mixins or loops where you’re generating multiple classes.
+
To help with this, we included the color-contrast function in Bootstrap. It uses the WCAG contrast ratio algorithm for calculating contrast thresholds based on relative luminance in an sRGB color space to automatically return a light (#fff), dark (#212529) or black (#000) contrast color based on the specified base color. This function is especially useful for mixins or loops where you’re generating multiple classes.
For example, to generate color swatches from our $theme-colors map:
We use the escape-svg function to escape the <, > and # characters for SVG background images. When using the escape-svg function, data URIs must be quoted.
-
Add and Subtract functions
-
We use the add and subtract functions to wrap the CSS calc function. The primary purpose of these functions is to avoid errors when a “unitless” 0 value is passed into a calc expression. Expressions like calc(10px - 0) will return an error in all browsers, despite being mathematically correct.
+
Add and Subtract functions
+
We use the add and subtract functions to wrap the CSS calc function. The primary purpose of these functions is to avoid errors when a “unitless” 0 value is passed into a calc expression. Expressions like calc(10px - 0) will return an error in all browsers, despite being mathematically correct.
Example where the calc is valid:
-
$border-radius:.25rem;
-$border-width:1px;
-
-.element{
-// Output calc(.25rem - 1px) is valid
-border-radius:calc($border-radius-$border-width);
-}
-
-.element{
-// Output the same calc(.25rem - 1px) as above
-border-radius:subtract($border-radius,$border-width);
-}
-
Our scss/mixins/ directory has a ton of mixins that power parts of Bootstrap and can also be used across your own project.
-
Color schemes
-
A shorthand mixin for the prefers-color-scheme media query is available with support for light and dark color schemes. See the color modes documentation for information on our color mode mixin.
.custom-element{
-@include color-scheme(light){
-// Insert light mode styles here
-}
-
-@include color-scheme(dark){
-// Insert dark mode styles here
-}
-}
-
-
-
-
+
Color schemes
+
A shorthand mixin for the prefers-color-scheme media query is available with support for light and dark color schemes. See the color modes documentation for information on our color mode mixin.
أضف بعض المعلومات حول الألبوم، المؤلف، أو أي سياق خلفية آخر. اجعلها بضع جمل حتى يتمكن الزوار من التقاط بعض التلميحات المفيدة. ثم اربطها ببعض مواقع التواصل الاجتماعي أو معلومات الاتصال.
هذه بطاقة أوسع مع نص داعم أدناه كمقدمة طبيعية لمحتوى إضافي. هذا المحتوى أطول قليلاً.
-
-
- عرض
- تعديل
-
- 9 دقائق
-
-
-
-
-
-
- Placeholderصورة مصغرة
-
-
هذه بطاقة أوسع مع نص داعم أدناه كمقدمة طبيعية لمحتوى إضافي. هذا المحتوى أطول قليلاً.
-
-
- عرض
- تعديل
-
- 9 دقائق
-
-
-
-
-
-
- Placeholderصورة مصغرة
-
-
هذه بطاقة أوسع مع نص داعم أدناه كمقدمة طبيعية لمحتوى إضافي. هذا المحتوى أطول قليلاً.
-
-
- عرض
- تعديل
-
- 9 دقائق
-
-
-
-
-
-
-
- Placeholderصورة مصغرة
-
-
هذه بطاقة أوسع مع نص داعم أدناه كمقدمة طبيعية لمحتوى إضافي. هذا المحتوى أطول قليلاً.
-
-
- عرض
- تعديل
-
- 9 دقائق
-
-
-
-
-
-
- Placeholderصورة مصغرة
-
-
هذه بطاقة أوسع مع نص داعم أدناه كمقدمة طبيعية لمحتوى إضافي. هذا المحتوى أطول قليلاً.
-
-
- عرض
- تعديل
-
- 9 دقائق
-
-
-
-
-
-
- Placeholderصورة مصغرة
-
-
هذه بطاقة أوسع مع نص داعم أدناه كمقدمة طبيعية لمحتوى إضافي. هذا المحتوى أطول قليلاً.
-
-
- عرض
- تعديل
-
- 9 دقائق
-
-
-
-
-
-
-
- Placeholderصورة مصغرة
-
-
هذه بطاقة أوسع مع نص داعم أدناه كمقدمة طبيعية لمحتوى إضافي. هذا المحتوى أطول قليلاً.
-
-
- عرض
- تعديل
-
- 9 دقائق
-
-
-
-
-
-
- Placeholderصورة مصغرة
-
-
هذه بطاقة أوسع مع نص داعم أدناه كمقدمة طبيعية لمحتوى إضافي. هذا المحتوى أطول قليلاً.
-
-
- عرض
- تعديل
-
- 9 دقائق
-
-
-
-
-
-
- Placeholderصورة مصغرة
-
-
هذه بطاقة أوسع مع نص داعم أدناه كمقدمة طبيعية لمحتوى إضافي. هذا المحتوى أطول قليلاً.
-
-
- عرض
- تعديل
-
- 9 دقائق
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ مثال الألبوم · Bootstrap v5.3
Toggle theme
+Light
+
+Dark
+
+Auto
+
حول
أضف بعض المعلومات حول الألبوم، المؤلف، أو أي سياق خلفية آخر. اجعلها بضع جمل حتى يتمكن الزوار من التقاط بعض التلميحات المفيدة. ثم اربطها ببعض مواقع التواصل الاجتماعي أو معلومات الاتصال.
Add some information about the album below, the author, or any other background context. Make it a few sentences long so folks can pick up some informative tidbits. Then, link them off to some social networking sites or contact information.
Something short and leading about the collection below—its contents, the creator, etc. Make it short and sweet, but not too short so folks don’t simply skip over it entirely.
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
- View
- Edit
-
- 9 mins
-
-
-
-
-
-
- PlaceholderThumbnail
-
-
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
- View
- Edit
-
- 9 mins
-
-
-
-
-
-
- PlaceholderThumbnail
-
-
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
- View
- Edit
-
- 9 mins
-
-
-
-
-
-
-
- PlaceholderThumbnail
-
-
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
- View
- Edit
-
- 9 mins
-
-
-
-
-
-
- PlaceholderThumbnail
-
-
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
- View
- Edit
-
- 9 mins
-
-
-
-
-
-
- PlaceholderThumbnail
-
-
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
- View
- Edit
-
- 9 mins
-
-
-
-
-
-
-
- PlaceholderThumbnail
-
-
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
- View
- Edit
-
- 9 mins
-
-
-
-
-
-
- PlaceholderThumbnail
-
-
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
- View
- Edit
-
- 9 mins
-
-
-
-
-
-
- PlaceholderThumbnail
-
-
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
- View
- Edit
-
- 9 mins
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Album example · Bootstrap v5.3
Toggle theme
+Light
+
+Dark
+
+Auto
+
About
Add some information about the album below, the author, or any other background context. Make it a few sentences long so folks can pick up some informative tidbits. Then, link them off to some social networking sites or contact information.
Something short and leading about the collection below—its contents, the creator, etc. Make it short and sweet, but not too short so folks don’t simply skip over it entirely.
تعرض مشاركة المدونة هذه بضعة أنواع مختلفة من المحتوى الذي يتم دعمه وتصميمه باستخدام Bootstrap. النصوص الأساسية، الصور، والأكواد مدعومة بشكل كامل.
-
-
يشكِّل تأمين الغذاء في المستقبل قضية تؤرِّق حكومات العالَم والعلماء على حدٍّ سواء. فخلال القرن العشرين ازداد عدد سكان الأرض أربعة أضعاف، وتشير التقديرات إلى أن العدد سوف يصل إلى عشرة مليارات إنسان بحلول عام 2050م. وسوف تمثل هذه الزيادة الهائلة تحدياً كبيراً وضغطاً متصاعداً على قدرة الإنتاج الزراعي. الأمر الذي كان ولا بد من أن يدفع إلى تطوير تقنيات مبتكرة في تصنيع الغذاء غير الزراعة، منها تقنية مستقبلية تقوم على تصنيع الغذاء من الهواء.
-
-
تشغل الزراعة مساحات كبيرة من اليابسة، وتستهلك كميات هائلة من المياه، كما أن إنتاج الغذاء بواسطة الزراعة يسهم بنسبة عالية من انبعاثات غازات الاحتباس الحراري العالمية
-
-
تشغل الزراعة مساحات كبيرة من اليابسة، وتستهلك كميات هائلة من المياه. كما أن إنتاج الغذاء بواسطة الزراعة يسهم بنسبة عالية من انبعاثات غازات الاحتباس الحراري العالمية، وللمقارنة فإن هذه النسبة من الانبعاثات هي أكبر مما ينتجه قطاع النقل بكل ما فيه من سيارات وشاحنات وطائرات وقطارات.
-
عنوان
-
تحصل النباتات على غذائها بواسطة عملية تسمى البناء الضوئي، حيث تقوم النباتات بتحويل ضوء الشمس والماء وثاني أكسيد الكربون الموجود في الغلاف الجوي إلى غذاء وتطلق الأكسجين كمنتج ثانوي لهذا التفاعل الكيميائي. وتحدث هذه العملية في "البلاستيدات الخضراء". فالنباتات تستفيد من طاقة ضوء الشمس في تقسيم الماء إلى هيدروجين وأكسجين، وتحدث تفاعلات كيميائية أخرى ينتج عنها سكر الجلكوز الذي تستخدمه كمصدر للغذاء وينطلق الأكسجين من النباتات إلى الغلاف الجوي. وهذا يعني أن النباتات تحوِّل ثاني أكسيد الكربون إلى غذاء من خلال تفاعلات كيميائية معقَّدة. ويُعد البناء الضوئي من أهم التفاعلات الكيميائية على كوكب الأرض، فقد ساعد في الماضي على تطوُّر كوكبنا وظهور الحياة عليه. فالنباتات تستخدم ثاني أكسيد الكربون لصنع غذائها، وتطلق الأكسجين لتساعد الكائنات الأخرى على التنفس!
-
عنوان فرعي
-
ألهمت هذه العملية علماء وكالة الفضاء الأمريكية (ناسا) خلال الستينيات من القرن الماضي، لبحث فكرة إطعام روَّاد الفضاء في مهمات الفضاء الطويلة مثل السفر إلى المريخ. وكانت واحدة من الأفكار الواعدة تصنيع الغذاء عن طريق ثاني أكسيد الكربون الذي ينتجه روَّاد الفضاء، لكن ليس بواسطة النباتات بل عن طريق ميكروبات صغيرة وحيدة الخلية قادرة على حصد ثاني أكسيد الكربون لإنتاج كميات وفيرة من البروتين المغذي على شكل مسحوق عديم النكهة، كما يمكن استخدام المادة في صنع الأطعمة المألوفة لدينا.
-
Example code block
-
وخلافاً لما هو الحال في عالم النبات، فإن هذه الميكروبات لا تستخدم الضوء كما يحدث في عملية البناء الضوئي التي تستخدمها النباتات للحصول على الغذاء، أي لأنها قادرة على النمو في الظلام. تسمى هذه البكتريا "هيدروجينوتروف" (Hydrogenotrophs)، وهي تستخدم الهيدروجين كوقود لإنتاج الغذاء من ثاني أكسيد الكربون. فعندما يُنتج روَّاد الفضاء ثاني أكسيد الكربون، تلتقطه الميكروبات، ويتحوَّل مع مدخلات أخرى إلى غذاء غني بالكربون. وبهذه الطريقة سوف نحصل على دورة كربون مغلقة الحلقة.
-
عنوان فرعي
-
بعد مرور أكثر من نصف قرن على أبحاث ناسا، تعمل حالياً عدة شركات في قطاع البيولوجيا التركيبية من ضمنها إير بروتين (Air Protein) وسولار فودز (Solar Foods) على تطوير جيل جديد من المنتجات الغذائية المستدامة، من دون وجود بصمة كربونية. ولن تقتصر هذه المنتجات الغذائية على روَّاد الفضاء فحسب، بل سوف تمتد لتشمل جميع سكان الأرض، وسوف تُنتَج في فترة زمنية قصيرة، بدلاً من الشهور، ومن دون الاعتماد على الأراضي الزراعية. وهذا يعني الحصول على منتجات غذائية بشكل سريع جداً. كما سيصبح من الممكن تصنيع الغذاء بطريقة عمودية من خلال هذه الميكروبات، بدلاً من الطريقة الأفقية التقليدية الشبيهة بتقنية الزراعة العمودية الحديثة. وهذا يعني توفير منتجات غذائية أكبر من المساحة نفسها.
-
يتكوَّن الغذاء البشري من ثلاثة أنواع رئيسة، هي:
-
-
البروتينات
-
الكربوهيدرات
-
الدهون
-
-
وتتكوَّن البروتينات من الأحماض الأمينية، وهي مجموعة من المركبات العضوية يبلغ عددها في جسم الإنسان عشرين حمضاً أمينياً، من بينها تسعة أساسية يحصل عليها الجسم من الغذاء. وتتكوَّن الأحماض الأمينية بشكل أساس من:
-
-
الكربون
-
الهيدروجين
-
الأكسجين
-
النيتروجين
-
-
ومن الملاحظ أن النيتروجين يشكِّل نسبة %78 من الهواء، كما أن الهيدروجين نحصل عليه من خلال التحليل الكهربائي للماء، ومن الممكن نظرياً سحب الكربون من الهواء لتشكيل هذه الأحماض، ذلك أن الكربون هو العمود الفقري للأحماض الأمينية، كما أن الحياة على كوكب الأرض قائمة على الكربون لقدرته على تكوين سلاسل كربونية طويلة، وهذا ما تفعله الميكروبات بتصنيع أحماض أمينية من ثاني أكسيد الكربون من خلال مجموعة من التفاعلات الكيميائية المعقَّدة. وإضافة إلى صنع وجبات غنية بالبروتين، فهذه الميكروبات تنتج منتجات أخرى مثل الزيوت التي لها عديد من الاستخدامات.
في الوقت الحالي، تدرس عدَّة شركات هذه الميكروبات بشكل أعمق، وتستزرعها من أجل الحصول على الغذاء. ففي عام 2019م، أعلن باحثون في شركة (Air Protein) الأمريكية نجاحهم في تحويل ثاني أكسيد الكربون الموجود في الهواء إلى لحوم صناعية مصنوعة من البروتين، التي لا تتطلَّب أي أرض زراعية، بل هي معتمدة بشكل أساسي على الهواء.
-
-
تم تصنيع اللحوم بأنواع عديدة
-
-
إذ استخدم هؤلاء الباحثون الهواء والطاقة المتجدِّدة كمدخلات في عملية مشابهة للتخمير، لإنتاج بروتين يحتوي على الأحماض الأمينية التسعة الأساسية وغني بالفيتامينات والمعادن، كما أنه خالٍ من الهرمونات والمضادات الحيوية والمبيدات الحشرية ومبيدات الأعشاب.
-
وتم تصنيع اللحوم بأنواع عديدة بما فيها الدواجن والأبقار والمأكولات البحرية، من دون حصول انبعاثات كربونية، على عكس تربية الأبقار التي تسهم في انبعاث غاز الميثان أحد غازات الاحتباس الحراري.
كما أن الشركة الفنلندية (Solar Foods) طوَّرت تقنية لإنتاج البروتين من الهواء، حيث تبدأ العملية بتقسيم الماء إلى مكوناته الهيدروجين والأكسجين عن طريق الكهرباء. فالهيدروجين يوفِّر الطاقة للبكتريا لتحويل ثاني أكسيد الكربون والنيتروجين الموجودين في الهواء إلى مادة عضوية غنية بالبروتين بشكل أكفأ من نمو النباتات باستخدام البناء الضوئي. وهذا البروتين يشبه دقيق القمح وقد أطلق عليه اسم "سولين" (Solein).
-
وتقوم الشركة حالياً بجمع البيانات حول المنتج الغذائي لتقديمه إلى الاتحاد الأوروبي بهدف الحصول على ترخيص غذائي، كما أنها تخطط لبدء الإنتاج التجاري في العام المقبل 2021م. وقد أوضحت الشركة أنها مهتمة بإنتاج أطعمة صديقة للبيئة من خلال استخدام المواد الأساسية: الكهرباء وثاني أكسيد الكربون، وهذه الأطعمة سوف تجنبنا الأثر السلبي البيئي للزراعة التقليدية الذي يشمل كل شيء من استخدام الأرض والمياه إلى الانبعاثات الناتجة من تسميد المحاصيل أو تربية الحيوانات.
-
وعلى هذا، فإن البروتينات المشتقة من الميكروبات سوف:
-
-
توفر حلاً ممكناً في ظل زيادة الطلب العالمي المستقبلي على الغذاء
-
تتوسع مصانع الغذاء في المستقبل لتكون أكفأ وأكثر استدامة
-
تصبح قادرة على توفير الغذاء لروَّاد الفضاء في سفرهم إلى المريخ وجميع سكان كوكب الأرض في عام 2050م
-
-
فتخيّل أن الميكروبات ستكون مصانع المستقبل، وأن غذاء المستقبل سيكون مصنوعاً من الهواء! وأن عام 2050م سيكون مختلفاً تماماً عن عالمنا اليوم. فهو عالم من دون زراعة ولا تربية حيوانات من أجل الغذاء! قد يبدو ذلك خيالياً لكنه ليس مستحيلاً!
أقبلت، فأقبلت معك الحياة بجميع صنوفها وألوانها: فالنبات ينبت، والأشجار تورق وتزهر، والهرة تموء، والقمري يسجع، والغنم يثغو، والبقر يخور، وكل أليف يدعو أليفه. كل شيء يشعر بالحياة وينسي هموم الحياة، ولا يذكر إلا سعادة الحياة، فإن كان الزمان جسدا فأنت روحه، وإن كان عمرا فأنت شبابه.
تعرض مشاركة المدونة هذه بضعة أنواع مختلفة من المحتوى الذي يتم دعمه وتصميمه باستخدام Bootstrap. النصوص الأساسية، الصور، والأكواد مدعومة بشكل كامل.
يشكِّل تأمين الغذاء في المستقبل قضية تؤرِّق حكومات العالَم والعلماء على حدٍّ سواء. فخلال القرن العشرين ازداد عدد سكان الأرض أربعة أضعاف، وتشير التقديرات إلى أن العدد سوف يصل إلى عشرة مليارات إنسان بحلول عام 2050م. وسوف تمثل هذه الزيادة الهائلة تحدياً كبيراً وضغطاً متصاعداً على قدرة الإنتاج الزراعي. الأمر الذي كان ولا بد من أن يدفع إلى تطوير تقنيات مبتكرة في تصنيع الغذاء غير الزراعة، منها تقنية مستقبلية تقوم على تصنيع الغذاء من الهواء.
تشغل الزراعة مساحات كبيرة من اليابسة، وتستهلك كميات هائلة من المياه، كما أن إنتاج الغذاء بواسطة الزراعة يسهم بنسبة عالية من انبعاثات غازات الاحتباس الحراري العالمية
تشغل الزراعة مساحات كبيرة من اليابسة، وتستهلك كميات هائلة من المياه. كما أن إنتاج الغذاء بواسطة الزراعة يسهم بنسبة عالية من انبعاثات غازات الاحتباس الحراري العالمية، وللمقارنة فإن هذه النسبة من الانبعاثات هي أكبر مما ينتجه قطاع النقل بكل ما فيه من سيارات وشاحنات وطائرات وقطارات.
عنوان
تحصل النباتات على غذائها بواسطة عملية تسمى البناء الضوئي، حيث تقوم النباتات بتحويل ضوء الشمس والماء وثاني أكسيد الكربون الموجود في الغلاف الجوي إلى غذاء وتطلق الأكسجين كمنتج ثانوي لهذا التفاعل الكيميائي. وتحدث هذه العملية في "البلاستيدات الخضراء". فالنباتات تستفيد من طاقة ضوء الشمس في تقسيم الماء إلى هيدروجين وأكسجين، وتحدث تفاعلات كيميائية أخرى ينتج عنها سكر الجلكوز الذي تستخدمه كمصدر للغذاء وينطلق الأكسجين من النباتات إلى الغلاف الجوي. وهذا يعني أن النباتات تحوِّل ثاني أكسيد الكربون إلى غذاء من خلال تفاعلات كيميائية معقَّدة. ويُعد البناء الضوئي من أهم التفاعلات الكيميائية على كوكب الأرض، فقد ساعد في الماضي على تطوُّر كوكبنا وظهور الحياة عليه. فالنباتات تستخدم ثاني أكسيد الكربون لصنع غذائها، وتطلق الأكسجين لتساعد الكائنات الأخرى على التنفس!
عنوان فرعي
ألهمت هذه العملية علماء وكالة الفضاء الأمريكية (ناسا) خلال الستينيات من القرن الماضي، لبحث فكرة إطعام روَّاد الفضاء في مهمات الفضاء الطويلة مثل السفر إلى المريخ. وكانت واحدة من الأفكار الواعدة تصنيع الغذاء عن طريق ثاني أكسيد الكربون الذي ينتجه روَّاد الفضاء، لكن ليس بواسطة النباتات بل عن طريق ميكروبات صغيرة وحيدة الخلية قادرة على حصد ثاني أكسيد الكربون لإنتاج كميات وفيرة من البروتين المغذي على شكل مسحوق عديم النكهة، كما يمكن استخدام المادة في صنع الأطعمة المألوفة لدينا.
Example code block
وخلافاً لما هو الحال في عالم النبات، فإن هذه الميكروبات لا تستخدم الضوء كما يحدث في عملية البناء الضوئي التي تستخدمها النباتات للحصول على الغذاء، أي لأنها قادرة على النمو في الظلام. تسمى هذه البكتريا "هيدروجينوتروف" (Hydrogenotrophs)، وهي تستخدم الهيدروجين كوقود لإنتاج الغذاء من ثاني أكسيد الكربون. فعندما يُنتج روَّاد الفضاء ثاني أكسيد الكربون، تلتقطه الميكروبات، ويتحوَّل مع مدخلات أخرى إلى غذاء غني بالكربون. وبهذه الطريقة سوف نحصل على دورة كربون مغلقة الحلقة.
عنوان فرعي
بعد مرور أكثر من نصف قرن على أبحاث ناسا، تعمل حالياً عدة شركات في قطاع البيولوجيا التركيبية من ضمنها إير بروتين (Air Protein) وسولار فودز (Solar Foods) على تطوير جيل جديد من المنتجات الغذائية المستدامة، من دون وجود بصمة كربونية. ولن تقتصر هذه المنتجات الغذائية على روَّاد الفضاء فحسب، بل سوف تمتد لتشمل جميع سكان الأرض، وسوف تُنتَج في فترة زمنية قصيرة، بدلاً من الشهور، ومن دون الاعتماد على الأراضي الزراعية. وهذا يعني الحصول على منتجات غذائية بشكل سريع جداً. كما سيصبح من الممكن تصنيع الغذاء بطريقة عمودية من خلال هذه الميكروبات، بدلاً من الطريقة الأفقية التقليدية الشبيهة بتقنية الزراعة العمودية الحديثة. وهذا يعني توفير منتجات غذائية أكبر من المساحة نفسها.
يتكوَّن الغذاء البشري من ثلاثة أنواع رئيسة، هي:
البروتينات
الكربوهيدرات
الدهون
وتتكوَّن البروتينات من الأحماض الأمينية، وهي مجموعة من المركبات العضوية يبلغ عددها في جسم الإنسان عشرين حمضاً أمينياً، من بينها تسعة أساسية يحصل عليها الجسم من الغذاء. وتتكوَّن الأحماض الأمينية بشكل أساس من:
الكربون
الهيدروجين
الأكسجين
النيتروجين
ومن الملاحظ أن النيتروجين يشكِّل نسبة %78 من الهواء، كما أن الهيدروجين نحصل عليه من خلال التحليل الكهربائي للماء، ومن الممكن نظرياً سحب الكربون من الهواء لتشكيل هذه الأحماض، ذلك أن الكربون هو العمود الفقري للأحماض الأمينية، كما أن الحياة على كوكب الأرض قائمة على الكربون لقدرته على تكوين سلاسل كربونية طويلة، وهذا ما تفعله الميكروبات بتصنيع أحماض أمينية من ثاني أكسيد الكربون من خلال مجموعة من التفاعلات الكيميائية المعقَّدة. وإضافة إلى صنع وجبات غنية بالبروتين، فهذه الميكروبات تنتج منتجات أخرى مثل الزيوت التي لها عديد من الاستخدامات.
في الوقت الحالي، تدرس عدَّة شركات هذه الميكروبات بشكل أعمق، وتستزرعها من أجل الحصول على الغذاء. ففي عام 2019م، أعلن باحثون في شركة (Air Protein) الأمريكية نجاحهم في تحويل ثاني أكسيد الكربون الموجود في الهواء إلى لحوم صناعية مصنوعة من البروتين، التي لا تتطلَّب أي أرض زراعية، بل هي معتمدة بشكل أساسي على الهواء.
تم تصنيع اللحوم بأنواع عديدة
إذ استخدم هؤلاء الباحثون الهواء والطاقة المتجدِّدة كمدخلات في عملية مشابهة للتخمير، لإنتاج بروتين يحتوي على الأحماض الأمينية التسعة الأساسية وغني بالفيتامينات والمعادن، كما أنه خالٍ من الهرمونات والمضادات الحيوية والمبيدات الحشرية ومبيدات الأعشاب.
وتم تصنيع اللحوم بأنواع عديدة بما فيها الدواجن والأبقار والمأكولات البحرية، من دون حصول انبعاثات كربونية، على عكس تربية الأبقار التي تسهم في انبعاث غاز الميثان أحد غازات الاحتباس الحراري.
كما أن الشركة الفنلندية (Solar Foods) طوَّرت تقنية لإنتاج البروتين من الهواء، حيث تبدأ العملية بتقسيم الماء إلى مكوناته الهيدروجين والأكسجين عن طريق الكهرباء. فالهيدروجين يوفِّر الطاقة للبكتريا لتحويل ثاني أكسيد الكربون والنيتروجين الموجودين في الهواء إلى مادة عضوية غنية بالبروتين بشكل أكفأ من نمو النباتات باستخدام البناء الضوئي. وهذا البروتين يشبه دقيق القمح وقد أطلق عليه اسم "سولين" (Solein).
وتقوم الشركة حالياً بجمع البيانات حول المنتج الغذائي لتقديمه إلى الاتحاد الأوروبي بهدف الحصول على ترخيص غذائي، كما أنها تخطط لبدء الإنتاج التجاري في العام المقبل 2021م. وقد أوضحت الشركة أنها مهتمة بإنتاج أطعمة صديقة للبيئة من خلال استخدام المواد الأساسية: الكهرباء وثاني أكسيد الكربون، وهذه الأطعمة سوف تجنبنا الأثر السلبي البيئي للزراعة التقليدية الذي يشمل كل شيء من استخدام الأرض والمياه إلى الانبعاثات الناتجة من تسميد المحاصيل أو تربية الحيوانات.
وعلى هذا، فإن البروتينات المشتقة من الميكروبات سوف:
توفر حلاً ممكناً في ظل زيادة الطلب العالمي المستقبلي على الغذاء
تتوسع مصانع الغذاء في المستقبل لتكون أكفأ وأكثر استدامة
تصبح قادرة على توفير الغذاء لروَّاد الفضاء في سفرهم إلى المريخ وجميع سكان كوكب الأرض في عام 2050م
فتخيّل أن الميكروبات ستكون مصانع المستقبل، وأن غذاء المستقبل سيكون مصنوعاً من الهواء! وأن عام 2050م سيكون مختلفاً تماماً عن عالمنا اليوم. فهو عالم من دون زراعة ولا تربية حيوانات من أجل الغذاء! قد يبدو ذلك خيالياً لكنه ليس مستحيلاً!
أقبلت، فأقبلت معك الحياة بجميع صنوفها وألوانها: فالنبات ينبت، والأشجار تورق وتزهر، والهرة تموء، والقمري يسجع، والغنم يثغو، والبقر يخور، وكل أليف يدعو أليفه. كل شيء يشعر بالحياة وينسي هموم الحياة، ولا يذكر إلا سعادة الحياة، فإن كان الزمان جسدا فأنت روحه، وإن كان عمرا فأنت شبابه.
This blog post shows a few different types of content that’s supported and styled with Bootstrap. Basic typography, lists, tables, images, code, and more are all supported as expected.
-
-
This is some additional paragraph placeholder content. It has been written to fill the available space and show how a longer snippet of text affects the surrounding content. We'll repeat it often to keep the demonstration flowing, so be on the lookout for this exact same string of text.
-
Blockquotes
-
This is an example blockquote in action:
-
-
Quoted text goes here.
-
-
This is some additional paragraph placeholder content. It has been written to fill the available space and show how a longer snippet of text affects the surrounding content. We'll repeat it often to keep the demonstration flowing, so be on the lookout for this exact same string of text.
-
Example lists
-
This is some additional paragraph placeholder content. It's a slightly shorter version of the other highly repetitive body text used throughout. This is an example unordered list:
-
-
First list item
-
Second list item with a longer description
-
Third list item to close it out
-
-
And this is an ordered list:
-
-
First list item
-
Second list item with a longer description
-
Third list item to close it out
-
-
And this is a definition list:
-
-
HyperText Markup Language (HTML)
-
The language used to describe and define the content of a Web page
-
Cascading Style Sheets (CSS)
-
Used to describe the appearance of Web content
-
JavaScript (JS)
-
The programming language used to build advanced Web sites and applications
-
-
Inline HTML elements
-
HTML defines a long list of available inline tags, a complete list of which can be found on the Mozilla Developer Network.
-
-
To bold text, use <strong>.
-
To italicize text, use <em>.
-
Abbreviations, like HTML should use <abbr>, with an optional title attribute for the full phrase.
-
Citations, like — Mark Otto, should use <cite>.
-
Deleted text should use <del> and inserted text should use <ins>.
-
Superscript text uses <sup> and subscript text uses <sub>.
-
-
Most of these elements are styled by browsers with few modifications on our part.
-
Heading
-
This is some additional paragraph placeholder content. It has been written to fill the available space and show how a longer snippet of text affects the surrounding content. We'll repeat it often to keep the demonstration flowing, so be on the lookout for this exact same string of text.
-
Sub-heading
-
This is some additional paragraph placeholder content. It has been written to fill the available space and show how a longer snippet of text affects the surrounding content. We'll repeat it often to keep the demonstration flowing, so be on the lookout for this exact same string of text.
-
Example code block
-
This is some additional paragraph placeholder content. It's a slightly shorter version of the other highly repetitive body text used throughout.
This is some additional paragraph placeholder content. It has been written to fill the available space and show how a longer snippet of text affects the surrounding content. We'll repeat it often to keep the demonstration flowing, so be on the lookout for this exact same string of text.
-
-
Longer quote goes here, maybe with some emphasized text in the middle of it.
-
-
This is some additional paragraph placeholder content. It has been written to fill the available space and show how a longer snippet of text affects the surrounding content. We'll repeat it often to keep the demonstration flowing, so be on the lookout for this exact same string of text.
-
Example table
-
And don't forget about tables in these posts:
-
-
-
-
Name
-
Upvotes
-
Downvotes
-
-
-
-
-
Alice
-
10
-
11
-
-
-
Bob
-
4
-
3
-
-
-
Charlie
-
7
-
9
-
-
-
-
-
Totals
-
21
-
23
-
-
-
-
-
This is some additional paragraph placeholder content. It's a slightly shorter version of the other highly repetitive body text used throughout.
This is some additional paragraph placeholder content. It has been written to fill the available space and show how a longer snippet of text affects the surrounding content. We'll repeat it often to keep the demonstration flowing, so be on the lookout for this exact same string of text.
-
-
First list item
-
Second list item with a longer description
-
Third list item to close it out
-
-
This is some additional paragraph placeholder content. It's a slightly shorter version of the other highly repetitive body text used throughout.
This blog post shows a few different types of content that’s supported and styled with Bootstrap. Basic typography, lists, tables, images, code, and more are all supported as expected.
This is some additional paragraph placeholder content. It has been written to fill the available space and show how a longer snippet of text affects the surrounding content. We'll repeat it often to keep the demonstration flowing, so be on the lookout for this exact same string of text.
Blockquotes
This is an example blockquote in action:
Quoted text goes here.
This is some additional paragraph placeholder content. It has been written to fill the available space and show how a longer snippet of text affects the surrounding content. We'll repeat it often to keep the demonstration flowing, so be on the lookout for this exact same string of text.
Example lists
This is some additional paragraph placeholder content. It's a slightly shorter version of the other highly repetitive body text used throughout. This is an example unordered list:
First list item
Second list item with a longer description
Third list item to close it out
And this is an ordered list:
First list item
Second list item with a longer description
Third list item to close it out
And this is a definition list:
HyperText Markup Language (HTML)
The language used to describe and define the content of a Web page
Cascading Style Sheets (CSS)
Used to describe the appearance of Web content
JavaScript (JS)
The programming language used to build advanced Web sites and applications
Inline HTML elements
HTML defines a long list of available inline tags, a complete list of which can be found on the Mozilla Developer Network.
To bold text, use <strong>.
To italicize text, use <em>.
Abbreviations, like HTML should use <abbr>, with an optional title attribute for the full phrase.
Citations, like — Mark Otto, should use <cite>.
Deleted text should use <del> and inserted text should use <ins>.
Superscript text uses <sup> and subscript text uses <sub>.
Most of these elements are styled by browsers with few modifications on our part.
Heading
This is some additional paragraph placeholder content. It has been written to fill the available space and show how a longer snippet of text affects the surrounding content. We'll repeat it often to keep the demonstration flowing, so be on the lookout for this exact same string of text.
Sub-heading
This is some additional paragraph placeholder content. It has been written to fill the available space and show how a longer snippet of text affects the surrounding content. We'll repeat it often to keep the demonstration flowing, so be on the lookout for this exact same string of text.
Example code block
This is some additional paragraph placeholder content. It's a slightly shorter version of the other highly repetitive body text used throughout.
This is some additional paragraph placeholder content. It has been written to fill the available space and show how a longer snippet of text affects the surrounding content. We'll repeat it often to keep the demonstration flowing, so be on the lookout for this exact same string of text.
Longer quote goes here, maybe with some emphasized text in the middle of it.
This is some additional paragraph placeholder content. It has been written to fill the available space and show how a longer snippet of text affects the surrounding content. We'll repeat it often to keep the demonstration flowing, so be on the lookout for this exact same string of text.
Example table
And don't forget about tables in these posts:
Name
Upvotes
Downvotes
Alice
10
11
Bob
4
3
Charlie
7
9
Totals
21
23
This is some additional paragraph placeholder content. It's a slightly shorter version of the other highly repetitive body text used throughout.
This is some additional paragraph placeholder content. It has been written to fill the available space and show how a longer snippet of text affects the surrounding content. We'll repeat it often to keep the demonstration flowing, so be on the lookout for this exact same string of text.
First list item
Second list item with a longer description
Third list item to close it out
This is some additional paragraph placeholder content. It's a slightly shorter version of the other highly repetitive body text used throughout.
حسب المجلس الثقافي البريطاني فإن تعليم الإنجليزية داخل بريطانيا يسهم في تعزيز اقتصادها بما يتجاوز ملياري جنيه سنوياً، كما أنه وفر أكثر من 26 ألف وظيفة.
الإحصاءات لحجم الاستثمار اللغوي خارج بريطانيا تتفاوت من سنة لأخرى إلا أن المدير التنفيذي للمجلس الثقافي البريطاني إدي بايرز يرى أن استثمار تعليم الإنجليزية في الخارج لا يحسب على المستوى المالي فحسب بل على المستوى السياسي أيضاً.
تذكر دائماً أن الحاسوب لا يمتلك ذكاءً، ولكنه يكتسب الذكاء الاصطناعي من خلال ثلاثة عناصر وظيفية رئيسة، هي: القدرة على التحليل، والقدرة على التأليف، والاستدلال المنطقي.
إذا أردنا استخدام الحاسوب الذكي في معالجة اللغة العربية فإننا نجد أنفسنا أمام تحدٍّ كبير، خاصة وأن لغتنا تمتاز بتماسك منظوماتها وتداخلها، ومع ذلك فإن الذكاء الاصطناعي يمكّننا من الحصول على أربعة أنواع من المعالجة، هي: المعالجة الصوتية، والمعالجة الصرفية، والمعالجة النحوية، والمعالجة الدلالية.
بفضل بحوث الذكاء الاصطناعي وتقنياته استطعنا الانتقال من مرحلة التعامل مع الفيزيائي إلى مرحلة التعامل مع المنطقي، وقد انعكس هذا الانتقال بصورة إيجابية على الكيفية التي تتعامل بها الشعوب مع لغاتها الحيَّة، وهذا يعني أنه يجب أن ينعكس بصورة إيجابية على كيفية تعاملنا مع لغتنا العربية.
وجه الإنسان هو جزء معقَّد ومتميِّز للغاية من جسمه. وفي الواقع، إنه أحد أكثر أنظمة الإشارات المتاحة تعقيداً لدينا؛ فهو يتضمَّن أكثر من 40 عضلة مستقلة هيكلياً ووظيفياً، بحيث يمكن تشغيل كل منها بشكل مستقل عن البعض الآخر؛ وتشكِّل أحد أقوى مؤشرات العواطف.
-
-
- Placeholder500x500
-
-
-
-
-
-
-
-
أوه نعم، هذا جيد. شاهد بنفسك.
-
عندما نضحك أو نبكي، فإننا نعرض عواطفنا، مما يسمح للآخرين بإلقاء نظرة خاطفة على أذهاننا أثناء "قراءة" وجوهنا بناءً على التغييرات في مكوّنات الوجه الرئيسة، مثل: العينين والحاجبين والجفنين والأنف والشفتين.
-
-
- Placeholder500x500
-
-
-
-
-
-
-
-
وأخيرًا، هذا. كش ملك.
-
إن جميع العضلات في أجسامنا مدعمة بالأعصاب المتصلة من كافة أنحاء الجسم بالنخاع الشوكي والدماغ. وهذا الاتصال العصبي هو ثنائي الاتجاه، أي إن العصب يتسبَّب في تقلصات العضلات بناءً على إشارات الدماغ، ويقوم في الوقت نفسه بإرسال معلومات عن حالة العضلات إلى الدماغ
حسب المجلس الثقافي البريطاني فإن تعليم الإنجليزية داخل بريطانيا يسهم في تعزيز اقتصادها بما يتجاوز ملياري جنيه سنوياً، كما أنه وفر أكثر من 26 ألف وظيفة.
الإحصاءات لحجم الاستثمار اللغوي خارج بريطانيا تتفاوت من سنة لأخرى إلا أن المدير التنفيذي للمجلس الثقافي البريطاني إدي بايرز يرى أن استثمار تعليم الإنجليزية في الخارج لا يحسب على المستوى المالي فحسب بل على المستوى السياسي أيضاً.
تذكر دائماً أن الحاسوب لا يمتلك ذكاءً، ولكنه يكتسب الذكاء الاصطناعي من خلال ثلاثة عناصر وظيفية رئيسة، هي: القدرة على التحليل، والقدرة على التأليف، والاستدلال المنطقي.
إذا أردنا استخدام الحاسوب الذكي في معالجة اللغة العربية فإننا نجد أنفسنا أمام تحدٍّ كبير، خاصة وأن لغتنا تمتاز بتماسك منظوماتها وتداخلها، ومع ذلك فإن الذكاء الاصطناعي يمكّننا من الحصول على أربعة أنواع من المعالجة، هي: المعالجة الصوتية، والمعالجة الصرفية، والمعالجة النحوية، والمعالجة الدلالية.
بفضل بحوث الذكاء الاصطناعي وتقنياته استطعنا الانتقال من مرحلة التعامل مع الفيزيائي إلى مرحلة التعامل مع المنطقي، وقد انعكس هذا الانتقال بصورة إيجابية على الكيفية التي تتعامل بها الشعوب مع لغاتها الحيَّة، وهذا يعني أنه يجب أن ينعكس بصورة إيجابية على كيفية تعاملنا مع لغتنا العربية.
وجه الإنسان هو جزء معقَّد ومتميِّز للغاية من جسمه. وفي الواقع، إنه أحد أكثر أنظمة الإشارات المتاحة تعقيداً لدينا؛ فهو يتضمَّن أكثر من 40 عضلة مستقلة هيكلياً ووظيفياً، بحيث يمكن تشغيل كل منها بشكل مستقل عن البعض الآخر؛ وتشكِّل أحد أقوى مؤشرات العواطف.
Placeholder500x500
أوه نعم، هذا جيد. شاهد بنفسك.
عندما نضحك أو نبكي، فإننا نعرض عواطفنا، مما يسمح للآخرين بإلقاء نظرة خاطفة على أذهاننا أثناء "قراءة" وجوهنا بناءً على التغييرات في مكوّنات الوجه الرئيسة، مثل: العينين والحاجبين والجفنين والأنف والشفتين.
Placeholder500x500
وأخيرًا، هذا. كش ملك.
إن جميع العضلات في أجسامنا مدعمة بالأعصاب المتصلة من كافة أنحاء الجسم بالنخاع الشوكي والدماغ. وهذا الاتصال العصبي هو ثنائي الاتجاه، أي إن العصب يتسبَّب في تقلصات العضلات بناءً على إشارات الدماغ، ويقوم في الوقت نفسه بإرسال معلومات عن حالة العضلات إلى الدماغ
Some great placeholder content for the first featurette here. Imagine some exciting prose here.
-
-
- Placeholder500x500
-
-
-
-
-
-
-
-
Oh yeah, it’s that good. See for yourself.
-
Another featurette? Of course. More placeholder content here to give you an idea of how this layout would work with some actual real-world content in place.
-
-
- Placeholder500x500
-
-
-
-
-
-
-
-
And lastly, this one. Checkmate.
-
And yes, this is the last block of representative placeholder content. Again, not really intended to be actually read, simply here to give you a better view of what this would look like with some actual content. Your content.
Some great placeholder content for the first featurette here. Imagine some exciting prose here.
Placeholder500x500
Oh yeah, it’s that good. See for yourself.
Another featurette? Of course. More placeholder content here to give you an idea of how this layout would work with some actual real-world content in place.
Placeholder500x500
And lastly, this one. Checkmate.
And yes, this is the last block of representative placeholder content. Again, not really intended to be actually read, simply here to give you a better view of what this would look like with some actual content. Your content.
تنبيه primary بسيط مع رابط مثال. أعطها نقرة إذا أردت.
+
+
تنبيه secondary بسيط مع رابط مثال. أعطها نقرة إذا أردت.
+
+
تنبيه success بسيط مع رابط مثال. أعطها نقرة إذا أردت.
+
+
تنبيه danger بسيط مع رابط مثال. أعطها نقرة إذا أردت.
+
+
تنبيه warning بسيط مع رابط مثال. أعطها نقرة إذا أردت.
+
+
تنبيه info بسيط مع رابط مثال. أعطها نقرة إذا أردت.
+
+
تنبيه light بسيط مع رابط مثال. أعطها نقرة إذا أردت.
+
+
تنبيه dark بسيط مع رابط مثال. أعطها نقرة إذا أردت.
-
-
-
-
-
-
-
-
+
أحسنت!
لقد نجحت في قراءة رسالة التنبيه المهمة هذه. سيتم تشغيل نص المثال هذا لفترة أطول قليلاً حتى تتمكن من رؤية كيفية عمل التباعد داخل التنبيه مع هذا النوع من المحتوى.
كلما احتجت إلى ذلك ، تأكد من استخدام أدوات الهامش للحفاظ على الأشياء لطيفة ومرتبة.
محتوى لتوضيح كيف يعمل التبويب. هذا المحتوى مرتبط بتبويب الاتصال بنا. أمامنا بعض التحدّيات الصعبة. لكن لا يمكننا أن نعتمد على التطورات التكنولوجية وحدها في ميدان قوى السوق الحرة، بل يجب وضع معايير جدوى جديدة لشركات البناء ومعايير أعلى لجدوى التكييف من أجل تحفيز الحلول المستدامة قانونيًا.
محتوى لتوضيح كيف تعمل المخطوطة. ببساطة، المخطوطة عبارة عن منشور طويل يحتوي على عدة أقسام، ولديه شريط تنقل يسهل الوصول إلى هذه الأقسام الفرعية.
-
@mdo
-
بصرف النظر عن تحسيننا جدوى المكيّفات أو عدم تحسينها، فإن الطلب على الطاقة سيزداد. وطبقاً لما جاء في مقالة معهد ماساشوستس للتكنولوجيا، السالف ذكره، ثمَّة أمر يجب عدم إغفاله، وهو كيف أن هذا الطلب سيضغط على نظم توفير الطاقة الحالية. إذ لا بد من إعادة تأهيل كل شبكات الكهرباء، وتوسيعها لتلبية طلب الطاقة في زمن الذروة، خلال موجات الحرارة المتزايدة. فحين يكون الحر شديداً يجنح الناس إلى البقاء في الداخل، وإلى زيادة تشغيل المكيّفات، سعياً إلى جو لطيف وهم يستخدمون أدوات وأجهزة مختلفة أخرى.
-
واحد
-
وكل هذه الأمور المتزامنة من تشغيل الأجهزة، يزيد الضغط على شبكات الطاقة، كما أسلفنا. لكن مجرد زيادة سعة الشبكة ليس كافياً. إذ لا بد من تطوير الشبكات الذكية التي تستخدم الجسّاسات، ونظم المراقبة، والبرامج الإلكترونية، لتحديد متى يكون الشاغلون في المبنى، ومتى يكون ثمَّة حاجة إلى الطاقة، ومتى تكون الحرارة منخفضة، وبذلك يخرج الناس، فلا يستخدمون كثيراً من الكهرباء.
-
اثنان
-
مع الأسف، كل هذه الحلول المبتكرة مكلِّفة، وهذا ما يجعلها عديمة الجدوى في نظر بعض الشركات الخاصة والمواطن المتقشّف. إن بعض الأفراد الواعين بيئياً يبذلون قصارى جهدهم في تقليص استهلاكهم من الطاقة، ويعون جيداً أهمية أجهزة التكييف المجدية والأرفق بالبيئة. ولكن جهات كثيرة لن تتحرّك لمجرد حافز سلامة المناخ ووقف هدر الطاقة، ما دامت لا تحركها حوافز قانونية. وعلى الحكومات أن تُقدِم عند الاهتمام بالتغيّر المناخي، على وضع التشريعات المناسبة. فبالنظم والحوافز والدعم، يمكن دفع الشركات إلى اعتماد الحلول الأجدى في مكاتبها.
-
ثلاثة
-
وكما يتبيّن لنا، من عدد الحلول الملطِّفة للمشكلة، ومن تنوّعها، وهي الحلول التي أسلفنا الحديث عنها، فإن التكنولوجيا التي نحتاج إليها من أجل معالجة هذه التحديات، هي في مدى قدرتنا، لكنها ربما تتطلّب بعض التحسين، ودعماً استثمارياً أكبر!
محتوى لتوضيح كيف تعمل المخطوطة. ببساطة، المخطوطة عبارة عن منشور طويل يحتوي على عدة أقسام، ولديه شريط تنقل يسهل الوصول إلى هذه الأقسام الفرعية.
@mdo
بصرف النظر عن تحسيننا جدوى المكيّفات أو عدم تحسينها، فإن الطلب على الطاقة سيزداد. وطبقاً لما جاء في مقالة معهد ماساشوستس للتكنولوجيا، السالف ذكره، ثمَّة أمر يجب عدم إغفاله، وهو كيف أن هذا الطلب سيضغط على نظم توفير الطاقة الحالية. إذ لا بد من إعادة تأهيل كل شبكات الكهرباء، وتوسيعها لتلبية طلب الطاقة في زمن الذروة، خلال موجات الحرارة المتزايدة. فحين يكون الحر شديداً يجنح الناس إلى البقاء في الداخل، وإلى زيادة تشغيل المكيّفات، سعياً إلى جو لطيف وهم يستخدمون أدوات وأجهزة مختلفة أخرى.
واحد
وكل هذه الأمور المتزامنة من تشغيل الأجهزة، يزيد الضغط على شبكات الطاقة، كما أسلفنا. لكن مجرد زيادة سعة الشبكة ليس كافياً. إذ لا بد من تطوير الشبكات الذكية التي تستخدم الجسّاسات، ونظم المراقبة، والبرامج الإلكترونية، لتحديد متى يكون الشاغلون في المبنى، ومتى يكون ثمَّة حاجة إلى الطاقة، ومتى تكون الحرارة منخفضة، وبذلك يخرج الناس، فلا يستخدمون كثيراً من الكهرباء.
اثنان
مع الأسف، كل هذه الحلول المبتكرة مكلِّفة، وهذا ما يجعلها عديمة الجدوى في نظر بعض الشركات الخاصة والمواطن المتقشّف. إن بعض الأفراد الواعين بيئياً يبذلون قصارى جهدهم في تقليص استهلاكهم من الطاقة، ويعون جيداً أهمية أجهزة التكييف المجدية والأرفق بالبيئة. ولكن جهات كثيرة لن تتحرّك لمجرد حافز سلامة المناخ ووقف هدر الطاقة، ما دامت لا تحركها حوافز قانونية. وعلى الحكومات أن تُقدِم عند الاهتمام بالتغيّر المناخي، على وضع التشريعات المناسبة. فبالنظم والحوافز والدعم، يمكن دفع الشركات إلى اعتماد الحلول الأجدى في مكاتبها.
ثلاثة
وكما يتبيّن لنا، من عدد الحلول الملطِّفة للمشكلة، ومن تنوّعها، وهي الحلول التي أسلفنا الحديث عنها، فإن التكنولوجيا التي نحتاج إليها من أجل معالجة هذه التحديات، هي في مدى قدرتنا، لكنها ربما تتطلّب بعض التحسين، ودعماً استثمارياً أكبر!
تلميح يظهر في الأعلىتلميح يظهر على اليسارتلميح يظهر في الأسفلتلميح يظهر على اليمينتلميح مع HTML
-
-
-
-
-
-
-
-
-
-
-
-
-
-
عنوان الصندوق العائم
-
-
-
- ...
-
-
-
-
-
-
-
-
-
-
عنوان الصندوق العائم
-
-
-
-
لن أغلق إذا نقرت خارجي. لا تحاول حتى الضغط على مفتاح الهروب.
-
-
-
-
-
-
-
-
-
-
عنوان الصندوق العائم
-
-
-
-
نص لتوضيح عمل الصندوق العائم المتنصّف عاموديًا القابل للتمرير
-
في هذه الحالة، هذا الصندوق يحتوي على محتوى أكثر قليلًا، ولذلك لتوضيح كيف يمكن إضافة خاصية الإنتصاف العامودي لصندوق عائم قابل للتمرير.
-
يعتبر كوب أو فنجان القهوة عادة يومية عند غالبية سكان الكرة الأرضية في الصباح والمساء، وفي حين تكثر الدراسات حول إيجابياتها هناك أيضا سلبيات كثيرة للمشروب المفضل للكثيرين.
-
وفي هذا الشأن، أظهرت دراسة جديدة أن تناول الكافيين بانتظام يقلل من حجم المادة الرمادية في الدماغ، مما يشير إلى أن تناول القهوة يمكن أن يضعف القدرة على معالجة المعلومات، وفقاً لما نشرته "ديلي ميل" البريطانية.
-
وأعطى باحثون سويسريون متطوعين ثلاث حصص من الكافيين 150 ملغم يوميًا لمدة 10 أيام - وهو مقدار كافيين يعادل حوالي أربعة أو خمسة أكواب صغيرة من القهوة المخمرة يوميًا، أو سبعة إسبريسو فردي.
-
وتبين حدوث انخفاض في المادة الرمادية، والتي توجد غالبًا في الطبقة الخارجية للدماغ، أو القشرة، وتعمل على معالجة المعلومات.
-
كما كان الانخفاض مذهلاً بشكل خاص في الفص الصدغي الإنسي الأيمن، بما في ذلك الحُصين، وهي منطقة من الدماغ ضرورية لتقوية الذاكرة.
-
-
-
-
-
-
-
-
-
-
صندوق عائم يملأ الشاشة
-
-
-
-
في ما يلي، نص طويل لتعبئة كامل الشاشة. قد يبدو أنني أثرثر كثيرًا، لذا سأقوم بنسخ مقالة من إحدى الصحف العربية.
-
تكييف الهواء هو من التكنولوجيا التي ما إن نمتلكها حتى نصبح عاجزين عن تخيّل العيش من دونها. وتكييف الهواء في مناطق عديدة من العالم ليس ترفاً يمكن الاستغناء عنه. ولكن هذه الحاجة الحيوية تثير تحديات كبيرة على مستوى استهلاك الطاقة في معظم بلدان العالم. ويُتوقع أن تتفاقم هذه التحديات خلال العقود الثلاثة المقبلة، مع توقُّع ارتفاع عدد المكيفات في العالم نحو ثلاثة أضعاف. وفي حين أن الابتكارات التكنولوجية تحقِّق كل يوم إنجازاً جديداً، وعلى الرغم من بعض التحسينات والتدابير المحدودة التي طرأت على صناعة المكيفات، “فإن تكنولوجيتها الأساسية لا تزال تعمل كما كانت، منذ اعتمادها قبل نحو قرن من السنين"، حسبما جاء في تقرير لمعهد ماساشوستس للتكنولوجيا (MIT)، في الأول من سبتمبر 2020م. ولمعالجة هذه المشكلات الخطيرة، لا مفر من إعادة التفكير بجد.
-
التكييف حاجة حيويّة. فالتعرّض للحرارة لمدة طويلة ضارٌ بالصحة. ووفقاً لمنظمة الصحة العالميّة يمكن للتعرُّض الطويل للحرارة أيضاً أن يؤدي إلى "إعياء حراري، وضربة شمس، وتورّم في الرجلين، وطفح جلدي على العنق، وتشنج، وصداع، وحساسيّة، والخمول والوهَن. ويمكن للحرارة أن تسبِّب جفافاً خطراً، وأعراضاً حادة في أوعية الدماغ الدمويّة، وتسهم في تكوّن الجلطات".
-
وموجات الحر أيضاً من أشد المخاطر الطبيعيّة المميتة. إذ يقدَّر أن بين عامي 1998 و2017م، توفي نحو 166 ألف شخص من موجات الحر. ومات 70 ألفاً من هؤلاء في أوروبا سنة 2003م وحدها. ومن دون أن يصل الخطر إلى الموت، تتسبَّب الحرارة العالية بانخفاض الأداء المعرفي لدى الشبان البالغين في المباني غير المكيّفة. فقد بيّنت دراسة أجرتها "كليّة ت. هـ. تشان" للصحة العامة في جامعة هارفرد، نشرتها "بلوس ميديسين" في 10 يوليو 2018م، أن التلاميذ الذين ينامون في مهاجع غير مكيّفة، يقل أداؤهم عن أولئك الذين ينامون في مهاجع مكيّفة. ولتجنّب مخاطر التعرّض للحرارة، يلتفت الناس إلى استخدام التكييف.
-
يتطلّب التكييف كثيراً من الطاقة. فنحو %10 من استهلاك الكهرباء في العالم يُنفَق في تشغيل المكيّفات. وتصل هذه النسبة إلى %50 في المملكة حسب "المركز السعودي لكفاءة الطاقة". أضف إلى ذلك أن معظم البشر في بلدان العالم النامي، لم يقتنوا بعد مكيّفهم الأول، والمشكلة إلى ازدياد. فمعظم البلدان النامية هي من البلدان الأشد حرارة والأكثر اكتظاظاً بالسكان في العالم. وجاء في تقرير لوكالة الطاقة الدوليّة بعنوان "مستقبل التبريد"، ونُشر في مايو 2018م، أن في أجزاء من أمريكا الجنوبيّة وإفريقيا وآسيا والشرق الأوسط، يعيش 2.8 مليار نسمة، ولا يملك وحدات تكييف سوى %8 من المنازل. في حين الدول المتقدِّمة مثل كوريا الجنوبيّة، واليابان، والولايات المتحدة، فإن %89 من المنازل تملك مكيفات، وفي الصين %60 من البيوت تملكها أيضاً.
-
ولكن مع تنامي الدخل في بلدان الاقتصاد الصاعد، يتوقّع أن تزداد المنازل التي تقتني مكيّفاً. وبحسب مقالة نُشرت في صحيفة "نيويورك تايمز"، في 15 مايو 2018م، سيرتفع عدد المكيّفات في العالم من نحو 1.6 مليار حالياً، إلى 5.6 مليارات عام 2050م، طبقاً لمعدَّلات النمو الاقتصادي.
-
ومع الافتقار إلى الابتكار وتطوير النظم لفرض معايير الجدوى الأعلى، فسيتضاعف استهلاك الطاقة لتشغيل المكيّفات ثلاثة أضعاف. وسينتج من ذلك طلب إضافي للطاقة يساوي مجموع إنتاج الطاقة في الصين حالياً. فمبيعات المكيّفات ترتفع اليوم في البلدان النامية، لكن فعاليّة هذه الوحدات مشكوك فيها. فمثلاً، أوسع وحدات التكييف انتشاراً في بعض الأسواق الآسيوية تتطلّب ضعفي ما تتطلّبه وحدات تكييف أجدى. والمكيّفات التي تباع في اليابان والاتحاد الأوروبي أجدى بنسبة %25 عادة، من تلك التي تباع في الصين والولايات المتحدة.
-
وبصرف النظر عن كثير من الطاقة التي يحتاج إليها المكيّف، فإنه يبث مقادير وفيرة من غازات الدفيئة نفسها. وطبقاً لموقع تكييف الهواء (airconditioning.com)، فإن المبرِّدات في معظم المكيّفات مثل مواد مركبات الكربون الكلورية فلورية أو مواد هيدروفلوروولفينات، ومركبات ثاني أكسيد الكربون الهيدروكلورية فلورية، أسوأ بكثير للبيئة من ثاني أكسيد الكربون، لأنها تحتبس من الحرارة مقادير أكبر حين تتسرّب إلى الجو.
-
وبالإضافة إلى ظاهرة الدفيئة، فهذه الغازات تسهم أيضاً بالإضرار بطبقة الأوزون. ويمكن لهذه المواد الكيميائية أن تتسرّب خلال عملية التصنيع أو التصليح. ويعرف كل من يملك في منزله مكيّفاً كم تتكرر أعطال هذه الأجهزة. ثم إن المكيف يُرمَى حين يتعطّل نهائياً ولا يعود قابلاً للإصلاح، والمواد المبرِّدة فيه ستتسرّب على الأرجح لتلوث الهواء.
-
-
-
-
-
-
-
-
-
+
عنوان الصندوق العائم
+...
+
عنوان الصندوق العائم
لن أغلق إذا نقرت خارجي. لا تحاول حتى الضغط على مفتاح الهروب.
عنوان الصندوق العائم
نص لتوضيح عمل الصندوق العائم المتنصّف عاموديًا القابل للتمرير
في هذه الحالة، هذا الصندوق يحتوي على محتوى أكثر قليلًا، ولذلك لتوضيح كيف يمكن إضافة خاصية الإنتصاف العامودي لصندوق عائم قابل للتمرير.
يعتبر كوب أو فنجان القهوة عادة يومية عند غالبية سكان الكرة الأرضية في الصباح والمساء، وفي حين تكثر الدراسات حول إيجابياتها هناك أيضا سلبيات كثيرة للمشروب المفضل للكثيرين.
وفي هذا الشأن، أظهرت دراسة جديدة أن تناول الكافيين بانتظام يقلل من حجم المادة الرمادية في الدماغ، مما يشير إلى أن تناول القهوة يمكن أن يضعف القدرة على معالجة المعلومات، وفقاً لما نشرته "ديلي ميل" البريطانية.
وأعطى باحثون سويسريون متطوعين ثلاث حصص من الكافيين 150 ملغم يوميًا لمدة 10 أيام - وهو مقدار كافيين يعادل حوالي أربعة أو خمسة أكواب صغيرة من القهوة المخمرة يوميًا، أو سبعة إسبريسو فردي.
وتبين حدوث انخفاض في المادة الرمادية، والتي توجد غالبًا في الطبقة الخارجية للدماغ، أو القشرة، وتعمل على معالجة المعلومات.
كما كان الانخفاض مذهلاً بشكل خاص في الفص الصدغي الإنسي الأيمن، بما في ذلك الحُصين، وهي منطقة من الدماغ ضرورية لتقوية الذاكرة.
صندوق عائم يملأ الشاشة
في ما يلي، نص طويل لتعبئة كامل الشاشة. قد يبدو أنني أثرثر كثيرًا، لذا سأقوم بنسخ مقالة من إحدى الصحف العربية.
تكييف الهواء هو من التكنولوجيا التي ما إن نمتلكها حتى نصبح عاجزين عن تخيّل العيش من دونها. وتكييف الهواء في مناطق عديدة من العالم ليس ترفاً يمكن الاستغناء عنه. ولكن هذه الحاجة الحيوية تثير تحديات كبيرة على مستوى استهلاك الطاقة في معظم بلدان العالم. ويُتوقع أن تتفاقم هذه التحديات خلال العقود الثلاثة المقبلة، مع توقُّع ارتفاع عدد المكيفات في العالم نحو ثلاثة أضعاف. وفي حين أن الابتكارات التكنولوجية تحقِّق كل يوم إنجازاً جديداً، وعلى الرغم من بعض التحسينات والتدابير المحدودة التي طرأت على صناعة المكيفات، “فإن تكنولوجيتها الأساسية لا تزال تعمل كما كانت، منذ اعتمادها قبل نحو قرن من السنين"، حسبما جاء في تقرير لمعهد ماساشوستس للتكنولوجيا (MIT)، في الأول من سبتمبر 2020م. ولمعالجة هذه المشكلات الخطيرة، لا مفر من إعادة التفكير بجد.
التكييف حاجة حيويّة. فالتعرّض للحرارة لمدة طويلة ضارٌ بالصحة. ووفقاً لمنظمة الصحة العالميّة يمكن للتعرُّض الطويل للحرارة أيضاً أن يؤدي إلى "إعياء حراري، وضربة شمس، وتورّم في الرجلين، وطفح جلدي على العنق، وتشنج، وصداع، وحساسيّة، والخمول والوهَن. ويمكن للحرارة أن تسبِّب جفافاً خطراً، وأعراضاً حادة في أوعية الدماغ الدمويّة، وتسهم في تكوّن الجلطات".
وموجات الحر أيضاً من أشد المخاطر الطبيعيّة المميتة. إذ يقدَّر أن بين عامي 1998 و2017م، توفي نحو 166 ألف شخص من موجات الحر. ومات 70 ألفاً من هؤلاء في أوروبا سنة 2003م وحدها. ومن دون أن يصل الخطر إلى الموت، تتسبَّب الحرارة العالية بانخفاض الأداء المعرفي لدى الشبان البالغين في المباني غير المكيّفة. فقد بيّنت دراسة أجرتها "كليّة ت. هـ. تشان" للصحة العامة في جامعة هارفرد، نشرتها "بلوس ميديسين" في 10 يوليو 2018م، أن التلاميذ الذين ينامون في مهاجع غير مكيّفة، يقل أداؤهم عن أولئك الذين ينامون في مهاجع مكيّفة. ولتجنّب مخاطر التعرّض للحرارة، يلتفت الناس إلى استخدام التكييف.
يتطلّب التكييف كثيراً من الطاقة. فنحو %10 من استهلاك الكهرباء في العالم يُنفَق في تشغيل المكيّفات. وتصل هذه النسبة إلى %50 في المملكة حسب "المركز السعودي لكفاءة الطاقة". أضف إلى ذلك أن معظم البشر في بلدان العالم النامي، لم يقتنوا بعد مكيّفهم الأول، والمشكلة إلى ازدياد. فمعظم البلدان النامية هي من البلدان الأشد حرارة والأكثر اكتظاظاً بالسكان في العالم. وجاء في تقرير لوكالة الطاقة الدوليّة بعنوان "مستقبل التبريد"، ونُشر في مايو 2018م، أن في أجزاء من أمريكا الجنوبيّة وإفريقيا وآسيا والشرق الأوسط، يعيش 2.8 مليار نسمة، ولا يملك وحدات تكييف سوى %8 من المنازل. في حين الدول المتقدِّمة مثل كوريا الجنوبيّة، واليابان، والولايات المتحدة، فإن %89 من المنازل تملك مكيفات، وفي الصين %60 من البيوت تملكها أيضاً.
ولكن مع تنامي الدخل في بلدان الاقتصاد الصاعد، يتوقّع أن تزداد المنازل التي تقتني مكيّفاً. وبحسب مقالة نُشرت في صحيفة "نيويورك تايمز"، في 15 مايو 2018م، سيرتفع عدد المكيّفات في العالم من نحو 1.6 مليار حالياً، إلى 5.6 مليارات عام 2050م، طبقاً لمعدَّلات النمو الاقتصادي.
ومع الافتقار إلى الابتكار وتطوير النظم لفرض معايير الجدوى الأعلى، فسيتضاعف استهلاك الطاقة لتشغيل المكيّفات ثلاثة أضعاف. وسينتج من ذلك طلب إضافي للطاقة يساوي مجموع إنتاج الطاقة في الصين حالياً. فمبيعات المكيّفات ترتفع اليوم في البلدان النامية، لكن فعاليّة هذه الوحدات مشكوك فيها. فمثلاً، أوسع وحدات التكييف انتشاراً في بعض الأسواق الآسيوية تتطلّب ضعفي ما تتطلّبه وحدات تكييف أجدى. والمكيّفات التي تباع في اليابان والاتحاد الأوروبي أجدى بنسبة %25 عادة، من تلك التي تباع في الصين والولايات المتحدة.
وبصرف النظر عن كثير من الطاقة التي يحتاج إليها المكيّف، فإنه يبث مقادير وفيرة من غازات الدفيئة نفسها. وطبقاً لموقع تكييف الهواء (airconditioning.com)، فإن المبرِّدات في معظم المكيّفات مثل مواد مركبات الكربون الكلورية فلورية أو مواد هيدروفلوروولفينات، ومركبات ثاني أكسيد الكربون الهيدروكلورية فلورية، أسوأ بكثير للبيئة من ثاني أكسيد الكربون، لأنها تحتبس من الحرارة مقادير أكبر حين تتسرّب إلى الجو.
وبالإضافة إلى ظاهرة الدفيئة، فهذه الغازات تسهم أيضاً بالإضرار بطبقة الأوزون. ويمكن لهذه المواد الكيميائية أن تتسرّب خلال عملية التصنيع أو التصليح. ويعرف كل من يملك في منزله مكيّفاً كم تتكرر أعطال هذه الأجهزة. ثم إن المكيف يُرمَى حين يتعطّل نهائياً ولا يعود قابلاً للإصلاح، والمواد المبرِّدة فيه ستتسرّب على الأرجح لتلوث الهواء.
A simple primary alert with an example link. Give it a click if you like.
+
+
A simple secondary alert with an example link. Give it a click if you like.
+
+
A simple success alert with an example link. Give it a click if you like.
+
+
A simple danger alert with an example link. Give it a click if you like.
+
+
A simple warning alert with an example link. Give it a click if you like.
+
+
A simple info alert with an example link. Give it a click if you like.
+
+
A simple light alert with an example link. Give it a click if you like.
+
+
A simple dark alert with an example link. Give it a click if you like.
-
-
-
-
-
-
-
-
+
Well done!
Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.
Whenever you need to, be sure to use margin utilities to keep things nice and tidy.
This is some placeholder content the Contact tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Second heading
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Third heading
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Fourth heading
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
-
Fifth heading
-
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Second heading
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Third heading
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Fourth heading
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Fifth heading
This is some placeholder content for the scrollspy page. Note that as you scroll down the page, the appropriate navigation link is highlighted. It's repeated throughout the component example. We keep adding some more example copy here to emphasize the scrolling and highlighting.
Tooltip on topTooltip on endTooltip on bottomTooltip on startTooltip with HTML
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Modal title
-
-
-
- ...
-
-
-
-
-
-
-
-
-
-
Modal title
-
-
-
-
I will not close if you click outside me. Don't even try to press escape key.
-
-
-
-
-
-
-
-
-
-
Modal title
-
-
-
-
This is some placeholder content to show the scrolling behavior for modals. We use repeated line breaks to demonstrate how content can exceed minimum inner height, thereby showing inner scrolling. When content becomes longer than the predefined max-height of modal, content will be cropped and scrollable within the modal.
-
-
This content should appear at the bottom after you scroll.
-
-
-
-
-
-
-
-
-
-
Full screen modal
-
-
-
- ...
-
-
-
-
-
-
-
-
-
+
Modal title
+...
+
Modal title
I will not close if you click outside me. Don't even try to press escape key.
Modal title
This is some placeholder content to show the scrolling behavior for modals. We use repeated line breaks to demonstrate how content can exceed minimum inner height, thereby showing inner scrolling. When content becomes longer than the predefined max-height of modal, content will be cropped and scrollable within the modal.
This content should appear at the bottom after you scroll.
فيما يلي مثال على نموذج تم إنشاؤه بالكامل باستخدام عناصر تحكم النموذج في Bootstrap. لكل مجموعة نماذج مطلوبة حالة تحقق يمكن تشغيلها بمحاولة إرسال النموذج دون استكماله.
-
-
-
-
-
- عربة التسوق
- 3
-
-
-
-
-
اسم المنتج
- وصف مختصر
-
- $12
-
-
-
-
المنتج الثاني
- وصف مختصر
-
- $8
-
-
-
-
البند الثالث
- وصف مختصر
-
- $5
-
-
-
-
رمز ترويجي
- EXAMPLECODE
-
- -$5
-
-
- مجموع (USD)
- $20
-
-
-
-
-
-
-
عنوان الفوترة
-
-
-
-
-
-
-
-
-
-
+ مثال إتمام الشراء · Bootstrap v5.3
Toggle theme
+Light
+
+Dark
+
+Auto
+
نموذج إتمام الشراء
فيما يلي مثال على نموذج تم إنشاؤه بالكامل باستخدام عناصر تحكم النموذج في Bootstrap. لكل مجموعة نماذج مطلوبة حالة تحقق يمكن تشغيلها بمحاولة إرسال النموذج دون استكماله.
Below is an example form built entirely with Bootstrap’s form controls. Each required form group has a validation state that can be triggered by attempting to submit the form without completing it.
-
-
-
-
-
- Your cart
- 3
-
-
-
-
-
Product name
- Brief description
-
- $12
-
-
-
-
Second product
- Brief description
-
- $8
-
-
-
-
Third item
- Brief description
-
- $5
-
-
-
-
Promo code
- EXAMPLECODE
-
- −$5
-
-
- Total (USD)
- $20
-
-
-
-
-
-
-
Billing address
-
-
-
-
-
-
-
-
-
-
-
+ Checkout example · Bootstrap v5.3
Toggle theme
+Light
+
+Dark
+
+Auto
+
Checkout form
Below is an example form built entirely with Bootstrap’s form controls. Each required form group has a validation state that can be triggered by attempting to submit the form without completing it.
Cover is a one-page template for building simple and beautiful home pages. Download, edit the text, and add your own fullscreen background photo to make it your own.
Cover is a one-page template for building simple and beautiful home pages. Download, edit the text, and add your own fullscreen background photo to make it your own.
Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words.
Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words.
Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words.
Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words.
Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words.
Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words.
Paragraph of text beneath the heading to explain the heading.
-
-
-
-
-
-
Featured title
-
Paragraph of text beneath the heading to explain the heading.
-
-
-
-
-
-
Featured title
-
Paragraph of text beneath the heading to explain the heading.
-
-
-
-
-
-
Featured title
-
Paragraph of text beneath the heading to explain the heading.
-
-
-
-
-
-
Featured title
-
Paragraph of text beneath the heading to explain the heading.
-
-
-
-
-
-
Featured title
-
Paragraph of text beneath the heading to explain the heading.
-
-
-
-
-
-
Featured title
-
Paragraph of text beneath the heading to explain the heading.
-
-
-
-
-
-
Featured title
-
Paragraph of text beneath the heading to explain the heading.
-
-
-
-
-
-
-
-
-
Features with title
-
-
-
-
Left-aligned title explaining these awesome features
-
Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words.
Paragraph of text beneath the heading to explain the heading.
-
-
-
-
-
-
-
-
-
Featured title
-
Paragraph of text beneath the heading to explain the heading.
-
-
-
-
-
-
-
-
-
Featured title
-
Paragraph of text beneath the heading to explain the heading.
-
-
-
-
-
-
-
-
-
Featured title
-
Paragraph of text beneath the heading to explain the heading.
-
-
-
-
-
-
-
-
-
-
+ Features · Bootstrap v5.3
Toggle theme
+Light
+
+Dark
+
+Auto
+
Bootstrap
Features examples
Columns with icons
Featured title
Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words.
Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words.
Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words.
Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words.
Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words.
Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words.
Paragraph of text beneath the heading to explain the heading.
Featured title
Paragraph of text beneath the heading to explain the heading.
Featured title
Paragraph of text beneath the heading to explain the heading.
Featured title
Paragraph of text beneath the heading to explain the heading.
Featured title
Paragraph of text beneath the heading to explain the heading.
Featured title
Paragraph of text beneath the heading to explain the heading.
Featured title
Paragraph of text beneath the heading to explain the heading.
Featured title
Paragraph of text beneath the heading to explain the heading.
Features with title
Left-aligned title explaining these awesome features
Paragraph of text beneath the heading to explain the heading. We'll add onto it with another sentence and probably just keep going until we run out of words.
Basic grid layouts to get you familiar with building within the Bootstrap grid system.
-
In these examples the .themed-grid-col class is added to the columns to add some theming. This is not a class that is available in Bootstrap by default.
-
-
Five grid tiers
-
There are five tiers to the Bootstrap grid system, one for each range of devices we support. Each tier starts at a minimum viewport size and automatically applies to the larger devices unless overridden.
-
-
-
.col-4
-
.col-4
-
.col-4
-
-
-
-
.col-sm-4
-
.col-sm-4
-
.col-sm-4
-
-
-
-
.col-md-4
-
.col-md-4
-
.col-md-4
-
-
-
-
.col-lg-4
-
.col-lg-4
-
.col-lg-4
-
-
-
-
.col-xl-4
-
.col-xl-4
-
.col-xl-4
-
-
-
-
.col-xxl-4
-
.col-xxl-4
-
.col-xxl-4
-
-
-
Three equal columns
-
Get three equal-width columns starting at desktops and scaling to large desktops. On mobile devices, tablets and below, the columns will automatically stack.
-
-
.col-md-4
-
.col-md-4
-
.col-md-4
-
-
-
Three equal columns alternative
-
By using the .row-cols-* classes, you can easily create a grid with equal columns.
-
-
.col child of .row-cols-md-3
-
.col child of .row-cols-md-3
-
.col child of .row-cols-md-3
-
-
-
Three unequal columns
-
Get three columns starting at desktops and scaling to large desktops of various widths. Remember, grid columns should add up to twelve for a single horizontal block. More than that, and columns start stacking no matter the viewport.
-
-
.col-md-3
-
.col-md-6
-
.col-md-3
-
-
-
Two columns
-
Get two columns starting at desktops and scaling to large desktops.
-
-
.col-md-8
-
.col-md-4
-
-
-
Full width, single column
-
- No grid classes are necessary for full-width elements.
-
-
-
-
-
Two columns with two nested columns
-
Per the documentation, nesting is easy—just put a row of columns within an existing column. This gives you two columns starting at desktops and scaling to large desktops, with another two (equal widths) within the larger column.
-
At mobile device sizes, tablets and down, these columns and their nested columns will stack.
-
-
-
- .col-md-8
-
-
-
.col-md-6
-
.col-md-6
-
-
-
.col-md-4
-
-
-
-
-
Mixed: mobile and desktop
-
The Bootstrap v5 grid system has six tiers of classes: xs (extra small, this class infix is not used), sm (small), md (medium), lg (large), xl (x-large), and xxl (xx-large). You can use nearly any combination of these classes to create more dynamic and flexible layouts.
-
Each tier of classes scales up, meaning if you plan on setting the same widths for md, lg, xl and xxl, you only need to specify md.
-
-
.col-md-8
-
.col-6 .col-md-4
-
-
-
.col-6 .col-md-4
-
.col-6 .col-md-4
-
.col-6 .col-md-4
-
-
-
.col-6
-
.col-6
-
-
-
-
-
Mixed: mobile, tablet, and desktop
-
-
.col-sm-6 .col-lg-8
-
.col-6 .col-lg-4
-
-
-
.col-6 .col-sm-4
-
.col-6 .col-sm-4
-
.col-6 .col-sm-4
-
-
-
-
-
Gutters
-
With .gx-* classes, the horizontal gutters can be adjusted.
-
-
.col with .gx-4 gutters
-
.col with .gx-4 gutters
-
.col with .gx-4 gutters
-
.col with .gx-4 gutters
-
.col with .gx-4 gutters
-
.col with .gx-4 gutters
-
-
Use the .gy-* classes to control the vertical gutters.
-
-
.col with .gy-4 gutters
-
.col with .gy-4 gutters
-
.col with .gy-4 gutters
-
.col with .gy-4 gutters
-
.col with .gy-4 gutters
-
.col with .gy-4 gutters
-
-
With .g-* classes, the gutters in both directions can be adjusted.
-
-
.col with .g-3 gutters
-
.col with .g-3 gutters
-
.col with .g-3 gutters
-
.col with .g-3 gutters
-
.col with .g-3 gutters
-
.col with .g-3 gutters
-
-
-
-
-
-
-
Containers
-
Additional classes added in Bootstrap v4.4 allow containers that are 100% wide until a particular breakpoint. v5 adds a new xxl breakpoint.
-
-
-
.container
-
.container-sm
-
.container-md
-
.container-lg
-
.container-xl
-
.container-xxl
-
.container-fluid
-
-
-
-
-
+ Grid Template · Bootstrap v5.3
Toggle theme
+Light
+
+Dark
+
+Auto
+
Bootstrap grid examples
Basic grid layouts to get you familiar with building within the Bootstrap grid system.
In these examples the .themed-grid-col class is added to the columns to add some theming. This is not a class that is available in Bootstrap by default.
Five grid tiers
There are five tiers to the Bootstrap grid system, one for each range of devices we support. Each tier starts at a minimum viewport size and automatically applies to the larger devices unless overridden.
.col-4
.col-4
.col-4
.col-sm-4
.col-sm-4
.col-sm-4
.col-md-4
.col-md-4
.col-md-4
.col-lg-4
.col-lg-4
.col-lg-4
.col-xl-4
.col-xl-4
.col-xl-4
.col-xxl-4
.col-xxl-4
.col-xxl-4
Three equal columns
Get three equal-width columns starting at desktops and scaling to large desktops. On mobile devices, tablets and below, the columns will automatically stack.
.col-md-4
.col-md-4
.col-md-4
Three equal columns alternative
By using the .row-cols-* classes, you can easily create a grid with equal columns.
.col child of .row-cols-md-3
.col child of .row-cols-md-3
.col child of .row-cols-md-3
Three unequal columns
Get three columns starting at desktops and scaling to large desktops of various widths. Remember, grid columns should add up to twelve for a single horizontal block. More than that, and columns start stacking no matter the viewport.
.col-md-3
.col-md-6
.col-md-3
Two columns
Get two columns starting at desktops and scaling to large desktops.
.col-md-8
.col-md-4
Full width, single column
+No grid classes are necessary for full-width elements.
+
Two columns with two nested columns
Per the documentation, nesting is easy—just put a row of columns within an existing column. This gives you two columns starting at desktops and scaling to large desktops, with another two (equal widths) within the larger column.
At mobile device sizes, tablets and down, these columns and their nested columns will stack.
+.col-md-8
+
.col-md-6
.col-md-6
.col-md-4
Mixed: mobile and desktop
The Bootstrap v5 grid system has six tiers of classes: xs (extra small, this class infix is not used), sm (small), md (medium), lg (large), xl (x-large), and xxl (xx-large). You can use nearly any combination of these classes to create more dynamic and flexible layouts.
Each tier of classes scales up, meaning if you plan on setting the same widths for md, lg, xl and xxl, you only need to specify md.
.col-md-8
.col-6 .col-md-4
.col-6 .col-md-4
.col-6 .col-md-4
.col-6 .col-md-4
.col-6
.col-6
Mixed: mobile, tablet, and desktop
.col-sm-6 .col-lg-8
.col-6 .col-lg-4
.col-6 .col-sm-4
.col-6 .col-sm-4
.col-6 .col-sm-4
Gutters
With .gx-* classes, the horizontal gutters can be adjusted.
.col with .gx-4 gutters
.col with .gx-4 gutters
.col with .gx-4 gutters
.col with .gx-4 gutters
.col with .gx-4 gutters
.col with .gx-4 gutters
Use the .gy-* classes to control the vertical gutters.
.col with .gy-4 gutters
.col with .gy-4 gutters
.col with .gy-4 gutters
.col with .gy-4 gutters
.col with .gy-4 gutters
.col with .gy-4 gutters
With .g-* classes, the gutters in both directions can be adjusted.
.col with .g-3 gutters
.col with .g-3 gutters
.col with .g-3 gutters
.col with .g-3 gutters
.col with .g-3 gutters
.col with .g-3 gutters
Containers
Additional classes added in Bootstrap v4.4 allow containers that are 100% wide until a particular breakpoint. v5 adds a new xxl breakpoint.
Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit, featuring Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful JavaScript plugins.
-
- Primary button
- Secondary
-
-
-
-
-
-
-
-
Centered screenshot
-
-
Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit, featuring Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful JavaScript plugins.
-
- Primary button
- Secondary
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Responsive left-aligned hero with image
-
Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit, featuring Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful JavaScript plugins.
-
- Primary
- Default
-
-
-
-
-
-
-
-
-
-
-
Vertically centered hero sign-up form
-
Below is an example form built entirely with Bootstrap’s form controls. Each required form group has a validation state that can be triggered by attempting to submit the form without completing it.
-
-
-
-
-
-
-
-
-
-
-
-
-
Border hero with cropped image and shadows
-
Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit, featuring Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful JavaScript plugins.
-
- Primary
- Default
-
-
-
-
-
-
-
-
-
-
-
-
-
Dark color hero
-
-
Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit, featuring Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful JavaScript plugins.
-
- Custom button
- Secondary
-
-
-
-
-
-
-
-
-
-
-
+ Heroes · Bootstrap v5.3
Toggle theme
+Light
+
+Dark
+
+Auto
+
Heroes examples
Centered hero
Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit, featuring Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful JavaScript plugins.
Primary buttonSecondary
Centered screenshot
Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit, featuring Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful JavaScript plugins.
Primary buttonSecondary
Responsive left-aligned hero with image
Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit, featuring Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful JavaScript plugins.
PrimaryDefault
Vertically centered hero sign-up form
Below is an example form built entirely with Bootstrap’s form controls. Each required form group has a validation state that can be triggered by attempting to submit the form without completing it.
Border hero with cropped image and shadows
Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit, featuring Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful JavaScript plugins.
PrimaryDefault
Dark color hero
Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit, featuring Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful JavaScript plugins.
Combine the powers of the Bootstrap grid and the Masonry layout.
-
-
-
-
-
-
-
-
-
-
-
-
-
Go further with Bootstrap Themes
-
- Need something more than these examples? Take Bootstrap to the next level with premium themes from the official Bootstrap Themes marketplace. They’re built as their own extended frameworks, rich with new components and plugins, documentation, and powerful build tools.
-
Combine the powers of the Bootstrap grid and the Masonry layout.
Go further with Bootstrap Themes
+Need something more than these examples? Take Bootstrap to the next level with premium themes from the official Bootstrap Themes marketplace. They’re built as their own extended frameworks, rich with new components and plugins, documentation, and
+ powerful build tools.
+
Using a series of utilities, you can create this jumbotron, just like the one in previous versions of Bootstrap. Check out the examples below for how you can remix and restyle it to your liking.
- Example button
-
-
-
-
-
-
-
Change the background
-
Swap the background-color utility and add a `.text-*` color utility to mix up the jumbotron look. Then, mix and match with additional component themes and more.
- Example button
-
-
-
-
-
Add borders
-
Or, keep it light and add a border for some added definition to the boundaries of your content. Be sure to look under the hood at the source HTML here as we've adjusted the alignment and sizing of both column's content for equal-height.
Using a series of utilities, you can create this jumbotron, just like the one in previous versions of Bootstrap. Check out the examples below for how you can remix and restyle it to your liking.
Example button
Change the background
Swap the background-color utility and add a `.text-*` color utility to mix up the jumbotron look. Then, mix and match with additional component themes and more.
Example button
Add borders
Or, keep it light and add a border for some added definition to the boundaries of your content. Be sure to look under the hood at the source HTML here as we've adjusted the alignment and sizing of both column's content for equal-height.
- This is a custom jumbotron featuring an SVG image at the top, some longer text that wraps early thanks to a responsive .col-* class, and a customized call to action.
-
-
-
- Call to action
-
-
-
- Secondary link
-
-
-
-
-
-
-
-
-
-
-
-
Placeholder jumbotron
-
- This faded back jumbotron is useful for placeholder content. It's also a great way to add a bit of context to a page or section when no content is available and to encourage visitors to take a specific action.
-
-
- Call to action
-
-
-
-
-
-
-
-
-
-
Full-width jumbotron
-
- This takes the basic jumbotron above and makes its background edge-to-edge with a .container inside to align content. Similar to above, it's been recreated with built-in grid and utility classes.
-
-
-
-
-
-
-
-
-
-
Basic jumbotron
-
- This is a simple Bootstrap jumbotron that sits within a .container, recreated with built-in utility classes.
-
-
-
-
-
-
-
-
-
+ Jumbotrons · Bootstrap v5.3
Toggle theme
+Light
+
+Dark
+
+Auto
+
Bootstrap
Jumbotron with icon
+This is a custom jumbotron featuring an SVG image at the top, some longer text that wraps early thanks to a responsive .col-* class, and a customized call to action.
+
+Call to action
+
+Secondary link
+
Placeholder jumbotron
+This faded back jumbotron is useful for placeholder content. It's also a great way to add a bit of context to a page or section when no content is available and to encourage visitors to take a specific action.
+
+Call to action
+
Full-width jumbotron
+This takes the basic jumbotron above and makes its background edge-to-edge with a .container inside to align content. Similar to above, it's been recreated with built-in grid and utility classes.
+
Basic jumbotron
+This is a simple Bootstrap jumbotron that sits within a .container, recreated with built-in utility classes.
+
By adding data-masonry='{"percentPosition": true }' to the .row wrapper, we can combine the powers of Bootstrap's responsive grid and Masonry's positioning.
-
-
-
-
-
-
- PlaceholderImage cap
-
-
Card title that wraps to a new line
-
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
-
-
-
-
-
-
A well-known quote, contained in a blockquote element.
-
-
- Someone famous in Source Title
-
-
-
-
-
-
- PlaceholderImage cap
-
-
Card title
-
This card has supporting text below as a natural lead-in to additional content.
-
Last updated 3 mins ago
-
-
-
-
-
-
-
-
A well-known quote, contained in a blockquote element.
-
-
- Someone famous in Source Title
-
-
-
-
-
-
-
-
Card title
-
This card has a regular title and short paragraph of text below it.
-
Last updated 3 mins ago
-
-
-
-
-
- PlaceholderCard image
-
-
-
-
-
-
-
A well-known quote, contained in a blockquote element.
-
-
- Someone famous in Source Title
-
-
-
-
-
-
-
-
Card title
-
This is another card with title and supporting text below. This card has some additional content to make it slightly taller overall.
-
Last updated 3 mins ago
-
-
-
-
-
-
-
-
-
-
+
By adding data-masonry='}"percentPosition": true }' to the .row wrapper, we can combine the powers of Bootstrap's responsive grid and Masonry's positioning.
PlaceholderImage cap
Card title that wraps to a new line
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
A well-known quote, contained in a blockquote element.
+Someone famous in Source Title
PlaceholderImage cap
Card title
This card has supporting text below as a natural lead-in to additional content.
Last updated 3 mins ago
A well-known quote, contained in a blockquote element.
+Someone famous in Source Title
Card title
This card has a regular title and short paragraph of text below it.
Last updated 3 mins ago
PlaceholderCard image
A well-known quote, contained in a blockquote element.
+Someone famous in Source Title
Card title
This is another card with title and supporting text below. This card has some additional content to make it slightly taller overall.
This example is a quick exercise to illustrate how fixed to top navbar works. As you scroll, it will remain fixed to the top of your browser’s viewport.
This example is a quick exercise to illustrate how fixed to top navbar works. As you scroll, it will remain fixed to the top of your browser’s viewport.
This example is a quick exercise to illustrate how the top-aligned navbar works. As you scroll, this navbar remains in its original position and moves with the rest of the page.
This example is a quick exercise to illustrate how the top-aligned navbar works. As you scroll, this navbar remains in its original position and moves with the rest of the page.
This example shows how responsive offcanvas menus work within the navbar. For positioning of navbars, checkout the top and fixed top examples.
-
From the top down, you'll see a dark navbar, light navbar and a responsive navbar—each with offcanvases built in. Resize your browser window to the large breakpoint to see the toggle for the offcanvas.
This example shows how responsive offcanvas menus work within the navbar. For positioning of navbars, checkout the top and fixed top examples.
From the top down, you'll see a dark navbar, light navbar and a responsive navbar—each with offcanvases built in. Resize your browser window to the large breakpoint to see the toggle for the offcanvas.
This example is a quick exercise to illustrate how the navbar and its contents work. Some navbars extend the width of the viewport, others are confined within a .container. For positioning of navbars, checkout the top and fixed top examples.
-
At the smallest breakpoint, the collapse plugin is used to hide the links and show a menu button to toggle the collapsed content.
This example is a quick exercise to illustrate how the navbar and its contents work. Some navbars extend the width of the viewport, others are confined within a .container. For positioning of navbars, checkout the top and fixed top examples.
At the smallest breakpoint, the collapse plugin is used to hide the links and show a menu button to toggle the collapsed content.
- @username
- Some representative placeholder content, with some information about this user. Imagine this being some sort of status update, perhaps?
-
-
-
- Placeholder32x32
-
- @username
- Some more representative placeholder content, related to this other user. Another status update, perhaps.
-
-
-
- Placeholder32x32
-
- @username
- This user also gets some representative placeholder content. Maybe they did something interesting, and you really want to highlight this in the recent updates.
-
@username
+Some representative placeholder content, with some information about this user. Imagine this being some sort of status update, perhaps?
+
Placeholder32x32
@username
+Some more representative placeholder content, related to this other user. Another status update, perhaps.
+
Placeholder32x32
@username
+This user also gets some representative placeholder content. Maybe they did something interesting, and you really want to highlight this in the recent updates.
+
Quickly build an effective pricing table for your potential customers with this Bootstrap example. It’s built with default Bootstrap components and utilities with little customization.
Quickly build an effective pricing table for your potential customers with this Bootstrap example. It’s built with default Bootstrap components and utilities with little customization.
Quickly and easily get started with Bootstrap's compiled, production-ready files with this barebones example featuring some basic HTML and helpful links. Download all our examples to get started.
Quickly and easily get started with Bootstrap's compiled, production-ready files with this barebones example featuring some basic HTML and helpful links. Download all our examples to get started.
Pin a footer to the bottom of the viewport in desktop browsers with this custom HTML and CSS. A fixed navbar has been added with padding-top: 60px; on the main > .container.
Pin a footer to the bottom of the viewport in desktop browsers with this custom HTML and CSS. A fixed navbar has been added with padding-top: 60px; on the main > .container.
Learn about the guiding principles, strategies, and techniques used to build and maintain Bootstrap so you can more easily customize and extend it yourself.
-
-
-
-
-
-
-
-
-
-
While the getting started pages provide an introductory tour of the project and what it offers, this document focuses on why we do the things we do in Bootstrap. It explains our philosophy to building on the web so that others can learn from us, contribute with us, and help us improve.
-
See something that doesn’t sound right, or perhaps could be done better? Open an issue—we’d love to discuss it with you.
-
Summary
-
We’ll dive into each of these more throughout, but at a high level, here’s what guides our approach.
Learn about the guiding principles, strategies, and techniques used to build and maintain Bootstrap so you can more easily customize and extend it yourself.
+
While the getting started pages provide an introductory tour of the project and what it offers, this document focuses on why we do the things we do in Bootstrap. It explains our philosophy to building on the web so that others can learn from us, contribute with us, and help us improve.
+
See something that doesn’t sound right, or perhaps could be done better? Open an issue—we’d love to discuss it with you.
+
Summary
+
We'll dive into each of these more throughout, but at a high level, here’s what guides our approach.
Components should be responsive and mobile-first
Components should be built with a base class and extended via modifier classes
@@ -550,115 +31,42 @@
Whenever possible, use utilities over custom styles
Whenever possible, avoid enforcing strict HTML requirements (children selectors)
-
Responsive
-
Bootstrap’s responsive styles are built to be responsive, an approach that’s often referred to as mobile-first. We use this term in our docs and largely agree with it, but at times it can be too broad. While not every component must be entirely responsive in Bootstrap, this responsive approach is about reducing CSS overrides by pushing you to add styles as the viewport becomes larger.
-
Across Bootstrap, you’ll see this most clearly in our media queries. In most cases, we use min-width queries that begin to apply at a specific breakpoint and carry up through the higher breakpoints. For example, a .d-none applies from min-width: 0 to infinity. On the other hand, a .d-md-none applies from the medium breakpoint and up.
-
At times we’ll use max-width when a component’s inherent complexity requires it. At times, these overrides are functionally and mentally clearer to implement and support than rewriting core functionality from our components. We strive to limit this approach, but will use it from time to time.
-
Classes
+
Responsive
+
Bootstrap’s responsive styles are built to be responsive, an approach that’s often referred to as mobile-first. We use this term in our docs and largely agree with it, but at times it can be too broad. While not every component must be entirely responsive in Bootstrap, this responsive approach is about reducing CSS overrides by pushing you to add styles as the viewport becomes larger.
+
Across Bootstrap, you’ll see this most clearly in our media queries. In most cases, we use min-width queries that begin to apply at a specific breakpoint and carry up through the higher breakpoints. For example, a .d-none applies from min-width: 0 to infinity. On the other hand, a .d-md-none applies from the medium breakpoint and up.
+
At times we'll use max-width when a component’s inherent complexity requires it. At times, these overrides are functionally and mentally clearer to implement and support than rewriting core functionality from our components. We strive to limit this approach, but will use it from time to time.
+
Classes
Aside from our Reboot, a cross-browser normalization stylesheet, all our styles aim to use classes as selectors. This means steering clear of type selectors (e.g., input[type="text"]) and extraneous parent classes (e.g., .parent .child) that make styles too specific to easily override.
As such, components should be built with a base class that houses common, not-to-be overridden property-value pairs. For example, .btn and .btn-primary. We use .btn for all the common styles like display, padding, and border-width. We then use modifiers like .btn-primary to add the color, background-color, border-color, etc.
-
Modifier classes should only be used when there are multiple properties or values to be changed across multiple variants. Modifiers are not always necessary, so be sure you’re actually saving lines of code and preventing unnecessary overrides when creating them. Good examples of modifiers are our theme color classes and size variants.
-
z-index scales
+
Modifier classes should only be used when there are multiple properties or values to be changed across multiple variants. Modifiers are not always necessary, so be sure you’re actually saving lines of code and preventing unnecessary overrides when creating them. Good examples of modifiers are our theme color classes and size variants.
+
z-index scales
There are two z-index scales in Bootstrap—elements within a component and overlay components.
-
Component elements
+
Component elements
Some components in Bootstrap are built with overlapping elements to prevent double borders without modifying the border property. For example, button groups, input groups, and pagination.
These components share a standard z-index scale of 0 through 3.
0 is default (initial), 1 is :hover, 2 is :active/.active, and 3 is :focus.
-
This approach matches our expectations of highest user priority. If an element is focused, it’s in view and at the user’s attention. Active elements are second highest because they indicate state. Hover is third highest because it indicates user intent, but nearly anything can be hovered.
+
This approach matches our expectations of highest user priority. If an element is focused, it’s in view and at the user’s attention. Active elements are second highest because they indicate state. Hover is third highest because it indicates user intent, but nearly anything can be hovered.
-
Overlay components
-
Bootstrap includes several components that function as an overlay of some kind. This includes, in order of highest z-index, dropdowns, fixed and sticky navbars, modals, tooltips, and popovers. These components have their own z-index scale that begins at 1000. This starting number was chosen arbitrarily and serves as a small buffer between our styles and your project’s custom styles.
-
Each overlay component increases its z-index value slightly in such a way that common UI principles allow user focused or hovered elements to remain in view at all times. For example, a modal is document blocking (e.g., you cannot take any other action save for the modal’s action), so we put that above our navbars.
Bootstrap includes several components that function as an overlay of some kind. This includes, in order of highest z-index, dropdowns, fixed and sticky navbars, modals, tooltips, and popovers. These components have their own z-index scale that begins at 1000. This starting number was chosen arbitrarily and serves as a small buffer between our styles and your project’s custom styles.
+
Each overlay component increases its z-index value slightly in such a way that common UI principles allow user focused or hovered elements to remain in view at all times. For example, a modal is document blocking (e.g., you cannot take any other action save for the modal’s action), so we put that above our navbars.
Whenever possible, we prefer to write HTML and CSS over JavaScript. In general, HTML and CSS are more prolific and accessible to more people of all different experience levels. HTML and CSS are also faster in your browser than JavaScript, and your browser generally provides a great deal of functionality for you.
-
This principle is our first-class JavaScript API using data attributes. You don’t need to write nearly any JavaScript to use our JavaScript plugins; instead, write HTML. Read more about this in our JavaScript overview page.
-
Lastly, our styles build on the fundamental behaviors of common web elements. Whenever possible, we prefer to use what the browser provides. For example, you can put a .btn class on nearly any element, but most elements don’t provide any semantic value or browser functionality. So instead, we use <button>s and <a>s.
-
The same goes for more complex components. While we could write our own form validation plugin to add classes to a parent element based on an input’s state, thereby allowing us to style the text say red, we prefer using the :valid/:invalid pseudo-elements every browser provides us.
-
Utilities
+
This principle is our first-class JavaScript API using data attributes. You don’t need to write nearly any JavaScript to use our JavaScript plugins; instead, write HTML. Read more about this in our JavaScript overview page.
+
Lastly, our styles build on the fundamental behaviors of common web elements. Whenever possible, we prefer to use what the browser provides. For example, you can put a .btn class on nearly any element, but most elements don’t provide any semantic value or browser functionality. So instead, we use <button>s and <a>s.
+
The same goes for more complex components. While we could write our own form validation plugin to add classes to a parent element based on an input’s state, thereby allowing us to style the text say red, we prefer using the :valid/:invalid pseudo-elements every browser provides us.
+
Utilities
Utility classes—formerly helpers in Bootstrap 3—are a powerful ally in combating CSS bloat and poor page performance. A utility class is typically a single, immutable property-value pairing expressed as a class (e.g., .d-block represents display: block;). Their primary appeal is speed of use while writing HTML and limiting the amount of custom CSS you have to write.
Specifically regarding custom CSS, utilities can help combat increasing file size by reducing your most commonly repeated property-value pairs into single classes. This can have a dramatic effect at scale in your projects.
-
Flexible HTML
+
Flexible HTML
While not always possible, we strive to avoid being overly dogmatic in our HTML requirements for components. Thus, we focus on single classes in our CSS selectors and try to avoid immediate children selectors (>). This gives you more flexibility in your implementation and helps keep our CSS simpler and less specific.
-
Code conventions
+
Code conventions
Code Guide (from Bootstrap co-creator, @mdo) documents how we write our HTML and CSS across Bootstrap. It specifies guidelines for general formatting, common sense defaults, property and attribute orders, and more.
We use Stylelint to enforce these standards and more in our Sass/CSS. Our custom Stylelint config is open source and available for others to use and extend.
-
We use vnu-jar to enforce standard and semantic HTML, as well as detecting common errors.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
We use vnu-jar to enforce standard and semantic HTML, as well as detecting common errors.
Guidance and suggestions for using external icon libraries with Bootstrap.
-
-
-
-
-
-
-
-
-
-
While Bootstrap doesn’t include an icon set by default, we do have our own comprehensive icon library called Bootstrap Icons. Feel free to use them or any other icon set in your project. We’ve included details for Bootstrap Icons and other preferred icon sets below.
Guidance and suggestions for using external icon libraries with Bootstrap.
+
While Bootstrap doesn’t include an icon set by default, we do have our own comprehensive icon library called Bootstrap Icons. Feel free to use them or any other icon set in your project. We’ve included details for Bootstrap Icons and other preferred icon sets below.
While most icon sets include multiple file formats, we prefer SVG implementations for their improved accessibility and vector support.
-
Bootstrap Icons
-
Bootstrap Icons is a growing library of SVG icons that are designed by @mdo and maintained by the Bootstrap Team. The beginnings of this icon set come from Bootstrap’s very own components—our forms, carousels, and more. Bootstrap has very few icon needs out of the box, so we didn’t need much. However, once we got going, we couldn’t stop making more.
-
Oh, and did we mention they’re completely open source? Licensed under MIT, just like Bootstrap, our icon set is available to everyone.
+
Bootstrap Icons
+
Bootstrap Icons is a growing library of SVG icons that are designed by @mdo and maintained by the Bootstrap Team. The beginnings of this icon set come from Bootstrap’s very own components—our forms, carousels, and more. Bootstrap has very few icon needs out of the box, so we didn’t need much. However, once we got going, we couldn’t stop making more.
+
Oh, and did we mention they’re completely open source? Licensed under MIT, just like Bootstrap, our icon set is available to everyone.
Browser default checkboxes and radios are replaced with the help of .form-check, a series of classes for both input types that improves the layout and behavior of their HTML elements, that provide greater customization and cross browser consistency. Checkboxes are for selecting one or several options in a list, while radios are for selecting one option from many.
-
Structurally, our <input>s and <label>s are sibling elements as opposed to an <input> within a <label>. This is slightly more verbose as you must specify id and for attributes to relate the <input> and <label>. We use the sibling selector (~) for all our <input> states, like :checked or :disabled. When combined with the .form-check-label class, we can easily style the text for each item based on the <input>’s state.
+
Structurally, our <input>s and <label>s are sibling elements as opposed to an <input> within a <label>. This is slightly more verbose as you must specify id and for attributes to relate the <input> and <label>. We use the sibling selector (~) for all our <input> states, like :checked or :disabled. When combined with the .form-check-label class, we can easily style the text for each item based on the <input>’s state.
Our checks use custom Bootstrap icons to indicate checked or indeterminate states.
A switch has the markup of a custom checkbox but uses the .form-switch class to render a toggle switch. Consider using role="switch" to more accurately convey the nature of the control to assistive technologies that support this role. In older assistive technologies, it will simply be announced as a regular checkbox as a fallback. Switches also support the disabled attribute.
Omit the wrapping .form-check for checkboxes and radios that have no label text. Remember to still provide some form of accessible name for assistive technologies (for instance, using aria-label). See the forms overview accessibility section for details.
Create button-like checkboxes and radio buttons by using .btn styles rather than .form-check-label on the <label> elements. These toggle buttons can further be grouped in a button group if needed.
Create button-like checkboxes and radio buttons by using .btn styles rather than .form-check-label on the <label> elements. These toggle buttons can further be grouped in a button group if needed.
-Visually, these checkbox toggle buttons are identical to the button plugin toggle buttons. However, they are conveyed differently by assistive technologies: the checkbox toggles will be announced by screen readers as “checked”/“not checked” (since, despite their appearance, they are fundamentally still checkboxes), whereas the button plugin toggle buttons will be announced as “button”/“button pressed”. The choice between these two approaches will depend on the type of toggle you are creating, and whether or not the toggle will make sense to users when announced as a checkbox or as an actual button.
-
Visually, these checkbox toggle buttons are identical to the button plugin toggle buttons. However, they are conveyed differently by assistive technologies: the checkbox toggles will be announced by screen readers as “checked”/“not checked” (since, despite their appearance, they are fundamentally still checkboxes), whereas the button plugin toggle buttons will be announced as “button”/“button pressed”. The choice between these two approaches will depend on the type of toggle you are creating, and whether or not the toggle will make sense to users when announced as a checkbox or as an actual button.
+
Radio toggle buttons
+
Checked
@@ -1189,35 +384,18 @@ Visually, these checkbox toggle buttons are identical to the Disabled
-Radio
+Radio
Wrap a pair of <input class="form-control"> and <label> elements in .form-floating to enable floating labels with Bootstrap’s textual form fields. A placeholder is required on each <input> as our method of CSS-only floating labels uses the :placeholder-shown pseudo-element. Also note that the <input> must come first so we can utilize a sibling selector (e.g., ~).
Wrap a pair of <input class="form-control"> and <label> elements in .form-floating to enable floating labels with Bootstrap’s textual form fields. A placeholder is required on each <input> as our method of CSS-only floating labels uses the :placeholder-shown pseudo-element. Also note that the <input> must come first so we can utilize a sibling selector (i.e., ~).
By default, <textarea>s with .form-control will be the same height as <input>s.
-
-
-
-
+
Comments
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="form-floating">
-<textareaclass="form-control"placeholder="Leave a comment here"id="floatingTextarea"></textarea>
-<labelfor="floatingTextarea">Comments</label>
-</div>
-
-
+
html
<divclass="form-floating">
+ <textareaclass="form-control"placeholder="Leave a comment here"id="floatingTextarea"></textarea>
+ <labelfor="floatingTextarea">Comments</label>
+</div>
To set a custom height on your <textarea>, do not use the rows attribute. Instead, set an explicit height (either inline or via custom CSS).
-
-
-
-
+
Comments
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="form-floating">
-<textareaclass="form-control"placeholder="Leave a comment here"id="floatingTextarea2"style="height: 100px"></textarea>
-<labelfor="floatingTextarea2">Comments</label>
-</div>
-
-
-
Selects
-
Other than .form-control, floating labels are only available on .form-selects. They work in the same way, but unlike <input>s, they’ll always show the <label> in its floated state. Selects with size and multiple are not supported.
-
-
-
-
+
html
<divclass="form-floating">
+ <textareaclass="form-control"placeholder="Leave a comment here"id="floatingTextarea2"style="height: 100px"></textarea>
+ <labelfor="floatingTextarea2">Comments</label>
+</div>
+
Selects
+
Other than .form-control, floating labels are only available on .form-selects. They work in the same way, but unlike <input>s, they’ll always show the <label> in its floated state. Selects with size and multiple are not supported.
+
Works with selects
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="form-floating">
-<selectclass="form-select"id="floatingSelect"aria-label="Floating label select example">
-<optionselected>Open this select menu</option>
-<optionvalue="1">One</option>
-<optionvalue="2">Two</option>
-<optionvalue="3">Three</option>
-</select>
-<labelfor="floatingSelect">Works with selects</label>
-</div>
Add the disabled boolean attribute on an input, a textarea or a select to give it a grayed out appearance, remove pointer events, and prevent focusing.
-
-
-
-
+
Email address
@@ -761,112 +112,61 @@
Works with selects
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="form-floating mb-3">
-<inputtype="email"class="form-control"id="floatingInputDisabled"placeholder="name@example.com"disabled>
-<labelfor="floatingInputDisabled">Email address</label>
-</div>
-<divclass="form-floating mb-3">
-<textareaclass="form-control"placeholder="Leave a comment here"id="floatingTextareaDisabled"disabled></textarea>
-<labelfor="floatingTextareaDisabled">Comments</label>
-</div>
-<divclass="form-floating mb-3">
-<textareaclass="form-control"placeholder="Leave a comment here"id="floatingTextarea2Disabled"style="height: 100px"disabled>Disabled textarea with some text inside</textarea>
-<labelfor="floatingTextarea2Disabled">Comments</label>
-</div>
-<divclass="form-floating">
-<selectclass="form-select"id="floatingSelectDisabled"aria-label="Floating label disabled select example"disabled>
-<optionselected>Open this select menu</option>
-<optionvalue="1">One</option>
-<optionvalue="2">Two</option>
-<optionvalue="3">Three</option>
-</select>
-<labelfor="floatingSelectDisabled">Works with selects</label>
-</div>
-
-
-
Readonly plaintext
+
html
<divclass="form-floating mb-3">
+ <inputtype="email"class="form-control"id="floatingInputDisabled"placeholder="name@example.com"disabled>
+ <labelfor="floatingInputDisabled">Email address</label>
+</div>
+<divclass="form-floating mb-3">
+ <textareaclass="form-control"placeholder="Leave a comment here"id="floatingTextareaDisabled"disabled></textarea>
+ <labelfor="floatingTextareaDisabled">Comments</label>
+</div>
+<divclass="form-floating mb-3">
+ <textareaclass="form-control"placeholder="Leave a comment here"id="floatingTextarea2Disabled"style="height: 100px"disabled>Disabled textarea with some text inside</textarea>
+ <labelfor="floatingTextarea2Disabled">Comments</label>
+</div>
+<divclass="form-floating">
+ <selectclass="form-select"id="floatingSelectDisabled"aria-label="Floating label disabled select example"disabled>
+ <optionselected>Open this select menu</option>
+ <optionvalue="1">One</option>
+ <optionvalue="2">Two</option>
+ <optionvalue="3">Three</option>
+ </select>
+ <labelfor="floatingSelectDisabled">Works with selects</label>
+</div>
+
Readonly plaintext
Floating labels also support .form-control-plaintext, which can be helpful for toggling from an editable <input> to a plaintext value without affecting the page layout.
When using .input-group and .form-floating along with form validation, the -feedback should be placed outside of the .form-floating, but inside of the .input-group. This means that the feedback will need to be shown using javascript.
Block-level or inline-level form text can be created using .form-text.
-
-Form text should be explicitly associated with the form control it relates to using the aria-describedby attribute. This will ensure that assistive technologies—such as screen readers—will announce this form text when the user focuses or enters the control.
-
-
+
Form text should be explicitly associated with the form control it relates to using the aria-describedby attribute. This will ensure that assistive technologies—such as screen readers—will announce this form text when the user focuses or enters the control.
Form text below inputs can be styled with .form-text. If a block-level element will be used, a top margin is added for easy spacing from the inputs above.
-
-
-
-Password
+
Password
Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<labelfor="inputPassword5"class="form-label">Password</label>
-<inputtype="password"id="inputPassword5"class="form-control"aria-describedby="passwordHelpBlock">
-<divid="passwordHelpBlock"class="form-text">
- Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji.
-</div>
-
-
+
html
<labelfor="inputPassword5"class="form-label">Password</label>
+<inputtype="password"id="inputPassword5"class="form-control"aria-describedby="passwordHelpBlock">
+<divid="passwordHelpBlock"class="form-text">
+ Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji.
+</div>
Inline text can use any typical inline HTML element (be it a <span>, <small>, or something else) with nothing more than the .form-text class.
-
-
-
-
+
Password
@@ -674,121 +71,53 @@ Form text should be explicitly associated with the form control it relates to us
Must be 8-20 characters long.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="row g-3 align-items-center">
-<divclass="col-auto">
-<labelfor="inputPassword6"class="col-form-label">Password</label>
-</div>
-<divclass="col-auto">
-<inputtype="password"id="inputPassword6"class="form-control"aria-describedby="passwordHelpInline">
-</div>
-<divclass="col-auto">
-<spanid="passwordHelpInline"class="form-text">
- Must be 8-20 characters long.
-</span>
-</div>
-</div>
Add the readonly boolean attribute on an input to prevent modification of the input’s value. readonly inputs can still be focused and selected, while disabled inputs cannot.
Add the readonly boolean attribute on an input to prevent modification of the input’s value. readonly inputs can still be focused and selected, while disabled inputs cannot.
If you want to have <input readonly> elements in your form styled as plain text, replace .form-control with .form-control-plaintext to remove the default form field styling and preserve the correct margin and padding.
Set the type="color" and add .form-control-color to the <input>. We use the modifier class to set fixed heights and override some inconsistencies between browsers.
-
-
-
-Color picker
-
-
-
- html
-
-
-
-
-
-
-
-
-
<labelfor="exampleColorInput"class="form-label">Color picker</label>
-<inputtype="color"class="form-control form-control-color"id="exampleColorInput"value="#563d7c"title="Choose your color">
-
-
-
Datalists
+
Color picker
+
html
<labelfor="exampleColorInput"class="form-label">Color picker</label>
+<inputtype="color"class="form-control form-control-color"id="exampleColorInput"value="#563d7c"title="Choose your color">
+
Datalists
Datalists allow you to create a group of <option>s that can be accessed (and autocompleted) from within an <input>. These are similar to <select> elements, but come with more menu styling limitations and differences. While most browsers and operating systems include some support for <datalist> elements, their styling is inconsistent at best.
Place one add-on or button on either side of an input. You may also place one on both sides of an input. Remember to place <label>s outside the input group.
Input groups wrap by default via flex-wrap: wrap in order to accommodate custom form field validation within an input group. You may disable this with .flex-nowrap.
Due to limitations of browser support at the time, border-radius styles can only be applied to the first and last children within the .input-group class. Any non-visible element in one of those positions will cause the input group to render incorrectly. This will unfortunately not be fixed until v6 most likely.
Add the relative form sizing classes to the .input-group itself and contents within will automatically resize—no need for repeating the form control size classes on each element.
-
Sizing on the individual input group elements isn’t supported.
-
-
-
-
+
Sizing on the individual input group elements isn’t supported.
<divclass="input-group input-group-sm mb-3">
-<spanclass="input-group-text"id="inputGroup-sizing-sm">Small</span>
-<inputtype="text"class="form-control"aria-label="Sizing example input"aria-describedby="inputGroup-sizing-sm">
-</div>
-
-<divclass="input-group mb-3">
-<spanclass="input-group-text"id="inputGroup-sizing-default">Default</span>
-<inputtype="text"class="form-control"aria-label="Sizing example input"aria-describedby="inputGroup-sizing-default">
-</div>
-
-<divclass="input-group input-group-lg">
-<spanclass="input-group-text"id="inputGroup-sizing-lg">Large</span>
-<inputtype="text"class="form-control"aria-label="Sizing example input"aria-describedby="inputGroup-sizing-lg">
-</div>
-
+<divclass="input-group mb-3">
+ <spanclass="input-group-text"id="inputGroup-sizing-default">Default</span>
+ <inputtype="text"class="form-control"aria-label="Sizing example input"aria-describedby="inputGroup-sizing-default">
+</div>
-
Checkboxes and radios
-
Place any checkbox or radio option within an input group’s addon instead of text. We recommend adding .mt-0 to the .form-check-input when there’s no visible text next to the input.
-
-
-
-
+<divclass="input-group input-group-lg">
+ <spanclass="input-group-text"id="inputGroup-sizing-lg">Large</span>
+ <inputtype="text"class="form-control"aria-label="Sizing example input"aria-describedby="inputGroup-sizing-lg">
+</div>
+
Checkboxes and radios
+
Place any checkbox or radio option within an input group’s addon instead of text. We recommend adding .mt-0 to the .form-check-input when there’s no visible text next to the input.
+
@@ -751,67 +156,33 @@
-
+
html
<divclass="input-group mb-3">
+ <divclass="input-group-text">
+ <inputclass="form-check-input mt-0"type="checkbox"value=""aria-label="Checkbox for following text input">
+ </div>
+ <inputtype="text"class="form-control"aria-label="Text input with checkbox">
+</div>
-
- html
-
-
-
-
-
-
-
-
-
<divclass="input-group mb-3">
-<divclass="input-group-text">
-<inputclass="form-check-input mt-0"type="checkbox"value=""aria-label="Checkbox for following text input">
-</div>
-<inputtype="text"class="form-control"aria-label="Text input with checkbox">
-</div>
-
-<divclass="input-group">
-<divclass="input-group-text">
-<inputclass="form-check-input mt-0"type="radio"value=""aria-label="Radio button for following text input">
-</div>
-<inputtype="text"class="form-control"aria-label="Text input with radio button">
-</div>
-
-
-
Multiple inputs
+<divclass="input-group">
+ <divclass="input-group-text">
+ <inputclass="form-check-input mt-0"type="radio"value=""aria-label="Radio button for following text input">
+ </div>
+ <inputtype="text"class="form-control"aria-label="Text input with radio button">
+</div>
+
Multiple inputs
While multiple <input>s are supported visually, validation styles are only available for input groups with a single <input>.
-
-
-
-
+
First and last name
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="input-group">
-<spanclass="input-group-text">First and last name</span>
-<inputtype="text"aria-label="First name"class="form-control">
-<inputtype="text"aria-label="Last name"class="form-control">
-</div>
-
-
-
Multiple addons
+
html
<divclass="input-group">
+ <spanclass="input-group-text">First and last name</span>
+ <inputtype="text"aria-label="First name"class="form-control">
+ <inputtype="text"aria-label="Last name"class="form-control">
+</div>
+
Multiple addons
Multiple add-ons are supported and can be mixed with checkbox and radio input versions.
-
-
-
-
+
$0.00
@@ -821,42 +192,25 @@
$0.00
-
+
html
<divclass="input-group mb-3">
+ <spanclass="input-group-text">$</span>
+ <spanclass="input-group-text">0.00</span>
+ <inputtype="text"class="form-control"aria-label="Dollar amount (with dot and two decimal places)">
+</div>
-
- html
-
-
-
-
-
-
-
-
-
<divclass="input-group mb-3">
-<spanclass="input-group-text">$</span>
-<spanclass="input-group-text">0.00</span>
-<inputtype="text"class="form-control"aria-label="Dollar amount (with dot and two decimal places)">
-</div>
-
-<divclass="input-group">
-<inputtype="text"class="form-control"aria-label="Dollar amount (with dot and two decimal places)">
-<spanclass="input-group-text">$</span>
-<spanclass="input-group-text">0.00</span>
-</div>
-
-
-
Button addons
-
-
-
-
+<divclass="input-group">
+ <inputtype="text"class="form-control"aria-label="Dollar amount (with dot and two decimal places)">
+ <spanclass="input-group-text">$</span>
+ <spanclass="input-group-text">0.00</span>
+</div>
+
Button addons
+
Button
-
+
Button
@@ -867,49 +221,32 @@
-
+
ButtonButton
-
+
html
<divclass="input-group mb-3">
+ <buttonclass="btn btn-outline-secondary"type="button"id="button-addon1">Button</button>
+ <inputtype="text"class="form-control"placeholder=""aria-label="Example text with button addon"aria-describedby="button-addon1">
+</div>
-
- html
-
-
-
-
-
-
-
-
-
<divclass="input-group mb-3">
-<buttonclass="btn btn-outline-secondary"type="button"id="button-addon1">Button</button>
-<inputtype="text"class="form-control"placeholder=""aria-label="Example text with button addon"aria-describedby="button-addon1">
-</div>
-
-<divclass="input-group mb-3">
-<inputtype="text"class="form-control"placeholder="Recipient's username"aria-label="Recipient's username"aria-describedby="button-addon2">
-<buttonclass="btn btn-outline-secondary"type="button"id="button-addon2">Button</button>
-</div>
-
-<divclass="input-group mb-3">
-<buttonclass="btn btn-outline-secondary"type="button">Button</button>
-<buttonclass="btn btn-outline-secondary"type="button">Button</button>
-<inputtype="text"class="form-control"placeholder=""aria-label="Example text with two button addons">
-</div>
-
-<divclass="input-group">
-<inputtype="text"class="form-control"placeholder="Recipient's username"aria-label="Recipient's username with two button addons">
-<buttonclass="btn btn-outline-secondary"type="button">Button</button>
-<buttonclass="btn btn-outline-secondary"type="button">Button</button>
-</div>
Every group of form fields should reside in a <form> element. Bootstrap provides no default styling for the <form> element, but there are some powerful browser features that are provided by default.
New to browser forms? Consider reviewing the MDN form docs for an overview and complete list of available attributes.
<button>s within a <form> default to type="submit", so strive to be specific and always include a type.
Since Bootstrap applies display: block and width: 100% to almost all our form controls, forms will by default stack vertically. Additional classes can be used to vary this layout on a per-form basis.
-
Utilities
-
Margin utilities are the easiest way to add some structure to forms. They provide basic grouping of labels, controls, optional form text, and form validation messaging. We recommend sticking to margin-bottom utilities, and using a single direction throughout the form for consistency.
+
Utilities
+
Margin utilities are the easiest way to add some structure to forms. They provide basic grouping of labels, controls, optional form text, and form validation messaging. We recommend sticking to margin-bottom utilities, and using a single direction throughout the form for consistency.
Feel free to build your forms however you like, with <fieldset>s, <div>s, or nearly any other element.
More complex forms can be built using our grid classes. Use these for form layouts that require multiple columns, varied widths, and additional alignment options. Requires the $enable-grid-classes Sass variable to be enabled (on by default).
By adding gutter modifier classes, you can have control over the gutter width in as well the inline as block direction. Also requires the $enable-grid-classes Sass variable to be enabled (on by default).
By adding gutter modifier classes, you can have control over the gutter width in as well the inline as block direction. Also requires the $enable-grid-classes Sass variable to be enabled (on by default).
Create horizontal forms with the grid by adding the .row class to form groups and using the .col-*-* classes to specify the width of your labels and controls. Be sure to add .col-form-label to your <label>s as well so they’re vertically centered with their associated form controls.
-
At times, you maybe need to use margin or padding utilities to create that perfect alignment you need. For example, we’ve removed the padding-top on our stacked radio inputs label to better align the text baseline.
Create horizontal forms with the grid by adding the .row class to form groups and using the .col-*-* classes to specify the width of your labels and controls. Be sure to add .col-form-label to your <label>s as well so they’re vertically centered with their associated form controls.
+
At times, you maybe need to use margin or padding utilities to create that perfect alignment you need. For example, we’ve removed the padding-top on our stacked radio inputs label to better align the text baseline.
+
Email
@@ -833,74 +218,57 @@
Sign in
-
-
-
- html
-
-
-
-
-
-
-
-
-
<form>
-<divclass="row mb-3">
-<labelfor="inputEmail3"class="col-sm-2 col-form-label">Email</label>
-<divclass="col-sm-10">
-<inputtype="email"class="form-control"id="inputEmail3">
-</div>
-</div>
-<divclass="row mb-3">
-<labelfor="inputPassword3"class="col-sm-2 col-form-label">Password</label>
-<divclass="col-sm-10">
-<inputtype="password"class="form-control"id="inputPassword3">
-</div>
-</div>
-<fieldsetclass="row mb-3">
-<legendclass="col-form-label col-sm-2 pt-0">Radios</legend>
-<divclass="col-sm-10">
-<divclass="form-check">
-<inputclass="form-check-input"type="radio"name="gridRadios"id="gridRadios1"value="option1"checked>
-<labelclass="form-check-label"for="gridRadios1">
- First radio
-</label>
-</div>
-<divclass="form-check">
-<inputclass="form-check-input"type="radio"name="gridRadios"id="gridRadios2"value="option2">
-<labelclass="form-check-label"for="gridRadios2">
- Second radio
-</label>
-</div>
-<divclass="form-check disabled">
-<inputclass="form-check-input"type="radio"name="gridRadios"id="gridRadios3"value="option3"disabled>
-<labelclass="form-check-label"for="gridRadios3">
- Third disabled radio
-</label>
-</div>
-</div>
-</fieldset>
-<divclass="row mb-3">
-<divclass="col-sm-10 offset-sm-2">
-<divclass="form-check">
-<inputclass="form-check-input"type="checkbox"id="gridCheck1">
-<labelclass="form-check-label"for="gridCheck1">
- Example checkbox
-</label>
-</div>
-</div>
-</div>
-<buttontype="submit"class="btn btn-primary">Sign in</button>
-</form>
Be sure to use .col-form-label-sm or .col-form-label-lg to your <label>s or <legend>s to correctly follow the size of .form-control-lg and .form-control-sm.
As shown in the previous examples, our grid system allows you to place any number of .cols within a .row. They’ll split the available width equally between them. You may also pick a subset of your columns to take up more or less space, while the remaining .cols equally split the rest, with specific column classes like .col-sm-7.
As shown in the previous examples, our grid system allows you to place any number of .cols within a .row. They’ll split the available width equally between them. You may also pick a subset of your columns to take up more or less space, while the remaining .cols equally split the rest, with specific column classes like .col-sm-7.
The example below uses a flexbox utility to vertically center the contents and changes .col to .col-auto so that your columns only take up as much space as needed. Put another way, the column sizes itself based on the contents.
Use the .row-cols-* classes to create responsive horizontal layouts. By adding gutter modifier classes, we’ll have gutters in horizontal and vertical directions. On narrow mobile viewports, the .col-12 helps stack the form controls and more. The .align-items-center aligns the form elements to the middle, making the .form-check align properly.
Use the .row-cols-* classes to create responsive horizontal layouts. By adding gutter modifier classes, we'll have gutters in horizontal and vertical directions. On narrow mobile viewports, the .col-12 helps stack the form controls and more. The .align-items-center aligns the form elements to the middle, making the .form-check align properly.
Bootstrap’s form controls expand on our Rebooted form styles with classes. Use these classes to opt into their customized displays for a more consistent rendering across browsers and devices.
Bootstrap’s form controls expand on our Rebooted form styles with classes. Use these classes to opt into their customized displays for a more consistent rendering across browsers and devices.
Be sure to use an appropriate type attribute on all inputs (e.g., email for email address or number for numerical information) to take advantage of newer input controls like email verification, number selection, and more.
-
Here’s a quick example to demonstrate Bootstrap’s form styles. Keep reading for documentation on required classes, form layout, and more.
-
-
-
-
+
Here’s a quick example to demonstrate Bootstrap’s form styles. Keep reading for documentation on required classes, form layout, and more.
+
Email address
@@ -643,45 +40,29 @@
Check me out
Submit
-
-
-
- html
-
-
-
-
-
-
-
-
-
<form>
-<divclass="mb-3">
-<labelfor="exampleInputEmail1"class="form-label">Email address</label>
-<inputtype="email"class="form-control"id="exampleInputEmail1"aria-describedby="emailHelp">
-<divid="emailHelp"class="form-text">We'll never share your email with anyone else.</div>
-</div>
-<divclass="mb-3">
-<labelfor="exampleInputPassword1"class="form-label">Password</label>
-<inputtype="password"class="form-control"id="exampleInputPassword1">
-</div>
-<divclass="mb-3 form-check">
-<inputtype="checkbox"class="form-check-input"id="exampleCheck1">
-<labelclass="form-check-label"for="exampleCheck1">Check me out</label>
-</div>
-<buttontype="submit"class="btn btn-primary">Submit</button>
-</form>
Add the disabled attribute to a <fieldset> to disable all the controls within. Browsers treat all native form controls (<input>, <select>, and <button> elements) inside a <fieldset disabled> as disabled, preventing both keyboard and mouse interactions on them.
Add the disabled attribute to a <fieldset> to disable all the controls within. Browsers treat all native form controls (<input>, <select>, and <button> elements) inside a <fieldset disabled> as disabled, preventing both keyboard and mouse interactions on them.
However, if your form also includes custom button-like elements such as <a class="btn btn-*">...</a>, these will only be given a style of pointer-events: none, meaning they are still focusable and operable using the keyboard. In this case, you must manually modify these controls by adding tabindex="-1" to prevent them from receiving focus and aria-disabled="disabled" to signal their state to assistive technologies.
Ensure that all form controls have an appropriate accessible name so that their purpose can be conveyed to users of assistive technologies. The simplest way to achieve this is to use a <label> element, or—in the case of buttons—to include sufficiently descriptive text as part of the <button>...</button> content.
-
For situations where it’s not possible to include a visible <label> or appropriate text content, there are alternative ways of still providing an accessible name, such as:
+
For situations where it’s not possible to include a visible <label> or appropriate text content, there are alternative ways of still providing an accessible name, such as:
<label> elements hidden using the .visually-hidden class
Pointing to an existing element that can act as a label using aria-labelledby
@@ -753,114 +120,33 @@
If none of these are present, assistive technologies may resort to using the placeholder attribute as a fallback for the accessible name on <input> and <textarea> elements. The examples in this section provide a few suggested, case-specific approaches.
While using visually hidden content (.visually-hidden, aria-label, and even placeholder content, which disappears once a form field has content) will benefit assistive technology users, a lack of visible label text may still be problematic for certain users. Some form of visible label is generally the best approach, both for accessibility and usability.
-
CSS
-
Many form variables are set at a general level to be re-used and extended by individual form components. You’ll see these most often as $input-btn-* and $input-* variables.
-
Sass variables
-
$input-btn-* variables are shared global variables between our buttons and our form components. You’ll find these frequently reassigned as values to other component-specific variables.
Many form variables are set at a general level to be re-used and extended by individual form components. You’ll see these most often as $input-btn-* and $input-* variables.
+
Sass variables
+
$input-btn-* variables are shared global variables between our buttons and our form components. You’ll find these frequently reassigned as values to other component-specific variables.
Create custom <input type="range"> controls with .form-range. The track (the background) and thumb (the value) are both styled to appear the same across browsers. As only Firefox supports “filling” their track from the left or right of the thumb as a means to visually indicate progress, we do not currently support it.
Create custom <input type="range"> controls with .form-range. The track (the background) and thumb (the value) are both styled to appear the same across browsers. As only Firefox supports “filling” their track from the left or right of the thumb as a means to visually indicate progress, we do not currently support it.
By default, range inputs “snap” to integer values. To change this, you can specify a step value. In the example below, we double the number of steps by using step="0.5".
By default, range inputs “snap” to integer values. To change this, you can specify a step value. In the example below, we double the number of steps by using step="0.5".
Custom <select> menus need only a custom class, .form-select to trigger the custom styles. Custom styles are limited to the <select>’s initial appearance and cannot modify the <option>s due to browser limitations.
-We are aware that currently the client-side custom validation styles and tooltips are not accessible, since they are not exposed to assistive technologies. While we work on a solution, we’d recommend either using the server-side option or the default browser validation method.
-
We are aware that currently the client-side custom validation styles and tooltips are not accessible, since they are not exposed to assistive technologies. While we work on a solution, we’d recommend either using the server-side option or the default browser validation method.
+
How it works
+
Here’s how form validation works with Bootstrap:
-
HTML form validation is applied via CSS’s two pseudo-classes, :invalid and :valid. It applies to <input>, <select>, and <textarea> elements.
+
HTML form validation is applied via CSS’s two pseudo-classes, :invalid and :valid. It applies to <input>, <select>, and <textarea> elements.
Bootstrap scopes the :invalid and :valid styles to parent .was-validated class, usually applied to the <form>. Otherwise, any required field without a value shows up as invalid on page load. This way, you may choose when to activate them (typically after form submission is attempted).
To reset the appearance of the form (for instance, in the case of dynamic form submissions using Ajax), remove the .was-validated class from the <form> again after submission.
As a fallback, .is-invalid and .is-valid classes may be used instead of the pseudo-classes for server-side validation. They do not require a .was-validated parent class.
@@ -586,13 +35,10 @@ We are aware that currently the client-side custom validation styles and tooltip
You may provide custom validity messages with setCustomValidity in JavaScript.
With that in mind, consider the following demos for our custom form validation styles, optional server-side classes, and browser defaults.
-
Custom styles
-
For custom Bootstrap form validation messages, you’ll need to add the novalidate boolean attribute to your <form>. This disables the browser default feedback tooltips, but still provides access to the form validation APIs in JavaScript. Try to submit the form below; our JavaScript will intercept the submit button and relay feedback to you. When attempting to submit, you’ll see the :invalid and :valid styles applied to your form controls.
+
Custom styles
+
For custom Bootstrap form validation messages, you’ll need to add the novalidate boolean attribute to your <form>. This disables the browser default feedback tooltips, but still provides access to the form validation APIs in JavaScript. Try to submit the form below; our JavaScript will intercept the submit button and relay feedback to you. When attempting to submit, you’ll see the :invalid and :valid styles applied to your form controls.
Custom feedback styles apply custom colors, borders, focus styles, and background icons to better communicate feedback. Background icons for <select>s are only available with .form-select, and not .form-control.
-
-
-
-
+
First name
@@ -655,112 +101,94 @@ We are aware that currently the client-side custom validation styles and tooltip
// Example starter JavaScript for disabling form submissions if there are invalid fields
+(()=>{
+ 'use strict'
-
- html
-
-
-
-
-
-
-
-
-
<formclass="row g-3 needs-validation"novalidate>
-<divclass="col-md-4">
-<labelfor="validationCustom01"class="form-label">First name</label>
-<inputtype="text"class="form-control"id="validationCustom01"value="Mark"required>
-<divclass="valid-feedback">
- Looks good!
-</div>
-</div>
-<divclass="col-md-4">
-<labelfor="validationCustom02"class="form-label">Last name</label>
-<inputtype="text"class="form-control"id="validationCustom02"value="Otto"required>
-<divclass="valid-feedback">
- Looks good!
-</div>
-</div>
-<divclass="col-md-4">
-<labelfor="validationCustomUsername"class="form-label">Username</label>
-<divclass="input-group has-validation">
-<spanclass="input-group-text"id="inputGroupPrepend">@</span>
-<inputtype="text"class="form-control"id="validationCustomUsername"aria-describedby="inputGroupPrepend"required>
-<divclass="invalid-feedback">
- Please choose a username.
-</div>
-</div>
-</div>
-<divclass="col-md-6">
-<labelfor="validationCustom03"class="form-label">City</label>
-<inputtype="text"class="form-control"id="validationCustom03"required>
-<divclass="invalid-feedback">
- Please provide a valid city.
-</div>
-</div>
-<divclass="col-md-3">
-<labelfor="validationCustom04"class="form-label">State</label>
-<selectclass="form-select"id="validationCustom04"required>
-<optionselecteddisabledvalue="">Choose...</option>
-<option>...</option>
-</select>
-<divclass="invalid-feedback">
- Please select a valid state.
-</div>
-</div>
-<divclass="col-md-3">
-<labelfor="validationCustom05"class="form-label">Zip</label>
-<inputtype="text"class="form-control"id="validationCustom05"required>
-<divclass="invalid-feedback">
- Please provide a valid zip.
-</div>
-</div>
-<divclass="col-12">
-<divclass="form-check">
-<inputclass="form-check-input"type="checkbox"value=""id="invalidCheck"required>
-<labelclass="form-check-label"for="invalidCheck">
- Agree to terms and conditions
-</label>
-<divclass="invalid-feedback">
- You must agree before submitting.
-</div>
-</div>
-</div>
-<divclass="col-12">
-<buttonclass="btn btn-primary"type="submit">Submit form</button>
-</div>
-</form>
-
+ // Fetch all the forms we want to apply custom Bootstrap validation styles to
+ const forms = document.querySelectorAll('.needs-validation')
-
// Example starter JavaScript for disabling form submissions if there are invalid fields
-(()=>{
-'use strict'
-
-// Fetch all the forms we want to apply custom Bootstrap validation styles to
-constforms=document.querySelectorAll('.needs-validation')
-
-// Loop over them and prevent submission
-Array.from(forms).forEach(form=>{
-form.addEventListener('submit',event=>{
-if(!form.checkValidity()){
-event.preventDefault()
-event.stopPropagation()
-}
-
-form.classList.add('was-validated')
-},false)
-})
-})()
-
+ // Loop over them and prevent submission
+ Array.from(forms).forEach(form=>{
+ form.addEventListener('submit',event=>{
+ if(!form.checkValidity()){
+ event.preventDefault()
+ event.stopPropagation()
+ }
-
Browser defaults
-
Not interested in custom validation feedback messages or writing JavaScript to change form behaviors? All good, you can use the browser defaults. Try submitting the form below. Depending on your browser and OS, you’ll see a slightly different style of feedback.
Not interested in custom validation feedback messages or writing JavaScript to change form behaviors? All good, you can use the browser defaults. Try submitting the form below. Depending on your browser and OS, you’ll see a slightly different style of feedback.
While these feedback styles cannot be styled with CSS, you can still customize the feedback text through JavaScript.
-
-
-
-
+
First name
@@ -802,71 +230,54 @@ We are aware that currently the client-side custom validation styles and tooltip
We recommend using client-side validation, but in case you require server-side validation, you can indicate invalid and valid form fields with .is-invalid and .is-valid. Note that .invalid-feedback is also supported with these classes.
For invalid fields, ensure that the invalid feedback/error message is associated with the relevant form field using aria-describedby (noting that this attribute allows more than one id to be referenced, in case the field already points to additional form text).
Validation styles are available for the following form controls and components:
<input>s and <textarea>s with .form-control (including up to one .form-control in input groups)
<select>s with .form-select
.form-checks
-
-
-
-
+
Textarea
@@ -1060,70 +454,53 @@ We are aware that currently the client-side custom validation styles and tooltip
Submit form
-
+
html
<formclass="was-validated">
+ <divclass="mb-3">
+ <labelfor="validationTextarea"class="form-label">Textarea</label>
+ <textareaclass="form-control"id="validationTextarea"placeholder="Required example textarea"required></textarea>
+ <divclass="invalid-feedback">
+ Please enter a message in the textarea.
+ </div>
+ </div>
-
- html
-
-
-
-
-
-
-
-
-
<formclass="was-validated">
-<divclass="mb-3">
-<labelfor="validationTextarea"class="form-label">Textarea</label>
-<textareaclass="form-control"id="validationTextarea"placeholder="Required example textarea"required></textarea>
-<divclass="invalid-feedback">
- Please enter a message in the textarea.
-</div>
-</div>
-
-<divclass="form-check mb-3">
-<inputtype="checkbox"class="form-check-input"id="validationFormCheck1"required>
-<labelclass="form-check-label"for="validationFormCheck1">Check this checkbox</label>
-<divclass="invalid-feedback">Example invalid feedback text</div>
-</div>
-
-<divclass="form-check">
-<inputtype="radio"class="form-check-input"id="validationFormCheck2"name="radio-stacked"required>
-<labelclass="form-check-label"for="validationFormCheck2">Toggle this radio</label>
-</div>
-<divclass="form-check mb-3">
-<inputtype="radio"class="form-check-input"id="validationFormCheck3"name="radio-stacked"required>
-<labelclass="form-check-label"for="validationFormCheck3">Or toggle this other radio</label>
-<divclass="invalid-feedback">More example invalid feedback text</div>
-</div>
-
-<divclass="mb-3">
-<selectclass="form-select"requiredaria-label="select example">
-<optionvalue="">Open this select menu</option>
-<optionvalue="1">One</option>
-<optionvalue="2">Two</option>
-<optionvalue="3">Three</option>
-</select>
-<divclass="invalid-feedback">Example invalid select feedback</div>
-</div>
-
-<divclass="mb-3">
-<inputtype="file"class="form-control"aria-label="file example"required>
-<divclass="invalid-feedback">Example invalid form file feedback</div>
-</div>
-
-<divclass="mb-3">
-<buttonclass="btn btn-primary"type="submit"disabled>Submit form</button>
-</div>
-</form>
If your form layout allows it, you can swap the .{valid|invalid}-feedback classes for .{valid|invalid}-tooltip classes to display validation feedback in a styled tooltip. Be sure to have a parent with position: relative on it for tooltip positioning. In the example below, our column classes have this already, but your project may require an alternative setup.
-
-
-
-
+
First name
@@ -1175,426 +552,283 @@ We are aware that currently the client-side custom validation styles and tooltip
As part of Bootstrap’s evolving CSS variables approach, forms now use local CSS variables for validation for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
As part of Bootstrap’s evolving CSS variables approach, forms now use local CSS variables for validation for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
Maps of $form-validation-states can contain three optional parameters to override tooltips and focus styles.
-
Sass loops
+
Sass loops
Used to iterate over $form-validation-states map values to generate our validation styles. Any modifications to the above Sass map will be reflected in your compiled CSS via this loop.
Validation states can be customized via Sass with the $form-validation-states map. Located in our _variables.scss file, this Sass map is how we generate the default valid/invalid validation states. Included is a nested map for customizing each state’s color, icon, tooltip color, and focus shadow. While no other states are supported by browsers, those using custom styles can easily add more complex form feedback.
@each$state, $data in $form-validation-states{
+ @includeform-validation-state($state,$data...);
+}
+
+
Customizing
+
Validation states can be customized via Sass with the $form-validation-states map. Located in our _variables.scss file, this Sass map is how we generate the default valid/invalid validation states. Included is a nested map for customizing each state’s color, icon, tooltip color, and focus shadow. While no other states are supported by browsers, those using custom styles can easily add more complex form feedback.
Bootstrap provides an easy-to-use framework of ready-made styles, layout tools, and interactive components, allowing developers to create websites and applications that are visually appealing, functionally rich, and accessible out of the box.
-
Overview and limitations
-
The overall accessibility of any project built with Bootstrap depends in large part on the author’s markup, additional styling, and scripting they’ve included. However, provided that these have been implemented correctly, it should be perfectly possible to create websites and applications with Bootstrap that fulfill WCAG 2.2 (A/AA/AAA), Section 508, and similar accessibility standards and requirements.
-
Structural markup
-
Bootstrap’s styling and layout can be applied to a wide range of markup structures. This documentation aims to provide developers with best practice examples to demonstrate the use of Bootstrap itself and illustrate appropriate semantic markup, including ways in which potential accessibility concerns can be addressed.
-
Interactive components
-
Bootstrap’s interactive components—such as modal dialogs, dropdown menus, and custom tooltips—are designed to work for touch, mouse, and keyboard users. Through the use of relevant WAI-ARIA roles and attributes, these components should also be understandable and operable using assistive technologies (such as screen readers).
-
Because Bootstrap’s components are purposely designed to be fairly generic, authors may need to include further ARIA roles and attributes, as well as JavaScript behavior, to more accurately convey the precise nature and functionality of their component. This is usually noted in the documentation.
-
Color contrast
-
Some combinations of colors that currently make up Bootstrap’s default palette—used throughout the framework for things such as button variations, alert variations, form validation indicators—may lead to insufficient color contrast (below the recommended WCAG 2.2 text color contrast ratio of 4.5:1 and the WCAG 2.2 non-text color contrast ratio of 3:1), particularly when used against a light background. Authors are encouraged to test their specific uses of color and, where necessary, manually modify/extend these default colors to ensure adequate color contrast ratios.
Bootstrap provides an easy-to-use framework of ready-made styles, layout tools, and interactive components, allowing developers to create websites and applications that are visually appealing, functionally rich, and accessible out of the box.
+
Overview and limitations
+
The overall accessibility of any project built with Bootstrap depends in large part on the author’s markup, additional styling, and scripting they’ve included. However, provided that these have been implemented correctly, it should be perfectly possible to create websites and applications with Bootstrap that fulfill WCAG 2.2 (A/AA/AAA), Section 508, and similar accessibility standards and requirements.
+
Structural markup
+
Bootstrap’s styling and layout can be applied to a wide range of markup structures. This documentation aims to provide developers with best practice examples to demonstrate the use of Bootstrap itself and illustrate appropriate semantic markup, including ways in which potential accessibility concerns can be addressed.
+
Interactive components
+
Bootstrap’s interactive components—such as modal dialogs, dropdown menus, and custom tooltips—are designed to work for touch, mouse, and keyboard users. Through the use of relevant WAI-ARIA roles and attributes, these components should also be understandable and operable using assistive technologies (such as screen readers).
+
Because Bootstrap’s components are purposely designed to be fairly generic, authors may need to include further ARIA roles and attributes, as well as JavaScript behavior, to more accurately convey the precise nature and functionality of their component. This is usually noted in the documentation.
+
Color contrast
+
Some combinations of colors that currently make up Bootstrap’s default palette—used throughout the framework for things such as button variations, alert variations, form validation indicators—may lead to insufficient color contrast (below the recommended WCAG 2.2 text color contrast ratio of 4.5:1 and the WCAG 2.2 non-text color contrast ratio of 3:1), particularly when used against a light background. Authors are encouraged to test their specific uses of color and, where necessary, manually modify/extend these default colors to ensure adequate color contrast ratios.
+
Visually hidden content
Content which should be visually hidden, but remain accessible to assistive technologies such as screen readers, can be styled using the .visually-hidden class. This can be useful in situations where additional visual information or cues (such as meaning denoted through the use of color) need to also be conveyed to non-visual users.
-
<pclass="text-danger">
-<spanclass="visually-hidden">Danger: </span>
- This action is not reversible
-</p>
-
For visually hidden interactive controls, such as traditional “skip” links, use the .visually-hidden-focusable class. This will ensure that the control becomes visible once focused (for sighted keyboard users). Watch out, compared to the equivalent .sr-only and .sr-only-focusable classes in past versions, Bootstrap 5’s .visually-hidden-focusable is a standalone class, and must not be used in combination with the .visually-hidden class.
-
<aclass="visually-hidden-focusable"href="#content">Skip to main content</a>
-
Reduced motion
+
<pclass="text-danger">
+ <spanclass="visually-hidden">Danger: </span>
+ This action is not reversible
+</p>
+
+
For visually hidden interactive controls, such as traditional “skip” links, use the .visually-hidden-focusable class. This will ensure that the control becomes visible once focused (for sighted keyboard users). Watch out, compared to the equivalent .sr-only and .sr-only-focusable classes in past versions, Bootstrap 5’s .visually-hidden-focusable is a standalone class, and must not be used in combination with the .visually-hidden class.
+
<aclass="visually-hidden-focusable"href="#content">Skip to main content</a>
+
+
Reduced motion
Bootstrap includes support for the prefers-reduced-motion media feature. In browsers/environments that allow the user to specify their preference for reduced motion, most CSS transition effects in Bootstrap (for instance, when a modal dialog is opened or closed, or the sliding animation in carousels) will be disabled, and meaningful animations (such as spinners) will be slowed down.
-
On browsers that support prefers-reduced-motion, and where the user has not explicitly signaled that they’d prefer reduced motion (i.e. where prefers-reduced-motion: no-preference), Bootstrap enables smooth scrolling using the scroll-behavior property.
-
Additional resources
+
On browsers that support prefers-reduced-motion, and where the user has not explicitly signaled that they’d prefer reduced motion (i.e. where prefers-reduced-motion: no-preference), Bootstrap enables smooth scrolling using the scroll-behavior property.
Learn about some of the best practices we’ve gathered from years of working on and using Bootstrap.
-
-
-
-
-
-
-
-
-
-
We’ve designed and developed Bootstrap to work in a number of environments. Here are some of the best practices we’ve gathered from years of working on and using it ourselves.
Learn about some of the best practices we’ve gathered from years of working on and using Bootstrap.
+
We’ve designed and developed Bootstrap to work in a number of environments. Here are some of the best practices we’ve gathered from years of working on and using it ourselves.
Bootstrap supports the latest, stable releases of all major browsers and platforms.
-
Alternative browsers which use the latest version of WebKit, Blink, or Gecko, whether directly or via the platform’s web view API, are not explicitly supported. However, Bootstrap should (in most cases) display and function correctly in these browsers as well. More specific support information is provided below.
+
Alternative browsers which use the latest version of WebKit, Blink, or Gecko, whether directly or via the platform’s web view API, are not explicitly supported. However, Bootstrap should (in most cases) display and function correctly in these browsers as well. More specific support information is provided below.
# https://github.com/browserslist/browserslist#readme
->= 0.5%
+>= 0.5%
last 2 major versions
not dead
-Chrome >= 60
-Firefox >= 60
+Chrome >= 60
+Firefox >= 60
Firefox ESR
-iOS >= 12
-Safari >= 12
+iOS >= 12
+Safari >= 12
not Explorer <= 11
not kaios <= 2.5 # fix floating label issues in Firefox (see https://github.com/postcss/autoprefixer/issues/1533)
-
We use Autoprefixer to handle intended browser support via CSS prefixes, which uses Browserslist to manage these browser versions. Consult their documentation for how to integrate these tools into your projects.
-
Mobile devices
-
Generally speaking, Bootstrap supports the latest versions of each major platform’s default browsers. Note that proxy browsers (such as Opera Mini, Opera Mobile’s Turbo mode, UC Browser Mini, Amazon Silk) are not supported.
-
-
-
-
-
Chrome
-
Firefox
-
Safari
-
Android Browser & WebView
-
-
-
-
-
Android
-
Supported
-
Supported
-
—
-
v6.0+
-
-
-
iOS
-
Supported
-
Supported
-
Supported
-
—
-
-
-
+
+
We use Autoprefixer to handle intended browser support via CSS prefixes, which uses Browserslist to manage these browser versions. Consult their documentation for how to integrate these tools into your projects.
+
Mobile devices
+
Generally speaking, Bootstrap supports the latest versions of each major platform’s default browsers. Note that proxy browsers (such as Opera Mini, Opera Mobile’s Turbo mode, UC Browser Mini, Amazon Silk) are not supported.
+
-
Desktop browsers
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Chrome
Firefox
Safari
Android Browser & WebView
Android
Supported
Supported
—
v6.0+
iOS
Supported
Supported
Supported
—
+
Desktop browsers
Similarly, the latest versions of most desktop browsers are supported.
For Firefox, in addition to the latest normal stable release, we also support the latest Extended Support Release (ESR) version of Firefox.
Unofficially, Bootstrap should look and behave well enough in Chromium and Chrome for Linux, and Firefox for Linux, though they are not officially supported.
-
Internet Explorer
+
Internet Explorer
Internet Explorer is not supported. If you require Internet Explorer support, please use Bootstrap v4.
-
Modals and dropdowns on mobile
-
Overflow and scrolling
-
Support for overflow: hidden; on the <body> element is quite limited in iOS and Android. To that end, when you scroll past the top or bottom of a modal in either of those devices’ browsers, the <body> content will begin to scroll. See Chrome bug #175502 (fixed in Chrome v40) and WebKit bug #153852.
-
iOS text fields and scrolling
+
Modals and dropdowns on mobile
+
Overflow and scrolling
+
Support for overflow: hidden; on the <body> element is quite limited in iOS and Android. To that end, when you scroll past the top or bottom of a modal in either of those devices’ browsers, the <body> content will begin to scroll. See Chrome bug #175502 (fixed in Chrome v40) and WebKit bug #153852.
+
iOS text fields and scrolling
As of iOS 9.2, while a modal is open, if the initial touch of a scroll gesture is within the boundary of a textual <input> or a <textarea>, the <body> content underneath the modal will be scrolled instead of the modal itself. See WebKit bug #153856.
-
Navbar Dropdowns
-
The .dropdown-backdrop element isn’t used on iOS in the nav because of the complexity of z-indexing. Thus, to close dropdowns in navbars, you must directly click the dropdown element (or any other element which will fire a click event in iOS).
-
Browser zooming
+
Navbar Dropdowns
+
The .dropdown-backdrop element isn’t used on iOS in the nav because of the complexity of z-indexing. Thus, to close dropdowns in navbars, you must directly click the dropdown element (or any other element which will fire a click event in iOS).
+
Browser zooming
Page zooming inevitably presents rendering artifacts in some components, both in Bootstrap and the rest of the web. Depending on the issue, we may be able to fix it (search first and then open an issue if need be). However, we tend to ignore these as they often have no direct solution other than hacky workarounds.
-
Validators
-
In order to provide the best possible experience to old and buggy browsers, Bootstrap uses CSS browser hacks in several places to target special CSS to certain browser versions in order to work around bugs in the browsers themselves. These hacks understandably cause CSS validators to complain that they are invalid. In a couple places, we also use bleeding-edge CSS features that aren’t yet fully standardized, but these are used purely for progressive enhancement.
-
These validation warnings don’t matter in practice since the non-hacky portion of our CSS does fully validate and the hacky portions don’t interfere with the proper functioning of the non-hacky portion, hence why we deliberately ignore these particular warnings.
-
Our HTML docs likewise have some trivial and inconsequential HTML validation warnings due to our inclusion of a workaround for a certain Firefox bug.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
Validators
+
In order to provide the best possible experience to old and buggy browsers, Bootstrap uses CSS browser hacks in several places to target special CSS to certain browser versions in order to work around bugs in the browsers themselves. These hacks understandably cause CSS validators to complain that they are invalid. In a couple places, we also use bleeding-edge CSS features that aren’t yet fully standardized, but these are used purely for progressive enhancement.
+
These validation warnings don’t matter in practice since the non-hacky portion of our CSS does fully validate and the hacky portions don’t interfere with the proper functioning of the non-hacky portion, hence why we deliberately ignore these particular warnings.
+
Our HTML docs likewise have some trivial and inconsequential HTML validation warnings due to our inclusion of a workaround for a certain Firefox bug.
\ No newline at end of file
diff --git a/docs/5.3/getting-started/build-tools/index.html b/docs/5.3/getting-started/build-tools/index.html
index 6a806fa1ba..93d65fe91c 100644
--- a/docs/5.3/getting-started/build-tools/index.html
+++ b/docs/5.3/getting-started/build-tools/index.html
@@ -1,12 +1 @@
-
-
-
-
-
- https://getbootstrap.com/docs/5.3/getting-started/contribute/
-
-
-
-
-
-
+ Bootstrap
\ No newline at end of file
diff --git a/docs/5.3/getting-started/contents/index.html b/docs/5.3/getting-started/contents/index.html
index 3cd6fadab6..f65853fd86 100644
--- a/docs/5.3/getting-started/contents/index.html
+++ b/docs/5.3/getting-started/contents/index.html
@@ -1,770 +1,158 @@
-
-
-
-
-
-
-
-
+ Contents · Bootstrap v5.3
This is the most basic form of Bootstrap: compiled files for quick drop-in usage in nearly any web project. We provide compiled CSS and JS (bootstrap.*), as well as compiled and minified CSS and JS (bootstrap.min.*). Source maps (bootstrap.*.map) are available for use with certain browsers’ developer tools. Bundled JS files (bootstrap.bundle.js and minified bootstrap.bundle.min.js) include Popper.
This is the most basic form of Bootstrap: compiled files for quick drop-in usage in nearly any web project. We provide compiled CSS and JS (bootstrap.*), as well as compiled and minified CSS and JS (bootstrap.min.*). Source maps (bootstrap.*.map) are available for use with certain browsers’ developer tools. Bundled JS files (bootstrap.bundle.js and minified bootstrap.bundle.min.js) include Popper.
+
CSS files
Bootstrap includes a handful of options for including some or all of our compiled CSS.
Similarly, we have options for including some or all of our compiled JavaScript.
-
-
-
-
JS Files
-
Popper
-
-
-
-
-
bootstrap.bundle.js bootstrap.bundle.min.js
-
Included
-
-
-
bootstrap.js bootstrap.min.js
-
–
-
-
-
+
-
Bootstrap source code
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
JS Files
Popper
bootstrap.bundle.js bootstrap.bundle.min.js
Included
bootstrap.js bootstrap.min.js
–
+
Bootstrap source code
The Bootstrap source code download includes the compiled CSS and JavaScript assets, along with source Sass, JavaScript, and documentation. More specifically, it includes the following and more:
The scss/ and js/ are the source code for our CSS and JavaScript. The dist/ folder includes everything listed in the compiled download section above. The site/content/docs/ folder includes the source code for our hosted documentation, including our live examples of Bootstrap usage.
-
Beyond that, any other included file provides support for packages, license information, and development.
The scss/ and js/ are the source code for our CSS and JavaScript. The dist/ folder includes everything listed in the compiled download section above. The site/content/docs/ folder includes the source code for our hosted documentation, including our live examples of Bootstrap usage.
+
Beyond that, any other included file provides support for packages, license information, and development.
Bootstrap uses npm scripts to build the documentation and compile source files. Our package.json houses these scripts for compiling code, running tests, and more. These aren’t intended for use outside our repository and documentation.
-
To use our build system and run our documentation locally, you’ll need a copy of Bootstrap’s source files and Node. Follow these steps and you should be ready to rock:
Bootstrap uses npm scripts to build the documentation and compile source files. Our package.json houses these scripts for compiling code, running tests, and more. These aren’t intended for use outside our repository and documentation.
+
To use our build system and run our documentation locally, you’ll need a copy of Bootstrap’s source files and Node. Follow these steps and you should be ready to rock:
-Get started with Bootstrap via npm with our starter project! Head to the Sass & JS example template repository to see how to build and customize Bootstrap in your own npm project. Includes Sass compiler, Autoprefixer, Stylelint, PurgeCSS, and Bootstrap Icons.
-
-
Sass
-
Bootstrap uses Dart Sass for compiling our Sass source files into CSS files (included in our build process), and we recommend you do the same if you’re compiling Sass using your own asset pipeline. We previously used Node Sass for Bootstrap v4, but LibSass and packages built on top of it, including Node Sass, are now deprecated.
-
Dart Sass uses a rounding precision of 10 and for efficiency reasons does not allow adjustment of this value. We don’t lower this precision during further processing of our generated CSS, such as during minification, but if you chose to do so we recommend maintaining a precision of at least 6 to prevent issues with browser rounding.
-
Autoprefixer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Task
Description
npm start
Compiles CSS and JavaScript, builds the documentation, and starts a local server.
Get started with Bootstrap via npm with our starter project! Head to the Sass & JS example template repository to see how to build and customize Bootstrap in your own npm project. Includes Sass compiler, Autoprefixer, Stylelint, PurgeCSS, and Bootstrap Icons.
+
Sass
+
Bootstrap uses Dart Sass for compiling our Sass source files into CSS files (included in our build process), and we recommend you do the same if you’re compiling Sass using your own asset pipeline. We previously used Node Sass for Bootstrap v4, but LibSass and packages built on top of it, including Node Sass, are now deprecated.
+
Dart Sass uses a rounding precision of 10 and for efficiency reasons does not allow adjustment of this value. We don’t lower this precision during further processing of our generated CSS, such as during minification, but if you chose to do so we recommend maintaining a precision of at least 6 to prevent issues with browser rounding.
+
Autoprefixer
Bootstrap uses Autoprefixer (included in our build process) to automatically add vendor prefixes to some CSS properties at build time. Doing so saves us time and code by allowing us to write key parts of our CSS a single time while eliminating the need for vendor mixins like those found in v3.
We maintain the list of browsers supported through Autoprefixer in a separate file within our GitHub repository. See .browserslistrc for details.
-
RTLCSS
+
RTLCSS
Bootstrap uses RTLCSS to process compiled CSS and convert them to RTL – basically replacing horizontal direction aware properties (e.g. padding-left) with their opposite. It allows us only write our CSS a single time and make minor tweaks using RTLCSS control and value directives.
-
Local documentation
-
Running our documentation locally requires the use of Hugo, which gets installed via the hugo-bin npm package. Hugo is a blazingly fast and quite extensible static site generator that provides us: basic includes, Markdown-based files, templates, and more. Here’s how to get it started:
+
Local documentation
+
Running our documentation locally requires the use of Astro. Astro is a modern static site generator that allows us to build our documentation with a combination of Markdown and React components. Here’s how to get it started:
Run through the tooling setup above to install all dependencies.
From the root /bootstrap directory, run npm run docs-serve in the command line.
-
Open http://localhost:9001/ in your browser, and voilà.
+
Open http://localhost:4321/ in your browser, and voilà.
-
Learn more about using Hugo by reading its documentation.
-
Troubleshooting
-
Should you encounter problems with installing dependencies, uninstall all previous dependency versions (global and local). Then, rerun npm install.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
Learn more about using Astro by reading its documentation.
+
Troubleshooting
+
Should you encounter problems with installing dependencies, uninstall all previous dependency versions (global and local). Then, rerun npm install.
Download Bootstrap to get the compiled CSS and JavaScript, source code, or include it with your favorite package managers like npm, RubyGems, and more.
Download Bootstrap to get the compiled CSS and JavaScript, source code, or include it with your favorite package managers like npm, RubyGems, and more.
Compile Bootstrap with your own asset pipeline by downloading our source Sass, JavaScript, and documentation files. This option requires some additional tooling:
-
Sass compiler for compiling Sass source files into CSS files
+
Sass compiler for compiling Sass source files into CSS files
Should you require our full set of build tools, they are included for developing Bootstrap and its docs, but they’re likely unsuitable for your own purposes.
Should you require our full set of build tools, they are included for developing Bootstrap and its docs, but they’re likely unsuitable for your own purposes.
We recommend jsDelivr and use it ourselves in our documentation. However, in some cases—like in some specific countries or environments—you may need to use other CDN providers like cdnjs or unpkg.
-
You’ll find the same files on these CDN providers, albeit with different URLs. With cdnjs, you can use this direct Bootstrap package link to copy and paste ready-to-use HTML snippets for each dist file from any version of Bootstrap.
-
-If the SRI hashes differ for a given file, you shouldn’t use the files from that CDN, because it means that the file was modified by someone else.
-
-
-
Note that you should compare same length hashes, e.g. sha384 with sha384, otherwise it’s expected for them to be different.
+
You’ll find the same files on these CDN providers, albeit with different URLs. With cdnjs, you can use this direct Bootstrap package link to copy and paste ready-to-use HTML snippets for each dist file from any version of Bootstrap.
+
If the SRI hashes differ for a given file, you shouldn’t use the files from that CDN, because it means that the file was modified by someone else.
+
Note that you should compare same length hashes, e.g. sha384 with sha384, otherwise it’s expected for them to be different.
As such, you can use an online tool like SRI Hash Generator to make sure that the hashes are the same for a given file.
Alternatively, assuming you have OpenSSL installed, you can achieve the same from the CLI, for example:
-
openssl dgst -sha384 -binary bootstrap.min.js | openssl base64 -A
-
Package managers
-
Pull in Bootstrap’s source files into nearly any project with some of the most popular package managers. No matter the package manager, Bootstrap will require a Sass compiler and Autoprefixer for a setup that matches our official compiled versions.
-
npm
+
openssl dgst -sha384-binary bootstrap.min.js | openssl base64 -A
+
+
Package managers
+
Pull in Bootstrap’s source files into nearly any project with some of the most popular package managers. No matter the package manager, Bootstrap will require a Sass compiler and Autoprefixer for a setup that matches our official compiled versions.
+
npm
Install Bootstrap in your Node.js powered apps with the npm package:
-
npm install bootstrap@5.3.5
-
const bootstrap = require('bootstrap') or import bootstrap from 'bootstrap' will load all of Bootstrap’s plugins onto a bootstrap object.
-The bootstrap module itself exports all of our plugins. You can manually load Bootstrap’s plugins individually by loading the /js/dist/*.js files under the package’s top-level directory.
-
Bootstrap’s package.json contains some additional metadata under the following keys:
+
npminstall bootstrap@5.3.5
+
+
const bootstrap = require('bootstrap') or import bootstrap from 'bootstrap' will load all of Bootstrap’s plugins onto a bootstrap object.
+The bootstrap module itself exports all of our plugins. You can manually load Bootstrap’s plugins individually by loading the /js/dist/*.js files under the package’s top-level directory.
+
Bootstrap’s package.json contains some additional metadata under the following keys:
style - path to Bootstrap’s non-minified CSS that’s been compiled using the default settings (no customization)
-
-Get started with Bootstrap via npm with our starter project! Head to the Sass & JS example template repository to see how to build and customize Bootstrap in your own npm project. Includes Sass compiler, Autoprefixer, Stylelint, PurgeCSS, and Bootstrap Icons.
-
-
-
yarn
+
Get started with Bootstrap via npm with our starter project! Head to the Sass & JS example template repository to see how to build and customize Bootstrap in your own npm project. Includes Sass compiler, Autoprefixer, Stylelint, PurgeCSS, and Bootstrap Icons.
+
yarn
Install Bootstrap in your Node.js powered apps with the yarn package:
-
yarn add bootstrap@5.3.5
-
-
Yarn 2+ (aka Yarn Berry) doesn’t support the node_modules directory by default: using our Sass & JS example needs some adjustments:
-
yarn config set nodeLinker node-modules # Use the node_modules linker
-touch yarn.lock # Create an empty yarn.lock file
-yarn install # Install the dependencies
-yarn start # Start the project
-
-
-
-
RubyGems
+
yarnadd bootstrap@5.3.5
+
+
Yarn 2+ (aka Yarn Berry) doesn’t support the node_modules directory by default: using our Sass & JS example needs some adjustments:
yarn config set nodeLinker node-modules # Use the node_modules linker
+touch yarn.lock # Create an empty yarn.lock file
+yarninstall# Install the dependencies
+yarn start # Start the project
+
+
Bun
+
Install Bootstrap in your Bun or Node.js powered apps with the Bun CLI:
+
bun add bootstrap@5.3.5
+
+
RubyGems
Install Bootstrap in your Ruby apps using Bundler (recommended) and RubyGems by adding the following line to your Gemfile:
-
gem'bootstrap','~> 5.3.5'
-
Alternatively, if you’re not using Bundler, you can install the gem by running this command:
You can also install and manage Bootstrap’s Sass and JavaScript using Composer:
-
composer require twbs/bootstrap:5.3.5
-
NuGet
-
If you develop in .NET Framework, you can also install and manage Bootstrap’s CSS or Sass and JavaScript using NuGet. Newer projects should use libman or another method as NuGet is designed for compiled code, not frontend assets.
-
Install-Packagebootstrap
-
Install-Packagebootstrap.sass
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
gem 'bootstrap','~> 5.3.5'
+
+
Alternatively, if you’re not using Bundler, you can install the gem by running this command:
You can also install and manage Bootstrap’s Sass and JavaScript using Composer:
+
composer require twbs/bootstrap:5.3.5
+
+
NuGet
+
If you develop in .NET Framework, you can also install and manage Bootstrap’s CSS or Sass and JavaScript using NuGet. Newer projects should use libman or another method as NuGet is designed for compiled code, not frontend assets.
+
Install-Package bootstrap
+
+
Install-Package bootstrap.sass
+
\ No newline at end of file
diff --git a/docs/5.3/getting-started/index.html b/docs/5.3/getting-started/index.html
index 349df656a8..77668bc23d 100644
--- a/docs/5.3/getting-started/index.html
+++ b/docs/5.3/getting-started/index.html
@@ -1,12 +1 @@
-
-
-
-
-
- https://getbootstrap.com/docs/5.3/getting-started/introduction/
-
-
-
-
-
-
+ Bootstrap
\ No newline at end of file
diff --git a/docs/5.3/getting-started/introduction/index.html b/docs/5.3/getting-started/introduction/index.html
index c15654c426..17d3c6c4e8 100644
--- a/docs/5.3/getting-started/introduction/index.html
+++ b/docs/5.3/getting-started/introduction/index.html
@@ -1,643 +1,100 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Get started with Bootstrap · Bootstrap v5.3
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Get started by including Bootstrap’s production-ready CSS and JavaScript via CDN without the need for any build steps. See it in practice with this Bootstrap CodePen demo.
Get started by including Bootstrap’s production-ready CSS and JavaScript via CDN without the need for any build steps. See it in practice with this Bootstrap CodePen demo.
+
Create a new index.html file in your project root. Include the <meta name="viewport"> tag as well for proper responsive behavior in mobile devices.
Include Bootstrap’s CSS and JS. Place the <link> tag in the <head> for our CSS, and the <script> tag for our JavaScript bundle (including Popper for positioning dropdowns, popovers, and tooltips) before the closing </body>. Learn more about our CDN links.
You can also include Popper and our JS separately. If you don’t plan to use dropdowns, popovers, or tooltips, save some kilobytes by not including Popper.
Include Bootstrap’s CSS and JS. Place the <link> tag in the <head> for our CSS, and the <script> tag for our JavaScript bundle (including Popper for positioning dropdowns, popovers, and tooltips) before the closing </body>. Learn more about our CDN links.
You can also include Popper and our JS separately. If you don’t plan to use dropdowns, popovers, or tooltips, save some kilobytes by not including Popper.
Hello, world! Open the page in your browser of choice to see your Bootstrapped page. Now you can start building with Bootstrap by creating your own layout, adding dozens of components, and utilizing our official examples.
+
Hello, world! Open the page in your browser of choice to see your Bootstrapped page. Now you can start building with Bootstrap by creating your own layout, adding dozens of components, and utilizing our official examples.
Looking to use Bootstrap as a module with <script type="module">? Please refer to our using Bootstrap as a module section.
-
JS components
-
Curious which components explicitly require our JavaScript and Popper? If you’re at all unsure about the general page structure, keep reading for an example page template.
+
JS components
+
Curious which components explicitly require our JavaScript and Popper? If you’re at all unsure about the general page structure, keep reading for an example page template.
Accordions for extending our Collapse plugin
Alerts for dismissing
@@ -653,29 +110,32 @@
Toasts for displaying and dismissing
Tooltips and popovers for displaying and positioning (also requires Popper)
-
Important globals
-
Bootstrap employs a handful of important global styles and settings, all of which are almost exclusively geared towards the normalization of cross browser styles. Let’s dive in.
-
HTML5 doctype
-
Bootstrap requires the use of the HTML5 doctype. Without it, you’ll see some funky and incomplete styling.
-
<!doctype html>
-<htmllang="en">
- ...
-</html>
-
Viewport meta
+
Important globals
+
Bootstrap employs a handful of important global styles and settings, all of which are almost exclusively geared towards the normalization of cross browser styles. Let’s dive in.
+
HTML5 doctype
+
Bootstrap requires the use of the HTML5 doctype. Without it, you’ll see some funky and incomplete styling.
+
<!doctypehtml>
+<htmllang="en">
+ ...
+</html>
+
+
Viewport meta
Bootstrap is developed mobile first, a strategy in which we optimize code for mobile devices first and then scale up components as necessary using CSS media queries. To ensure proper rendering and touch zooming for all devices, add the responsive viewport meta tag to your <head>.
You can see an example of this in action in the quick start.
+
Box-sizing
For more straightforward sizing in CSS, we switch the global box-sizing value from content-box to border-box. This ensures padding does not affect the final computed width of an element, but it can cause problems with some third-party software like Google Maps and Google Custom Search Engine.
On the rare occasion you need to override it, use something like the following:
With the above snippet, nested elements—including generated content via ::before and ::after—will all inherit the specified box-sizing for that .selector-for-some-widget.
With the above snippet, nested elements—including generated content via ::before and ::after—will all inherit the specified box-sizing for that .selector-for-some-widget.
For improved cross-browser rendering, we use Reboot to correct inconsistencies across browsers and devices while providing slightly more opinionated resets to common HTML elements.
-
Community
+
Reboot
+
For improved cross-browser rendering, we use Reboot to correct inconsistencies across browsers and devices while providing slightly more opinionated resets to common HTML elements.
+
Community
Stay up-to-date on the development of Bootstrap and reach out to the community with these helpful resources.
Implementation help may be found at Stack Overflow (tagged bootstrap-5).
Developers should use the keyword bootstrap on packages that modify or add to the functionality of Bootstrap when distributing through npm or similar delivery mechanisms for maximum discoverability.
-
You can also follow @getbootstrap on X for the latest gossip and awesome music videos.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
You can also follow @getbootstrap on X for the latest gossip and awesome music videos.
Plugins can be included individually (using Bootstrap’s individual js/dist/*.js), or all at once using bootstrap.js or the minified bootstrap.min.js (don’t include both).
-
If you use a bundler (Webpack, Parcel, Vite…), you can use /js/dist/*.js files which are UMD ready.
-
Usage with JavaScript frameworks
-
While the Bootstrap CSS can be used with any framework, the Bootstrap JavaScript is not fully compatible with JavaScript frameworks like React, Vue, and Angular which assume full knowledge of the DOM. Both Bootstrap and the framework may attempt to mutate the same DOM element, resulting in bugs like dropdowns that are stuck in the “open” position.
Plugins can be included individually (using Bootstrap’s individual js/dist/*.js), or all at once using bootstrap.js or the minified bootstrap.min.js (don’t include both).
+
If you use a bundler (Webpack, Parcel, Vite…), you can use /js/dist/*.js files which are UMD ready.
+
Usage with JavaScript frameworks
+
While the Bootstrap CSS can be used with any framework, the Bootstrap JavaScript is not fully compatible with JavaScript frameworks like React, Vue, and Angular which assume full knowledge of the DOM. Both Bootstrap and the framework may attempt to mutate the same DOM element, resulting in bugs like dropdowns that are stuck in the “open” position.
A better alternative for those using this type of frameworks is to use a framework-specific package instead of the Bootstrap JavaScript. Here are some of the most popular options:
We provide a version of Bootstrap built as ESM (bootstrap.esm.js and bootstrap.esm.min.js) which allows you to use Bootstrap as a module in the browser, if your targeted browsers support it.
Compared to JS bundlers, using ESM in the browser requires you to use the full path and filename instead of the module name. Read more about JS modules in the browser. That’s why we use 'bootstrap.esm.min.js' instead of 'bootstrap' above. However, this is further complicated by our Popper dependency, which imports Popper into our JavaScript like so:
-
-
import*asPopperfrom"@popperjs/core"
-
If you try this as-is, you’ll see an error in the console like the following:
-
Uncaught TypeError: Failed to resolve module specifier "@popperjs/core". Relative references must start with either "/", "./", or "../".
-
To fix this, you can use an importmap to resolve the arbitrary module names to complete paths. If your targeted browsers do not support importmap, you’ll need to use the es-module-shims project. Here’s how it works for Bootstrap and Popper:
Compared to JS bundlers, using ESM in the browser requires you to use the full path and filename instead of the module name. Read more about JS modules in the browser. That’s why we use 'bootstrap.esm.min.js' instead of 'bootstrap' above. However, this is further complicated by our Popper dependency, which imports Popper into our JavaScript like so:
+
import*as Popper from"@popperjs/core"
+
+
If you try this as-is, you’ll see an error in the console like the following:
+
Uncaught TypeError: Failed to resolve module specifier "@popperjs/core". Relative references must start with either "/", "./", or "../".
+
+
To fix this, you can use an importmap to resolve the arbitrary module names to complete paths. If your targeted browsers do not support importmap, you’ll need to use the es-module-shims project. Here’s how it works for Bootstrap and Popper:
Some plugins and CSS components depend on other plugins. If you include plugins individually, make sure to check for these dependencies in the docs.
Our dropdowns, popovers, and tooltips also depend on Popper.
-
Data attributes
+
Data attributes
Nearly all Bootstrap plugins can be enabled and configured through HTML alone with data attributes (our preferred way of using JavaScript functionality). Be sure to only use one set of data attributes on a single element (e.g., you cannot trigger a tooltip and modal from the same button.)
-
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
-
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
+
As options can be passed via data attributes or JavaScript, you can append an option name to data-bs-, as in data-bs-animation="{value}". Make sure to change the case type of the option name from “camelCase” to “kebab-case” when passing the options via data attributes. For example, use data-bs-custom-class="beautifier" instead of data-bs-customClass="beautifier".
+
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute data-bs-config that can house simple component configuration as a JSON string. When an element has data-bs-config='{"delay":0, "title":123}' and data-bs-title="456" attributes, the final title value will be 456 and the separate data attributes will override values given on data-bs-config. In addition, existing data attributes are able to house JSON values like data-bs-delay='{"show":0,"hide":150}'.
The final configuration object is the merged result of data-bs-config, data-bs-, and js object where the latest given key-value overrides the others.
-
-
Selectors
+
Selectors
We use the native querySelector and querySelectorAll methods to query DOM elements for performance reasons, so you must use valid selectors. If you use special selectors like collapse:Example, be sure to escape them.
-
Events
-
Bootstrap provides custom events for most plugins’ unique actions. Generally, these come in an infinitive and past participle form - where the infinitive (ex. show) is triggered at the start of an event, and its past participle form (ex. shown) is triggered on the completion of an action.
+
Events
+
Bootstrap provides custom events for most plugins’ unique actions. Generally, these come in an infinitive and past participle form - where the infinitive (ex. show) is triggered at the start of an event, and its past participle form (ex. shown) is triggered on the completion of an action.
All infinitive events provide preventDefault() functionality. This provides the ability to stop the execution of an action before it starts. Returning false from an event handler will also automatically call preventDefault().
-
constmyModal=document.querySelector('#myModal')
-
-myModal.addEventListener('show.bs.modal',event=>{
-returnevent.preventDefault()// stops modal from being shown
-})
-
Programmatic API
+
const myModal = document.querySelector('#myModal')
+
+myModal.addEventListener('show.bs.modal',event=>{
+ return event.preventDefault()// stops modal from being shown
+})
+
+
Programmatic API
All constructors accept an optional options object or nothing (which initiates a plugin with its default behavior):
-
constmyModalEl=document.querySelector('#myModal')
-constmodal=newbootstrap.Modal(myModalEl)// initialized with defaults
-
-constconfigObject={keyboard:false}
-constmodal1=newbootstrap.Modal(myModalEl,configObject)// initialized with no keyboard
-
If you’d like to get a particular plugin instance, each plugin exposes a getInstance method. For example, to retrieve an instance directly from an element:
-
bootstrap.Popover.getInstance(myPopoverEl)
-
This method will return null if an instance is not initiated over the requested element.
-
Alternatively, getOrCreateInstance can be used to get the instance associated with a DOM element, or create a new one in case it wasn’t initialized.
In case an instance wasn’t initialized, it may accept and use an optional configuration object as second argument.
-
CSS selectors in constructors
+
const myModalEl = document.querySelector('#myModal')
+const modal =newbootstrap.Modal(myModalEl)// initialized with defaults
+
+const configObject ={keyboard:false}
+const modal1 =newbootstrap.Modal(myModalEl, configObject)// initialized with no keyboard
+
+
If you’d like to get a particular plugin instance, each plugin exposes a getInstance method. For example, to retrieve an instance directly from an element:
+
bootstrap.Popover.getInstance(myPopoverEl)
+
+
This method will return null if an instance is not initiated over the requested element.
+
Alternatively, getOrCreateInstance can be used to get the instance associated with a DOM element, or create a new one in case it wasn’t initialized.
In case an instance wasn’t initialized, it may accept and use an optional configuration object as second argument.
+
CSS selectors in constructors
In addition to the getInstance and getOrCreateInstance methods, all plugin constructors can accept a DOM element or a valid CSS selector as the first argument. Plugin elements are found with the querySelector method since our plugins only support a single element.
All programmatic API methods are asynchronous and return to the caller once the transition is started, but before it ends. In order to execute an action once the transition is complete, you can listen to the corresponding event.
-
constmyCollapseEl=document.querySelector('#myCollapse')
-
-myCollapseEl.addEventListener('shown.bs.collapse',event=>{
-// Action to execute once the collapsible area is expanded
-})
-
In addition, a method call on a transitioning component will be ignored.
-
constmyCarouselEl=document.querySelector('#myCarousel')
-constcarousel=bootstrap.Carousel.getInstance(myCarouselEl)// Retrieve a Carousel instance
-
-myCarouselEl.addEventListener('slid.bs.carousel',event=>{
-carousel.to('2')// Will slide to the slide 2 as soon as the transition to slide 1 is finished
-})
-
-carousel.to('1')// Will start sliding to the slide 1 and returns to the caller
-carousel.to('2')// !! Will be ignored, as the transition to the slide 1 is not finished !!
-
dispose method
-
While it may seem correct to use the dispose method immediately after hide(), it will lead to incorrect results. Here’s an example of the problem use:
-
constmyModal=document.querySelector('#myModal')
-myModal.hide()// it is asynchronous
-
-myModal.addEventListener('shown.bs.hidden',event=>{
-myModal.dispose()
-})
-
Default settings
-
You can change the default settings for a plugin by modifying the plugin’s Constructor.Default object:
-
// changes default for the modal plugin's `keyboard` option to false
-bootstrap.Modal.Default.keyboard=false
-
Methods and properties
+
const myCollapseEl = document.querySelector('#myCollapse')
+
+myCollapseEl.addEventListener('shown.bs.collapse',event=>{
+ // Action to execute once the collapsible area is expanded
+})
+
+
In addition, a method call on a transitioning component will be ignored.
+
const myCarouselEl = document.querySelector('#myCarousel')
+const carousel = bootstrap.Carousel.getInstance(myCarouselEl)// Retrieve a Carousel instance
+
+myCarouselEl.addEventListener('slid.bs.carousel',event=>{
+ carousel.to('2')// Will slide to the slide 2 as soon as the transition to slide 1 is finished
+})
+
+carousel.to('1')// Will start sliding to the slide 1 and returns to the caller
+carousel.to('2')// !! Will be ignored, as the transition to the slide 1 is not finished !!
+
+
dispose method
+
While it may seem correct to use the dispose method immediately after hide(), it will lead to incorrect results. Here’s an example of the problem use:
+
const myModal = document.querySelector('#myModal')
+myModal.hide()// it is asynchronous
+
+myModal.addEventListener('shown.bs.hidden',event=>{
+ myModal.dispose()
+})
+
+
Default settings
+
You can change the default settings for a plugin by modifying the plugin’s Constructor.Default object:
+
// changes default for the modal plugin’s `keyboard` option to false
+bootstrap.Modal.Default.keyboard =false
+
+
Methods and properties
Every Bootstrap plugin exposes the following methods and static properties.
-
-
-
-
Method
-
Description
-
-
-
-
-
dispose
-
Destroys an element’s modal. (Removes stored data on the DOM element)
-
-
-
getInstance
-
Static method which allows you to get the modal instance associated with a DOM element.
-
-
-
getOrCreateInstance
-
Static method which allows you to get the modal instance associated with a DOM element, or create a new one in case it wasn’t initialized.
-
-
-
+
-
-
-
-
Static property
-
Description
-
-
-
-
-
NAME
-
Returns the plugin name. (Example: bootstrap.Tooltip.NAME)
-
-
-
VERSION
-
The version of each of Bootstrap’s plugins can be accessed via the VERSION property of the plugin’s constructor (Example: bootstrap.Tooltip.VERSION)
-
-
-
-
Sanitizer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Method
Description
dispose
Destroys an element’s modal. (Removes stored data on the DOM element)
getInstance
Static method which allows you to get the modal instance associated with a DOM element.
getOrCreateInstance
Static method which allows you to get the modal instance associated with a DOM element, or create a new one in case it wasn’t initialized.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Static property
Description
NAME
Returns the plugin name. (Example: bootstrap.Tooltip.NAME)
VERSION
The version of each of Bootstrap’s plugins can be accessed via the VERSION property of the plugin’s constructor (Example: bootstrap.Tooltip.VERSION)
+
Sanitizer
Tooltips and Popovers use our built-in sanitizer to sanitize options which accept HTML.
If you want to add new values to this default allowList you can do the following:
-
constmyDefaultAllowList=bootstrap.Tooltip.Default.allowList
-
-// To allow table elements
-myDefaultAllowList.table=[]
-
-// To allow td elements and data-bs-option attributes on td elements
-myDefaultAllowList.td=['data-bs-option']
-
-// You can push your custom regex to validate your attributes.
-// Be careful about your regular expressions being too lax
-constmyCustomRegex=/^data-my-app-[\w-]+/
-myDefaultAllowList['*'].push(myCustomRegex)
-
If you want to bypass our sanitizer because you prefer to use a dedicated library, for example DOMPurify, you should do the following:
You don’t need jQuery in Bootstrap 5, but it’s still possible to use our components with jQuery. If Bootstrap detects jQuery in the window object, it’ll add all of our components in jQuery’s plugin system. This allows you to do the following:
-
// to enable tooltips with the default configuration
-$('[data-bs-toggle="tooltip"]').tooltip()
-
-// to initialize tooltips with given configuration
-$('[data-bs-toggle="tooltip"]').tooltip({
-boundary:'clippingParents',
-customClass:'myClass'
-})
-
-// to trigger the `show` method
-$('#myTooltip').tooltip('show')
-
The same goes for our other components.
-
No conflict
+
const myDefaultAllowList = bootstrap.Tooltip.Default.allowList
+
+// To allow table elements
+myDefaultAllowList.table =[]
+
+// To allow td elements and data-bs-option attributes on td elements
+myDefaultAllowList.td =['data-bs-option']
+
+// You can push your custom regex to validate your attributes.
+// Be careful about your regular expressions being too lax
+const myCustomRegex =/^data-my-app-[\w-]+/
+myDefaultAllowList['*'].push(myCustomRegex)
+
+
If you want to bypass our sanitizer because you prefer to use a dedicated library, for example DOMPurify, you should do the following:
You don’t need jQuery in Bootstrap 5, but it’s still possible to use our components with jQuery. If Bootstrap detects jQuery in the window object, it'll add all of our components in jQuery’s plugin system. This allows you to do the following:
+
// to enable tooltips with the default configuration
+$('[data-bs-toggle="tooltip"]').tooltip()
+
+// to initialize tooltips with given configuration
+$('[data-bs-toggle="tooltip"]').tooltip({
+ boundary:'clippingParents',
+ customClass:'myClass'
+})
+
+// to trigger the `show` method
+$('#myTooltip').tooltip('show')
+
+
The same goes for our other components.
+
No conflict
Sometimes it is necessary to use Bootstrap plugins with other UI frameworks. In these circumstances, namespace collisions can occasionally occur. If this happens, you may call .noConflict on the plugin you wish to revert the value of.
-
constbootstrapButton=$.fn.button.noConflict()// return $.fn.button to previously assigned value
-$.fn.bootstrapBtn=bootstrapButton// give $().bootstrapBtn the Bootstrap functionality
-
Bootstrap does not officially support third-party JavaScript libraries like Prototype or jQuery UI. Despite .noConflict and namespaced events, there may be compatibility problems that you need to fix on your own.
-
jQuery events
-
Bootstrap will detect jQuery if jQuery is present in the window object and there is no data-bs-no-jquery attribute set on <body>. If jQuery is found, Bootstrap will emit events thanks to jQuery’s event system. So if you want to listen to Bootstrap’s events, you’ll have to use the jQuery methods (.on, .one) instead of addEventListener.
-
$('#myTab a').on('shown.bs.tab',()=>{
-// do something...
-})
-
Disabled JavaScript
-
Bootstrap’s plugins have no special fallback when JavaScript is disabled. If you care about the user experience in this case, use <noscript> to explain the situation (and how to re-enable JavaScript) to your users, and/or add your own custom fallbacks.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
const bootstrapButton = $.fn.button.noConflict()// return $.fn.button to previously assigned value
+$.fn.bootstrapBtn = bootstrapButton // give $().bootstrapBtn the Bootstrap functionality
+
+
Bootstrap does not officially support third-party JavaScript libraries like Prototype or jQuery UI. Despite .noConflict and namespaced events, there may be compatibility problems that you need to fix on your own.
+
jQuery events
+
Bootstrap will detect jQuery if jQuery is present in the window object and there is no data-bs-no-jquery attribute set on <body>. If jQuery is found, Bootstrap will emit events thanks to jQuery’s event system. So if you want to listen to Bootstrap’s events, you’ll have to use the jQuery methods (.on, .one) instead of addEventListener.
+
$('#myTab a').on('shown.bs.tab',()=>{
+ // do something...
+})
+
+
Disabled JavaScript
+
Bootstrap’s plugins have no special fallback when JavaScript is disabled. If you care about the user experience in this case, use <noscript> to explain the situation (and how to re-enable JavaScript) to your users, and/or add your own custom fallbacks.
-Want to skip to the end? Download the source code and working demo for this guide from the twbs/examples repository. You can also open the example in StackBlitz but not run it because Parcel isn’t currently supported there.
-
Want to skip to the end? Download the source code and working demo for this guide from the twbs/examples repository. You can also open the example in StackBlitz but not run it because Parcel isn’t currently supported there.
+
What is Parcel?
Parcel is a web application bundler designed to simplify the development process with a zero-configuration setup out of the box. It offers features found in more advanced bundlers while focusing on ease of use, making it ideal for developers seeking a quick start.
-
Setup
-
We’re building a Parcel project with Bootstrap from scratch, so there are some prerequisites and upfront steps before we can really get started. This guide requires you to have Node.js installed and some familiarity with the terminal.
+
Setup
+
We’re building a Parcel project with Bootstrap from scratch, so there are some prerequisites and upfront steps before we can really get started. This guide requires you to have Node.js installed and some familiarity with the terminal.
-
Create a project folder and set up npm. We’ll create the my-project folder and initialize npm with the -y argument to avoid it asking us all the interactive questions.
-
mkdir my-project &&cd my-project
-npm init -y
-
+
Create a project folder and set up npm. We'll create the my-project folder and initialize npm with the -y argument to avoid it asking us all the interactive questions.
+
mkdir my-project &&cd my-project
+npm init -y
+
+
-
Install Parcel. Unlike our Webpack guide, there’s only a single build tool dependency here. Parcel will automatically install language transformers (like Sass) as it detects them. We use --save-dev to signal that this dependency is only for development use and not for production.
-
npm i --save-dev parcel
-
+
Install Parcel. Unlike our Webpack guide, there’s only a single build tool dependency here. Parcel will automatically install language transformers (like Sass) as it detects them. We use --save-dev to signal that this dependency is only for development use and not for production.
+
npm i --save-dev parcel
+
+
-
Install Bootstrap. Now we can install Bootstrap. We’ll also install Popper since our dropdowns, popovers, and tooltips depend on it for their positioning. If you don’t plan on using those components, you can omit Popper here.
-
npm i --save bootstrap @popperjs/core
-
+
Install Bootstrap. Now we can install Bootstrap. We'll also install Popper since our dropdowns, popovers, and tooltips depend on it for their positioning. If you don’t plan on using those components, you can omit Popper here.
+
npm i --save bootstrap @popperjs/core
+
+
Now that we have all the necessary dependencies installed, we can get to work creating the project files and importing Bootstrap.
-
Project structure
-
We’ve already created the my-project folder and initialized npm. Now we’ll also create our src folder, stylesheet, and JavaScript file to round out the project structure. Run the following from my-project, or manually create the folder and file structure shown below.
At this point, everything is in the right place, but Parcel needs an HTML page and npm script to start our server.
-
Configure Parcel
+
Project structure
+
We’ve already created the my-project folder and initialized npm. Now we'll also create our src folder, stylesheet, and JavaScript file to round out the project structure. Run the following from my-project, or manually create the folder and file structure shown below.
At this point, everything is in the right place, but Parcel needs an HTML page and npm script to start our server.
+
Configure Parcel
With dependencies installed and our project folder ready for us to start coding, we can now configure Parcel and run our project locally. Parcel itself requires no configuration file by design, but we do need an npm script and an HTML file to start our server.
Fill in the src/index.html file. Parcel needs a page to render, so we use our index.html page to set up some basic HTML, including our CSS and JavaScript files.
We’re including a little bit of Bootstrap styling here with the div class="container" and <button> so that we see when Bootstrap’s CSS is loaded by Parcel.
-
Parcel will automatically detect we’re using Sass and install the Sass Parcel plugin to support it. However, if you wish, you can also manually run npm i --save-dev @parcel/transformer-sass.
We’re including a little bit of Bootstrap styling here with the div class="container" and <button> so that we see when Bootstrap’s CSS is loaded by Parcel.
+
Parcel will automatically detect we’re using Sass and install the Sass Parcel plugin to support it. However, if you wish, you can also manually run npm i --save-dev @parcel/transformer-sass.
-
Add the Parcel npm scripts. Open the package.json and add the following start script to the scripts object. We’ll use this script to start our Parcel development server and render the HTML file we created after it’s compiled into the dist directory.
Add the Parcel npm scripts. Open the package.json and add the following start script to the scripts object. We'll use this script to start our Parcel development server and render the HTML file we created after it’s compiled into the dist directory.
And finally, we can start Parcel. From the my-project folder in your terminal, run that newly added npm script:
-
npm start
-
-
+
npm start
+
+
-
In the next and final section to this guide, we’ll import all of Bootstrap’s CSS and JavaScript.
-
Import Bootstrap
+
In the next and final section to this guide, we'll import all of Bootstrap’s CSS and JavaScript.
+
Import Bootstrap
Importing Bootstrap into Parcel requires two imports, one into our styles.scss and one into our main.js.
-
Import Bootstrap’s CSS. Add the following to src/scss/styles.scss to import all of Bootstrap’s source Sass.
-
// Import all of Bootstrap's CSS
-@import"bootstrap/scss/bootstrap";
-
You can also import our stylesheets individually if you want. Read our Sass import docs for details.
+
Import Bootstrap’s CSS. Add the following to src/scss/styles.scss to import all of Bootstrap’s source Sass.
+
// Import all of Bootstrap’s CSS
+@import"bootstrap/scss/bootstrap";
+
+
You can also import our stylesheets individually if you want. Read our Sass import docs for details.
+
Optional: You may see Sass deprecation warnings with the latest versions of Dart Sass. These can silenced by adding the following configuration in a .sassrc.js file in the root folder with the following:
And you’re done! 🎉 With Bootstrap’s source Sass and JS fully loaded, your local development server should now look like this:
-
-
-
Now you can start adding any Bootstrap components you want to use. Be sure to check out the complete Parcel example project for how to include additional custom Sass and optimize your build by importing only the parts of Bootstrap’s CSS and JS that you need.
+
And you’re done! 🎉 With Bootstrap’s source Sass and JS fully loaded, your local development server should now look like this:
+
+
Now you can start adding any Bootstrap components you want to use. Be sure to check out the complete Parcel example project for how to include additional custom Sass and optimize your build by importing only the parts of Bootstrap’s CSS and JS that you need.
Bootstrap’s side project RFS is a unit resizing engine which was initially developed to resize font sizes (hence its abbreviation for Responsive Font Sizes). Nowadays RFS is capable of rescaling most CSS properties with unit values like margin, padding, border-radius, or even box-shadow.
Bootstrap’s side project RFS is a unit resizing engine which was initially developed to resize font sizes (hence its abbreviation for Responsive Font Sizes). Nowadays RFS is capable of rescaling most CSS properties with unit values like margin, padding, border-radius, or even box-shadow.
The mechanism automatically calculates the appropriate values based on the dimensions of the browser viewport. It will be compiled into calc() functions with a mix of rem and viewport units to enable the responsive scaling behavior.
-
Using RFS
-
The mixins are included in Bootstrap and are available once you include Bootstrap’s scss. RFS can also be installed standalone if needed.
-
Using the mixins
+
Using RFS
+
The mixins are included in Bootstrap and are available once you include Bootstrap’s scss. RFS can also be installed standalone if needed.
+
Using the mixins
The rfs() mixin has shorthands for font-size, margin, margin-top, margin-right, margin-bottom, margin-left, padding, padding-top, padding-right, padding-bottom, and padding-left. See the example below for source Sass and compiled CSS.
@media(max-width:991.98px){
-.selector{
-padding:calc(1.325rem+0.9vw);
-font-size:1.125rem;/* 1.125rem is small enough, so RFS won't rescale this */
-}
-}
-
Extended documentation
-
RFS is a separate project under the Bootstrap organization. More about RFS and its configuration can be found on its GitHub repository.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
In this example, we use one of Bootstrap’s built-in responsive breakpoint mixins to only apply styling below the lg breakpoint.
We recommend getting familiar with Bootstrap first by reading through our Getting Started Introduction page. Once you’ve run through it, continue reading here for how to enable RTL.
We recommend getting familiar with Bootstrap first by reading through our Getting Started Introduction page. Once you’ve run through it, continue reading here for how to enable RTL.
You may also want to read up on the RTLCSS project, as it powers our approach to RTL.
-
-Bootstrap’s RTL feature is still experimental and will evolve based on user feedback. Spotted something or have an improvement to suggest? Open an issue, we’d love to get your insights.
-
-
-
Required HTML
+
Bootstrap’s RTL feature is still experimental and will evolve based on user feedback. Spotted something or have an improvement to suggest? Open an issue, we’d love to get your insights.
+
Required HTML
There are two strict requirements for enabling RTL in Bootstrap-powered pages.
Set dir="rtl" on the <html> element.
Add an appropriate lang attribute, like lang="ar", on the <html> element.
-
From there, you’ll need to include an RTL version of our CSS. For example, here’s the stylesheet for our compiled and minified CSS with RTL enabled:
Our approach to building RTL support into Bootstrap comes with two important decisions that impact how we write and use our CSS:
First, we decided to build it with the RTLCSS project. This gives us some powerful features for managing changes and overrides when moving from LTR to RTL. It also allows us to build two versions of Bootstrap from one codebase.
-
Second, we’ve renamed a handful of directional classes to adopt a logical properties approach. Most of you have already interacted with logical properties thanks to our flex utilities—they replace direction properties like left and right in favor start and end. That makes the class names and values appropriate for LTR and RTL without any overhead.
+
Second, we’ve renamed a handful of directional classes to adopt a logical properties approach. Most of you have already interacted with logical properties thanks to our flex utilities—they replace direction properties like left and right in favor start and end. That makes the class names and values appropriate for LTR and RTL without any overhead.
For example, instead of .ml-3 for margin-left, use .ms-3.
-
Working with RTL, through our source Sass or compiled CSS, shouldn’t be much different from our default LTR though.
-
Customize from source
-
When it comes to customization, the preferred way is to take advantage of variables, maps, and mixins. This approach works the same for RTL, even if it’s post-processed from the compiled files, thanks to how RTLCSS works.
-
Custom RTL values
+
Working with RTL, through our source Sass or compiled CSS, shouldn’t be much different from our default LTR though.
+
Customize from source
+
When it comes to customization, the preferred way is to take advantage of variables, maps, and mixins. This approach works the same for RTL, even if it’s post-processed from the compiled files, thanks to how RTLCSS works.
+
Custom RTL values
Using RTLCSS value directives, you can make a variable output a different value for RTL. For example, to decrease the weight for $font-weight-bold throughout the codebase, you may use the /*rtl: {value}*/ syntax:
-
$font-weight-bold:700#{/* rtl:600 */}!default;
-
Which would output to the following for our default CSS and RTL CSS:
In the case you’re using a custom font, be aware that not all fonts support the non-Latin alphabet. To switch from Pan-European to Arabic family, you may need to use /*rtl:insert: {value}*/ in your font stack to modify the names of font families.
In the case you’re using a custom font, be aware that not all fonts support the non-Latin alphabet. To switch from Pan-European to Arabic family, you may need to use /*rtl:insert: {value}*/ in your font stack to modify the names of font families.
For example, to switch from Helvetica Neue font for LTR to Helvetica Neue Arabic for RTL, your Sass code could look like this:
-
$font-family-sans-serif:
-HelveticaNeue#{"/* rtl:insert:Arabic */"},
-// Cross-platform generic font family (default user interface font)
-system-ui,
-// Safari for macOS and iOS (San Francisco)
--apple-system,
-// Chrome < 56 for macOS (San Francisco)
-BlinkMacSystemFont,
-// Windows
-"Segoe UI",
-// Android
-Roboto,
-// Basic web fallback
-Arial,
-// Linux
-"Noto Sans",
-// Sans serif fallback
-sans-serif,
-// Emoji fonts
-"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"!default;
-
LTR and RTL at the same time
+
$font-family-sans-serif:
+ Helvetica Neue #{"/* rtl:insert:Arabic */"},
+ // Cross-platform generic font family (default user interface font)
+ system-ui,
+ // Safari for macOS and iOS (San Francisco)
+ -apple-system,
+ // Chrome < 56 for macOS (San Francisco)
+ BlinkMacSystemFont,
+ // Windows
+ "Segoe UI",
+ // Android
+ Roboto,
+ // Basic web fallback
+ Arial,
+ // Linux
+ "Noto Sans",
+ // Sans serif fallback
+ sans-serif,
+ // Emoji fonts
+ "Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"!default;
+
+
LTR and RTL at the same time
Need both LTR and RTL on the same page? Thanks to RTLCSS String Maps, this is pretty straightforward. Wrap your @imports with a class, and set a custom rename rule for RTLCSS:
After running Sass then RTLCSS, each selector in your CSS files will be prepended by .ltr, and .rtl for RTL files. Now you’re able to use both files on the same page, and simply use .ltr or .rtl on your components wrappers to use one or the other direction.
-
-
Edge cases and known limitations to consider when working with a combined LTR and RTL implementation:
After running Sass then RTLCSS, each selector in your CSS files will be prepended by .ltr, and .rtl for RTL files. Now you’re able to use both files on the same page, and simply use .ltr or .rtl on your components wrappers to use one or the other direction.
+
Edge cases and known limitations to consider when working with a combined LTR and RTL implementation:
When switching .ltr and .rtl, make sure you add dir and lang attributes accordingly.
Nesting styles this way will prevent our form-validation-state() mixin from working as intended, thus require you tweak it a bit by yourself. See #31223.
-
-
-
+
Do you want to automate this process and address several edge cases involving both directions within a single stylesheet? Then, consider using PostCSS RTLCSS as a PostCSS plugin to process your source files. PostCSS RTLCSS uses RTLCSS behind the scenes to manage the direction flipping process, but it separates the flipped declarations into rules with a different prefix for LTR and RTL, something that allows you to have both directions within the same stylesheet file. By doing this, you can switch between LTR and RTL orientations by simply changing the dir of the page (or even by modifying a specific class if you configure the plugin accordingly).
-
-
Important things to take into account when using PostCSS RTLCSS to build a combined LTR and RTL implementation:
-
+
Important things to take into account when using PostCSS RTLCSS to build a combined LTR and RTL implementation:
It is recommended that you add the dir attribute to the html element. This way, the entire page will be affected when you change the direction. Also, make sure you add the lang attribute accordingly.
-
Having a single bundle with both directions will increase the size of the final stylesheet (on average, by 20%-30%): consider some optimization.
-
Take into account that PostCSS RTLCSS is not compatible with /* rtl:remove */ directives because it doesn’t remove any CSS rule. You should replace your /* rtl:remove */, /* rtl:begin:remove */ and /* rtl:end:remove */ directives with /* rtl:freeze */, /* rtl:begin:freeze */ and /* rtl:end:freeze */ directives respectively. These directives will prefix the targeted rules or declarations with the current direction but will not create an RTL counterpart (same result as the remove ones in RTLCSS).
-
-
-
-
The breadcrumb case
-
The breadcrumb separator is the only case requiring its own brand-new variable— namely $breadcrumb-divider-flipped —defaulting to $breadcrumb-divider.
-
Additional resources
+
Having a single bundle with both directions will increase the size of the final stylesheet (on average, by 20%-30%): consider some optimization.
+
Take into account that PostCSS RTLCSS is not compatible with /* rtl:remove */ directives because it doesn’t remove any CSS rule. You should replace your /* rtl:remove */, /* rtl:begin:remove */ and /* rtl:end:remove */ directives with /* rtl:freeze */, /* rtl:begin:freeze */ and /* rtl:end:freeze */ directives respectively. These directives will prefix the targeted rules or declarations with the current direction but will not create an RTL counterpart (same result as the remove ones in RTLCSS).
+
+
The breadcrumb case
+
The breadcrumb separator is the only case requiring its own brand-new variable— namely $breadcrumb-divider-flipped —defaulting to $breadcrumb-divider.
Vite is a modern frontend build tool designed for speed and simplicity. It provides an efficient and streamlined development experience, especially for modern JavaScript frameworks.
-
Setup
-
We’re building a Vite project with Bootstrap from scratch, so there are some prerequisites and upfront steps before we can really get started. This guide requires you to have Node.js installed and some familiarity with the terminal.
+
Setup
+
We’re building a Vite project with Bootstrap from scratch, so there are some prerequisites and upfront steps before we can really get started. This guide requires you to have Node.js installed and some familiarity with the terminal.
-
Create a project folder and set up npm. We’ll create the my-project folder and initialize npm with the -y argument to avoid it asking us all the interactive questions.
-
mkdir my-project &&cd my-project
-npm init -y
-
+
Create a project folder and set up npm. We'll create the my-project folder and initialize npm with the -y argument to avoid it asking us all the interactive questions.
+
mkdir my-project &&cd my-project
+npm init -y
+
+
Install Vite. Unlike our Webpack guide, there’s only a single build tool dependency here. We use --save-dev to signal that this dependency is only for development use and not for production.
-
npm i --save-dev vite
-
+
npm i --save-dev vite
+
+
-
Install Bootstrap. Now we can install Bootstrap. We’ll also install Popper since our dropdowns, popovers, and tooltips depend on it for their positioning. If you don’t plan on using those components, you can omit Popper here.
-
npm i --save bootstrap @popperjs/core
-
+
Install Bootstrap. Now we can install Bootstrap. We'll also install Popper since our dropdowns, popovers, and tooltips depend on it for their positioning. If you don’t plan on using those components, you can omit Popper here.
+
npm i --save bootstrap @popperjs/core
+
+
-
Install additional dependency. In addition to Vite and Bootstrap, we need another dependency (Sass) to properly import and bundle Bootstrap’s CSS.
-
npm i --save-dev sass
-
+
Install additional dependency. In addition to Vite and Bootstrap, we need another dependency (Sass) to properly import and bundle Bootstrap’s CSS.
+
npm i --save-dev sass
+
+
Now that we have all the necessary dependencies installed and set up, we can get to work creating the project files and importing Bootstrap.
-
Project structure
-
We’ve already created the my-project folder and initialized npm. Now we’ll also create our src folder, stylesheet, and JavaScript file to round out the project structure. Run the following from my-project, or manually create the folder and file structure shown below.
At this point, everything is in the right place, but Vite won’t work because we haven’t filled in our vite.config.js yet.
-
Configure Vite
+
Project structure
+
We’ve already created the my-project folder and initialized npm. Now we'll also create our src folder, stylesheet, and JavaScript file to round out the project structure. Run the following from my-project, or manually create the folder and file structure shown below.
At this point, everything is in the right place, but Vite won’t work because we haven’t filled in our vite.config.js yet.
+
Configure Vite
With dependencies installed and our project folder ready for us to start coding, we can now configure Vite and run our project locally.
-
Open vite.config.js in your editor. Since it’s blank, we’ll need to add some boilerplate config to it so we can start our server. This part of the config tells Vite where to look for our project’s JavaScript and how the development server should behave (pulling from the src folder with hot reload).
We’re including a little bit of Bootstrap styling here with the div class="container" and <button> so that we see when Bootstrap’s CSS is loaded by Vite.
+
Open vite.config.js in your editor. Since it’s blank, we'll need to add some boilerplate config to it so we can start our server. This part of the config tells Vite where to look for our project’s JavaScript and how the development server should behave (pulling from the src folder with hot reload).
Note: Sass deprecation warnings are shown when compiling source Sass files with the latest versions of Dart Sass. This does not prevent compilation or usage of Bootstrap. We’re working on a long-term fix, but in the meantime these deprecation notices can be ignored.
-
Now we need an npm script to run Vite. Open package.json and add the start script shown below (you should already have the test script). We’ll use this script to start our local Vite dev server.
-
{
-// ...
-"scripts":{
-"start":"vite",
-"test":"echo \"Error: no test specified\" && exit 1"
-},
-// ...
-}
-
+
Next we fill in src/index.html. This is the HTML page Vite will load in the browser to utilize the bundled CSS and JS we'll add to it in later steps.
We’re including a little bit of Bootstrap styling here with the div class="container" and <button> so that we see when Bootstrap’s CSS is loaded by Vite.
+
+
+
Now we need an npm script to run Vite. Open package.json and add the start script shown below (you should already have the test script). We'll use this script to start our local Vite dev server.
And finally, we can start Vite. From the my-project folder in your terminal, run that newly added npm script:
-
npm start
-
-
+
npm start
+
+
In the next and final section to this guide, we’ll import all of Bootstrap’s CSS and JavaScript.
-
Import Bootstrap
+
Import Bootstrap
-
Import Bootstrap’s CSS. Add the following to src/scss/styles.scss to import all of Bootstrap’s source Sass.
-
// Import all of Bootstrap's CSS
-@import"bootstrap/scss/bootstrap";
-
You can also import our stylesheets individually if you want. Read our Sass import docs for details.
+
Import Bootstrap’s CSS. Add the following to src/scss/styles.scss to import all of Bootstrap’s source Sass.
+
// Import all of Bootstrap’s CSS
+@import"bootstrap/scss/bootstrap";
+
+
You can also import our stylesheets individually if you want. Read our Sass import docs for details.
-
Next we load the CSS and import Bootstrap’s JavaScript. Add the following to src/js/main.js to load the CSS and import all of Bootstrap’s JS. Popper will be imported automatically through Bootstrap.
-
-
// Import our custom CSS
-import'../scss/styles.scss'
-
-// Import all of Bootstrap's JS
-import*asbootstrapfrom'bootstrap'
-
You can also import JavaScript plugins individually as needed to keep bundle sizes down:
-
-
importAlertfrom'bootstrap/js/dist/alert';
-
-// or, specify which plugins you need:
-import{Tooltip,Toast,Popover}from'bootstrap';
-
Next we load the CSS and import Bootstrap’s JavaScript. Add the following to src/js/main.js to load the CSS and import all of Bootstrap’s JS. Popper will be imported automatically through Bootstrap.
+
// Import our custom CSS
+import'../scss/styles.scss'
+
+// Import all of Bootstrap’s JS
+import*as bootstrap from'bootstrap'
+
+
You can also import JavaScript plugins individually as needed to keep bundle sizes down:
+
import Alert from'bootstrap/js/dist/alert';
+
+// or, specify which plugins you need:
+import{ Tooltip, Toast, Popover }from'bootstrap';
+
And you’re done! 🎉 With Bootstrap’s source Sass and JS fully loaded, your local development server should now look like this:
-
-
-
Now you can start adding any Bootstrap components you want to use. Be sure to check out the complete Vite example project for how to include additional custom Sass and optimize your build by importing only the parts of Bootstrap’s CSS and JS that you need.
+
And you’re done! 🎉 With Bootstrap’s source Sass and JS fully loaded, your local development server should now look like this:
+
+
Now you can start adding any Bootstrap components you want to use. Be sure to check out the complete Vite example project for how to include additional custom Sass and optimize your build by importing only the parts of Bootstrap’s CSS and JS that you need.
Webpack is a JavaScript module bundler that processes modules and their dependencies to generate static assets. It simplifies managing complex web applications with multiple files and dependencies.
-
Setup
-
We’re building a Webpack project with Bootstrap from scratch, so there are some prerequisites and upfront steps before we can really get started. This guide requires you to have Node.js installed and some familiarity with the terminal.
+
Setup
+
We’re building a Webpack project with Bootstrap from scratch, so there are some prerequisites and upfront steps before we can really get started. This guide requires you to have Node.js installed and some familiarity with the terminal.
-
Create a project folder and set up npm. We’ll create the my-project folder and initialize npm with the -y argument to avoid it asking us all the interactive questions.
-
mkdir my-project &&cd my-project
-npm init -y
-
+
Create a project folder and set up npm. We'll create the my-project folder and initialize npm with the -y argument to avoid it asking us all the interactive questions.
+
mkdir my-project &&cd my-project
+npm init -y
+
+
-
Install Webpack. Next we need to install our Webpack development dependencies: webpack for the core of Webpack, webpack-cli so we can run Webpack commands from the terminal, and webpack-dev-server so we can run a local development server. Additionally, we’ll install html-webpack-plugin to be able to store our index.html in src directory instead of the default dist one. We use --save-dev to signal that these dependencies are only for development use and not for production.
-
npm i --save-dev webpack webpack-cli webpack-dev-server html-webpack-plugin
-
+
Install Webpack. Next we need to install our Webpack development dependencies: webpack for the core of Webpack, webpack-cli so we can run Webpack commands from the terminal, and webpack-dev-server so we can run a local development server. Additionally, we'll install html-webpack-plugin to be able to store our index.html in src directory instead of the default dist one. We use --save-dev to signal that these dependencies are only for development use and not for production.
+
npm i --save-dev webpack webpack-cli webpack-dev-server html-webpack-plugin
+
+
-
Install Bootstrap. Now we can install Bootstrap. We’ll also install Popper since our dropdowns, popovers, and tooltips depend on it for their positioning. If you don’t plan on using those components, you can omit Popper here.
-
npm i --save bootstrap @popperjs/core
-
+
Install Bootstrap. Now we can install Bootstrap. We'll also install Popper since our dropdowns, popovers, and tooltips depend on it for their positioning. If you don’t plan on using those components, you can omit Popper here.
+
npm i --save bootstrap @popperjs/core
+
+
-
Install additional dependencies. In addition to Webpack and Bootstrap, we need a few more dependencies to properly import and bundle Bootstrap’s CSS and JS with Webpack. These include Sass, some loaders, and Autoprefixer.
-
npm i --save-dev autoprefixer css-loader postcss-loader sass sass-loader style-loader
-
+
Install additional dependencies. In addition to Webpack and Bootstrap, we need a few more dependencies to properly import and bundle Bootstrap’s CSS and JS with Webpack. These include Sass, some loaders, and Autoprefixer.
+
npm i --save-dev autoprefixer css-loader postcss-loader sass sass-loader style-loader
+
+
Now that we have all the necessary dependencies installed, we can get to work creating the project files and importing Bootstrap.
-
Project structure
-
We’ve already created the my-project folder and initialized npm. Now we’ll also create our src and dist folders to round out the project structure. Run the following from my-project, or manually create the folder and file structure shown below.
At this point, everything is in the right place, but Webpack won’t work because we haven’t filled in our webpack.config.js yet.
-
Configure Webpack
+
Project structure
+
We’ve already created the my-project folder and initialized npm. Now we'll also create our src and dist folders to round out the project structure. Run the following from my-project, or manually create the folder and file structure shown below.
At this point, everything is in the right place, but Webpack won’t work because we haven’t filled in our webpack.config.js yet.
+
Configure Webpack
With dependencies installed and our project folder ready for us to start coding, we can now configure Webpack and run our project locally.
-
Open webpack.config.js in your editor. Since it’s blank, we’ll need to add some boilerplate config to it so we can start our server. This part of the config tells Webpack where to look for our project’s JavaScript, where to output the compiled code to (dist), and how the development server should behave (pulling from the dist folder with hot reload).
Next we fill in our src/index.html. This is the HTML page Webpack will load in the browser to utilize the bundled CSS and JS we’ll add to it in later steps. Before we can do that, we have to give it something to render and include the output JS from the previous step.
We’re including a little bit of Bootstrap styling here with the div class="container" and <button> so that we see when Bootstrap’s CSS is loaded by Webpack.
+
Open webpack.config.js in your editor. Since it’s blank, we'll need to add some boilerplate config to it so we can start our server. This part of the config tells Webpack where to look for our project’s JavaScript, where to output the compiled code to (dist), and how the development server should behave (pulling from the dist folder with hot reload).
Now we need an npm script to run Webpack. Open package.json and add the start script shown below (you should already have the test script). We’ll use this script to start our local Webpack dev server. You can also add a build script shown below to build your project.
Next we fill in our src/index.html. This is the HTML page Webpack will load in the browser to utilize the bundled CSS and JS we'll add to it in later steps. Before we can do that, we have to give it something to render and include the output JS from the previous step.
We’re including a little bit of Bootstrap styling here with the div class="container" and <button> so that we see when Bootstrap’s CSS is loaded by Webpack.
+
+
+
Now we need an npm script to run Webpack. Open package.json and add the start script shown below (you should already have the test script). We'll use this script to start our local Webpack dev server. You can also add a build script shown below to build your project.
And finally, we can start Webpack. From the my-project folder in your terminal, run that newly added npm script:
-
npm start
-
-
+
npm start
+
+
-
In the next and final section to this guide, we’ll set up the Webpack loaders and import all of Bootstrap’s CSS and JavaScript.
-
Import Bootstrap
-
Importing Bootstrap into Webpack requires the loaders we installed in the first section. We’ve installed them with npm, but now Webpack needs to be configured to use them.
+
In the next and final section to this guide, we'll set up the Webpack loaders and import all of Bootstrap’s CSS and JavaScript.
+
Import Bootstrap
+
Importing Bootstrap into Webpack requires the loaders we installed in the first section. We’ve installed them with npm, but now Webpack needs to be configured to use them.
Set up the loaders in webpack.config.js. Your configuration file is now complete and should match the snippet below. The only new part here is the module section.
-
'use strict'
-
-constpath=require('path')
-constautoprefixer=require('autoprefixer')
-constHtmlWebpackPlugin=require('html-webpack-plugin')
-
-module.exports={
-mode:'development',
-entry:'./src/js/main.js',
-output:{
-filename:'main.js',
-path:path.resolve(__dirname,'dist')
-},
-devServer:{
-static:path.resolve(__dirname,'dist'),
-port:8080,
-hot:true
-},
-plugins:[
-newHtmlWebpackPlugin({template:'./src/index.html'})
-],
-module:{
-rules:[
-{
-test:/\.(scss)$/,
-use:[
-{
-// Adds CSS to the DOM by injecting a `<style>` tag
-loader:'style-loader'
-},
-{
-// Interprets `@import` and `url()` like `import/require()` and will resolve them
-loader:'css-loader'
-},
-{
-// Loader for webpack to process CSS with PostCSS
-loader:'postcss-loader',
-options:{
-postcssOptions:{
-plugins:[
-autoprefixer
-]
-}
-}
-},
-{
-// Loads a SASS/SCSS file and compiles it to CSS
-loader:'sass-loader'
-}
-]
-}
-]
-}
-}
-
Here’s a recap of why we need all these loaders. style-loader injects the CSS into a <style> element in the <head> of the HTML page, css-loader helps with using @import and url(), postcss-loader is required for Autoprefixer, and sass-loader allows us to use Sass.
+
'use strict'
+
+const path =require('path')
+const autoprefixer =require('autoprefixer')
+const HtmlWebpackPlugin =require('html-webpack-plugin')
+
+module.exports ={
+ mode:'development',
+ entry:'./src/js/main.js',
+ output:{
+ filename:'main.js',
+ path: path.resolve(__dirname,'dist')
+ },
+ devServer:{
+ static: path.resolve(__dirname,'dist'),
+ port:8080,
+ hot:true
+ },
+ plugins:[
+ newHtmlWebpackPlugin({template:'./src/index.html'})
+ ],
+ module:{
+ rules:[
+ {
+ test:/\.(scss)$/,
+ use:[
+ {
+ // Adds CSS to the DOM by injecting a `<style>` tag
+ loader:'style-loader'
+ },
+ {
+ // Interprets `@import` and `url()` like `import/require()` and will resolve them
+ loader:'css-loader'
+ },
+ {
+ // Loader for webpack to process CSS with PostCSS
+ loader:'postcss-loader',
+ options:{
+ postcssOptions:{
+ plugins:[
+ autoprefixer
+ ]
+ }
+ }
+ },
+ {
+ // Loads a SASS/SCSS file and compiles it to CSS
+ loader:'sass-loader',
+ options:{
+ sassOptions:{
+ // Optional: Silence Sass deprecation warnings. See note below.
+ silenceDeprecations:[
+ 'mixed-decls',
+ 'color-functions',
+ 'global-builtin',
+ 'import'
+ ]
+ }
+ }
+ }
+ ]
+ }
+ ]
+ }
+}
+
+
Here’s a recap of why we need all these loaders. style-loader injects the CSS into a <style> element in the <head> of the HTML page, css-loader helps with using @import and url(), postcss-loader is required for Autoprefixer, and sass-loader allows us to use Sass.
+
Note: Sass deprecation warnings are shown when compiling source Sass files with the latest versions of Dart Sass. This does not prevent compilation or usage of Bootstrap. We’re working on a long-term fix, but in the meantime these deprecation notices can be ignored.
-
Now, let’s import Bootstrap’s CSS. Add the following to src/scss/styles.scss to import all of Bootstrap’s source Sass.
-
// Import all of Bootstrap's CSS
-@import"bootstrap/scss/bootstrap";
-
You can also import our stylesheets individually if you want. Read our Sass import docs for details.
+
Now, let’s import Bootstrap’s CSS. Add the following to src/scss/styles.scss to import all of Bootstrap’s source Sass.
+
// Import all of Bootstrap’s CSS
+@import"bootstrap/scss/bootstrap";
+
+
You can also import our stylesheets individually if you want. Read our Sass import docs for details.
-
Next we load the CSS and import Bootstrap’s JavaScript. Add the following to src/js/main.js to load the CSS and import all of Bootstrap’s JS. Popper will be imported automatically through Bootstrap.
-
-
// Import our custom CSS
-import'../scss/styles.scss'
-
-// Import all of Bootstrap's JS
-import*asbootstrapfrom'bootstrap'
-
You can also import JavaScript plugins individually as needed to keep bundle sizes down:
-
-
importAlertfrom'bootstrap/js/dist/alert'
-
-// or, specify which plugins you need:
-import{Tooltip,Toast,Popover}from'bootstrap'
-
Next we load the CSS and import Bootstrap’s JavaScript. Add the following to src/js/main.js to load the CSS and import all of Bootstrap’s JS. Popper will be imported automatically through Bootstrap.
+
// Import our custom CSS
+import'../scss/styles.scss'
+
+// Import all of Bootstrap’s JS
+import*as bootstrap from'bootstrap'
+
+
You can also import JavaScript plugins individually as needed to keep bundle sizes down:
+
import Alert from'bootstrap/js/dist/alert'
+
+// or, specify which plugins you need:
+import{ Tooltip, Toast, Popover }from'bootstrap'
+
And you’re done! 🎉 With Bootstrap’s source Sass and JS fully loaded, your local development server should now look like this:
-
-
-
Now you can start adding any Bootstrap components you want to use. Be sure to check out the complete Webpack example project for how to include additional custom Sass and optimize your build by importing only the parts of Bootstrap’s CSS and JS that you need.
+
And you’re done! 🎉 With Bootstrap’s source Sass and JS fully loaded, your local development server should now look like this:
+
+
Now you can start adding any Bootstrap components you want to use. Be sure to check out the complete Webpack example project for how to include additional custom Sass and optimize your build by importing only the parts of Bootstrap’s CSS and JS that you need.
-
Production optimizations
+
Production optimizations
Depending on your setup, you may want to implement some additional security and speed optimizations useful for running the project in production. Note that these optimizations are not applied on the Webpack example project and are up to you to implement.
-
Extracting CSS
-
The style-loader we configured above conveniently emits CSS into the bundle so that manually loading a CSS file in dist/index.html isn’t necessary. This approach may not work with a strict Content Security Policy, however, and it may become a bottleneck in your application due to the large bundle size.
+
Extracting CSS
+
The style-loader we configured above conveniently emits CSS into the bundle so that manually loading a CSS file in dist/index.html isn’t necessary. This approach may not work with a strict Content Security Policy, however, and it may become a bottleneck in your application due to the large bundle size.
To separate the CSS so that we can load it directly from dist/index.html, use the mini-css-extract-loader Webpack plugin.
First, install the plugin:
-
npm install --save-dev mini-css-extract-plugin
-
Then instantiate and use the plugin in the Webpack configuration:
-
--- a/webpack.config.js
-+++ b/webpack.config.js
-@@ -3,6 +3,7 @@
- const path = require('path')
- const autoprefixer = require('autoprefixer')
- const HtmlWebpackPlugin = require('html-webpack-plugin')
-+const miniCssExtractPlugin = require('mini-css-extract-plugin')
-
- module.exports = {
- mode: 'development',
-@@ -17,7 +18,8 @@ module.exports = {
- hot: true
- },
- plugins: [
-- new HtmlWebpackPlugin({ template: './src/index.html' })
-+ new HtmlWebpackPlugin({ template: './src/index.html' }),
-+ new miniCssExtractPlugin()
- ],
- module: {
- rules: [
-@@ -25,8 +27,8 @@ module.exports = {
- test: /\.(scss)$/,
- use: [
- {
-- // Adds CSS to the DOM by injecting a `<style>` tag
-- loader: 'style-loader'
-+ // Extracts CSS for each JS file that includes CSS
-+ loader: miniCssExtractPlugin.loader
- },
- {
-
After running npm run build again, there will be a new file dist/main.css, which will contain all of the CSS imported by src/js/main.js. If you view dist/index.html in your browser now, the style will be missing, as it is now in dist/main.css. You can include the generated CSS in dist/index.html like this:
Bootstrap’s CSS includes multiple references to SVG files via inline data: URIs. If you define a Content Security Policy for your project that blocks data: URIs for images, then these SVG files will not load. You can get around this problem by extracting the inline SVG files using Webpack’s asset modules feature.
+
npminstall --save-dev mini-css-extract-plugin
+
+
Then instantiate and use the plugin in the Webpack configuration:
+
--- a/webpack.config.js
++++ b/webpack.config.js
+@@ -3,6 +3,7 @@
+const path = require('path')
+const autoprefixer = require('autoprefixer')
+const HtmlWebpackPlugin = require('html-webpack-plugin')
++const miniCssExtractPlugin = require('mini-css-extract-plugin')
+
+module.exports = {
+ mode: 'development',
+@@ -17,7 +18,8 @@ module.exports = {
+ hot: true
+ },
+ plugins: [
+- new HtmlWebpackPlugin({ template: './src/index.html' })
++ new HtmlWebpackPlugin({ template: './src/index.html' }),
++ new miniCssExtractPlugin()
+ ],
+ module: {
+ rules: [
+@@ -25,8 +27,8 @@ module.exports = {
+ test: /\.(scss)$/,
+ use: [
+ {
+- // Adds CSS to the DOM by injecting a `<style>` tag
+- loader: 'style-loader'
++ // Extracts CSS for each JS file that includes CSS
++ loader: miniCssExtractPlugin.loader
+ },
+ {
+
+
After running npm run build again, there will be a new file dist/main.css, which will contain all of the CSS imported by src/js/main.js. If you view dist/index.html in your browser now, the style will be missing, as it is now in dist/main.css. You can include the generated CSS in dist/index.html like this:
Bootstrap’s CSS includes multiple references to SVG files via inline data: URIs. If you define a Content Security Policy for your project that blocks data: URIs for images, then these SVG files will not load. You can get around this problem by extracting the inline SVG files using Webpack’s asset modules feature.
Configure Webpack to extract inline SVG files like this:
The following example shows how the clearfix can be used. Without the clearfix the wrapping div would not span around the buttons which would cause a broken layout.
-
-
-
-
+
.element {
+ @include clearfix;
+}
+
+
The following example shows how the clearfix can be used. Without the clearfix the wrapping div would not span around the buttons which would cause a broken layout.
+
Example Button floated leftExample Button floated right
-
Color and background helpers combine the power of our .text-* utilities and .bg-* utilities in one class. Using our Sass color-contrast() function, we automatically determine a contrasting color for a particular background-color.
-
-Heads up! There’s currently no support for a CSS-native color-contrast function, so we use our own via Sass. This means that customizing our theme colors via CSS variables may cause color contrast issues with these utilities.
-
Color and background helpers combine the power of our .text-* utilities and .bg-* utilities in one class. Using our Sass color-contrast() function, we automatically determine a contrasting color for a particular background-color.
+
Heads up! There’s currently no support for a CSS-native color-contrast function, so we use our own via Sass. This means that customizing our theme colors via CSS variables may cause color contrast issues with these utilities.
+
Primary with contrasting color
Secondary with contrasting color
Success with contrasting color
Danger with contrasting color
Warning with contrasting color
Info with contrasting color
Light with contrasting color
-
Dark with contrasting color
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="text-bg-primary p-3">Primary with contrasting color</div>
-<divclass="text-bg-secondary p-3">Secondary with contrasting color</div>
-<divclass="text-bg-success p-3">Success with contrasting color</div>
-<divclass="text-bg-danger p-3">Danger with contrasting color</div>
-<divclass="text-bg-warning p-3">Warning with contrasting color</div>
-<divclass="text-bg-info p-3">Info with contrasting color</div>
-<divclass="text-bg-light p-3">Light with contrasting color</div>
-<divclass="text-bg-dark p-3">Dark with contrasting color</div>
-
-
-
-Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
-
-
-
With components
-
Use them in place of combined .text-* and .bg-* classes, like on badges:
<divclass="text-bg-primary p-3">Primary with contrasting color</div>
+<divclass="text-bg-secondary p-3">Secondary with contrasting color</div>
+<divclass="text-bg-success p-3">Success with contrasting color</div>
+<divclass="text-bg-danger p-3">Danger with contrasting color</div>
+<divclass="text-bg-warning p-3">Warning with contrasting color</div>
+<divclass="text-bg-info p-3">Info with contrasting color</div>
+<divclass="text-bg-light p-3">Light with contrasting color</div>
+<divclass="text-bg-dark p-3">Dark with contrasting color</div>
+
Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
+
With components
+
Use them in place of combined .text-* and .bg-* classes, like on badges:
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
Header
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="card text-bg-primary mb-3"style="max-width: 18rem;">
-<divclass="card-header">Header</div>
-<divclass="card-body">
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-</div>
-<divclass="card text-bg-info mb-3"style="max-width: 18rem;">
-<divclass="card-header">Header</div>
-<divclass="card-body">
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-</div>
-</div>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
html
<divclass="card text-bg-primary mb-3"style="max-width: 18rem;">
+ <divclass="card-header">Header</div>
+ <divclass="card-body">
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+</div>
+<divclass="card text-bg-info mb-3"style="max-width: 18rem;">
+ <divclass="card-header">Header</div>
+ <divclass="card-body">
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ </div>
+</div>
You can use the .link-* classes to colorize links. Unlike the .text-* classes, these classes have a :hover and :focus state. Some of the link styles use a relatively light foreground color, and should only be used on a dark background in order to have sufficient contrast.
-
-Heads up!.link-body-emphasis is currently the only colored link that adapts to color modes. It’s treated as a special case until v6 arrives and we can more thoroughly rebuild our theme colors for color modes. Until then, it’s a unique, high-contrast link color with custom :hover and :focus styles. However, it still responds to the new link utilities.
-
You can use the .link-* classes to colorize links. Unlike the .text-* classes, these classes have a :hover and :focus state. Some of the link styles use a relatively light foreground color, and should only be used on a dark background in order to have sufficient contrast.
+
Heads up!.link-body-emphasis is currently the only colored link that adapts to color modes. It’s treated as a special case until v6 arrives and we can more thoroughly rebuild our theme colors for color modes. Until then, it’s a unique, high-contrast link color with custom :hover and :focus styles. However, it still responds to the new link utilities.
-Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
-
Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
+
Link utilities
Added in v5.3.0
-
Colored links can also be modified by our link utilities.
The .focus-ring helper removes the default outline on :focus, replacing it with a box-shadow that can be more broadly customized. The new shadow is made up of a series of CSS variables, inherited from the :root level, that can be modified for any element or component.
The .focus-ring helper removes the default outline on :focus, replacing it with a box-shadow that can be more broadly customized. The new shadow is made up of a series of CSS variables, inherited from the :root level, that can be modified for any element or component.
+
Example
Click directly on the link below to see the focus ring in action, or into the example below and then press Tab.
<ahref="#"class="d-inline-flex focus-ring py-1 px-2 text-decoration-none border rounded-2"style="--bs-focus-ring-color: rgba(var(--bs-success-rgb), .25)">
- Green focus ring
-</a>
-
-
+
html
<ahref="#"class="d-inline-flex focus-ring py-1 px-2 text-decoration-none border rounded-2"style="--bs-focus-ring-color:rgba(var(--bs-success-rgb), .25)">
+ Green focus ring
+</a>
.focus-ring sets styles via global CSS variables that can be overridden on any parent element, as shown above. These variables are generated from their Sass variable counterparts.
By default, there is no --bs-focus-ring-x, --bs-focus-ring-y, or --bs-focus-ring-blur, but we provide CSS variables with fallbacks to initial 0 values. Modify them to change the default appearance.
In addition to .focus-ring, we have several .focus-ring-* utilities to modify the helper class defaults. Modify the color with any of our theme colors. Note that the light and dark variants may not be visible on all background colors given current color mode support.
In addition to .focus-ring, we have several .focus-ring-* utilities to modify the helper class defaults. Modify the color with any of our theme colors. Note that the light and dark variants may not be visible on all background colors given current color mode support.
The icon link helper component modifies our default link styles to enhance their appearance and quickly align any pairing of icon and text. Alignment is set via inline flexbox styling and a default gap value. We stylize the underline with a custom offset and color. Icons are automatically sized to 1em to best match their associated text’s font-size.
The icon link helper component modifies our default link styles to enhance their appearance and quickly align any pairing of icon and text. Alignment is set via inline flexbox styling and a default gap value. We stylize the underline with a custom offset and color. Icons are automatically sized to 1em to best match their associated text’s font-size.
Icon links assume Bootstrap Icons are being used, but you can use any icon or image you like.
-
-When icons are purely decorative, they should be hidden from assistive technologies using aria-hidden="true", as we’ve done in our examples. For icons that convey meaning, provide an appropriate text alternative by adding role="img" and an appropriate aria-label="..." to the SVGs.
-
-
-
Example
+
When icons are purely decorative, they should be hidden from assistive technologies using aria-hidden="true", as we’ve done in our examples. For icons that convey meaning, provide an appropriate text alternative by adding role="img" and an appropriate aria-label="..." to the SVGs.
+
Example
Take a regular <a> element, add .icon-link, and insert an icon on either the left or right of your link text. The icon is automatically sized, placed, and colored.
Position an element at the top of the viewport, from edge to edge. Be sure you understand the ramifications of fixed position in your project; you may need to add additional CSS.
-
<divclass="fixed-top">...</div>
-
Fixed bottom
+
<divclass="fixed-top">...</div>
+
+
Fixed bottom
Position an element at the bottom of the viewport, from edge to edge. Be sure you understand the ramifications of fixed position in your project; you may need to add additional CSS.
-
<divclass="fixed-bottom">...</div>
-
Sticky top
+
<divclass="fixed-bottom">...</div>
+
+
Sticky top
Position an element at the top of the viewport, from edge to edge, but only after you scroll past it.
-
<divclass="sticky-top">...</div>
-
Responsive sticky top
+
<divclass="sticky-top">...</div>
+
+
Responsive sticky top
Responsive variations also exist for .sticky-top utility.
-
<divclass="sticky-sm-top">Stick to the top on viewports sized SM (small) or wider</div>
-<divclass="sticky-md-top">Stick to the top on viewports sized MD (medium) or wider</div>
-<divclass="sticky-lg-top">Stick to the top on viewports sized LG (large) or wider</div>
-<divclass="sticky-xl-top">Stick to the top on viewports sized XL (extra-large) or wider</div>
-<divclass="sticky-xxl-top">Stick to the top on viewports sized XXL (extra-extra-large) or wider</div>
-
Sticky bottom
+
<divclass="sticky-sm-top">Stick to the top on viewports sized SM (small) or wider</div>
+<divclass="sticky-md-top">Stick to the top on viewports sized MD (medium) or wider</div>
+<divclass="sticky-lg-top">Stick to the top on viewports sized LG (large) or wider</div>
+<divclass="sticky-xl-top">Stick to the top on viewports sized XL (extra-large) or wider</div>
+<divclass="sticky-xxl-top">Stick to the top on viewports sized XXL (extra-extra-large) or wider</div>
+
+
Sticky bottom
Position an element at the bottom of the viewport, from edge to edge, but only after you scroll past it.
-
<divclass="sticky-bottom">...</div>
-
Responsive sticky bottom
+
<divclass="sticky-bottom">...</div>
+
+
Responsive sticky bottom
Responsive variations also exist for .sticky-bottom utility.
-
<divclass="sticky-sm-bottom">Stick to the bottom on viewports sized SM (small) or wider</div>
-<divclass="sticky-md-bottom">Stick to the bottom on viewports sized MD (medium) or wider</div>
-<divclass="sticky-lg-bottom">Stick to the bottom on viewports sized LG (large) or wider</div>
-<divclass="sticky-xl-bottom">Stick to the bottom on viewports sized XL (extra-large) or wider</div>
-<divclass="sticky-xxl-bottom">Stick to the bottom on viewports sized XXL (extra-extra-large) or wider</div>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
<divclass="sticky-sm-bottom">Stick to the bottom on viewports sized SM (small) or wider</div>
+<divclass="sticky-md-bottom">Stick to the bottom on viewports sized MD (medium) or wider</div>
+<divclass="sticky-lg-bottom">Stick to the bottom on viewports sized LG (large) or wider</div>
+<divclass="sticky-xl-bottom">Stick to the bottom on viewports sized XL (extra-large) or wider</div>
+<divclass="sticky-xxl-bottom">Stick to the bottom on viewports sized XXL (extra-extra-large) or wider</div>
+
Use generated pseudo elements to make an element maintain the aspect ratio of your choosing. Perfect for responsively handling video or slideshow embeds based on the width of the parent.
Use generated pseudo elements to make an element maintain the aspect ratio of your choosing. Perfect for responsively handling video or slideshow embeds based on the width of the parent.
Use the ratio helper to manage the aspect ratios of external content like <iframe>s, <embed>s, <video>s, and <object>s. These helpers also can be used on any standard HTML child element (e.g., a <div> or <img>). Styles are applied from the parent .ratio class directly to the child.
Aspect ratios are declared in a Sass map and included in each class via CSS variable, which also allows custom aspect ratios.
-
-Pro-Tip! You don’t need frameborder="0" on your <iframe>s as we override that for you in Reboot.
-
-
-
Example
+
Pro-Tip! You don’t need frameborder="0" on your <iframe>s as we override that for you in Reboot.
+
Example
Wrap any embed, like an <iframe>, in a parent element with .ratio and an aspect ratio class. The immediate child element is automatically sized thanks to our universal selector .ratio > *.
Each .ratio-* class includes a CSS custom property (or CSS variable) in the selector. You can override this CSS variable to create custom aspect ratios on the fly with some quick math on your part.
For example, to create a 2x1 aspect ratio, set --bs-aspect-ratio: 50% on the .ratio.
This CSS variable makes it easy to modify the aspect ratio across breakpoints. The following is 4x3 to start, but changes to a custom 2x1 at the medium breakpoint.
<divclass="ratio ratio-4x3">
-<div>4x3, then 2x1</div>
-</div>
-
-
-
Sass maps
-
Within _variables.scss, you can change the aspect ratios you want to use. Here’s our default $ratio-aspect-ratios map. Modify the map as you like and recompile your Sass to put them to use.
<divclass="ratio ratio-4x3">
+ <div>4x3, then 2x1</div>
+</div>
+
Sass maps
+
Within _variables.scss, you can change the aspect ratios you want to use. Here’s our default $ratio-aspect-ratios map. Modify the map as you like and recompile your Sass to put them to use.
Stacks offer a shortcut for applying a number of flexbox properties to quickly and easily create layouts in Bootstrap. All credit for the concept and implementation goes to the open source Pylon project.
-
-Heads up! Support for gap utilities with flexbox isn’t available in Safari prior to 14.5, so consider verifying your intended browser support. Grid layout should have no issues. Read more.
-
Stacks offer a shortcut for applying a number of flexbox properties to quickly and easily create layouts in Bootstrap. All credit for the concept and implementation goes to the open source Pylon project.
+
Heads up! Support for gap utilities with flexbox isn’t available in Safari prior to 14.5, so consider verifying your intended browser support. Grid layout should have no issues. Read more.
+
Vertical
Use .vstack to create vertical layouts. Stacked items are full-width by default. Use .gap-* utilities to add space between items.
Use .hstack for horizontal layouts. Stacked items are vertically centered by default and only take up their necessary width. Use .gap-* utilities to add space between items.
Make any HTML element or Bootstrap component clickable by “stretching” a nested link via CSS.
-
-
-
-
-
-
-
-
-
-
Add .stretched-link to a link to make its containing block clickable via a ::after pseudo element. In most cases, this means that an element with position: relative; that contains a link with the .stretched-link class is clickable. Please note given how CSS position works, .stretched-link cannot be mixed with most table elements.
Make any HTML element or Bootstrap component clickable by “stretching” a nested link via CSS.
+
Add .stretched-link to a link to make its containing block clickable via a ::after pseudo element. In most cases, this means that an element with position: relative; that contains a link with the .stretched-link class is clickable. Please note given how CSS position works, .stretched-link cannot be mixed with most table elements.
Cards have position: relative by default in Bootstrap, so in this case you can safely add the .stretched-link class to a link in the card without any other HTML changes.
Multiple links and tap targets are not recommended with stretched links. However, some position and z-index styles can help should this be required.
-
-
-
-
- Card image cap
+
+ Card image cap
Card with stretched link
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
<divclass="card"style="width: 18rem;">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card with stretched link</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-<ahref="#"class="btn btn-primary stretched-link">Go somewhere</a>
-</div>
-</div>
-
-
+
html
<divclass="card"style="width: 18rem;">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card with stretched link</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ <ahref="#"class="btn btn-primary stretched-link">Go somewhere</a>
+ </div>
+</div>
Most custom components do not have position: relative by default, so we need to add the .position-relative here to prevent the link from stretching outside the parent element.
-
-
-
-
- Generic placeholder image
+
+ Generic placeholder image22222
Custom component with stretched link
-
This is some placeholder content for the custom component. It is intended to mimic what some real-world content would look like, and we're using it here to give the component a bit of body and size.
+
This is some placeholder content for the custom component. It is intended to mimic what some real-world content would look like, and we’re using it here to give the component a bit of body and size.
<divclass="d-flex position-relative">
-<imgsrc="..."class="flex-shrink-0 me-3"alt="...">
-<div>
-<h5class="mt-0">Custom component with stretched link</h5>
-<p>This is some placeholder content for the custom component. It is intended to mimic what some real-world content would look like, and we're using it here to give the component a bit of body and size.</p>
-<ahref="#"class="stretched-link">Go somewhere</a>
-</div>
-</div>
-
-
-
-
-
-
+
html
<divclass="d-flex position-relative">
+ <imgsrc="..."class="flex-shrink-0 me-3"alt="...">
+ <div>
+ <h5class="mt-0">Custom component with stretched link</h5>
+ <p>This is some placeholder content for the custom component. It is intended to mimic what some real-world content would look like, and we’re using it here to give the component a bit of body and size.</p>
+ <ahref="#"class="stretched-link">Go somewhere</a>
+ </div>
+</div>
Another instance of placeholder content for this other custom component. It is intended to mimic what some real-world content would look like, and we're using it here to give the component a bit of body and size.
+
Another instance of placeholder content for this other custom component. It is intended to mimic what some real-world content would look like, and we’re using it here to give the component a bit of body and size.
<divclass="row g-0 bg-body-secondary position-relative">
-<divclass="col-md-6 mb-md-0 p-md-4">
-<imgsrc="..."class="w-100"alt="...">
-</div>
-<divclass="col-md-6 p-4 ps-md-0">
-<h5class="mt-0">Columns with stretched link</h5>
-<p>Another instance of placeholder content for this other custom component. It is intended to mimic what some real-world content would look like, and we're using it here to give the component a bit of body and size.</p>
-<ahref="#"class="stretched-link">Go somewhere</a>
-</div>
-</div>
-
-
-
Identifying the containing block
-
If the stretched link doesn’t seem to work, the containing block will probably be the cause. The following CSS properties will make an element the containing block:
+
html
<divclass="row g-0 bg-body-secondary position-relative">
+ <divclass="col-md-6 mb-md-0 p-md-4">
+ <imgsrc="..."class="w-100"alt="...">
+ </div>
+ <divclass="col-md-6 p-4 ps-md-0">
+ <h5class="mt-0">Columns with stretched link</h5>
+ <p>Another instance of placeholder content for this other custom component. It is intended to mimic what some real-world content would look like, and we’re using it here to give the component a bit of body and size.</p>
+ <ahref="#"class="stretched-link">Go somewhere</a>
+ </div>
+</div>
+
Identifying the containing block
+
If the stretched link doesn’t seem to work, the containing block will probably be the cause. The following CSS properties will make an element the containing block:
A position value other than static
A transform or perspective value other than none
A will-change value of transform or perspective
A filter value other than none or a will-change value of filter (only works on Firefox)
-
-
-
-
- Card image cap
+
+ Card image cap
Card with stretched links
-
Some quick example text to build on the card title and make up the bulk of the card's content.
+
Some quick example text to build on the card title and make up the bulk of the card’s content.
@@ -665,107 +92,20 @@
This stretched link will only be spread over the p-tag, because a transform is applied to it.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="card"style="width: 18rem;">
-<imgsrc="..."class="card-img-top"alt="...">
-<divclass="card-body">
-<h5class="card-title">Card with stretched links</h5>
-<pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
-<pclass="card-text">
-<ahref="#"class="stretched-link text-danger"style="position: relative;">Stretched link will not work here, because <code>position: relative</code> is added to the link</a>
-</p>
-<pclass="card-text bg-body-tertiary"style="transform: rotate(0);">
- This <ahref="#"class="text-warning stretched-link">stretched link</a> will only be spread over the <code>p</code>-tag, because a transform is applied to it.
-</p>
-</div>
-</div>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
html
<divclass="card"style="width: 18rem;">
+ <imgsrc="..."class="card-img-top"alt="...">
+ <divclass="card-body">
+ <h5class="card-title">Card with stretched links</h5>
+ <pclass="card-text">Some quick example text to build on the card title and make up the bulk of the card’s content.</p>
+ <pclass="card-text">
+ <ahref="#"class="stretched-link text-danger"style="position: relative;">Stretched link will not work here, because <code>position: relative</code> is added to the link</a>
+ </p>
+ <pclass="card-text bg-body-tertiary"style="transform:rotate(0);">
+ This <ahref="#"class="text-warning stretched-link">stretched link</a> will only be spread over the <code>p</code>-tag, because a transform is applied to it.
+ </p>
+ </div>
+</div>
For longer content, you can add a .text-truncate class to truncate the text with an ellipsis. Requires display: inline-block or display: block.
+
This text is quite long, and will be truncated once displayed.
@@ -552,105 +30,18 @@
This text is quite long, and will be truncated once displayed.
-
+
html
<!-- Block level -->
+<divclass="row">
+ <divclass="col-2 text-truncate">
+ This text is quite long, and will be truncated once displayed.
+ </div>
+</div>
-
- html
-
-
-
-
-
-
-
-
-
<!-- Block level -->
-<divclass="row">
-<divclass="col-2 text-truncate">
- This text is quite long, and will be truncated once displayed.
-</div>
-</div>
-
-<!-- Inline level -->
-<spanclass="d-inline-block text-truncate"style="max-width: 150px;">
- This text is quite long, and will be truncated once displayed.
-</span>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+<!-- Inline level -->
+<spanclass="d-inline-block text-truncate"style="max-width: 150px;">
+ This text is quite long, and will be truncated once displayed.
+</span>
Use these helpers to visually hide elements but keep them accessible to assistive technologies.
-
-
-
-
-
-
-
-
-
-
Visually hide an element while still allowing it to be exposed to assistive technologies (such as screen readers) with .visually-hidden. Use .visually-hidden-focusable to visually hide an element by default, but to display it when it’s focused (e.g. by a keyboard-only user). .visually-hidden-focusable can also be applied to a container–thanks to :focus-within, the container will be displayed when any child element of the container receives focus.
Use these helpers to visually hide elements but keep them accessible to assistive technologies.
+
Visually hide an element while still allowing it to be exposed to assistive technologies (such as screen readers) with .visually-hidden. Use .visually-hidden-focusable to visually hide an element by default, but to display it when it’s focused (e.g. by a keyboard-only user). .visually-hidden-focusable can also be applied to a container–thanks to :focus-within, the container will be displayed when any child element of the container receives focus.
<h2class="visually-hidden">Title for screen readers</h2>
-<aclass="visually-hidden-focusable"href="#content">Skip to main content</a>
-<divclass="visually-hidden-focusable">A container with a <ahref="#">focusable element</a>.</div>
<h2class="visually-hidden">Title for screen readers</h2>
+<aclass="visually-hidden-focusable"href="#content">Skip to main content</a>
+<divclass="visually-hidden-focusable">A container with a <ahref="#">focusable element</a>.</div>
Both visually-hidden and visually-hidden-focusable can also be used as mixins.
-
// Usage as a mixin
-
-.visually-hidden-title{
-@include visually-hidden;
-}
-
-.skip-navigation{
-@include visually-hidden-focusable;
-}
-
Breakpoints are the building blocks of responsive design. Use them to control when your layout can be adapted at a particular viewport or device size.
@@ -572,243 +30,166 @@
Use media queries to architect your CSS by breakpoint. Media queries are a feature of CSS that allow you to conditionally apply styles based on a set of browser and operating system parameters. We most commonly use min-width in our media queries.
-
Mobile first, responsive design is the goal. Bootstrap’s CSS aims to apply the bare minimum of styles to make a layout work at the smallest breakpoint, and then layers on styles to adjust that design for larger devices. This optimizes your CSS, improves rendering time, and provides a great experience for your visitors.
+
Mobile first, responsive design is the goal. Bootstrap’s CSS aims to apply the bare minimum of styles to make a layout work at the smallest breakpoint, and then layers on styles to adjust that design for larger devices. This optimizes your CSS, improves rendering time, and provides a great experience for your visitors.
-
Available breakpoints
-
Bootstrap includes six default breakpoints, sometimes referred to as grid tiers, for building responsively. These breakpoints can be customized if you’re using our source Sass files.
-
-
-
-
Breakpoint
-
Class infix
-
Dimensions
-
-
-
-
-
Extra small
-
None
-
<576px
-
-
-
Small
-
sm
-
≥576px
-
-
-
Medium
-
md
-
≥768px
-
-
-
Large
-
lg
-
≥992px
-
-
-
Extra large
-
xl
-
≥1200px
-
-
-
Extra extra large
-
xxl
-
≥1400px
-
-
-
+
Available breakpoints
+
Bootstrap includes six default breakpoints, sometimes referred to as grid tiers, for building responsively. These breakpoints can be customized if you’re using our source Sass files.
+
-
Each breakpoint was chosen to comfortably hold containers whose widths are multiples of 12. Breakpoints are also representative of a subset of common device sizes and viewport dimensions—they don’t specifically target every use case or device. Instead, the ranges provide a strong and consistent foundation to build on for nearly any device.
-
These breakpoints are customizable via Sass—you’ll find them in a Sass map in our _variables.scss stylesheet.
Each breakpoint was chosen to comfortably hold containers whose widths are multiples of 12. Breakpoints are also representative of a subset of common device sizes and viewport dimensions—they don’t specifically target every use case or device. Instead, the ranges provide a strong and consistent foundation to build on for nearly any device.
+
These breakpoints are customizable via Sass—you’ll find them in a Sass map in our _variables.scss stylesheet.
Since Bootstrap is developed to be mobile first, we use a handful of media queries to create sensible breakpoints for our layouts and interfaces. These breakpoints are mostly based on minimum viewport widths and allow us to scale up elements as the viewport changes.
-
Min-width
+
Min-width
Bootstrap primarily uses the following media query ranges—or breakpoints—in our source Sass files for our layout, grid system, and components.
-
// Source mixins
-
-// No media query necessary for xs breakpoint as it's effectively `@media (min-width: 0) { ... }`
-@include media-breakpoint-up(sm){...}
-@include media-breakpoint-up(md){...}
-@include media-breakpoint-up(lg){...}
-@include media-breakpoint-up(xl){...}
-@include media-breakpoint-up(xxl){...}
-
-// Usage
-
-// Example: Hide starting at `min-width: 0`, and then show at the `sm` breakpoint
-.custom-class{
-display:none;
-}
-@include media-breakpoint-up(sm){
-.custom-class{
-display:block;
-}
-}
-
These Sass mixins translate in our compiled CSS using the values declared in our Sass variables. For example:
-
// X-Small devices (portrait phones, less than 576px)
-// No media query for `xs` since this is the default in Bootstrap
-
-// Small devices (landscape phones, 576px and up)
-@media(min-width:576px){...}
-
-// Medium devices (tablets, 768px and up)
-@media(min-width:768px){...}
-
-// Large devices (desktops, 992px and up)
-@media(min-width:992px){...}
-
-// X-Large devices (large desktops, 1200px and up)
-@media(min-width:1200px){...}
-
-// XX-Large devices (larger desktops, 1400px and up)
-@media(min-width:1400px){...}
-
Max-width
+
// Source mixins
+
+// No media query necessary for xs breakpoint as it’s effectively `@media (min-width: 0) { ... }`
+@includemedia-breakpoint-up(sm){ ... }
+@includemedia-breakpoint-up(md){ ... }
+@includemedia-breakpoint-up(lg){ ... }
+@includemedia-breakpoint-up(xl){ ... }
+@includemedia-breakpoint-up(xxl){ ... }
+
+// Usage
+
+// Example: Hide starting at `min-width: 0`, and then show at the `sm` breakpoint
+.custom-class {
+ display: none;
+}
+@includemedia-breakpoint-up(sm){
+ .custom-class {
+ display: block;
+ }
+}
+
+
These Sass mixins translate in our compiled CSS using the values declared in our Sass variables. For example:
+
// X-Small devices (portrait phones, less than 576px)
+// No media query for `xs` since this is the default in Bootstrap
+
+// Small devices (landscape phones, 576px and up)
+@media(min-width: 576px){ ... }
+
+// Medium devices (tablets, 768px and up)
+@media(min-width: 768px){ ... }
+
+// Large devices (desktops, 992px and up)
+@media(min-width: 992px){ ... }
+
+// X-Large devices (large desktops, 1200px and up)
+@media(min-width: 1200px){ ... }
+
+// XX-Large devices (larger desktops, 1400px and up)
+@media(min-width: 1400px){ ... }
+
+
Max-width
We occasionally use media queries that go in the other direction (the given screen size or smaller):
-
// No media query necessary for xs breakpoint as it's effectively `@media (max-width: 0) { ... }`
-@include media-breakpoint-down(sm){...}
-@include media-breakpoint-down(md){...}
-@include media-breakpoint-down(lg){...}
-@include media-breakpoint-down(xl){...}
-@include media-breakpoint-down(xxl){...}
-
-// Example: Style from medium breakpoint and down
-@include media-breakpoint-down(md){
-.custom-class{
-display:block;
-}
-}
-
These mixins take those declared breakpoints, subtract .02px from them, and use them as our max-width values. For example:
-
// `xs` returns only a ruleset and no media query
-// ... { ... }
-
-// `sm` applies to x-small devices (portrait phones, less than 576px)
-@media(max-width:575.98px){...}
-
-// `md` applies to small devices (landscape phones, less than 768px)
-@media(max-width:767.98px){...}
-
-// `lg` applies to medium devices (tablets, less than 992px)
-@media(max-width:991.98px){...}
-
-// `xl` applies to large devices (desktops, less than 1200px)
-@media(max-width:1199.98px){...}
-
-// `xxl` applies to x-large devices (large desktops, less than 1400px)
-@media(max-width:1399.98px){...}
-
-Why subtract .02px? Browsers don’t currently support range context queries, so we work around the limitations of min- and max- prefixes and viewports with fractional widths (which can occur under certain conditions on high-dpi devices, for instance) by using values with higher precision.
-
+
// No media query necessary for xs breakpoint as it’s effectively `@media (max-width: 0) { ... }`
+@includemedia-breakpoint-down(sm){ ... }
+@includemedia-breakpoint-down(md){ ... }
+@includemedia-breakpoint-down(lg){ ... }
+@includemedia-breakpoint-down(xl){ ... }
+@includemedia-breakpoint-down(xxl){ ... }
-
Single breakpoint
+// Example: Style from medium breakpoint and down
+@includemedia-breakpoint-down(md){
+ .custom-class {
+ display: block;
+ }
+}
+
+
These mixins take those declared breakpoints, subtract .02px from them, and use them as our max-width values. For example:
+
// `xs` returns only a ruleset and no media query
+// ... { ... }
+
+// `sm` applies to x-small devices (portrait phones, less than 576px)
+@media(max-width: 575.98px){ ... }
+
+// `md` applies to small devices (landscape phones, less than 768px)
+@media(max-width: 767.98px){ ... }
+
+// `lg` applies to medium devices (tablets, less than 992px)
+@media(max-width: 991.98px){ ... }
+
+// `xl` applies to large devices (desktops, less than 1200px)
+@media(max-width: 1199.98px){ ... }
+
+// `xxl` applies to x-large devices (large desktops, less than 1400px)
+@media(max-width: 1399.98px){ ... }
+
+
Why subtract .02px? Browsers don’t currently support range context queries, so we work around the limitations of min- and max- prefixes and viewports with fractional widths (which can occur under certain conditions on high-dpi devices, for instance) by using values with higher precision.
+
Single breakpoint
There are also media queries and mixins for targeting a single segment of screen sizes using the minimum and maximum breakpoint widths.
Learn how to modify columns with a handful of options for alignment, ordering, and offsetting thanks to our flexbox grid system. Plus, see how to use column classes to manage widths of non-grid elements.
Learn how to modify columns with a handful of options for alignment, ordering, and offsetting thanks to our flexbox grid system. Plus, see how to use column classes to manage widths of non-grid elements.
Heads up! Be sure to read the Grid page first before diving into how to modify and customize your grid columns.
+
How they work
-
Columns build on the grid’s flexbox architecture. Flexbox means we have options for changing individual columns and modifying groups of columns at the row level. You choose how columns grow, shrink, or otherwise change.
+
Columns build on the grid’s flexbox architecture. Flexbox means we have options for changing individual columns and modifying groups of columns at the row level. You choose how columns grow, shrink, or otherwise change.
-
When building grid layouts, all content goes in columns. The hierarchy of Bootstrap’s grid goes from container to row to column to your content. On rare occasions, you may combine content and column, but be aware there can be unintended consequences.
+
When building grid layouts, all content goes in columns. The hierarchy of Bootstrap’s grid goes from container to row to column to your content. On rare occasions, you may combine content and column, but be aware there can be unintended consequences.
-
Bootstrap includes predefined classes for creating fast, responsive layouts. With six breakpoints and a dozen columns at each grid tier, we have dozens of classes already built for you to create your desired layouts. This can be disabled via Sass if you wish.
+
Bootstrap includes predefined classes for creating fast, responsive layouts. With six breakpoints and a dozen columns at each grid tier, we have dozens of classes already built for you to create your desired layouts. This can be disabled via Sass if you wish.
-
Alignment
+
Alignment
Use flexbox alignment utilities to vertically and horizontally align columns.
-
Vertical alignment
+
Vertical alignment
Change the vertical alignment with any of the responsive align-items-* classes.
-
-
-
-
+
One of three columns
@@ -609,37 +50,20 @@
One of three columns
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="container text-center">
-<divclass="row align-items-start">
-<divclass="col">
- One of three columns
-</div>
-<divclass="col">
- One of three columns
-</div>
-<divclass="col">
- One of three columns
-</div>
-</div>
-</div>
-
-
-
-
-
-
+
html
<divclass="container text-center">
+ <divclass="row align-items-start">
+ <divclass="col">
+ One of three columns
+ </div>
+ <divclass="col">
+ One of three columns
+ </div>
+ <divclass="col">
+ One of three columns
+ </div>
+ </div>
+</div>
+
One of three columns
@@ -651,37 +75,20 @@
One of three columns
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="container text-center">
-<divclass="row align-items-center">
-<divclass="col">
- One of three columns
-</div>
-<divclass="col">
- One of three columns
-</div>
-<divclass="col">
- One of three columns
-</div>
-</div>
-</div>
-
-
-
-
-
-
+
html
<divclass="container text-center">
+ <divclass="row align-items-center">
+ <divclass="col">
+ One of three columns
+ </div>
+ <divclass="col">
+ One of three columns
+ </div>
+ <divclass="col">
+ One of three columns
+ </div>
+ </div>
+</div>
+
One of three columns
@@ -693,38 +100,21 @@
One of three columns
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="container text-center">
-<divclass="row align-items-end">
-<divclass="col">
- One of three columns
-</div>
-<divclass="col">
- One of three columns
-</div>
-<divclass="col">
- One of three columns
-</div>
-</div>
-</div>
-
-
+
html
<divclass="container text-center">
+ <divclass="row align-items-end">
+ <divclass="col">
+ One of three columns
+ </div>
+ <divclass="col">
+ One of three columns
+ </div>
+ <divclass="col">
+ One of three columns
+ </div>
+ </div>
+</div>
Or, change the alignment of each column individually with any of the responsive .align-self-* classes.
-
-
-
-
+
One of three columns
@@ -736,39 +126,22 @@
One of three columns
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="container text-center">
-<divclass="row">
-<divclass="col align-self-start">
- One of three columns
-</div>
-<divclass="col align-self-center">
- One of three columns
-</div>
-<divclass="col align-self-end">
- One of three columns
-</div>
-</div>
-</div>
-
-
-
Horizontal alignment
+
html
<divclass="container text-center">
+ <divclass="row">
+ <divclass="col align-self-start">
+ One of three columns
+ </div>
+ <divclass="col align-self-center">
+ One of three columns
+ </div>
+ <divclass="col align-self-end">
+ One of three columns
+ </div>
+ </div>
+</div>
+
Horizontal alignment
Change the horizontal alignment with any of the responsive justify-content-* classes.
-
-
-
-
+
One of two columns
@@ -817,108 +190,74 @@
One of two columns
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="container text-center">
-<divclass="row justify-content-start">
-<divclass="col-4">
- One of two columns
-</div>
-<divclass="col-4">
- One of two columns
-</div>
-</div>
-<divclass="row justify-content-center">
-<divclass="col-4">
- One of two columns
-</div>
-<divclass="col-4">
- One of two columns
-</div>
-</div>
-<divclass="row justify-content-end">
-<divclass="col-4">
- One of two columns
-</div>
-<divclass="col-4">
- One of two columns
-</div>
-</div>
-<divclass="row justify-content-around">
-<divclass="col-4">
- One of two columns
-</div>
-<divclass="col-4">
- One of two columns
-</div>
-</div>
-<divclass="row justify-content-between">
-<divclass="col-4">
- One of two columns
-</div>
-<divclass="col-4">
- One of two columns
-</div>
-</div>
-<divclass="row justify-content-evenly">
-<divclass="col-4">
- One of two columns
-</div>
-<divclass="col-4">
- One of two columns
-</div>
-</div>
-</div>
-
-
-
Column wrapping
+
html
<divclass="container text-center">
+ <divclass="row justify-content-start">
+ <divclass="col-4">
+ One of two columns
+ </div>
+ <divclass="col-4">
+ One of two columns
+ </div>
+ </div>
+ <divclass="row justify-content-center">
+ <divclass="col-4">
+ One of two columns
+ </div>
+ <divclass="col-4">
+ One of two columns
+ </div>
+ </div>
+ <divclass="row justify-content-end">
+ <divclass="col-4">
+ One of two columns
+ </div>
+ <divclass="col-4">
+ One of two columns
+ </div>
+ </div>
+ <divclass="row justify-content-around">
+ <divclass="col-4">
+ One of two columns
+ </div>
+ <divclass="col-4">
+ One of two columns
+ </div>
+ </div>
+ <divclass="row justify-content-between">
+ <divclass="col-4">
+ One of two columns
+ </div>
+ <divclass="col-4">
+ One of two columns
+ </div>
+ </div>
+ <divclass="row justify-content-evenly">
+ <divclass="col-4">
+ One of two columns
+ </div>
+ <divclass="col-4">
+ One of two columns
+ </div>
+ </div>
+</div>
+
Column wrapping
If more than 12 columns are placed within a single row, each group of extra columns will, as one unit, wrap onto a new line.
-
-
-
-
+
.col-9
.col-4 Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.
.col-6 Subsequent columns continue along the new line.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="container">
-<divclass="row">
-<divclass="col-9">.col-9</div>
-<divclass="col-4">.col-4<br>Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.</div>
-<divclass="col-6">.col-6<br>Subsequent columns continue along the new line.</div>
-</div>
-</div>
-
-
-
Column breaks
+
html
<divclass="container">
+ <divclass="row">
+ <divclass="col-9">.col-9</div>
+ <divclass="col-4">.col-4<br>Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.</div>
+ <divclass="col-6">.col-6<br>Subsequent columns continue along the new line.</div>
+ </div>
+</div>
+
Column breaks
Breaking columns to a new line in flexbox requires a small hack: add an element with width: 100% wherever you want to wrap your columns to a new line. Normally this is accomplished with multiple .rows, but not every implementation method can account for this.
<divclass="container text-center">
-<divclass="row">
-<divclass="col-6 col-sm-3">.col-6 .col-sm-3</div>
-<divclass="col-6 col-sm-3">.col-6 .col-sm-3</div>
-
-<!-- Force next columns to break to new line -->
-<divclass="w-100"></div>
-
-<divclass="col-6 col-sm-3">.col-6 .col-sm-3</div>
-<divclass="col-6 col-sm-3">.col-6 .col-sm-3</div>
-</div>
-</div>
-
+ <!-- Force next columns to break to new line -->
+ <divclass="w-100"></div>
-
<divclass="container text-center">
-<divclass="row">
-<divclass="col-6 col-sm-4">.col-6 .col-sm-4</div>
-<divclass="col-6 col-sm-4">.col-6 .col-sm-4</div>
-
-<!-- Force next columns to break to new line at md breakpoint and up -->
-<divclass="w-100 d-none d-md-block"></div>
-
-<divclass="col-6 col-sm-4">.col-6 .col-sm-4</div>
-<divclass="col-6 col-sm-4">.col-6 .col-sm-4</div>
-</div>
-</div>
-
+ <!-- Force next columns to break to new line at md breakpoint and up -->
+ <divclass="w-100 d-none d-md-block"></div>
-
Use .order- classes for controlling the visual order of your content. These classes are responsive, so you can set the order by breakpoint (e.g., .order-1.order-md-2). Includes support for 1 through 5 across all six grid tiers.
-
-
-
-
+
First in DOM, no order applied
@@ -1014,38 +319,21 @@
Third in DOM, with an order of 1
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="container text-center">
-<divclass="row">
-<divclass="col">
- First in DOM, no order applied
-</div>
-<divclass="col order-5">
- Second in DOM, with a larger order
-</div>
-<divclass="col order-1">
- Third in DOM, with an order of 1
-</div>
-</div>
-</div>
-
-
+
html
<divclass="container text-center">
+ <divclass="row">
+ <divclass="col">
+ First in DOM, no order applied
+ </div>
+ <divclass="col order-5">
+ Second in DOM, with a larger order
+ </div>
+ <divclass="col order-1">
+ Third in DOM, with an order of 1
+ </div>
+ </div>
+</div>
There are also responsive .order-first and .order-last classes that change the order of an element by applying order: -1 and order: 6, respectively. These classes can also be intermixed with the numbered .order-* classes as needed.
-
-
-
-
+
First in DOM, ordered last
@@ -1057,59 +345,43 @@
Third in DOM, ordered first
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="container text-center">
-<divclass="row">
-<divclass="col order-last">
- First in DOM, ordered last
-</div>
-<divclass="col">
- Second in DOM, unordered
-</div>
-<divclass="col order-first">
- Third in DOM, ordered first
-</div>
-</div>
-</div>
$utilities:map-merge(
-$utilities,
-(
-"order":map-merge(
-map-get($utilities,"order"),
-(
-values:map-merge(
-map-get(map-get($utilities,"order"),"values"),
-(
-6:6,// Add a new `.order-{breakpoint}-6` utility
-last:7// Change the `.order-{breakpoint}-last` utility to use the next number
-)
-),
-),
-),
-)
-);
-
Offsetting columns
-
You can offset grid columns in two ways: our responsive .offset- grid classes and our margin utilities. Grid classes are sized to match columns while margins are more useful for quick layouts where the width of the offset is variable.
-
Offset classes
+
html
<divclass="container text-center">
+ <divclass="row">
+ <divclass="col order-last">
+ First in DOM, ordered last
+ </div>
+ <divclass="col">
+ Second in DOM, unordered
+ </div>
+ <divclass="col order-first">
+ Third in DOM, ordered first
+ </div>
+ </div>
+</div>
$utilities:map-merge(
+ $utilities,
+ (
+ "order":map-merge(
+ map-get($utilities,"order"),
+ (
+ values:map-merge(
+ map-get(map-get($utilities,"order"),"values"),
+ (
+ 6: 6,// Add a new `.order-{breakpoint}-6` utility
+ last: 7 // Change the `.order-{breakpoint}-last` utility to use the next number
+ )
+ ),
+ ),
+ ),
+ )
+);
+
+
Offsetting columns
+
You can offset grid columns in two ways: our responsive .offset- grid classes and our margin utilities. Grid classes are sized to match columns while margins are more useful for quick layouts where the width of the offset is variable.
+
Offset classes
Move columns to the right using .offset-md-* classes. These classes increase the left margin of a column by * columns. For example, .offset-md-4 moves .col-md-4 over four columns.
The .col-* classes can also be used outside a .row to give an element a specific width. Whenever column classes are used as non-direct children of a row, the paddings are omitted.
-
-
-
-
+
.col-3: width of 25%
.col-sm-9: width of 75% above sm breakpoint
-
+
html
<divclass="col-3 p-3 mb-2">
+ .col-3: width of 25%
+</div>
-
- html
-
-
-
-
-
-
-
-
-
<divclass="col-3 p-3 mb-2">
- .col-3: width of 25%
-</div>
-
-<divclass="col-sm-9 p-3">
- .col-sm-9: width of 75% above sm breakpoint
-</div>
-
-
-
The classes can be used together with utilities to create responsive floated images. Make sure to wrap the content in a .clearfix wrapper to clear the float if the text is shorter.
-
-
-
-
- PlaceholderResponsive floated image
+<divclass="col-sm-9 p-3">
+ .col-sm-9: width of 75% above sm breakpoint
+</div>
+
The classes can be used together with utilities to create responsive floated images. Make sure to wrap the content in a .clearfix wrapper to clear the float if the text is shorter.
+
+ PlaceholderResponsive floated image
- A paragraph of placeholder text. We're using it here to show the use of the clearfix class. We're adding quite a few meaningless phrases here to demonstrate how the columns interact here with the floated image.
+ A paragraph of placeholder text. We’re using it here to show the use of the clearfix class. We’re adding quite a few meaningless phrases here to demonstrate how the columns interact here with the floated image.
@@ -1279,111 +483,24 @@
- And yet, here you are, still persevering in reading this placeholder text, hoping for some more insights, or some hidden easter egg of content. A joke, perhaps. Unfortunately, there's none of that here.
+ And yet, here you are, still persevering in reading this placeholder text, hoping for some more insights, or some hidden easter egg of content. A joke, perhaps. Unfortunately, there’s none of that here.
<divclass="clearfix">
-<imgsrc="..."class="col-md-6 float-md-end mb-3 ms-md-3"alt="...">
-
-<p>
- A paragraph of placeholder text. We're using it here to show the use of the clearfix class. We're adding quite a few meaningless phrases here to demonstrate how the columns interact here with the floated image.
-</p>
-
-<p>
- As you can see the paragraphs gracefully wrap around the floated image. Now imagine how this would look with some actual content in here, rather than just this boring placeholder text that goes on and on, but actually conveys no tangible information at. It simply takes up space and should not really be read.
-</p>
-
-<p>
- And yet, here you are, still persevering in reading this placeholder text, hoping for some more insights, or some hidden easter egg of content. A joke, perhaps. Unfortunately, there's none of that here.
-</p>
-</div>
-
+ <p>
+ A paragraph of placeholder text. We’re using it here to show the use of the clearfix class. We’re adding quite a few meaningless phrases here to demonstrate how the columns interact here with the floated image.
+ </p>
+ <p>
+ As you can see the paragraphs gracefully wrap around the floated image. Now imagine how this would look with some actual content in here, rather than just this boring placeholder text that goes on and on, but actually conveys no tangible information at. It simply takes up space and should not really be read.
+ </p>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ <p>
+ And yet, here you are, still persevering in reading this placeholder text, hoping for some more insights, or some hidden easter egg of content. A joke, perhaps. Unfortunately, there’s none of that here.
+ </p>
+</div>
Containers are the most basic layout element in Bootstrap and are required when using our default grid system. Containers are used to contain, pad, and (sometimes) center the content within them. While containers can be nested, most layouts do not require a nested container.
Bootstrap comes with three different containers:
@@ -571,213 +29,135 @@
.container-{breakpoint}, which is width: 100% until the specified breakpoint
.container-fluid, which is width: 100% at all breakpoints
-
The table below illustrates how each container’s max-width compares to the original .container and .container-fluid across each breakpoint.
+
The table below illustrates how each container’s max-width compares to the original .container and .container-fluid across each breakpoint.
See them in action and compare them in our Grid example.
Our default .container class is a responsive, fixed-width container, meaning its max-width changes at each breakpoint.
-
<divclass="container">
-<!-- Content here -->
-</div>
-
Responsive containers
+
<divclass="container">
+ <!-- Content here -->
+</div>
+
+
Responsive containers
Responsive containers allow you to specify a class that is 100% wide until the specified breakpoint is reached, after which we apply max-widths for each of the higher breakpoints. For example, .container-sm is 100% wide to start until the sm breakpoint is reached, where it will scale up with md, lg, xl, and xxl.
-
<divclass="container-sm">100% wide until small breakpoint</div>
-<divclass="container-md">100% wide until medium breakpoint</div>
-<divclass="container-lg">100% wide until large breakpoint</div>
-<divclass="container-xl">100% wide until extra large breakpoint</div>
-<divclass="container-xxl">100% wide until extra extra large breakpoint</div>
-
Fluid containers
+
<divclass="container-sm">100% wide until small breakpoint</div>
+<divclass="container-md">100% wide until medium breakpoint</div>
+<divclass="container-lg">100% wide until large breakpoint</div>
+<divclass="container-xl">100% wide until extra large breakpoint</div>
+<divclass="container-xxl">100% wide until extra extra large breakpoint</div>
+
+
Fluid containers
Use .container-fluid for a full width container, spanning the entire width of the viewport.
-
<divclass="container-fluid">
- ...
-</div>
-
CSS
-
Sass variables
+
<divclass="container-fluid">
+ ...
+</div>
+
+
CSS
+
Sass variables
As shown above, Bootstrap generates a series of predefined container classes to help you build the layouts you desire. You may customize these predefined container classes by modifying the Sass map (found in _variables.scss) that powers them:
Bootstrap’s default grid system represents the culmination of over a decade of CSS layout techniques, tried and tested by millions of people. But, it was also created without many of the modern CSS features and techniques we’re seeing in browsers like the new CSS Grid.
-
-Heads up—our CSS Grid system is experimental and opt-in as of v5.1.0! We included it in our documentation’s CSS to demonstrate it for you, but it’s disabled by default. Keep reading to learn how to enable it in your projects.
-
-
-
How it works
-
With Bootstrap 5, we’ve added the option to enable a separate grid system that’s built on CSS Grid, but with a Bootstrap twist. You still get classes you can apply on a whim to build responsive layouts, but with a different approach under the hood.
Bootstrap’s default grid system represents the culmination of over a decade of CSS layout techniques, tried and tested by millions of people. But, it was also created without many of the modern CSS features and techniques we’re seeing in browsers like the new CSS Grid.
+
Heads up—our CSS Grid system is experimental and opt-in as of v5.1.0! We included it in our documentation’s CSS to demonstrate it for you, but it’s disabled by default. Keep reading to learn how to enable it in your projects.
+
How it works
+
With Bootstrap 5, we’ve added the option to enable a separate grid system that’s built on CSS Grid, but with a Bootstrap twist. You still get classes you can apply on a whim to build responsive layouts, but with a different approach under the hood.
CSS Grid is opt-in. Disable the default grid system by setting $enable-grid-classes: false and enable the CSS Grid by setting $enable-cssgrid: true. Then, recompile your Sass.
@@ -596,11 +39,11 @@
In the future, Bootstrap will likely shift to a hybrid solution as the gap property has achieved nearly full browser support for flexbox.
-
Key differences
+
Key differences
Compared to the default grid system:
-
Flex utilities don’t affect the CSS Grid columns in the same way.
+
Flex utilities don’t affect the CSS Grid columns in the same way.
Gaps replaces gutters. The gap property replaces the horizontal padding from our default grid system and functions more like margin.
@@ -615,152 +58,64 @@
Nesting works similarly, but may require you to reset your column counts on each instance of a nested .grid. See the nesting section for details.
-
Examples
-
Three columns
+
Examples
+
Three columns
Three equal-width columns across all viewports and devices can be created by using the .g-col-4 classes. Add responsive classes to change the layout by viewport size.
Use responsive classes to adjust your layout across viewports. Here we start with two columns on the narrowest viewports, and then grow to three columns on medium viewports and above.
Grid items automatically wrap to the next line when there’s no more room horizontally. Note that the gap applies to horizontal and vertical gaps between grid items.
Grid items automatically wrap to the next line when there’s no more room horizontally. Note that the gap applies to horizontal and vertical gaps between grid items.
Start classes aim to replace our default grid’s offset classes, but they’re not entirely the same. CSS Grid creates a grid template through styles that tell browsers to “start at this column” and “end at this column.” Those properties are grid-column-start and grid-column-end. Start classes are shorthand for the former. Pair them with the column classes to size and align your columns however you need. Start classes begin at 1 as 0 is an invalid value for these properties.
Start classes aim to replace our default grid’s offset classes, but they’re not entirely the same. CSS Grid creates a grid template through styles that tell browsers to “start at this column” and “end at this column”. Those properties are grid-column-start and grid-column-end. Start classes are shorthand for the former. Pair them with the column classes to size and align your columns however you need. Start classes begin at 1 as 0 is an invalid value for these properties.
Similar to our default grid system, our CSS Grid allows for easy nesting of .grids. However, unlike the default, this grid inherits changes in the rows, columns, and gaps. Consider the example below:
We override the default number of columns with a local CSS variable: --bs-columns: 3.
In the first auto-column, the column count is inherited and each column is one-third of the available width.
-
In the second auto-column, we’ve reset the column count on the nested .grid to 12 (our default).
+
In the second auto-column, we’ve reset the column count on the nested .grid to 12 (our default).
The third auto-column has no nested content.
In practice this allows for more complex and custom layouts when compared to our default grid system.
-
-
-
-
+
First auto-column
@@ -865,342 +186,135 @@
Third auto-column
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="grid text-center overflow-x-auto"style="--bs-columns: 3;">
-<div>
- First auto-column
-<divclass="grid">
-<div>Auto-column</div>
-<div>Auto-column</div>
-</div>
-</div>
-<div>
- Second auto-column
-<divclass="grid"style="--bs-columns: 12;">
-<divclass="g-col-6">6 of 12</div>
-<divclass="g-col-4">4 of 12</div>
-<divclass="g-col-2">2 of 12</div>
-</div>
-</div>
-<div>Third auto-column</div>
-</div>
-
-
-
Customizing
+
html
<divclass="grid text-center overflow-x-auto"style="--bs-columns: 3;">
+ <div>
+ First auto-column
+ <divclass="grid">
+ <div>Auto-column</div>
+ <div>Auto-column</div>
+ </div>
+ </div>
+ <div>
+ Second auto-column
+ <divclass="grid"style="--bs-columns: 12;">
+ <divclass="g-col-6">6 of 12</div>
+ <divclass="g-col-4">4 of 12</div>
+ <divclass="g-col-2">2 of 12</div>
+ </div>
+ </div>
+ <div>Third auto-column</div>
+</div>
+
Customizing
Customize the number of columns, the number of rows, and the width of the gaps with local CSS variables.
-
-
-
-
Variable
-
Fallback value
-
Description
-
-
-
-
-
--bs-rows
-
1
-
The number of rows in your grid template
-
-
-
--bs-columns
-
12
-
The number of columns in your grid template
-
-
-
--bs-gap
-
1.5rem
-
The size of the gap between columns (vertical and horizontal)
-
-
-
+
-
These CSS variables have no default value; instead, they apply fallback values that are used until a local instance is provided. For example, we use var(--bs-rows, 1) for our CSS Grid rows, which ignores --bs-rows because that hasn’t been set anywhere yet. Once it is, the .grid instance will use that value instead of the fallback value of 1.
-
No grid classes
-
Immediate children elements of .grid are grid items, so they’ll be sized without explicitly adding a .g-col class.
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Variable
Fallback value
Description
--bs-rows
1
The number of rows in your grid template
--bs-columns
12
The number of columns in your grid template
--bs-gap
1.5rem
The size of the gap between columns (vertical and horizontal)
+
These CSS variables have no default value; instead, they apply fallback values that are used until a local instance is provided. For example, we use var(--bs-rows, 1) for our CSS Grid rows, which ignores --bs-rows because that hasn’t been set anywhere yet. Once it is, the .grid instance will use that value instead of the fallback value of 1.
+
No grid classes
+
Immediate children elements of .grid are grid items, so they’ll be sized without explicitly adding a .g-col class.
Because of that, you can have different vertical and horizontal gaps, which can take a single value (all sides) or a pair of values (vertical and horizontal). This can be applied with an inline style for gap, or with our --bs-gap CSS variable.
One limitation of the CSS Grid is that our default classes are still generated by two Sass variables, $grid-columns and $grid-gutter-width. This effectively predetermines the number of classes generated in our compiled CSS. You have two options here:
Modify those default Sass variables and recompile your CSS.
Use inline or custom styles to augment the provided classes.
-
For example, you can increase the column count and change the gap size, and then size your “columns” with a mix of inline styles and predefined CSS Grid column classes (e.g., .g-col-4).
-
-
-
-
+
For example, you can increase the column count and change the gap size, and then size your “columns” with a mix of inline styles and predefined CSS Grid column classes (e.g., .g-col-4).
Use our powerful mobile-first flexbox grid to build layouts of all shapes and sizes thanks to a twelve column system, six default responsive tiers, Sass variables and mixins, and dozens of predefined classes.
Bootstrap’s grid system uses a series of containers, rows, and columns to layout and align content. It’s built with flexbox and is fully responsive. Below is an example and an in-depth explanation for how the grid system comes together.
Use our powerful mobile-first flexbox grid to build layouts of all shapes and sizes thanks to a twelve column system, six default responsive tiers, Sass variables and mixins, and dozens of predefined classes.
Bootstrap’s grid system uses a series of containers, rows, and columns to layout and align content. It’s built with flexbox and is fully responsive. Below is an example and an in-depth explanation for how the grid system comes together.
The above example creates three equal-width columns across all devices and viewports using our predefined grid classes. Those columns are centered in the page with the parent .container.
-
How it works
-
Breaking it down, here’s how the grid system comes together:
+
How it works
+
Breaking it down, here’s how the grid system comes together:
-
Our grid supports six responsive breakpoints. Breakpoints are based on min-width media queries, meaning they affect that breakpoint and all those above it (e.g., .col-sm-4 applies to sm, md, lg, xl, and xxl). This means you can control container and column sizing and behavior by each breakpoint.
+
Our grid supports six responsive breakpoints. Breakpoints are based on min-width media queries, meaning they affect that breakpoint and all those above it (e.g., .col-sm-4 applies to sm, md, lg, xl, and xxl). This means you can control container and column sizing and behavior by each breakpoint.
Containers center and horizontally pad your content. Use .container for a responsive pixel width, .container-fluid for width: 100% across all viewports and devices, or a responsive container (e.g., .container-md) for a combination of fluid and pixel widths.
-
Rows are wrappers for columns. Each column has horizontal padding (called a gutter) for controlling the space between them. This padding is then counteracted on the rows with negative margins to ensure the content in your columns is visually aligned down the left side. Rows also support modifier classes to uniformly apply column sizing and gutter classes to change the spacing of your content.
+
Rows are wrappers for columns. Each column has horizontal padding (called a gutter) for controlling the space between them. This padding is then counteracted on the rows with negative margins to ensure the content in your columns is visually aligned down the left side. Rows also support modifier classes to uniformly apply column sizing and gutter classes to change the spacing of your content.
Columns are incredibly flexible. There are 12 template columns available per row, allowing you to create different combinations of elements that span any number of columns. Column classes indicate the number of template columns to span (e.g., col-4 spans four). widths are set in percentages so you always have the same relative sizing.
-
Gutters are also responsive and customizable.Gutter classes are available across all breakpoints, with all the same sizes as our margin and padding spacing. Change horizontal gutters with .gx-* classes, vertical gutters with .gy-*, or all gutters with .g-* classes. .g-0 is also available to remove gutters.
+
Gutters are also responsive and customizable.Gutter classes are available across all breakpoints, with all the same sizes as our margin and padding spacing. Change horizontal gutters with .gx-* classes, vertical gutters with .gy-*, or all gutters with .g-* classes. .g-0 is also available to remove gutters.
-
Sass variables, maps, and mixins power the grid. If you don’t want to use the predefined grid classes in Bootstrap, you can use our grid’s source Sass to create your own with more semantic markup. We also include some CSS custom properties to consume these Sass variables for even greater flexibility for you.
+
Sass variables, maps, and mixins power the grid. If you don’t want to use the predefined grid classes in Bootstrap, you can use our grid’s source Sass to create your own with more semantic markup. We also include some CSS custom properties to consume these Sass variables for even greater flexibility for you.
Bootstrap’s grid system can adapt across all six default breakpoints, and any breakpoints you customize. The six default grid tiers are as follows:
+
Grid options
+
Bootstrap’s grid system can adapt across all six default breakpoints, and any breakpoints you customize. The six default grid tiers are as follows:
Extra small (xs)
Small (sm)
@@ -667,88 +83,13 @@
Extra large (xl)
Extra extra large (xxl)
-
As noted above, each of these breakpoints have their own container, unique class prefix, and modifiers. Here’s how the grid changes across these breakpoints:
As noted above, each of these breakpoints have their own container, unique class prefix, and modifiers. Here’s how the grid changes across these breakpoints:
Utilize breakpoint-specific column classes for easy column sizing without an explicit numbered class like .col-sm-6.
-
Equal-width
+
Equal-width
For example, here are two grid layouts that apply to every device and viewport, from xs to xxl. Add any number of unit-less classes for each breakpoint you need and every column will be the same width.
-
-
-
-
+
1 of 2
@@ -768,47 +109,30 @@
3 of 3
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="container text-center">
-<divclass="row">
-<divclass="col">
- 1 of 2
-</div>
-<divclass="col">
- 2 of 2
-</div>
-</div>
-<divclass="row">
-<divclass="col">
- 1 of 3
-</div>
-<divclass="col">
- 2 of 3
-</div>
-<divclass="col">
- 3 of 3
-</div>
-</div>
-</div>
Auto-layout for flexbox grid columns also means you can set the width of one column and have the sibling columns automatically resize around it. You may use predefined grid classes (as shown below), grid mixins, or inline widths. Note that the other columns will resize no matter the width of the center column.
-
-
-
-
+
1 of 3
@@ -831,50 +155,33 @@
3 of 3
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="container text-center">
-<divclass="row">
-<divclass="col">
- 1 of 3
-</div>
-<divclass="col-6">
- 2 of 3 (wider)
-</div>
-<divclass="col">
- 3 of 3
-</div>
-</div>
-<divclass="row">
-<divclass="col">
- 1 of 3
-</div>
-<divclass="col-5">
- 2 of 3 (wider)
-</div>
-<divclass="col">
- 3 of 3
-</div>
-</div>
-</div>
Bootstrap’s grid includes six tiers of predefined classes for building complex responsive layouts. Customize the size of your columns on extra small, small, medium, large, or extra large devices however you see fit.
Bootstrap’s grid includes six tiers of predefined classes for building complex responsive layouts. Customize the size of your columns on extra small, small, medium, large, or extra large devices however you see fit.
+
All breakpoints
For grids that are the same from the smallest of devices to the largest, use the .col and .col-* classes. Specify a numbered class when you need a particularly sized column; otherwise, feel free to stick to .col.
Using a single set of .col-sm-* classes, you can create a basic grid system that starts out stacked and becomes horizontal at the small breakpoint (sm).
Don’t want your columns to simply stack in some grid tiers? Use a combination of different classes for each tier as needed. See the example below for a better idea of how it all works.
Don’t want your columns to simply stack in some grid tiers? Use a combination of different classes for each tier as needed. See the example below for a better idea of how it all works.
+
.col-md-8
@@ -1043,251 +299,133 @@
.col-6
.col-6
-
+
html
<divclass="container text-center">
+ <!-- Stack the columns on mobile by making one full-width and the other half-width -->
+ <divclass="row">
+ <divclass="col-md-8">.col-md-8</div>
+ <divclass="col-6 col-md-4">.col-6 .col-md-4</div>
+ </div>
-
- html
-
-
-
-
-
-
-
-
-
<divclass="container text-center">
-<!-- Stack the columns on mobile by making one full-width and the other half-width -->
-<divclass="row">
-<divclass="col-md-8">.col-md-8</div>
-<divclass="col-6 col-md-4">.col-6 .col-md-4</div>
-</div>
-
-<!-- Columns start at 50% wide on mobile and bump up to 33.3% wide on desktop -->
-<divclass="row">
-<divclass="col-6 col-md-4">.col-6 .col-md-4</div>
-<divclass="col-6 col-md-4">.col-6 .col-md-4</div>
-<divclass="col-6 col-md-4">.col-6 .col-md-4</div>
-</div>
-
-<!-- Columns are always 50% wide, on mobile and desktop -->
-<divclass="row">
-<divclass="col-6">.col-6</div>
-<divclass="col-6">.col-6</div>
-</div>
-</div>
-
+ <!-- Columns start at 50% wide on mobile and bump up to 33.3% wide on desktop -->
+ <divclass="row">
+ <divclass="col-6 col-md-4">.col-6 .col-md-4</div>
+ <divclass="col-6 col-md-4">.col-6 .col-md-4</div>
+ <divclass="col-6 col-md-4">.col-6 .col-md-4</div>
+ </div>
-
Row columns
+ <!-- Columns are always 50% wide, on mobile and desktop -->
+ <divclass="row">
+ <divclass="col-6">.col-6</div>
+ <divclass="col-6">.col-6</div>
+ </div>
+</div>
+
Row columns
Use the responsive .row-cols-* classes to quickly set the number of columns that best render your content and layout. Whereas normal .col-* classes apply to the individual columns (e.g., .col-md-4), the row columns classes are set on the parent .row as a shortcut. With .row-cols-auto you can give the columns their natural width.
Use these row columns classes to quickly create basic grid layouts or to control your card layouts.
You can also use the accompanying Sass mixin, row-cols():
-
.element{
-// Three columns to start
-@include row-cols(3);
-
-// Five columns from medium breakpoint up
-@include media-breakpoint-up(md){
-@include row-cols(5);
-}
-}
-
Nesting
+
.element {
+ // Three columns to start
+ @includerow-cols(3);
+
+ // Five columns from medium breakpoint up
+ @includemedia-breakpoint-up(md){
+ @includerow-cols(5);
+ }
+}
+
+
Nesting
To nest your content with the default grid, add a new .row and set of .col-sm-* columns within an existing .col-sm-* column. Nested rows should include a set of columns that add up to 12 or fewer (it is not required that you use all 12 available columns).
When using Bootstrap’s source Sass files, you have the option of using Sass variables and mixins to create custom, semantic, and responsive page layouts. Our predefined grid classes use these same variables and mixins to provide a whole suite of ready-to-use classes for fast responsive layouts.
When using Bootstrap’s source Sass files, you have the option of using Sass variables and mixins to create custom, semantic, and responsive page layouts. Our predefined grid classes use these same variables and mixins to provide a whole suite of ready-to-use classes for fast responsive layouts.
+
Sass variables
Variables and maps determine the number of columns, the gutter width, and the media query point at which to begin floating columns. We use these to generate the predefined grid classes documented above, as well as for the custom mixins listed below.
Mixins are used in conjunction with the grid variables to generate semantic CSS for individual grid columns.
-
// Creates a wrapper for a series of columns
-@include make-row();
-
-// Make the element grid-ready (applying everything but the width)
-@include make-col-ready();
-
-// Without optional size values, the mixin will create equal columns (similar to using .col)
-@include make-col();
-@include make-col($size,$columns:$grid-columns);
-
-// Offset with margins
-@include make-col-offset($size,$columns:$grid-columns);
-
Example usage
-
You can modify the variables to your own custom values, or just use the mixins with their default values. Here’s an example of using the default settings to create a two-column layout with a gap between.
-
.example-container{
-@include make-container();
-// Make sure to define this width after the mixin to override
-// `width: 100%` generated by `make-container()`
-width:800px;
-}
-
-.example-row{
-@include make-row();
-}
-
-.example-content-main{
-@include make-col-ready();
-
-@include media-breakpoint-up(sm){
-@include make-col(6);
-}
-@include media-breakpoint-up(lg){
-@include make-col(8);
-}
-}
-
-.example-content-secondary{
-@include make-col-ready();
-
-@include media-breakpoint-up(sm){
-@include make-col(6);
-}
-@include media-breakpoint-up(lg){
-@include make-col(4);
-}
-}
-
-
-
-
+
// Creates a wrapper for a series of columns
+@includemake-row();
+
+// Make the element grid-ready (applying everything but the width)
+@includemake-col-ready();
+
+// Without optional size values, the mixin will create equal columns (similar to using .col)
+@includemake-col();
+@includemake-col($size,$columns:$grid-columns);
+
+// Offset with margins
+@includemake-col-offset($size,$columns:$grid-columns);
+
+
Example usage
+
You can modify the variables to your own custom values, or just use the mixins with their default values. Here’s an example of using the default settings to create a two-column layout with a gap between.
Using our built-in grid Sass variables and maps, it’s possible to completely customize the predefined grid classes. Change the number of tiers, the media query dimensions, and the container widths—then recompile.
Using our built-in grid Sass variables and maps, it’s possible to completely customize the predefined grid classes. Change the number of tiers, the media query dimensions, and the container widths—then recompile.
+
Columns and gutters
The number of grid columns can be modified via Sass variables. $grid-columns is used to generate the widths (in percent) of each individual column while $grid-gutter-width sets the width for the column gutters. $grid-row-columns is used to set the maximum number of columns of .row-cols-*, any number over this limit is ignored.
Moving beyond the columns themselves, you may also customize the number of grid tiers. If you wanted just four grid tiers, you’d update the $grid-breakpoints and $container-max-widths to something like this:
When making any changes to the Sass variables or maps, you’ll need to save your changes and recompile. Doing so will output a brand-new set of predefined grid classes for column widths, offsets, and ordering. Responsive visibility utilities will also be updated to use the custom breakpoints. Make sure to set grid values in px (not rem, em, or %).
Moving beyond the columns themselves, you may also customize the number of grid tiers. If you wanted just four grid tiers, you’d update the $grid-breakpoints and $container-max-widths to something like this:
When making any changes to the Sass variables or maps, you’ll need to save your changes and recompile. Doing so will output a brand-new set of predefined grid classes for column widths, offsets, and ordering. Responsive visibility utilities will also be updated to use the custom breakpoints. Make sure to set grid values in px (not rem, em, or %).
Gutters are the gaps between column content, created by horizontal padding. We set padding-right and padding-left on each column, and use negative margin to offset that at the start and end of each row to align content.
-
Gutters start at 1.5rem (24px) wide. This allows us to match our grid to the padding and margin spacers scale.
+
Gutters start at 1.5rem (24px) wide. This allows us to match our grid to the padding and margin spacers scale.
Gutters can be responsively adjusted. Use breakpoint-specific gutter classes to modify horizontal gutters, vertical gutters, and all gutters.
-
Horizontal gutters
-
.gx-* classes can be used to control the horizontal gutter widths. The .container or .container-fluid parent may need to be adjusted if larger gutters are used too to avoid unwanted overflow, using a matching padding utility. For example, in the following example we’ve increased the padding with .px-4:
-
-
-
-
+
Horizontal gutters
+
.gx-* classes can be used to control the horizontal gutter widths. The .container or .container-fluid parent may need to be adjusted if larger gutters are used too to avoid unwanted overflow, using a matching padding utility. For example, in the following example we’ve increased the padding with .px-4:
.gy-* classes can be used to control the vertical gutter widths within a row when columns wrap to new lines. Like the horizontal gutters, the vertical gutters can cause some overflow below the .row at the end of a page. If this occurs, you add a wrapper around .row with the .overflow-hidden class:
Use .g-* classes to control the horizontal and vertical grid gutters. In the example below, we use a smaller gutter width, so there isn’t a need for the .overflow-hidden wrapper class.
Use .g-* classes to control the horizontal and vertical grid gutters. In the example below, we use a smaller gutter width, so there isn’t a need for the .overflow-hidden wrapper class.
The gutters between columns in our predefined grid classes can be removed with .g-0. This removes the negative margins from .row and the horizontal padding from all immediate children columns.
Need an edge-to-edge design? Drop the parent .container or .container-fluid and add .mx-0 to the .row to prevent overflow.
-
In practice, here’s how it looks. Note that you can continue to use this with all other predefined grid classes (including column widths, responsive tiers, reorders, and more).
-
-
-
-
+
In practice, here’s how it looks. Note that you can continue to use this with all other predefined grid classes (including column widths, responsive tiers, reorders, and more).
For faster mobile-friendly and responsive development, Bootstrap includes dozens of utility classes for showing, hiding, aligning, and spacing content.
Use our display utilities for responsively toggling common values of the display property. Mix it with our grid system, content, or components to show or hide them across specific viewports.
-
Flexbox options
-
Bootstrap is built with flexbox, but not every element’s display has been changed to display: flex as this would add many unnecessary overrides and unexpectedly change key browser behaviors. Most of our components are built with flexbox enabled.
-
Should you need to add display: flex to an element, do so with .d-flex or one of the responsive variants (e.g., .d-sm-flex). You’ll need this class or display value to allow the use of our extra flexbox utilities for sizing, alignment, spacing, and more.
-
Margin and padding
-
Use the margin and paddingspacing utilities to control how elements and components are spaced and sized. Bootstrap includes a six-level scale for spacing utilities, based on a 1rem value default $spacer variable. Choose values for all viewports (e.g., .me-3 for margin-right: 1rem in LTR), or pick responsive variants to target specific viewports (e.g., .me-md-3 for margin-right: 1rem —in LTR— starting at the md breakpoint).
-
Toggle visibility
-
When toggling display isn’t needed, you can toggle the visibility of an element with our visibility utilities. Invisible elements will still affect the layout of the page, but are visually hidden from visitors.
For faster mobile-friendly and responsive development, Bootstrap includes dozens of utility classes for showing, hiding, aligning, and spacing content.
Use our display utilities for responsively toggling common values of the display property. Mix it with our grid system, content, or components to show or hide them across specific viewports.
+
Flexbox options
+
Bootstrap is built with flexbox, but not every element’s display has been changed to display: flex as this would add many unnecessary overrides and unexpectedly change key browser behaviors. Most of our components are built with flexbox enabled.
+
Should you need to add display: flex to an element, do so with .d-flex or one of the responsive variants (e.g., .d-sm-flex). You’ll need this class or display value to allow the use of our extra flexbox utilities for sizing, alignment, spacing, and more.
+
Margin and padding
+
Use the margin and paddingspacing utilities to control how elements and components are spaced and sized. Bootstrap includes a six-level scale for spacing utilities, based on a 1rem value default $spacer variable. Choose values for all viewports (e.g., .me-3 for margin-right: 1rem in LTR), or pick responsive variants to target specific viewports (e.g., .me-md-3 for margin-right: 1rem —in LTR— starting at the md breakpoint).
+
Toggle visibility
+
When toggling display isn’t needed, you can toggle the visibility of an element with our visibility utilities. Invisible elements will still affect the layout of the page, but are visually hidden from visitors.
While not a part of Bootstrap’s grid system, z-indexes play an important part in how our components overlay and interact with one another.
-
-
-
-
-
-
-
-
-
-
Several Bootstrap components utilize z-index, the CSS property that helps control layout by providing a third axis to arrange content. We utilize a default z-index scale in Bootstrap that’s been designed to properly layer navigation, tooltips and popovers, modals, and more.
-
These higher values start at an arbitrary number, high and specific enough to ideally avoid conflicts. We need a standard set of these across our layered components—tooltips, popovers, navbars, dropdowns, modals—so we can be reasonably consistent in the behaviors. There’s no reason we couldn’t have used 100+ or 500+.
-
We don’t encourage customization of these individual values; should you change one, you likely need to change them all.
To handle overlapping borders within components (e.g., buttons and inputs in input groups), we use low single digit z-index values of 1, 2, and 3 for default, hover, and active states. On hover/focus/active, we bring a particular element to the forefront with a higher z-index value to show their border over the sibling elements.
While not a part of Bootstrap’s grid system, z-indexes play an important part in how our components overlay and interact with one another.
+
Several Bootstrap components utilize z-index, the CSS property that helps control layout by providing a third axis to arrange content. We utilize a default z-index scale in Bootstrap that’s been designed to properly layer navigation, tooltips and popovers, modals, and more.
+
These higher values start at an arbitrary number, high and specific enough to ideally avoid conflicts. We need a standard set of these across our layered components—tooltips, popovers, navbars, dropdowns, modals—so we can be reasonably consistent in the behaviors. There’s no reason we couldn’t have used 100+ or 500+.
+
We don’t encourage customization of these individual values; should you change one, you likely need to change them all.
To handle overlapping borders within components (e.g., buttons and inputs in input groups), we use low single digit z-index values of 1, 2, and 3 for default, hover, and active states. On hover/focus/active, we bring a particular element to the forefront with a higher z-index value to show their border over the sibling elements.
If you’re migrating from our previous alpha release of v5.3.0, please review the changes listed below.
+
CSS variables
Removed several duplicate and unused root CSS variables.
-
Color modes
+
Color modes
Dark mode colors are now derived from our theme colors (e.g., $primary) in Sass, rather than color specific tints or shades (e.g., $blue-300). This allows for a more automated dark mode when customizing the default theme colors.
@@ -673,7 +60,7 @@
Form validation border-color and text color states now respond to dark mode, thanks to new Sass and CSS variables.
-
Dropped recently added form control background CSS variables and reassigned the Sass variables to use CSS variables instead. This simplifies the styling across color modes and avoids an issue where form controls in dark mode wouldn’t update properly.
+
Dropped recently added form control background CSS variables and reassigned the Sass variables to use CSS variables instead. This simplifies the styling across color modes and avoids an issue where form controls in dark mode wouldn’t update properly.
Our box-shadows will once again always stay dark instead of inverting to white when in dark mode.
@@ -685,23 +72,23 @@
Improved docs code syntax colors and more across light and dark modes.
-
Typography
+
Typography
-
We no longer set a color for $headings-color-dark or --bs-heading-color for dark mode. To avoid several problems of headings within components appearing the wrong color, we’ve set the Sass variable to null and added a null check like we use on the default light mode.
+
We no longer set a color for $headings-color-dark or --bs-heading-color for dark mode. To avoid several problems of headings within components appearing the wrong color, we’ve set the Sass variable to null and added a null check like we use on the default light mode.
-
Components
+
Components
Cards now have a color set on them to improve rendering across color modes.
-
Added new .nav-underline variant for our navigation with a simpler bottom border under the active nav link. See the docs for an example.
+
Added new .nav-underline variant for our navigation with a simpler bottom border under the active nav link. See the docs for an example.
Navs now have new :focus-visible styles that better match our custom button focus styles.
-
Helpers
+
Helpers
Added new .icon-link helper to quickly place and align Bootstrap Icons alongside a textual link. Icon links support our new link utilities, too.
@@ -710,16 +97,16 @@
Added new focus ring helper for removing the default outline and setting a custom box-shadow focus ring.
-
Utilities
+
Utilities
Renamed Sass and CSS variables ${color}-text to ${color}-text-emphasis to match their associated utilities.
-
Added new .link-body-emphasis helper alongside our colored links. This creates a colored link using our color mode responsive emphasis color.
+
Added new .link-body-emphasis helper alongside our colored links. This creates a colored link using our color mode responsive emphasis color.
-
Added new link utilities for link color opacity, underline offset, underline color, and underline opacity. Explore the new links utilities.
+
Added new link utilities for link color opacity, underline offset, underline color, and underline opacity. Explore the new links utilities.
CSS variable based border-width utilities have been reverted to set their property directly (as was done prior to v5.2.0). This avoids inheritance issues across nested elements, including tables.
@@ -731,7 +118,7 @@
Deprecated The .text-muted utility and $text-muted Sass variable have been deprecated and replaced with .text-body-secondary and $body-secondary-color.
-
Docs
+
Docs
Examples are now displayed with the appropriate light or dark color mode as dictated by the setting in our docs. Each example has an individual color mode picker.
@@ -743,7 +130,7 @@
Added twbs/examples repo contents to the top of the Examples page.
-
Tooling
+
Tooling
Added SCSS testing via True to help test our utilities API and other customizations.
@@ -752,52 +139,53 @@
Replaced instances of our bootstrap-npm-starter project with the newer and more complete twbs/examples repo.
Global support for light (default) and dark color modes. Set color mode globally on the :root element, on groups of elements and components with a wrapper class, or directly on components, with data-bs-theme="light|dark". Also included is a new color-mode() mixin that can output a ruleset with the data-bs-theme selector or a media query, depending on your preference.
Deprecated Color modes replace dark variants for components, so .btn-close-white, .carousel-dark, .dropdown-menu-dark, and .navbar-dark are deprecated.
-
New extended color system. We’ve added new theme colors (but not in $theme-colors) for a more nuanced, system-wide color palette with new secondary, tertiary, and emphasis colors for color and background-color. These new colors are available as Sass variables, CSS variables, and utilities.
+
New extended color system. We’ve added new theme colors (but not in $theme-colors) for a more nuanced, system-wide color palette with new secondary, tertiary, and emphasis colors for color and background-color. These new colors are available as Sass variables, CSS variables, and utilities.
-
We’ve also expanded our theme color Sass variables, CSS variables, and utilities to include text emphasis, subtle background colors, and subtle border colors. These are available as Sass variables, CSS variables, and utilities.
+
We’ve also expanded our theme color Sass variables, CSS variables, and utilities to include text emphasis, subtle background colors, and subtle border colors. These are available as Sass variables, CSS variables, and utilities.
Adds new _variables-dark.scss stylesheet to house dark-mode specific overrides. This stylesheet should be imported immediately after the existing _variables.scss file in your import stack.
Restores CSS variables for breakpoints, though we don’t use them in our media queries as they’re not supported. However, these can be useful in JS-specific contexts.
+
Restores CSS variables for breakpoints, though we don’t use them in our media queries as they’re not supported. However, these can be useful in JS-specific contexts.
-
Per the color modes update, we’ve added new utilities for new Sass CSS variables secondary and tertiary text and background colors, plus {color}-bg-subtle, {color}-border-subtle, and {color}-text-emphasis for our theme colors. These new colors are available through Sass and CSS variables (but not our color maps) with the express goal of making it easier to customize across multiple colors modes like light and dark.
+
Per the color modes update, we’ve added new utilities for new Sass CSS variables secondary and tertiary text and background colors, plus {color}-bg-subtle, {color}-border-subtle, and {color}-text-emphasis for our theme colors. These new colors are available through Sass and CSS variables (but not our color maps) with the express goal of making it easier to customize across multiple colors modes like light and dark.
Adds additional variables for alerts, .btn-close, and .offcanvas.
-
The --bs-heading-color variable is back with an update and dark mode support. First, we now check for a null value on the associated Sass variable, $headings-color, before trying to output the CSS variable, so by default it’s not present in our compiled CSS. Second, we use the CSS variable with a fallback value, inherit, allowing the original behavior to persist, but also allowing for overrides.
+
The --bs-heading-color variable is back with an update and dark mode support. First, we now check for a null value on the associated Sass variable, $headings-color, before trying to output the CSS variable, so by default it’s not present in our compiled CSS. Second, we use the CSS variable with a fallback value, inherit, allowing the original behavior to persist, but also allowing for overrides.
Converts links to use CSS variables for styling color, but not text-decoration. Colors are now set with --bs-link-color-rgb and --bs-link-opacity as rgba() color, allowing you to customize the translucency with ease. The a:hover pseudo-class now overrides --bs-link-color-rgb instead of explicitly setting the color property.
@@ -809,76 +197,78 @@
Adds new root CSS variables for our box-shadows, including --bs-box-shadow, --bs-box-shadow-sm, --bs-box-shadow-lg, and --bs-box-shadow-inset.
-
Components
-
Alert
+
Components
+
Alert
Alert variants are now styled via CSS variables.
-
Deprecated The alert-variant() mixin is now deprecated. We now use a Sass loop directly to modify the component’s default CSS variables for each variant.
+
Deprecated The alert-variant() mixin is now deprecated. We now use a Sass loop directly to modify the component’s default CSS variables for each variant.
-
List group
+
List group
List group item variants are now styled via CSS variables.
-
Deprecated The list-group-item-variant() mixin is now deprecated. We now use a Sass loop directly to modify the component’s default CSS variables for each variant.
+
Deprecated The list-group-item-variant() mixin is now deprecated. We now use a Sass loop directly to modify the component’s default CSS variables for each variant.
-
Dropdowns
+
Dropdowns
-
Deprecated The .dropdown-menu-dark class has been deprecated and replaced with data-bs-theme="dark" on the dropdown or any parent element. See the docs for an example.
+
Deprecated The .dropdown-menu-dark class has been deprecated and replaced with data-bs-theme="dark" on the dropdown or any parent element. See the docs for an example.
-
Close button
+
Close button
-
Deprecated The .btn-close-white class has been deprecated and replaced with data-bs-theme="dark" on the close button or any parent element. See the docs for an example.
+
Deprecated The .btn-close-white class has been deprecated and replaced with data-bs-theme="dark" on the close button or any parent element. See the docs for an example.
-
Navbar
+
Navbar
-
Deprecated The .navbar-dark class has been deprecated and replaced with data-bs-theme="dark" on the navbar or any parent element. See the docs for updated examples.
+
Deprecated The .navbar-dark class has been deprecated and replaced with data-bs-theme="dark" on the navbar or any parent element. See the docs for updated examples.
-
Progress bars
-
The markup for progress bars has been updated in v5.3.0. Due to the placement of role and various aria- attributes on the inner .progress-bar element, some screen readers were not announcing zero value progress bars. Now, role="progressbar" and the relevant aria-* attributes are on the outer .progress element, leaving the .progress-bar purely for the visual presentation of the bar and optional label.
+
Progress bars
+
The markup for progress bars has been updated in v5.3.0. Due to the placement of role and various aria- attributes on the inner .progress-bar element, some screen readers were not announcing zero value progress bars. Now, role="progressbar" and the relevant aria-* attributes are on the outer .progress element, leaving the .progress-bar purely for the visual presentation of the bar and optional label.
While we recommend adopting the new markup for improved compatibility with all screen readers, note that the legacy progress bar structure will continue to work as before.
.form-control is now styled with CSS variables to support color modes. This includes the addition of two new root CSS variables for the default and disabled form control backgrounds.
-
.form-check and .form-switch components are now built with CSS variables for setting the background-image. The usage here differs from other components in that the various focus, active, etc states for each component aren’t set on the base class. Instead, the states override one variable (e.g., --bs-form-switch-bg).
+
.form-check and .form-switch components are now built with CSS variables for setting the background-image. The usage here differs from other components in that the various focus, active, etc states for each component aren’t set on the base class. Instead, the states override one variable (e.g., --bs-form-switch-bg).
Floating form labels now have a background-color to fix support for <textarea> elements. Additional changes have been made to also support disabled states and more.
@@ -887,7 +277,7 @@
Fixed display of date and time inputs in WebKit based browsers.
-
Utilities
+
Utilities
Deprecated.text-muted will be replaced by .text-body-secondary in v6.
Box shadow utilities (and Sass variables) have been updated for dark mode. They now use --bs-body-color-rgb to generate the rgba() color values, allowing them to easily adapt to color modes based on the specified foreground color.
+
Box shadow utilities (and Sass variables) have been updated for dark mode. They now use --bs-body-color-rgb to generate the rgba() color values, allowing them to easily adapt to color modes based on the specified foreground color.
Bootstrap v5.2.0 features a subtle design update for a handful of components and properties across the project, most notably through refined border-radius values on buttons and form controls. Our documentation also has been updated with a new homepage, simpler docs layout that no longer collapses sections of the sidebar, and more prominent examples of Bootstrap Icons.
-
More CSS variables
-
We’ve updated all our components to use CSS variables. While Sass still underpins everything, each component has been updated to include CSS variables on the component base classes (e.g., .btn), allowing for more real-time customization of Bootstrap. In subsequent releases, we’ll continue to expand our use of CSS variables into our layout, forms, helpers, and utilities. Read more about CSS variables in each component on their respective documentation pages.
-
Our CSS variable usage will be somewhat incomplete until Bootstrap 6. While we’d love to fully implement these across the board, they do run the risk of causing breaking changes. For example, setting $alert-border-width: var(--bs-border-width) in our source code breaks potential Sass in your own code if you were doing $alert-border-width * 2 for some reason.
+
More CSS variables
+
We’ve updated all our components to use CSS variables. While Sass still underpins everything, each component has been updated to include CSS variables on the component base classes (e.g., .btn), allowing for more real-time customization of Bootstrap. In subsequent releases, we'll continue to expand our use of CSS variables into our layout, forms, helpers, and utilities. Read more about CSS variables in each component on their respective documentation pages.
+
Our CSS variable usage will be somewhat incomplete until Bootstrap 6. While we’d love to fully implement these across the board, they do run the risk of causing breaking changes. For example, setting $alert-border-width: var(--bs-border-width) in our source code breaks potential Sass in your own code if you were doing $alert-border-width * 2 for some reason.
As such, wherever possible, we will continue to push towards more CSS variables, but please recognize our implementation may be slightly limited in v5.
-
New _maps.scss
-
Bootstrap v5.2.0 introduced a new Sass file with _maps.scss. It pulls out several Sass maps from _variables.scss to fix an issue where updates to an original map were not applied to secondary maps that extend them. For example, updates to $theme-colors were not being applied to other theme maps that relied on $theme-colors, breaking key customization workflows. In short, Sass has a limitation where once a default variable or map has been used, it cannot be updated. There’s a similar shortcoming with CSS variables when they’re used to compose other CSS variables.
+
New _maps.scss
+
Bootstrap v5.2.0 introduced a new Sass file with _maps.scss. It pulls out several Sass maps from _variables.scss to fix an issue where updates to an original map were not applied to secondary maps that extend them. For example, updates to $theme-colors were not being applied to other theme maps that relied on $theme-colors, breaking key customization workflows. In short, Sass has a limitation where once a default variable or map has been used, it cannot be updated. There’s a similar shortcoming with CSS variables when they’re used to compose other CSS variables.
This is why variable customizations in Bootstrap have to come after @import "functions", but before @import "variables" and the rest of our import stack. The same applies to Sass maps—you must override the defaults before they get used. The following maps have been moved to the new _maps.scss:
$theme-colors-rgb
@@ -929,45 +319,46 @@
$gutters
Your custom Bootstrap CSS builds should now look something like this with a separate maps import.
-
// Functions come first
- @import "functions";
-
- // Optional variable overrides here
-+ $custom-color: #df711b;
-+ $custom-theme-colors: (
-+ "custom": $custom-color
-+ );
-
- // Variables come next
- @import "variables";
-
-+ // Optional Sass map overrides here
-+ $theme-colors: map-merge($theme-colors, $custom-theme-colors);
-+
-+ // Followed by our default maps
-+ @import "maps";
-+
- // Rest of our imports
- @import "mixins";
- @import "utilities";
- @import "root";
- @import "reboot";
- // etc
-
New utilities
+
// Functions come first
+ @import "functions";
+
+ // Optional variable overrides here
++ $custom-color: #df711b;
++ $custom-theme-colors: (
++ "custom": $custom-color
++ );
+
+ // Variables come next
+ @import "variables";
+
++ // Optional Sass map overrides here
++ $theme-colors: map-merge($theme-colors, $custom-theme-colors);
++
++ // Followed by our default maps
++ @import "maps";
++
+ // Rest of our imports
+ @import "mixins";
+ @import "utilities";
+ @import "root";
+ @import "reboot";
+ // etc
+
Expanded border-radius utilities to include two new sizes, .rounded-4 and .rounded-5, for more options.
-
Additional changes
+
Additional changes
Introduced new $enable-container-classes option. — Now when opting into the experimental CSS Grid layout, .container-* classes will still be compiled, unless this option is set to false. Containers also now keep their gutter values.
-
Offcanvas component now has responsive variations. The original .offcanvas class remains unchanged—it hides content across all viewports. To make it responsive, change that .offcanvas class to any .offcanvas-{sm|md|lg|xl|xxl} class.
+
Offcanvas component now has responsive variations. The original .offcanvas class remains unchanged—it hides content across all viewports. To make it responsive, change that .offcanvas class to any .offcanvas-{sm|md|lg|xl|xxl} class.
-
Thicker table dividers are now opt-in. — We’ve removed the thicker and more difficult to override border between table groups and moved it to an optional class you can apply, .table-group-divider. See the table docs for an example.
+
Thicker table dividers are now opt-in. — We’ve removed the thicker and more difficult to override border between table groups and moved it to an optional class you can apply, .table-group-divider. See the table docs for an example.
Scrollspy has been rewritten to use the Intersection Observer API, which means you no longer need relative parent wrappers, deprecates offset config, and more. Look for your Scrollspy implementations to be more accurate and consistent in their nav highlighting.
@@ -976,30 +367,30 @@
Popovers and tooltips now use CSS variables. Some CSS variables have been updated from their Sass counterparts to reduce the number of variables. As a result, three variables have been deprecated in this release: $popover-arrow-color, $popover-arrow-outer-color, and $tooltip-arrow-color.
-
Added new .text-bg-{color} helpers. Instead of setting individual .text-* and .bg-* utilities, you can now use the .text-bg-* helpers to set a background-color with contrasting foreground color.
+
Added new .text-bg-{color} helpers. Instead of setting individual .text-* and .bg-* utilities, you can now use the .text-bg-* helpers to set a background-color with contrasting foreground color.
Added .form-check-reverse modifier to flip the order of labels and associated checkboxes/radios.
-
Added striped columns support to tables via the new .table-striped-columns class.
+
Added striped columns support to tables via the new .table-striped-columns class.
Added experimental support for CSS Grid layout. — This is a work in progress, and is not yet ready for production use, but you can opt into the new feature via Sass. To enable it, disable the default grid, by setting $enable-grid-classes: false and enable the CSS Grid by setting $enable-cssgrid: true.
+
Added experimental support for CSS Grid layout. — This is a work in progress, and is not yet ready for production use, but you can opt into the new feature via Sass. To enable it, disable the default grid, by setting $enable-grid-classes: false and enable the CSS Grid by setting $enable-cssgrid: true.
-
Updated navbars to support offcanvas. — Add offcanvas drawers in any navbar with the responsive .navbar-expand-* classes and some offcanvas markup.
+
Updated navbars to support offcanvas. — Add offcanvas drawers in any navbar with the responsive .navbar-expand-* classes and some offcanvas markup.
Added new placeholder component. — Our newest component, a way to provide temporary blocks in lieu of real content to help indicate that something is still loading in your site or app.
-
Collapse plugin now supports horizontal collapsing. — Add .collapse-horizontal to your .collapse to collapse the width instead of the height. Avoid browser repainting by setting a min-height or height.
+
Collapse plugin now supports horizontal collapsing. — Add .collapse-horizontal to your .collapse to collapse the width instead of the height. Avoid browser repainting by setting a min-height or height.
Added new stack and vertical rule helpers. — Quickly apply multiple flexbox properties to quickly create custom layouts with stacks. Choose from horizontal (.hstack) and vertical (.vstack) stacks. Add vertical dividers similar to <hr> elements with the new .vr helpers.
@@ -1008,7 +399,7 @@
Added new global :root CSS variables. — Added several new CSS variables to the :root level for controlling <body> styles. More are in the works, including across our utilities and components, but for now read up CSS variables in the Customize section.
-
Overhauled color and background utilities to use CSS variables, and added new text opacity and background opacity utilities. —.text-* and .bg-* utilities are now built with CSS variables and rgba() color values, allowing you to easily customize any utility with new opacity utilities.
+
Overhauled color and background utilities to use CSS variables, and added new text opacity and background opacity utilities. —.text-* and .bg-* utilities are now built with CSS variables and rgba() color values, allowing you to easily customize any utility with new opacity utilities.
Added new snippet examples based to show how to customize our components. — Pull ready to use customized components and other common design patterns with our new Snippets examples. Includes footers, dropdowns, list groups, and modals.
Added new Customize section, replacing v4’s Theming page, with new details on Sass, global configuration options, color schemes, CSS variables, and more.
Added new Customize section, replacing v4’s Theming page, with new details on Sass, global configuration options, color schemes, CSS variables, and more.
Reorganized all form documentation into new Forms section, breaking apart the content into more focused pages.
-
Similarly, updated the Layout section, to flesh out grid content more clearly.
-
Renamed “Navs” component page to “Navs & Tabs”.
-
Renamed “Checks” page to “Checks & radios”.
+
Similarly, updated the Layout section, to flesh out grid content more clearly.
+
Renamed “Navs” component page to "Navs & Tabs".
+
Renamed “Checks” page to "Checks & radios".
Redesigned the navbar and added a new subnav to make it easier to get around our sites and docs versions.
Added new keyboard shortcut for the search field: Ctrl + /.
-
Sass
+
Sass
-
We’ve ditched the default Sass map merges to make it easier to remove redundant values. Keep in mind you now have to define all values in the Sass maps like $theme-colors. Check out how to deal with Sass maps.
+
We’ve ditched the default Sass map merges to make it easier to remove redundant values. Keep in mind you now have to define all values in the Sass maps like $theme-colors. Check out how to deal with Sass maps.
-
Breaking Renamed color-yiq() function and related variables to color-contrast() as it’s no longer related to YIQ color space. See #30168.
+
Breaking Renamed color-yiq() function and related variables to color-contrast() as it’s no longer related to YIQ color space. See #30168.
$yiq-contrasted-threshold is renamed to $min-contrast-ratio.
$yiq-text-dark and $yiq-text-light are respectively renamed to $color-contrast-dark and $color-contrast-light.
@@ -1101,7 +489,7 @@
-
Breaking Renamed scale-color() function to shift-color() to avoid collision with Sass’s own color scaling function.
+
Breaking Renamed scale-color() function to shift-color() to avoid collision with Sass’s own color scaling function.
box-shadow mixins now allow null values and drop none from multiple arguments. See #30394.
@@ -1110,7 +498,7 @@
The border-radius() mixin now has a default value.
-
Color system
+
Color system
The color system which worked with color-level() and $theme-color-interval was removed in favor of a new color system. All lighten() and darken() functions in our codebase are replaced by tint-color() and shade-color(). These functions will mix the color with either white or black instead of changing its lightness by a fixed amount. The shift-color() will either tint or shade a color depending on whether its weight parameter is positive or negative. See #30622 for more details.
@@ -1122,18 +510,18 @@
Improved color contrast. Bumped color contrast ratio from 3:1 to 4.5:1 and updated blue, green, cyan, and pink colors to ensure WCAG 2.2 AA contrast. Also changed our color contrast color from $gray-900 to $black.
-
To support our color system, we’ve added new custom tint-color() and shade-color() functions to mix our colors appropriately.
+
To support our color system, we’ve added new custom tint-color() and shade-color() functions to mix our colors appropriately.
-
Grid updates
+
Grid updates
New breakpoint! Added new xxl breakpoint for 1400px and up. No changes to all other breakpoints.
-
Improved gutters. Gutters are now set in rems, and are narrower than v4 (1.5rem, or about 24px, down from 30px). This aligns our grid system’s gutters with our spacing utilities.
+
Improved gutters. Gutters are now set in rems, and are narrower than v4 (1.5rem, or about 24px, down from 30px). This aligns our grid system’s gutters with our spacing utilities.
-
Added new gutter class (.g-*, .gx-*, and .gy-*) to control horizontal/vertical gutters, horizontal gutters, and vertical gutters.
+
Added new gutter class (.g-*, .gx-*, and .gy-*) to control horizontal/vertical gutters, horizontal gutters, and vertical gutters.
Breaking Renamed .no-gutters to .g-0 to match new gutter utilities.
@@ -1144,7 +532,7 @@
Breaking Dropped several .order-* classes that often went unused. We now only provide .order-0 to .order-5 out of the box.
Breakingbootstrap-grid.css now only applies box-sizing: border-box to the column instead of resetting the global box-sizing. This way, our grid styles can be used in more places without interference.
@@ -1156,10 +544,10 @@
Updated the make-col mixin to default to equal columns without a specified size.
-
Content, Reboot, etc
+
Content, Reboot, etc
-
RFS is now enabled by default. Headings using the font-size() mixin will automatically adjust their font-size to scale with the viewport. This feature was previously opt-in with v4.
+
RFS is now enabled by default. Headings using the font-size() mixin will automatically adjust their font-size to scale with the viewport. This feature was previously opt-in with v4.
Breaking Overhauled our display typography to replace our $display-* variables and with a $display-font-sizes Sass map. Also removed the individual $display-*-weight variables for a single $display-font-weight and adjusted font-sizes.
@@ -1168,7 +556,7 @@
Added two new .display-* heading sizes, .display-5 and .display-6.
-
Links are underlined by default (not just on hover), unless they’re part of specific components.
+
Links are underlined by default (not just on hover), unless they’re part of specific components.
Redesigned tables to refresh their styles and rebuild them with CSS variables for more control over styling.
@@ -1204,14 +592,14 @@
Added $enable-smooth-scroll, which applies scroll-behavior: smooth globally—except for users asking for reduced motion through prefers-reduced-motion media query. See #31877
-
RTL
+
RTL
Horizontal direction specific variables, utilities, and mixins have all been renamed to use logical properties like those found in flexbox layouts—e.g., start and end in lieu of left and right.
-
Forms
+
Forms
-
Added new floating forms! We’ve promoted the Floating labels example to fully supported form components. See the new Floating labels page.
+
Added new floating forms! We’ve promoted the Floating labels example to fully supported form components. See the new Floating labels page.
BreakingConsolidated native and custom form elements. Checkboxes, radios, selects, and other inputs that had native and custom classes in v4 have been consolidated. Now nearly all our form elements are entirely custom, most without the need for custom HTML.
@@ -1250,25 +638,25 @@
Rearranged source Sass files under scss/forms/, including input group styles.
-
-
Components
+
+
Components
Unified padding values for alerts, breadcrumbs, cards, dropdowns, list groups, modals, popovers, and tooltips to be based on our $spacer variable. See #30564.
Removed custom styles for <hr>s in each alert since they already use currentColor.
-
Badges
+
Badges
Breaking Dropped all .badge-* color classes for background utilities (e.g., use .bg-primary instead of .badge-primary).
@@ -1283,7 +671,7 @@
Increased default padding for badges from .25em/.5em to .35em/.65em.
-
Breadcrumbs
+
Breadcrumbs
Simplified the default appearance of breadcrumbs by removing padding, background-color, and border-radius.
@@ -1292,13 +680,13 @@
Added new CSS custom property --bs-breadcrumb-divider for easy customization without needing to recompile CSS.
-
Buttons
+
Buttons
-
BreakingToggle buttons, with checkboxes or radios, no longer require JavaScript and have new markup. We no longer require a wrapping element, add .btn-check to the <input>, and pair it with any .btn classes on the <label>. See #30650. The docs for this has moved from our Buttons page to the new Forms section.
+
BreakingToggle buttons, with checkboxes or radios, no longer require JavaScript and have new markup. We no longer require a wrapping element, add .btn-check to the <input>, and pair it with any .btn classes on the <label>. See #30650. The docs for this has moved from our Buttons page to the new Forms section.
-
BreakingDropped .btn-block for utilities. Instead of using .btn-block on the .btn, wrap your buttons with .d-grid and a .gap-* utility to space them as needed. Switch to responsive classes for even more control over them. Read the docs for some examples.
+
BreakingDropped .btn-block for utilities. Instead of using .btn-block on the .btn, wrap your buttons with .d-grid and a .gap-* utility to space them as needed. Switch to responsive classes for even more control over them. Read the docs for some examples.
Updated our button-variant() and button-outline-variant() mixins to support additional parameters.
@@ -1310,7 +698,7 @@
Disabled buttons now have pointer-events: none;.
-
Card
+
Card
Breaking Dropped .card-deck in favor of our grid. Wrap your cards in column classes and add a parent .row-cols-* container to recreate card decks (but with more control over responsive alignment).
@@ -1319,19 +707,19 @@
Breaking Dropped .card-columns in favor of Masonry. See #28922.
Added new .carousel-dark variant for dark text, controls, and indicators (great for lighter backgrounds).
+
Added new .carousel-dark variant for dark text, controls, and indicators (great for lighter backgrounds).
Replaced chevron icons for carousel controls with new SVGs from Bootstrap Icons.
-
Close button
+
Close button
Breaking Renamed .close to .btn-close for a less generic name.
@@ -1343,11 +731,11 @@
Added new .btn-close-white variant that uses filter: invert(1) to enable higher contrast dismiss icons against darker backgrounds.
-
Collapse
+
Collapse
Removed scroll anchoring for accordions.
-
Dropdowns
+
Dropdowns
Added new .dropdown-menu-dark variant and associated variables for on-demand dark dropdowns.
@@ -1362,40 +750,40 @@
Breaking All the events for the dropdown are now triggered on the dropdown toggle button and then bubbled up to the parent element.
-
Dropdown menus now have a data-bs-popper="static" attribute set when the positioning of the dropdown is static, or dropdown is in the navbar. This is added by our JavaScript and helps us use custom position styles without interfering with Popper’s positioning.
+
Dropdown menus now have a data-bs-popper="static" attribute set when the positioning of the dropdown is static, or dropdown is in the navbar. This is added by our JavaScript and helps us use custom position styles without interfering with Popper’s positioning.
Breaking Dropped flip option for dropdown plugin in favor of native Popper configuration. You can now disable the flipping behavior by passing an empty array for fallbackPlacements option in flip modifier.
-
Dropdown menus can now be clickable with a new autoClose option to handle the auto close behavior. You can use this option to accept the click inside or outside the dropdown menu to make it interactive.
+
Dropdown menus can now be clickable with a new autoClose option to handle the auto close behavior. You can use this option to accept the click inside or outside the dropdown menu to make it interactive.
Dropdowns now support .dropdown-items wrapped in <li>s.
Breaking Renamed .text-monospace to .font-monospace.
-
Breaking Removed .text-hide as it’s an antiquated method for hiding text that shouldn’t be used anymore.
+
Breaking Removed .text-hide as it’s an antiquated method for hiding text that shouldn’t be used anymore.
-
Added .fs-* utilities for font-size utilities (with RFS enabled). These use the same scale as HTML’s default headings (1-6, large to small), and can be modified via Sass map.
+
Added .fs-* utilities for font-size utilities (with RFS enabled). These use the same scale as HTML’s default headings (1-6, large to small), and can be modified via Sass map.
Breaking Renamed .font-weight-* utilities as .fw-* for brevity and consistency.
@@ -1496,7 +884,7 @@
Breaking Removed .rounded-sm and rounded-lg, and introduced a new scale of classes, .rounded-0 to .rounded-3. See #31687.
-
Added new line-height utilities: .lh-1, .lh-sm, .lh-base and .lh-lg. See here.
+
Added new line-height utilities: .lh-1, .lh-sm, .lh-base and .lh-lg. See here.
Moved the .d-none utility in our CSS to give it more weight over other display utilities.
@@ -1505,19 +893,19 @@
Extended the .visually-hidden-focusable helper to also work on containers, using :focus-within.
-
Helpers
+
Helpers
-
BreakingResponsive embed helpers have been renamed to ratio helpers with new class names and improved behaviors, as well as a helpful CSS variable.
+
BreakingResponsive embed helpers have been renamed to ratio helpers with new class names and improved behaviors, as well as a helpful CSS variable.
Classes have been renamed to change by to x in the aspect ratio. For example, .ratio-16by9 is now .ratio-16x9.
-
We’ve dropped the .embed-responsive-item and element group selector in favor of a simpler .ratio > * selector. No more class is needed, and the ratio helper now works with any HTML element.
+
We’ve dropped the .embed-responsive-item and element group selector in favor of a simpler .ratio > * selector. No more class is needed, and the ratio helper now works with any HTML element.
The $embed-responsive-aspect-ratios Sass map has been renamed to $aspect-ratios and its values have been simplified to include the class name and the percentage as the key: value pair.
-
CSS variables are now generated and included for each value in the Sass map. Modify the --bs-aspect-ratio variable on the .ratio to create any custom aspect ratio.
+
CSS variables are now generated and included for each value in the Sass map. Modify the --bs-aspect-ratio variable on the .ratio to create any custom aspect ratio.
Changed the Sass file from scss/helpers/_screenreaders.scss to scss/helpers/_visually-hidden.scss
Renamed .sr-only and .sr-only-focusable to .visually-hidden and .visually-hidden-focusable
@@ -1525,10 +913,10 @@
-
bootstrap-utilities.css now also includes our helpers. Helpers don’t need to be imported in custom builds anymore.
+
bootstrap-utilities.css now also includes our helpers. Helpers don’t need to be imported in custom builds anymore.
-
JavaScript
+
JavaScript
Dropped jQuery dependency and rewrote plugins to be in regular JavaScript.
@@ -1538,14 +926,15 @@
All plugins can now accept a CSS selector as the first argument. You can either pass a DOM element or any valid CSS selector to create a new instance of the plugin:
popperConfig can be passed as a function that accepts the Bootstrap’s default Popper config as an argument, so that you can merge this default configuration in your way. Applies to dropdowns, popovers, and tooltips.
The default value for the fallbackPlacements is changed to ['top', 'right', 'bottom', 'left'] for better placement of Popper elements. Applies to dropdowns, popovers, and tooltips.
+
popperConfig can be passed as a function that accepts the Bootstrap’s default Popper config as an argument, so that you can merge this default configuration in your way. Applies to dropdowns, popovers, and tooltips.
+
+
+
The default value for the fallbackPlacements is changed to ['top', 'right', 'bottom', 'left'] for better placement of Popper elements. Applies to dropdowns, popovers, and tooltips.
Removed underscore from public static methods like _getInstance() → getInstance().
@@ -1553,81 +942,8 @@
Removed util.js, with its functionality now integrated into individual plugins. If you previously included util.js manually, you can safely remove it, as it is no longer needed. Each plugin now contains only the utilities it requires, enhancing modularity and reducing dependencies.
Bootstrap utilities are generated with our utility API and can be used to modify or extend our default set of utility classes via Sass. Our utility API is based on a series of Sass maps and functions for generating families of classes with various options. If you’re unfamiliar with Sass maps, read up on the official Sass docs to get started.
Bootstrap utilities are generated with our utility API and can be used to modify or extend our default set of utility classes via Sass. Our utility API is based on a series of Sass maps and functions for generating families of classes with various options. If you’re unfamiliar with Sass maps, read up on the official Sass docs to get started.
The $utilities map contains all our utilities and is later merged with your custom $utilities map, if present. The utility map contains a keyed list of utility groups which accept the following options:
List of values, or a map if you don’t want the class name to be the same as the value. If null is used as map key, class is not prepended to the class name.
Name of the generated class. If not provided and property is an array of strings, class will default to the first element of the property array. If not provided and property is a string, the values keys are used for the class names.
List of values, or a map if you don’t want the class name to be the same as the value. If null is used as map key, class is not prepended to the class name.
Name of the generated class. If not provided and property is an array of strings, class will default to the first element of the property array. If not provided and property is a string, the values keys are used for the class names.
The required property key must be set for any utility, and it must contain a valid CSS property. This property is used in the generated utility’s ruleset. When the class key is omitted, it also serves as the default class name. Consider the text-decoration utility:
The required property key must be set for any utility, and it must contain a valid CSS property. This property is used in the generated utility’s ruleset. When the class key is omitted, it also serves as the default class name. Consider the text-decoration utility:
Use the values key to specify which values for the specified property should be used in the generated class names and rules. Can be a list or map (set in the utilities or in a Sass variable).
Set the css-var boolean option to true and the API will generate local CSS variables for the given selector instead of the usual property: value rules. Add an optional css-variable-name to set a different CSS variable name than the class name.
-
Consider our .text-opacity-* utilities. If we add the css-variable-name option, we’ll get a custom output.
Use the local-vars option to specify a Sass map that will generate local CSS variables within the utility class’s ruleset. Please note that it may require additional work to consume those local CSS variables in the generated CSS rules. For example, consider our .bg-* utilities:
Use the state option to generate pseudo-class variations. Example pseudo-classes are :hover and :focus. When a list of states are provided, classnames are created for that pseudo-class. For example, to change opacity on hover, add state: hover and you’ll get .opacity-hover:hover in your compiled CSS.
+
Consider our .text-opacity-* utilities. If we add the css-variable-name option, we'll get a custom output.
Use the local-vars option to specify a Sass map that will generate local CSS variables within the utility class’s ruleset. Please note that it may require additional work to consume those local CSS variables in the generated CSS rules. For example, consider our .bg-* utilities:
Use the state option to generate pseudo-class variations. Example pseudo-classes are :hover and :focus. When a list of states are provided, classnames are created for that pseudo-class. For example, to change opacity on hover, add state: hover and you’ll get .opacity-hover:hover in your compiled CSS.
Need multiple pseudo-classes? Use a space-separated list of states: state: hover focus.
All utilities generated by the API include !important to ensure they override components and modifier classes as intended. You can toggle this setting globally with the $enable-important-utilities variable (defaults to true).
-
Using the API
-
Now that you’re familiar with how the utilities API works, learn how to add your own custom classes and modify our default utilities.
-
Override utilities
+
Using the API
+
Now that you’re familiar with how the utilities API works, learn how to add your own custom classes and modify our default utilities.
+
Override utilities
Override existing utilities by using the same key. For example, if you want additional responsive overflow utility classes, you can do this:
New utilities can be added to the default $utilities map with a map-merge. Make sure our required Sass files and _utilities.scss are imported first, then use the map-merge to add your additional utilities. For example, here’s how to add a responsive cursor utility with three values.
Modify existing utilities in the default $utilities map with map-get and map-merge functions. In the example below, we’re adding an additional value to the width utilities. Start with an initial map-merge and then specify which utility you want to modify. From there, fetch the nested "width" map with map-get to access and modify the utility’s options and values.
New utilities can be added to the default $utilities map with a map-merge. Make sure our required Sass files and _utilities.scss are imported first, then use the map-merge to add your additional utilities. For example, here’s how to add a responsive cursor utility with three values.
Modify existing utilities in the default $utilities map with map-get and map-merge functions. In the example below, we’re adding an additional value to the width utilities. Start with an initial map-merge and then specify which utility you want to modify. From there, fetch the nested "width" map with map-get to access and modify the utility’s options and values.
You can enable responsive classes for an existing set of utilities that are not currently responsive by default. For example, to make the border classes responsive:
Missing v4 utilities, or used to another naming convention? The utilities API can be used to override the resulting class of a given utility—for example, to rename .ms-* utilities to oldish .ml-*:
You can add, remove, and modify many utilities all at once with the map-merge() Sass function. Here’s how you can combine the previous examples into one larger map.
You can add, remove, and modify many utilities all at once with the map-merge() Sass function. Here’s how you can combine the previous examples into one larger map.
Some edge cases make RTL styling difficult, such as line breaks in Arabic. Thus utilities can be dropped from RTL output by setting the rtl option to false:
-Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
-
-
-
Background color
-
Similar to the contextual text color classes, set the background of an element to any contextual class. Background utilities do not set color, so in some cases you’ll want to use .text-*color utilities.
-
-Background utilities like .bg-* that generated from our original $theme-colors Sass map don’t yet respond to color modes, however, any .bg-*-subtle utility will. This will be resolved in v6.
-
Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
+
Background color
+
Similar to the contextual text color classes, set the background of an element to any contextual class. Background utilities do not set color, so in some cases you’ll want to use .text-*color utilities.
+
Background utilities like .bg-* that generated from our original $theme-colors Sass map don’t yet respond to color modes, however, any .bg-*-subtle utility will. This will be resolved in v6.
+
.bg-primary
.bg-primary-subtle
.bg-secondary
.bg-secondary-subtle
@@ -604,517 +46,270 @@ Background utilities like .bg-* that generated from our original .bg-body
By adding a .bg-gradient class, a linear gradient is added as background image to the backgrounds. This gradient starts with a semi-transparent white which fades out to the bottom.
Do you need a gradient in your custom CSS? Just add background-image: var(--bs-gradient);.
-
.bg-primary.bg-gradient
-
.bg-secondary.bg-gradient
-
.bg-success.bg-gradient
-
.bg-danger.bg-gradient
-
.bg-warning.bg-gradient
-
.bg-info.bg-gradient
-
.bg-light.bg-gradient
-
.bg-dark.bg-gradient
+
.bg-primary.bg-gradient
.bg-secondary.bg-gradient
.bg-success.bg-gradient
.bg-danger.bg-gradient
.bg-warning.bg-gradient
.bg-info.bg-gradient
.bg-light.bg-gradient
.bg-dark.bg-gradient
.bg-black.bg-gradient
-
-
Opacity
+
Opacity
Added in v5.1.0
-
As of v5.1.0, background-color utilities are generated with Sass using CSS variables. This allows for real-time color changes without compilation and dynamic alpha transparency changes.
We use an RGB version of our --bs-success (with the value of 25, 135, 84) CSS variable and attached a second CSS variable, --bs-bg-opacity, for the alpha transparency (with a default value 1 thanks to a local CSS variable). That means anytime you use .bg-success now, your computed color value is rgba(25, 135, 84, 1). The local CSS variable inside each .bg-* class avoids inheritance issues so nested instances of the utilities don’t automatically have a modified alpha transparency.
We use an RGB version of our --bs-success (with the value of 25, 135, 84) CSS variable and attached a second CSS variable, --bs-bg-opacity, for the alpha transparency (with a default value 1 thanks to a local CSS variable). That means anytime you use .bg-success now, your computed color value is rgba(25, 135, 84, 1). The local CSS variable inside each .bg-* class avoids inheritance issues so nested instances of the utilities don’t automatically have a modified alpha transparency.
+
Example
To change that opacity, override --bs-bg-opacity via custom styles or inline styles.
-
-
-
-
This is default success background
-
This is 50% opacity success background
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="bg-success p-2 text-white">This is default success background</div>
-<divclass="bg-success p-2"style="--bs-bg-opacity: .5;">This is 50% opacity success background</div>
-
-
+
This is default success background
+
This is 50% opacity success background
html
<divclass="bg-success p-2 text-white">This is default success background</div>
+<divclass="bg-success p-2"style="--bs-bg-opacity: .5;">This is 50% opacity success background</div>
Or, choose from any of the .bg-opacity utilities:
-
-
-
-
This is default success background
+
This is default success background
This is 75% opacity success background
This is 50% opacity success background
This is 25% opacity success background
-
This is 10% opacity success background
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="bg-success p-2 text-white">This is default success background</div>
-<divclass="bg-success p-2 text-white bg-opacity-75">This is 75% opacity success background</div>
-<divclass="bg-success p-2 text-dark bg-opacity-50">This is 50% opacity success background</div>
-<divclass="bg-success p-2 text-dark bg-opacity-25">This is 25% opacity success background</div>
-<divclass="bg-success p-2 text-dark bg-opacity-10">This is 10% opacity success background</div>
-
-
-
CSS
-
In addition to the following Sass functionality, consider reading about our included CSS custom properties (aka CSS variables) for colors and more.
-
Sass variables
+
This is 10% opacity success background
html
<divclass="bg-success p-2 text-white">This is default success background</div>
+<divclass="bg-success p-2 text-white bg-opacity-75">This is 75% opacity success background</div>
+<divclass="bg-success p-2 text-dark bg-opacity-50">This is 50% opacity success background</div>
+<divclass="bg-success p-2 text-dark bg-opacity-25">This is 25% opacity success background</div>
+<divclass="bg-success p-2 text-dark bg-opacity-10">This is 10% opacity success background</div>
+
CSS
+
In addition to the following Sass functionality, consider reading about our included CSS custom properties (aka CSS variables) for colors and more.
+
Sass variables
Most background-color utilities are generated by our theme colors, reassigned from our generic color palette variables.
No mixins are used to generate our background utilities, but we do have some additional mixins for other situations where you’d like to create your own gradients.
// Horizontal gradient, from left to right
-//
-// Creates two color stops, start and end, by specifying a color and position for each color stop.
-@mixin gradient-x($start-color:$gray-700,$end-color:$gray-800,$start-percent:0%,$end-percent:100%){
-background-image:linear-gradient(toright,$start-color$start-percent,$end-color$end-percent);
-}
-
-// Vertical gradient, from top to bottom
-//
-// Creates two color stops, start and end, by specifying a color and position for each color stop.
-@mixin gradient-y($start-color:$gray-700,$end-color:$gray-800,$start-percent:null,$end-percent:null){
-background-image:linear-gradient(tobottom,$start-color$start-percent,$end-color$end-percent);
-}
-
-@mixin gradient-directional($start-color:$gray-700,$end-color:$gray-800,$deg:45deg){
-background-image:linear-gradient($deg,$start-color,$end-color);
-}
-
-@mixin gradient-x-three-colors($start-color:$blue,$mid-color:$purple,$color-stop:50%,$end-color:$red){
-background-image:linear-gradient(toright,$start-color,$mid-color$color-stop,$end-color);
-}
-
-@mixin gradient-y-three-colors($start-color:$blue,$mid-color:$purple,$color-stop:50%,$end-color:$red){
-background-image:linear-gradient($start-color,$mid-color$color-stop,$end-color);
-}
-
-@mixin gradient-radial($inner-color:$gray-700,$outer-color:$gray-800){
-background-image:radial-gradient(circle,$inner-color,$outer-color);
-}
-
-@mixin gradient-striped($color:rgba($white,.15),$angle:45deg){
-background-image:linear-gradient($angle,$color25%,transparent25%,transparent50%,$color50%,$color75%,transparent75%,transparent);
-}
-
No mixins are used to generate our background utilities, but we do have some additional mixins for other situations where you’d like to create your own gradients.
// Horizontal gradient, from left to right
+//
+// Creates two color stops, start and end, by specifying a color and position for each color stop.
+@mixingradient-x($start-color:$gray-700,$end-color:$gray-800,$start-percent: 0%,$end-percent: 100%){
+ background-image:linear-gradient(to right,$start-color$start-percent,$end-color$end-percent);
+}
+// Vertical gradient, from top to bottom
+//
+// Creates two color stops, start and end, by specifying a color and position for each color stop.
+@mixingradient-y($start-color:$gray-700,$end-color:$gray-800,$start-percent:null,$end-percent:null){
+ background-image:linear-gradient(to bottom,$start-color$start-percent,$end-color$end-percent);
+}
-
+@mixingradient-directional($start-color:$gray-700,$end-color:$gray-800,$deg: 45deg){
+ background-image:linear-gradient($deg,$start-color,$end-color);
+}
-
+@mixingradient-x-three-colors($start-color:$blue,$mid-color:$purple,$color-stop: 50%,$end-color:$red){
+ background-image:linear-gradient(to right,$start-color,$mid-color$color-stop,$end-color);
+}
-
-
-
+@mixingradient-y-three-colors($start-color:$blue,$mid-color:$purple,$color-stop: 50%,$end-color:$red){
+ background-image:linear-gradient($start-color,$mid-color$color-stop,$end-color);
+}
-
-
+@mixingradient-radial($inner-color:$gray-700,$outer-color:$gray-800){
+ background-image:radial-gradient(circle,$inner-color,$outer-color);
+}
-
-
+@mixingradient-striped($color:rgba($white, .15),$angle: 45deg){
+ background-image:linear-gradient($angle,$color 25%, transparent 25%, transparent 50%,$color 50%,$color 75%, transparent 75%, transparent);
+}
+
-Border utilities like .border-* that generated from our original $theme-colors Sass map don’t yet respond to color modes, however, any .border-*-subtle utility will. This will be resolved in v6.
-
Border utilities like .border-* that generated from our original $theme-colors Sass map don’t yet respond to color modes, however, any .border-*-subtle utility will. This will be resolved in v6.
Change the border color using utilities built on our theme colors.
-
-
-
-
-
+
@@ -666,43 +65,26 @@ Border utilities like .border-* that generated from our original
-
-
-
+<divclass="p-3 bg-info bg-opacity-10 border border-info border-start-0 rounded-end">
+ Changing border color and width
+</div>
+
Opacity
Added in v5.2.0
-
Bootstrap border-{color} utilities are generated with Sass using CSS variables. This allows for real-time color changes without compilation and dynamic alpha transparency changes.
We use an RGB version of our --bs-success (with the value of 25, 135, 84) CSS variable and attached a second CSS variable, --bs-border-opacity, for the alpha transparency (with a default value 1 thanks to a local CSS variable). That means anytime you use .border-success now, your computed color value is rgba(25, 135, 84, 1). The local CSS variable inside each .border-* class avoids inheritance issues so nested instances of the utilities don’t automatically have a modified alpha transparency.
We use an RGB version of our --bs-success (with the value of 25, 135, 84) CSS variable and attached a second CSS variable, --bs-border-opacity, for the alpha transparency (with a default value 1 thanks to a local CSS variable). That means anytime you use .border-success now, your computed color value is rgba(25, 135, 84, 1). The local CSS variable inside each .border-* class avoids inheritance issues so nested instances of the utilities don’t automatically have a modified alpha transparency.
+
Example
To change that opacity, override --bs-border-opacity via custom styles or inline styles.
-
-
-
-
This is default success border
-
This is 50% opacity success border
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="border border-success p-2 mb-2">This is default success border</div>
-<divclass="border border-success p-2"style="--bs-border-opacity: .5;">This is 50% opacity success border</div>
-
-
+
This is default success border
+
This is 50% opacity success border
html
<divclass="border border-success p-2 mb-2">This is default success border</div>
+<divclass="border border-success p-2"style="--bs-border-opacity: .5;">This is 50% opacity success border</div>
Or, choose from any of the .border-opacity utilities:
-
-
-
-
This is default success border
+
This is default success border
This is 75% opacity success border
This is 50% opacity success border
This is 25% opacity success border
-
This is 10% opacity success border
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="border border-success p-2 mb-2">This is default success border</div>
-<divclass="border border-success p-2 mb-2 border-opacity-75">This is 75% opacity success border</div>
-<divclass="border border-success p-2 mb-2 border-opacity-50">This is 50% opacity success border</div>
-<divclass="border border-success p-2 mb-2 border-opacity-25">This is 25% opacity success border</div>
-<divclass="border border-success p-2 border-opacity-10">This is 10% opacity success border</div>
-
-
-
Width
-
-
-
-
+
This is 10% opacity success border
html
<divclass="border border-success p-2 mb-2">This is default success border</div>
+<divclass="border border-success p-2 mb-2 border-opacity-75">This is 75% opacity success border</div>
+<divclass="border border-success p-2 mb-2 border-opacity-50">This is 50% opacity success border</div>
+<divclass="border border-success p-2 mb-2 border-opacity-25">This is 25% opacity success border</div>
+<divclass="border border-success p-2 border-opacity-10">This is 10% opacity success border</div>
Example rounded image75x75
+Example top rounded image75x75
+Example right rounded image75x75
+Example bottom rounded image75x75
+Example left rounded image75x75
Use the scaling classes for larger or smaller rounded corners. Sizes range from 0 to 5 including circle and pill, and can be configured by modifying the utilities API.
-
-
-
-Example non-rounded image75x75
-Example small rounded image75x75
-Example default rounded image75x75
-Example large rounded image75x75
-Example larger rounded image75x75
-Example extra large rounded image75x75
-Completely round image75x75
-Rounded pill image150x75
-
-
-
-Example small rounded image75x75
-Example default left rounded image75x75
-Example right completely round image75x75
-Example left rounded pill image75x75
-Example extra large bottom rounded image75x75
-
-
Example small rounded image75x75
+Example default left rounded image75x75
+Example right completely round image75x75
+Example left rounded pill image75x75
+Example extra large bottom rounded image75x75
-Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
-
-
-
Colors
-
Colorize text with color utilities. If you want to colorize links, you can use the .link-* helper classes which have :hover and :focus states.
-
-Color utilities like .text-* that generated from our original $theme-colors Sass map don’t yet respond to color modes, however, any .text-*-emphasis utility will. This will be resolved in v6.
-
Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
+
Colors
+
Colorize text with color utilities. If you want to colorize links, you can use the .link-* helper classes which have :hover and :focus states.
+
Color utilities like .text-* that generated from our original $theme-colors Sass map don’t yet respond to color modes, however, any .text-*-emphasis utility will. This will be resolved in v6.
+
.text-primary
.text-primary-emphasis
.text-secondary
.text-secondary-emphasis
@@ -607,468 +50,239 @@ Color utilities like .text-* that generated from our original .text-black
-Deprecation: With the addition of .text-opacity-* utilities and CSS variables for text utilities, .text-black-50 and .text-white-50 are deprecated as of v5.1.0. They’ll be removed in v6.0.0.
-
-
-
-Deprecation: With the addition of the expanded theme colors and variables, the .text-muted utility has been deprecated as of v5.3.0. Its default value has also been reassigned to the new --bs-secondary-color CSS variable to better support color modes. It will be removed in v6.0.0.
-
Deprecation: With the addition of .text-opacity-* utilities and CSS variables for text utilities, .text-black-50 and .text-white-50 are deprecated as of v5.1.0. They’ll be removed in v6.0.0.
+
Deprecation: With the addition of the expanded theme colors and variables, the .text-muted utility has been deprecated as of v5.3.0. Its default value has also been reassigned to the new --bs-secondary-color CSS variable to better support color modes. It will be removed in v6.0.0.
+
Opacity
Added in v5.1.0
-
As of v5.1.0, text color utilities are generated with Sass using CSS variables. This allows for real-time color changes without compilation and dynamic alpha transparency changes.
We use an RGB version of our --bs-primary (with the value of 13, 110, 253) CSS variable and attached a second CSS variable, --bs-text-opacity, for the alpha transparency (with a default value 1 thanks to a local CSS variable). That means anytime you use .text-primary now, your computed color value is rgba(13, 110, 253, 1). The local CSS variable inside each .text-* class avoids inheritance issues so nested instances of the utilities don’t automatically have a modified alpha transparency.
We use an RGB version of our --bs-primary (with the value of 13, 110, 253) CSS variable and attached a second CSS variable, --bs-text-opacity, for the alpha transparency (with a default value 1 thanks to a local CSS variable). That means anytime you use .text-primary now, your computed color value is rgba(13, 110, 253, 1). The local CSS variable inside each .text-* class avoids inheritance issues so nested instances of the utilities don’t automatically have a modified alpha transparency.
+
Example
To change that opacity, override --bs-text-opacity via custom styles or inline styles.
-
-
-
-
This is default primary text
-
This is 50% opacity primary text
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="text-primary">This is default primary text</div>
-<divclass="text-primary"style="--bs-text-opacity: .5;">This is 50% opacity primary text</div>
-
-
+
This is default primary text
+
This is 50% opacity primary text
html
<divclass="text-primary">This is default primary text</div>
+<divclass="text-primary"style="--bs-text-opacity: .5;">This is 50% opacity primary text</div>
Or, choose from any of the .text-opacity utilities:
-
-
-
-
This is default primary text
+
This is default primary text
This is 75% opacity primary text
This is 50% opacity primary text
-
This is 25% opacity primary text
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="text-primary">This is default primary text</div>
-<divclass="text-primary text-opacity-75">This is 75% opacity primary text</div>
-<divclass="text-primary text-opacity-50">This is 50% opacity primary text</div>
-<divclass="text-primary text-opacity-25">This is 25% opacity primary text</div>
-
-
-
Specificity
-
Sometimes contextual classes cannot be applied due to the specificity of another selector. In some cases, a sufficient workaround is to wrap your element’s content in a <div> or more semantic element with the desired class.
-
CSS
-
In addition to the following Sass functionality, consider reading about our included CSS custom properties (aka CSS variables) for colors and more.
-
Sass variables
+
This is 25% opacity primary text
html
<divclass="text-primary">This is default primary text</div>
+<divclass="text-primary text-opacity-75">This is 75% opacity primary text</div>
+<divclass="text-primary text-opacity-50">This is 50% opacity primary text</div>
+<divclass="text-primary text-opacity-25">This is 25% opacity primary text</div>
+
Specificity
+
Sometimes contextual classes cannot be applied due to the specificity of another selector. In some cases, a sufficient workaround is to wrap your element’s content in a <div> or more semantic element with the desired class.
+
CSS
+
In addition to the following Sass functionality, consider reading about our included CSS custom properties (aka CSS variables) for colors and more.
+
Sass variables
Most color utilities are generated by our theme colors, reassigned from our generic color palette variables.
Quickly and responsively toggle the display value of components and more with our display utilities. Includes support for some of the more common values, as well as some extras for controlling display when printing.
Quickly and responsively toggle the display value of components and more with our display utilities. Includes support for some of the more common values, as well as some extras for controlling display when printing.
Change the value of the display property with our responsive display utility classes. We purposely support only a subset of all possible values for display. Classes can be combined for various effects as you need.
-
Notation
-
Display utility classes that apply to all breakpoints, from xs to xxl, have no breakpoint abbreviation in them. This is because those classes are applied from min-width: 0; and up, and thus are not bound by a media query. The remaining breakpoints, however, do include a breakpoint abbreviation.
+
Notation
+
Display utility classes that apply to all breakpoints, from xs to xxl, have no breakpoint abbreviation in them. This is because those classes are applied from min-width: 0; and up, and thus are not bound by a media query. The remaining breakpoints, however, do include a breakpoint abbreviation.
As such, the classes are named using the format:
.d-{value} for xs
@@ -588,139 +46,87 @@
The display values can be altered by changing the display values defined in $utilities and recompiling the SCSS.
The media queries affect screen widths with the given breakpoint or larger. For example, .d-lg-none sets display: none; on lg, xl, and xxl screens.
For faster mobile-friendly development, use responsive display classes for showing and hiding elements by device. Avoid creating entirely different versions of the same site, instead hide elements responsively for each screen size.
To hide elements simply use the .d-none class or one of the .d-{sm,md,lg,xl,xxl}-none classes for any responsive screen variation.
To show an element only on a given interval of screen sizes you can combine one .d-*-none class with a .d-*-* class, for example .d-none .d-md-block .d-xl-none will hide the element for all screen sizes except on medium and large devices.
-
-
-
-
Screen size
-
Class
-
-
-
-
-
Hidden on all
-
.d-none
-
-
-
Hidden only on xs
-
.d-none .d-sm-block
-
-
-
Hidden only on sm
-
.d-sm-none .d-md-block
-
-
-
Hidden only on md
-
.d-md-none .d-lg-block
-
-
-
Hidden only on lg
-
.d-lg-none .d-xl-block
-
-
-
Hidden only on xl
-
.d-xl-none .d-xxl-block
-
-
-
Hidden only on xxl
-
.d-xxl-none
-
-
-
Visible on all
-
.d-block
-
-
-
Visible only on xs
-
.d-block .d-sm-none
-
-
-
Visible only on sm
-
.d-none .d-sm-block .d-md-none
-
-
-
Visible only on md
-
.d-none .d-md-block .d-lg-none
-
-
-
Visible only on lg
-
.d-none .d-lg-block .d-xl-none
-
-
-
Visible only on xl
-
.d-none .d-xl-block .d-xxl-none
-
-
-
Visible only on xxl
-
.d-none .d-xxl-block
-
-
-
+
-
-
-
-
hide on lg and wider screens
-
hide on screens smaller than lg
-
- html
-
-
-
-
-
-
-
-
-
<divclass="d-lg-none">hide on lg and wider screens</div>
-<divclass="d-none d-lg-block">hide on screens smaller than lg</div>
<divclass="d-lg-none">hide on lg and wider screens</div>
+<divclass="d-none d-lg-block">hide on screens smaller than lg</div>
+
Display in print
Change the display value of elements when printing with our print display utility classes. Includes support for the same display values as our responsive .d-* utilities.
.d-print-none
@@ -736,120 +142,23 @@
.d-print-inline-flex
The print and display classes can be combined.
-
-
-
-
Screen Only (Hide on print only)
+
Screen Only (Hide on print only)
Print Only (Hide on screen only)
-
Hide up to large on screen, but always show on print
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="d-print-none">Screen Only (Hide on print only)</div>
-<divclass="d-none d-print-block">Print Only (Hide on screen only)</div>
-<divclass="d-none d-lg-block d-print-block">Hide up to large on screen, but always show on print</div>
Hide up to large on screen, but always show on print
html
<divclass="d-print-none">Screen Only (Hide on print only)</div>
+<divclass="d-none d-print-block">Print Only (Hide on screen only)</div>
+<divclass="d-none d-lg-block d-print-block">Hide up to large on screen, but always show on print</div>
Quickly manage the layout, alignment, and sizing of grid columns, navigation, components, and more with a full suite of responsive flexbox utilities. For more complex implementations, custom CSS may be necessary.
Quickly manage the layout, alignment, and sizing of grid columns, navigation, components, and more with a full suite of responsive flexbox utilities. For more complex implementations, custom CSS may be necessary.
Apply display utilities to create a flexbox container and transform direct children elements into flex items. Flex containers and items are able to be modified further with additional flex properties.
-
-
-
-
I'm a flexbox container!
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="d-flex p-2">I'm a flexbox container!</div>
-
-
-
-
-
-
I'm an inline flexbox container!
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="d-inline-flex p-2">I'm an inline flexbox container!</div>
-
-
+
I'm a flexbox container!
html
<divclass="d-flex p-2">I'm a flexbox container!</div>
+
I'm an inline flexbox container!
html
<divclass="d-inline-flex p-2">I'm an inline flexbox container!</div>
Responsive variations also exist for .d-flex and .d-inline-flex.
-
-
.d-flex
-
.d-inline-flex
-
.d-sm-flex
-
.d-sm-inline-flex
-
.d-md-flex
-
.d-md-inline-flex
-
.d-lg-flex
-
.d-lg-inline-flex
-
.d-xl-flex
-
.d-xl-inline-flex
-
.d-xxl-flex
-
.d-xxl-inline-flex
-
-
-
Direction
+
.d-flex
.d-inline-flex
.d-sm-flex
.d-sm-inline-flex
.d-md-flex
.d-md-inline-flex
.d-lg-flex
.d-lg-inline-flex
.d-xl-flex
.d-xl-inline-flex
.d-xxl-flex
.d-xxl-inline-flex
+
Direction
Set the direction of flex items in a flex container with direction utilities. In most cases you can omit the horizontal class here as the browser default is row. However, you may encounter situations where you needed to explicitly set this value (like responsive layouts).
Use .flex-row to set a horizontal direction (the browser default), or .flex-row-reverse to start the horizontal direction from the opposite side.
Responsive variations also exist for flex-direction.
-
-
.flex-row
-
.flex-row-reverse
-
.flex-column
-
.flex-column-reverse
-
.flex-sm-row
-
.flex-sm-row-reverse
-
.flex-sm-column
-
.flex-sm-column-reverse
-
.flex-md-row
-
.flex-md-row-reverse
-
.flex-md-column
-
.flex-md-column-reverse
-
.flex-lg-row
-
.flex-lg-row-reverse
-
.flex-lg-column
-
.flex-lg-column-reverse
-
.flex-xl-row
-
.flex-xl-row-reverse
-
.flex-xl-column
-
.flex-xl-column-reverse
-
.flex-xxl-row
-
.flex-xxl-row-reverse
-
.flex-xxl-column
-
.flex-xxl-column-reverse
-
-
-
Justify content
+
.flex-row
.flex-row-reverse
.flex-column
.flex-column-reverse
.flex-sm-row
.flex-sm-row-reverse
.flex-sm-column
.flex-sm-column-reverse
.flex-md-row
.flex-md-row-reverse
.flex-md-column
.flex-md-column-reverse
.flex-lg-row
.flex-lg-row-reverse
.flex-lg-column
.flex-lg-column-reverse
.flex-xl-row
.flex-xl-row-reverse
.flex-xl-column
.flex-xl-column-reverse
.flex-xxl-row
.flex-xxl-row-reverse
.flex-xxl-column
.flex-xxl-column-reverse
+
Justify content
Use justify-content utilities on flexbox containers to change the alignment of flex items on the main axis (the x-axis to start, y-axis if flex-direction: column). Choose from start (browser default), end, center, between, around, or evenly.
Responsive variations also exist for justify-content.
+
.justify-content-start
.justify-content-end
.justify-content-center
.justify-content-between
.justify-content-around
.justify-content-evenly
.justify-content-sm-start
.justify-content-sm-end
.justify-content-sm-center
.justify-content-sm-between
.justify-content-sm-around
.justify-content-sm-evenly
.justify-content-md-start
.justify-content-md-end
.justify-content-md-center
.justify-content-md-between
.justify-content-md-around
.justify-content-md-evenly
.justify-content-lg-start
.justify-content-lg-end
.justify-content-lg-center
.justify-content-lg-between
.justify-content-lg-around
.justify-content-lg-evenly
.justify-content-xl-start
.justify-content-xl-end
.justify-content-xl-center
.justify-content-xl-between
.justify-content-xl-around
.justify-content-xl-evenly
.justify-content-xxl-start
.justify-content-xxl-end
.justify-content-xxl-center
.justify-content-xxl-between
.justify-content-xxl-around
.justify-content-xxl-evenly
+
Align items
Use align-items utilities on flexbox containers to change the alignment of flex items on the cross axis (the y-axis to start, x-axis if flex-direction: column). Choose from start, end, center, baseline, or stretch (browser default).
Use align-self utilities on flexbox items to individually change their alignment on the cross axis (the y-axis to start, x-axis if flex-direction: column). Choose from the same options as align-items: start, end, center, baseline, or stretch (browser default).
Use the .flex-fill class on a series of sibling elements to force them into widths equal to their content (or equal widths if their content does not surpass their border-boxes) while taking up all available horizontal space.
-
-
-
-
+
Flex item with a lot of content
Flex item
Flex item
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="d-flex">
-<divclass="p-2 flex-fill">Flex item with a lot of content</div>
-<divclass="p-2 flex-fill">Flex item</div>
-<divclass="p-2 flex-fill">Flex item</div>
-</div>
-
-
+
html
<divclass="d-flex">
+ <divclass="p-2 flex-fill">Flex item with a lot of content</div>
+ <divclass="p-2 flex-fill">Flex item</div>
+ <divclass="p-2 flex-fill">Flex item</div>
+</div>
Responsive variations also exist for flex-fill.
-
-
.flex-fill
-
.flex-sm-fill
-
.flex-md-fill
-
.flex-lg-fill
-
.flex-xl-fill
-
.flex-xxl-fill
-
-
-
Grow and shrink
-
Use .flex-grow-* utilities to toggle a flex item’s ability to grow to fill available space. In the example below, the .flex-grow-1 elements uses all available space it can, while allowing the remaining two flex items their necessary space.
-
-
-
-
+
.flex-fill
.flex-sm-fill
.flex-md-fill
.flex-lg-fill
.flex-xl-fill
.flex-xxl-fill
+
Grow and shrink
+
Use .flex-grow-* utilities to toggle a flex item’s ability to grow to fill available space. In the example below, the .flex-grow-1 elements uses all available space it can, while allowing the remaining two flex items their necessary space.
Use .flex-shrink-* utilities to toggle a flex item’s ability to shrink if necessary. In the example below, the second flex item with .flex-shrink-1 is forced to wrap its contents to a new line, “shrinking” to allow more space for the previous flex item with .w-100.
Use .flex-shrink-* utilities to toggle a flex item’s ability to shrink if necessary. In the example below, the second flex item with .flex-shrink-1 is forced to wrap its contents to a new line, “shrinking” to allow more space for the previous flex item with .w-100.
Responsive variations also exist for flex-grow and flex-shrink.
-
-
.flex-{grow|shrink}-0
-
.flex-{grow|shrink}-1
-
.flex-sm-{grow|shrink}-0
-
.flex-sm-{grow|shrink}-1
-
.flex-md-{grow|shrink}-0
-
.flex-md-{grow|shrink}-1
-
.flex-lg-{grow|shrink}-0
-
.flex-lg-{grow|shrink}-1
-
.flex-xl-{grow|shrink}-0
-
.flex-xl-{grow|shrink}-1
-
.flex-xxl-{grow|shrink}-0
-
.flex-xxl-{grow|shrink}-1
-
-
-
Auto margins
+
.flex-{grow|shrink}-0
.flex-{grow|shrink}-1
.flex-sm-{grow|shrink}-0
.flex-sm-{grow|shrink}-1
.flex-md-{grow|shrink}-0
.flex-md-{grow|shrink}-1
.flex-lg-{grow|shrink}-0
.flex-lg-{grow|shrink}-1
.flex-xl-{grow|shrink}-0
.flex-xl-{grow|shrink}-1
.flex-xxl-{grow|shrink}-0
.flex-xxl-{grow|shrink}-1
+
Auto margins
Flexbox can do some pretty awesome things when you mix flex alignments with auto margins. Shown below are three examples of controlling flex items via auto margins: default (no auto margin), pushing two items to the right (.me-auto), and pushing two items to the left (.ms-auto).
Vertically move one flex item to the top or bottom of a container by mixing align-items, flex-direction: column, and margin-top: auto or margin-bottom: auto.
Change how flex items wrap in a flex container. Choose from no wrapping at all (the browser default) with .flex-nowrap, wrapping with .flex-wrap, or reverse wrapping with .flex-wrap-reverse.
Change the visual order of specific flex items with a handful of order utilities. We only provide options for making an item first or last, as well as a reset to use the DOM order. As order takes any integer value from 0 to 5, add custom CSS for any additional values needed.
Additionally there are also responsive .order-first and .order-last classes that change the order of an element by applying order: -1 and order: 6, respectively.
-
-
.order-first
-
.order-last
-
.order-sm-first
-
.order-sm-last
-
.order-md-first
-
.order-md-last
-
.order-lg-first
-
.order-lg-last
-
.order-xl-first
-
.order-xl-last
-
.order-xxl-first
-
.order-xxl-last
-
-
-
Align content
-
Use align-content utilities on flexbox containers to align flex items together on the cross axis. Choose from start (browser default), end, center, between, around, or stretch. To demonstrate these utilities, we’ve enforced flex-wrap: wrap and increased the number of flex items.
+
.order-first
.order-last
.order-sm-first
.order-sm-last
.order-md-first
.order-md-last
.order-lg-first
.order-lg-last
.order-xl-first
.order-xl-last
.order-xxl-first
.order-xxl-last
+
Align content
+
Use align-content utilities on flexbox containers to align flex items together on the cross axis. Choose from start (browser default), end, center, between, around, or stretch. To demonstrate these utilities, we’ve enforced flex-wrap: wrap and increased the number of flex items.
Heads up! This property has no effect on single rows of flex items.
Responsive variations also exist for align-content.
+
.align-content-start
.align-content-end
.align-content-center
.align-content-between
.align-content-around
.align-content-stretch
.align-content-sm-start
.align-content-sm-end
.align-content-sm-center
.align-content-sm-between
.align-content-sm-around
.align-content-sm-stretch
.align-content-md-start
.align-content-md-end
.align-content-md-center
.align-content-md-between
.align-content-md-around
.align-content-md-stretch
.align-content-lg-start
.align-content-lg-end
.align-content-lg-center
.align-content-lg-between
.align-content-lg-around
.align-content-lg-stretch
.align-content-xl-start
.align-content-xl-end
.align-content-xl-center
.align-content-xl-between
.align-content-xl-around
.align-content-xl-stretch
.align-content-xxl-start
.align-content-xxl-end
.align-content-xxl-center
.align-content-xxl-between
.align-content-xxl-around
.align-content-xxl-stretch
+
Media object
Looking to replicate the media object component from Bootstrap 4? Recreate it in no time with a few flex utilities that allow even more flexibility and customization than before.
-
-
-
-
+
- PlaceholderImage
+ PlaceholderImage
This is some content from a media component. You can replace this with any content and adjust it as needed.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="d-flex">
-<divclass="flex-shrink-0">
-<imgsrc="..."alt="...">
-</div>
-<divclass="flex-grow-1 ms-3">
- This is some content from a media component. You can replace this with any content and adjust it as needed.
-</div>
-</div>
-
-
+
html
<divclass="d-flex">
+ <divclass="flex-shrink-0">
+ <imgsrc="..."alt="...">
+ </div>
+ <divclass="flex-grow-1 ms-3">
+ This is some content from a media component. You can replace this with any content and adjust it as needed.
+ </div>
+</div>
And say you want to vertically center the content next to the image:
-
-
-
-
+
- PlaceholderImage
+ PlaceholderImage
This is some content from a media component. You can replace this with any content and adjust it as needed.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="d-flex align-items-center">
-<divclass="flex-shrink-0">
-<imgsrc="..."alt="...">
-</div>
-<divclass="flex-grow-1 ms-3">
- This is some content from a media component. You can replace this with any content and adjust it as needed.
-</div>
-</div>
<divclass="d-flex align-items-center">
+ <divclass="flex-shrink-0">
+ <imgsrc="..."alt="...">
+ </div>
+ <divclass="flex-grow-1 ms-3">
+ This is some content from a media component. You can replace this with any content and adjust it as needed.
+ </div>
+</div>
These utility classes float an element to the left or right, or disable floating, based on the current viewport size using the CSS float property. !important is included to avoid specificity issues. These use the same viewport breakpoints as our grid system. Please be aware float utilities have no effect on flex items.
-
-
-
-
Float start on all viewport sizes
+
Float start on all viewport sizes
Float end on all viewport sizes
-
Don't float on all viewport sizes
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="float-start">Float start on all viewport sizes</div><br>
-<divclass="float-end">Float end on all viewport sizes</div><br>
-<divclass="float-none">Don't float on all viewport sizes</div>
-
-
-
Use the clearfix helper on a parent element to clear floats.
-
Responsive
+
Don’t float on all viewport sizes
html
<divclass="float-start">Float start on all viewport sizes</div><br>
+<divclass="float-end">Float end on all viewport sizes</div><br>
+<divclass="float-none">Don’t float on all viewport sizes</div>
+
Use the clearfix helper on a parent element to clear floats.
+
Responsive
Responsive variations also exist for each float value.
-
-
-
-
Float end on viewports sized SM (small) or wider
+
Float end on viewports sized SM (small) or wider
Float end on viewports sized MD (medium) or wider
Float end on viewports sized LG (large) or wider
Float end on viewports sized XL (extra large) or wider
-
Float end on viewports sized XXL (extra extra large) or wider
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="float-sm-end">Float end on viewports sized SM (small) or wider</div><br>
-<divclass="float-md-end">Float end on viewports sized MD (medium) or wider</div><br>
-<divclass="float-lg-end">Float end on viewports sized LG (large) or wider</div><br>
-<divclass="float-xl-end">Float end on viewports sized XL (extra large) or wider</div><br>
-<divclass="float-xxl-end">Float end on viewports sized XXL (extra extra large) or wider</div><br>
-
-
+
Float end on viewports sized XXL (extra extra large) or wider
html
<divclass="float-sm-end">Float end on viewports sized SM (small) or wider</div><br>
+<divclass="float-md-end">Float end on viewports sized MD (medium) or wider</div><br>
+<divclass="float-lg-end">Float end on viewports sized LG (large) or wider</div><br>
+<divclass="float-xl-end">Float end on viewports sized XL (extra large) or wider</div><br>
+<divclass="float-xxl-end">Float end on viewports sized XXL (extra extra large) or wider</div><br>
Utility classes that change how users interact with contents of a website.
+
Text selection
Change the way in which the content is selected when the user interacts with it.
-
-
-
-
This paragraph will be entirely selected when clicked by the user.
+
This paragraph will be entirely selected when clicked by the user.
This paragraph has default select behavior.
-
This paragraph will not be selectable when clicked by the user.
-
-
- html
-
-
-
-
-
-
-
-
-
<pclass="user-select-all">This paragraph will be entirely selected when clicked by the user.</p>
-<pclass="user-select-auto">This paragraph has default select behavior.</p>
-<pclass="user-select-none">This paragraph will not be selectable when clicked by the user.</p>
-
-
-
Pointer events
+
This paragraph will not be selectable when clicked by the user.
html
<pclass="user-select-all">This paragraph will be entirely selected when clicked by the user.</p>
+<pclass="user-select-auto">This paragraph has default select behavior.</p>
+<pclass="user-select-none">This paragraph will not be selectable when clicked by the user.</p>
+
Pointer events
Bootstrap provides .pe-none and .pe-auto classes to prevent or add element interactions.
This link can be clicked (this is default behavior).
-
This link can not be clicked because the pointer-events property is inherited from its parent. However, this link has a pe-auto class and can be clicked.
-
-
- html
-
-
-
-
-
-
-
-
-
<p><ahref="#"class="pe-none"tabindex="-1"aria-disabled="true">This link</a> can not be clicked.</p>
-<p><ahref="#"class="pe-auto">This link</a> can be clicked (this is default behavior).</p>
-<pclass="pe-none"><ahref="#"tabindex="-1"aria-disabled="true">This link</a> can not be clicked because the <code>pointer-events</code> property is inherited from its parent. However, <ahref="#"class="pe-auto">this link</a> has a <code>pe-auto</code> class and can be clicked.</p>
-
-
+
This link can not be clicked because the pointer-events property is inherited from its parent. However, this link has a pe-auto class and can be clicked.
html
<p><ahref="#"class="pe-none"tabindex="-1"aria-disabled="true">This link</a> can not be clicked.</p>
+<p><ahref="#"class="pe-auto">This link</a> can be clicked (this is default behavior).</p>
+<pclass="pe-none"><ahref="#"tabindex="-1"aria-disabled="true">This link</a> can not be clicked because the <code>pointer-events</code> property is inherited from its parent. However, <ahref="#"class="pe-auto">this link</a> has a <code>pe-auto</code> class and can be clicked.</p>
The .pe-none class (and the pointer-events CSS property it sets) only prevents interactions with a pointer (mouse, stylus, touch). Links and controls with .pe-none are, by default, still focusable and actionable for keyboard users. To ensure that they are completely neutralized even for keyboard users, you may need to add further attributes such as tabindex="-1" (to prevent them from receiving keyboard focus) and aria-disabled="true" (to convey the fact they are effectively disabled to assistive technologies), and possibly use JavaScript to completely prevent them from being actionable.
If possible, the simpler solution is:
For form controls, add the disabled HTML attribute.
For links, remove the href attribute, making it a non-interactive anchor or placeholder link.
Change the alpha opacity of the link rgba() color value with utilities. Please be aware that changes to a color’s opacity can lead to links with insufficient contrast.
Change the alpha opacity of the link rgba() color value with utilities. Please be aware that changes to a color’s opacity can lead to links with insufficient contrast.
Just like the .link-opacity-*-hover utilities, .link-offset and .link-underline-opacity utilities include :hover variants by default. Mix and match to create unique link styles.
Colored link helpers have been updated to pair with our link utilities. Use the new utilities to modify the link opacity, underline opacity, and underline offset.
-Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
-
-
-
CSS
-
In addition to the following Sass functionality, consider reading about our included CSS custom properties (aka CSS variables) for colors and more.
Accessibility tip: Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies like screen readers. Please ensure the meaning is obvious from the content itself (e.g., the visible text with a sufficient color contrast) or is included through alternative means, such as additional text hidden with the .visually-hidden class.
+
CSS
+
In addition to the following Sass functionality, consider reading about our included CSS custom properties (aka CSS variables) for colors and more.
Change the value of the object-fit property with our responsive object-fit utility classes. This property tells the content to fill the parent container in a variety of ways, such as preserving the aspect ratio or stretching to take up as much space as possible.
Classes for the value of object-fit are named using the format .object-fit-{value}. Choose from the following values:
Responsive variations also exist for each object-fit value using the format .object-fit-{breakpoint}-{value}, for the following breakpoint abbreviations: sm, md, lg, xl, and xxl. Classes can be combined for various effects as you need.
The opacity property sets the opacity level for an element. The opacity level describes the transparency level, where 1 is not transparent at all, .5 is 50% visible, and 0 is completely transparent.
The opacity property sets the opacity level for an element. The opacity level describes the transparency level, where 1 is not transparent at all, .5 is 50% visible, and 0 is completely transparent.
Set the opacity of an element using .opacity-{value} utilities.
In addition, you can also center the elements with the transform utility class .translate-middle.
This class applies the transformations translateX(-50%) and translateY(-50%) to the element which, in combination with the edge positioning utilities, allows you to absolute center an element.
You can use these classes with existing components to create new ones. Remember that you can extend its functionality by adding entries to the $position-values variable.
While shadows on components are disabled by default in Bootstrap and can be enabled via $enable-shadows, you can also quickly add or remove a shadow with our box-shadow utility classes. Includes support for .shadow-none and three default sizes (which have associated variables to match).
Width and height utilities are generated from the utility API in _utilities.scss. Includes support for 25%, 50%, 75%, 100%, and auto by default. Modify those values as you need to generate different utilities here.
Assign responsive-friendly margin or padding values to an element or a subset of its sides with shorthand classes. Includes support for individual properties, all properties, and vertical and horizontal properties. Classes are built from a default Sass map ranging from .25rem to 3rem.
-
-Using the CSS Grid layout module? Consider using the gap utility instead.
-
-
-
Notation
+
Using the CSS Grid layout module? Consider using the gap utility instead.
+
Notation
Spacing utilities that apply to all breakpoints, from xs to xxl, have no breakpoint abbreviation in them. This is because those classes are applied from min-width: 0 and up, and thus are not bound by a media query. The remaining breakpoints, however, do include a breakpoint abbreviation.
The classes are named using the format {property}{sides}-{size} for xs and {property}{sides}-{breakpoint}-{size} for sm, md, lg, xl, and xxl.
Where property is one of:
@@ -608,383 +53,245 @@
auto - for classes that set the margin to auto
(You can add more sizes by adding entries to the $spacers Sass map variable.)
-
Examples
+
Examples
Here are some representative examples of these classes:
Additionally, Bootstrap also includes an .mx-auto class for horizontally centering fixed-width block level content—that is, content that has display: block and a width set—by setting the horizontal margins to auto.
-
-
- Centered element
-
-
-
<divclass="mx-auto p-2"style="width: 200px;">
- Centered element
-</div>
-
Negative margin
+
+ Centered element
+
+
<divclass="mx-auto p-2"style="width: 200px;">
+ Centered element
+</div>
+
+
Negative margin
In CSS, margin properties can utilize negative values (padding cannot). These negative margins are disabled by default, but can be enabled in Sass by setting $enable-negative-margins: true.
-
The syntax is nearly the same as the default, positive margin utilities, but with the addition of n before the requested size. Here’s an example class that’s the opposite of .mt-1:
-
.mt-n1{
-margin-top:-0.25rem!important;
-}
-
Gap
+
The syntax is nearly the same as the default, positive margin utilities, but with the addition of n before the requested size. Here’s an example class that’s the opposite of .mt-1:
+
.mt-n1 {
+ margin-top: -0.25rem !important;
+}
+
+
Gap
When using display: grid or display: flex, you can make use of gap utilities on the parent element. This can save on having to add margin utilities to individual children of a grid or flex container. Gap utilities are responsive by default, and are generated via our utilities API, based on the $spacers Sass map.
Support includes responsive options for all of Bootstrap’s grid breakpoints, as well as six sizes from the $spacers map (0–5). There is no .gap-auto utility class as it’s effectively the same as .gap-0.
Support includes responsive options for all of Bootstrap’s grid breakpoints, as well as six sizes from the $spacers map (0–5). There is no .gap-auto utility class as it’s effectively the same as .gap-0.
+
row-gap
row-gap sets the vertical space between children items in the specified container.
Easily realign text to components with text alignment classes. For start, end, and center alignment, responsive classes are available that use the same viewport width breakpoints as the grid system.
-
-
-
-
Start aligned text on all viewport sizes.
+
Start aligned text on all viewport sizes.
Center aligned text on all viewport sizes.
End aligned text on all viewport sizes.
@@ -583,166 +31,58 @@
End aligned text on viewports sized MD (medium) or wider.
End aligned text on viewports sized LG (large) or wider.
End aligned text on viewports sized XL (extra large) or wider.
-
End aligned text on viewports sized XXL (extra extra large) or wider.
+
End aligned text on viewports sized XXL (extra extra large) or wider.
html
<pclass="text-start">Start aligned text on all viewport sizes.</p>
+<pclass="text-center">Center aligned text on all viewport sizes.</p>
+<pclass="text-end">End aligned text on all viewport sizes.</p>
-
- html
-
-
-
-
-
-
-
-
-
<pclass="text-start">Start aligned text on all viewport sizes.</p>
-<pclass="text-center">Center aligned text on all viewport sizes.</p>
-<pclass="text-end">End aligned text on all viewport sizes.</p>
-
-<pclass="text-sm-end">End aligned text on viewports sized SM (small) or wider.</p>
-<pclass="text-md-end">End aligned text on viewports sized MD (medium) or wider.</p>
-<pclass="text-lg-end">End aligned text on viewports sized LG (large) or wider.</p>
-<pclass="text-xl-end">End aligned text on viewports sized XL (extra large) or wider.</p>
-<pclass="text-xxl-end">End aligned text on viewports sized XXL (extra extra large) or wider.</p>
-
-
-
-Note that we don’t provide utility classes for justified text. While, aesthetically, justified text might look more appealing, it does make word-spacing more random and therefore harder to read.
-
-
-
Text wrapping and overflow
+<pclass="text-sm-end">End aligned text on viewports sized SM (small) or wider.</p>
+<pclass="text-md-end">End aligned text on viewports sized MD (medium) or wider.</p>
+<pclass="text-lg-end">End aligned text on viewports sized LG (large) or wider.</p>
+<pclass="text-xl-end">End aligned text on viewports sized XL (extra large) or wider.</p>
+<pclass="text-xxl-end">End aligned text on viewports sized XXL (extra extra large) or wider.</p>
+
Note that we don’t provide utility classes for justified text. While, aesthetically, justified text might look more appealing, it does make word-spacing more random and therefore harder to read.
+
Text wrapping and overflow
Wrap text with a .text-wrap class.
-
-
-
-
+
This text should wrap.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="badge text-bg-primary text-wrap"style="width: 6rem;">
- This text should wrap.
-</div>
-
-
+
html
<divclass="badge text-bg-primary text-wrap"style="width: 6rem;">
+ This text should wrap.
+</div>
Prevent text from wrapping with a .text-nowrap class.
-
-
-
-
+
This text should overflow the parent.
-
-
-
- html
-
-
-
-
-
-
-
-
-
<divclass="text-nowrap bg-body-secondary border"style="width: 8rem;">
- This text should overflow the parent.
-</div>
-
-
-
Word break
-
Prevent long strings of text from breaking your components’ layout by using .text-break to set word-wrap: break-word and word-break: break-word. We use word-wrap instead of the more common overflow-wrap for wider browser support, and add the deprecated word-break: break-word to avoid issues with flex containers.
<divclass="text-nowrap bg-body-secondary border"style="width: 8rem;">
+ This text should overflow the parent.
+</div>
+
Word break
+
Prevent long strings of text from breaking your components’ layout by using .text-break to set word-wrap: break-word and word-break: break-word. We use word-wrap instead of the more common overflow-wrap for wider browser support, and add the deprecated word-break: break-word to avoid issues with flex containers.
Note how .text-capitalize only changes the first letter of each word, leaving the case of any other letters unaffected.
-
Font size
-
Quickly change the font-size of text. While our heading classes (e.g., .h1–.h6) apply font-size, font-weight, and line-height, these utilities only apply font-size. Sizing for these utilities matches HTML’s heading elements, so as the number increases, their size decreases.
-
-
-
-
.fs-1 text
+
Font size
+
Quickly change the font-size of text. While our heading classes (e.g., .h1–.h6) apply font-size, font-weight, and line-height, these utilities only apply font-size. Sizing for these utilities matches HTML’s heading elements, so as the number increases, their size decreases.
Customize your available font-sizes by modifying the $font-sizes Sass map.
-
Font weight and italics
+
Font weight and italics
Quickly change the font-weight or font-style of text with these utilities. font-style utilities are abbreviated as .fst-* and font-weight utilities are abbreviated as .fw-*.
-
-
-
-
Bold text.
+
Bold text.
Bolder weight text (relative to the parent element).
<pclass="fw-bold">Bold text.</p>
-<pclass="fw-bolder">Bolder weight text (relative to the parent element).</p>
-<pclass="fw-semibold">Semibold weight text.</p>
-<pclass="fw-medium">Medium weight text.</p>
-<pclass="fw-normal">Normal weight text.</p>
-<pclass="fw-light">Light weight text.</p>
-<pclass="fw-lighter">Lighter weight text (relative to the parent element).</p>
-<pclass="fst-italic">Italic text.</p>
-<pclass="fst-normal">Text with normal font style</p>
-
-
-
Line height
+
Text with normal font style
html
<pclass="fw-bold">Bold text.</p>
+<pclass="fw-bolder">Bolder weight text (relative to the parent element).</p>
+<pclass="fw-semibold">Semibold weight text.</p>
+<pclass="fw-medium">Medium weight text.</p>
+<pclass="fw-normal">Normal weight text.</p>
+<pclass="fw-light">Light weight text.</p>
+<pclass="fw-lighter">Lighter weight text (relative to the parent element).</p>
+<pclass="fst-italic">Italic text.</p>
+<pclass="fst-normal">Text with normal font style</p>
+
Line height
Change the line height with .lh-* utilities.
-
-
-
-
This is a long paragraph written to show how the line-height of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.
+
This is a long paragraph written to show how the line-height of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.
This is a long paragraph written to show how the line-height of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.
This is a long paragraph written to show how the line-height of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.
-
This is a long paragraph written to show how the line-height of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.
-
-
- html
-
-
-
-
-
-
-
-
-
<pclass="lh-1">This is a long paragraph written to show how the line-height of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.</p>
-<pclass="lh-sm">This is a long paragraph written to show how the line-height of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.</p>
-<pclass="lh-base">This is a long paragraph written to show how the line-height of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.</p>
-<pclass="lh-lg">This is a long paragraph written to show how the line-height of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.</p>
-
-
-
Monospace
+
This is a long paragraph written to show how the line-height of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.
html
<pclass="lh-1">This is a long paragraph written to show how the line-height of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.</p>
+<pclass="lh-sm">This is a long paragraph written to show how the line-height of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.</p>
+<pclass="lh-base">This is a long paragraph written to show how the line-height of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.</p>
+<pclass="lh-lg">This is a long paragraph written to show how the line-height of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.</p>
+
Monospace
Change a selection to our monospace font stack with .font-monospace.
-
-
-
-
This is in monospace
-
-
- html
-
-
-
-
-
-
-
-
-
<pclass="font-monospace">This is in monospace</p>
-
-
-
Reset color
-
Reset a text or link’s color with .text-reset, so that it inherits the color from its parent.
-
-
-
-
+
This is in monospace
html
<pclass="font-monospace">This is in monospace</p>
+
Reset color
+
Reset a text or link’s color with .text-reset, so that it inherits the color from its parent.
<pclass="text-decoration-underline">This text has a line underneath it.</p>
-<pclass="text-decoration-line-through">This text has a line going through it.</p>
-<ahref="#"class="text-decoration-none">This link has its text decoration removed</a>
<pclass="text-decoration-underline">This text has a line underneath it.</p>
+<pclass="text-decoration-line-through">This text has a line going through it.</p>
+<ahref="#"class="text-decoration-none">This link has its text decoration removed</a>
// stylelint-disable value-keyword-case
-$font-family-sans-serif:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue","Noto Sans","Liberation Sans",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";
-$font-family-monospace:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
-// stylelint-enable value-keyword-case
-$font-family-base:var(--#{$prefix}font-sans-serif);
-$font-family-code:var(--#{$prefix}font-monospace);
-
-// $font-size-root affects the value of `rem`, which is used for as well font sizes, paddings, and margins
-// $font-size-base affects the font size of the body text
-$font-size-root:null;
-$font-size-base:1rem;// Assumes the browser default, typically `16px`
-$font-size-sm:$font-size-base*.875;
-$font-size-lg:$font-size-base*1.25;
-
-$font-weight-lighter:lighter;
-$font-weight-light:300;
-$font-weight-normal:400;
-$font-weight-medium:500;
-$font-weight-semibold:600;
-$font-weight-bold:700;
-$font-weight-bolder:bolder;
-
-$font-weight-base:$font-weight-normal;
-
-$line-height-base:1.5;
-$line-height-sm:1.25;
-$line-height-lg:2;
-
-$h1-font-size:$font-size-base*2.5;
-$h2-font-size:$font-size-base*2;
-$h3-font-size:$font-size-base*1.75;
-$h4-font-size:$font-size-base*1.5;
-$h5-font-size:$font-size-base*1.25;
-$h6-font-size:$font-size-base;
-
Easily change the vertical alignment of inline, inline-block, inline-table, and table cell elements.
-
-
-
-
-
-
-
-
-
-
Change the alignment of elements with the vertical-alignment utilities. Please note that vertical-align only affects inline, inline-block, inline-table, and table cell elements.
Easily change the vertical alignment of inline, inline-block, inline-table, and table cell elements.
+
Change the alignment of elements with the vertical-alignment utilities. Please note that vertical-align only affects inline, inline-block, inline-table, and table cell elements.
Choose from .align-baseline, .align-top, .align-middle, .align-bottom, .align-text-bottom, and .align-text-top as needed.
-
To vertically center non-inline content (like <div>s and more), use our flex box utilities.
+
To vertically center non-inline content (like <div>s and more), use our flex box utilities.
Control the visibility of elements, without modifying their display, with visibility utilities.
-
-
-
-
-
-
-
-
-
-
Set the visibility of elements with our visibility utilities. These utility classes do not modify the display value at all and do not affect layout – .invisible elements still take up space in the page.
-
-Elements with the .invisible class will be hidden both visually and for assistive technology/screen reader users.
-
Control the visibility of elements, without modifying their display, with visibility utilities.
+
Set the visibility of elements with our visibility utilities. These utility classes do not modify the display value at all and do not affect layout – .invisible elements still take up space in the page.
+
Elements with the .invisible class will be hidden both visually and for assistive technology/screen reader users.
Use z-index utilities to stack elements on top of one another. Requires a position value other than static, which can be set with custom styles or using our position utilities.
-
-We call these “low-level” z-index utilities because of their default values of -1 through 3, which we use for the layout of overlapping components. High-level z-index values are used for overlay components like modals and tooltips.
-
-
-
-
-
-
z-3
+
We call these “low-level” z-index utilities because of their default values of -1 through 3, which we use for the layout of overlapping components. High-level z-index values are used for overlay components like modals and tooltips.
Bootstrap overlay components—dropdown, modal, offcanvas, popover, toast, and tooltip—all have their own z-index values to ensure a usable experience with competing “layers” of an interface.
Bootstrap overlay components—dropdown, modal, offcanvas, popover, toast, and tooltip—all have their own z-index values to ensure a usable experience with competing “layers” of an interface.
On some components, we use our low-level z-index values to manage repeating elements that overlap one another (like buttons in a button group or items in a list group).
\ No newline at end of file
diff --git a/docsref/index.html b/docsref/index.html
index 92d31ba7e2..edb45fd414 100644
--- a/docsref/index.html
+++ b/docsref/index.html
@@ -1,12 +1 @@
-
-
-
-
-
- https://getbootstrap.com/docs/5.3/docsref/
-
-
-
-
-
-
+ Bootstrap
\ No newline at end of file
diff --git a/examples/blog/index.html b/examples/blog/index.html
deleted file mode 100644
index 16c5e15335..0000000000
--- a/examples/blog/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Redirecting…
-
-
-
-
-
Redirecting…
- Click here if you are not redirected.
-
diff --git a/examples/carousel/index.html b/examples/carousel/index.html
deleted file mode 100644
index de1ada7f95..0000000000
--- a/examples/carousel/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Redirecting…
-
-
-
-
-
Redirecting…
- Click here if you are not redirected.
-
diff --git a/examples/cover/index.html b/examples/cover/index.html
deleted file mode 100644
index da46e3986b..0000000000
--- a/examples/cover/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Redirecting…
-
-
-
-
-
Redirecting…
- Click here if you are not redirected.
-
diff --git a/examples/dashboard/index.html b/examples/dashboard/index.html
deleted file mode 100644
index d407d7c71e..0000000000
--- a/examples/dashboard/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Redirecting…
-
-
-
-
-
Redirecting…
- Click here if you are not redirected.
-
diff --git a/examples/grid/index.html b/examples/grid/index.html
deleted file mode 100644
index a6224e7d31..0000000000
--- a/examples/grid/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Redirecting…
-
-
-
-
-
Redirecting…
- Click here if you are not redirected.
-
diff --git a/examples/index.html b/examples/index.html
index e4db458d4a..2c88cbb27d 100644
--- a/examples/index.html
+++ b/examples/index.html
@@ -1,12 +1 @@
-
-
-
-
-
- https://getbootstrap.com/docs/5.3/examples/
-
-
-
-
-
-
+ Bootstrap
\ No newline at end of file
diff --git a/examples/jumbotron-narrow/index.html b/examples/jumbotron-narrow/index.html
deleted file mode 100644
index 4cf9b3a875..0000000000
--- a/examples/jumbotron-narrow/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Redirecting…
-
-
-
-
-
Redirecting…
- Click here if you are not redirected.
-
diff --git a/examples/jumbotron/index.html b/examples/jumbotron/index.html
deleted file mode 100644
index 30ca77673e..0000000000
--- a/examples/jumbotron/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Redirecting…
-
-
-
-
-
Redirecting…
- Click here if you are not redirected.
-
diff --git a/examples/justified-nav/index.html b/examples/justified-nav/index.html
deleted file mode 100644
index 57461b77e8..0000000000
--- a/examples/justified-nav/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Redirecting…
-
-
-
-
-
Redirecting…
- Click here if you are not redirected.
-
diff --git a/examples/navbar-fixed-top/index.html b/examples/navbar-fixed-top/index.html
deleted file mode 100644
index d1c8466b58..0000000000
--- a/examples/navbar-fixed-top/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Redirecting…
-
-
-
-
-
Redirecting…
- Click here if you are not redirected.
-
diff --git a/examples/navbar-static-top/index.html b/examples/navbar-static-top/index.html
deleted file mode 100644
index 89edf9874f..0000000000
--- a/examples/navbar-static-top/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Redirecting…
-
-
-
-
-
Redirecting…
- Click here if you are not redirected.
-
diff --git a/examples/navbar/index.html b/examples/navbar/index.html
deleted file mode 100644
index 43d677f805..0000000000
--- a/examples/navbar/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Redirecting…
-
-
-
-
-
Redirecting…
- Click here if you are not redirected.
-
diff --git a/examples/non-responsive/index.html b/examples/non-responsive/index.html
deleted file mode 100644
index b4b1756f48..0000000000
--- a/examples/non-responsive/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Redirecting…
-
-
-
-
-
Redirecting…
- Click here if you are not redirected.
-
diff --git a/examples/offcanvas/index.html b/examples/offcanvas/index.html
deleted file mode 100644
index daf48fa468..0000000000
--- a/examples/offcanvas/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Redirecting…
-
-
-
-
-
Redirecting…
- Click here if you are not redirected.
-
diff --git a/examples/signin/index.html b/examples/signin/index.html
deleted file mode 100644
index bf4a79e49d..0000000000
--- a/examples/signin/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Redirecting…
-
-
-
-
-
Redirecting…
- Click here if you are not redirected.
-
diff --git a/examples/starter-template/index.html b/examples/starter-template/index.html
deleted file mode 100644
index 883f86ee4d..0000000000
--- a/examples/starter-template/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Redirecting…
-
-
-
-
-
Redirecting…
- Click here if you are not redirected.
-
diff --git a/examples/sticky-footer-navbar/index.html b/examples/sticky-footer-navbar/index.html
deleted file mode 100644
index ce063820cc..0000000000
--- a/examples/sticky-footer-navbar/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Redirecting…
-
-
-
-
-
Redirecting…
- Click here if you are not redirected.
-
diff --git a/examples/sticky-footer/index.html b/examples/sticky-footer/index.html
deleted file mode 100644
index 5aed843575..0000000000
--- a/examples/sticky-footer/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Redirecting…
-
-
-
-
-
Redirecting…
- Click here if you are not redirected.
-
diff --git a/examples/theme/index.html b/examples/theme/index.html
deleted file mode 100644
index 0b34bc7eab..0000000000
--- a/examples/theme/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Redirecting…
-
-
-
-
-
Redirecting…
- Click here if you are not redirected.
-
diff --git a/examples/tooltip-viewport/index.html b/examples/tooltip-viewport/index.html
deleted file mode 100644
index 343bcde83d..0000000000
--- a/examples/tooltip-viewport/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- Redirecting…
-
-
-
-
-
Redirecting…
- Click here if you are not redirected.
-
diff --git a/getting-started/index.html b/getting-started/index.html
index 349df656a8..77668bc23d 100644
--- a/getting-started/index.html
+++ b/getting-started/index.html
@@ -1,12 +1 @@
-
-
-
-
-
- https://getbootstrap.com/docs/5.3/getting-started/introduction/
-
-
-
-
-
-
+ Bootstrap
\ No newline at end of file
diff --git a/index.html b/index.html
index 13f2c17b6b..5c12da27cf 100644
--- a/index.html
+++ b/index.html
@@ -1,866 +1,176 @@
-
-
-
-
-
-
-
-
+ Bootstrap · The most popular HTML, CSS, and JS library in the world.
+Powerful, extensible, and feature-packed frontend toolkit. Build and customize with Sass, utilize prebuilt grid
+ system and components, and bring projects to life with powerful JavaScript plugins.
+
+Install Bootstrap’s source Sass and JavaScript files via npm, RubyGems, Composer, or Meteor. Package-managed
+ installs don’t include documentation or our full build scripts. You can also use any demo from our Examples repo to quickly jumpstart Bootstrap projects.
+
+When you only need to include Bootstrap’s compiled CSS or JS, you can use jsDelivr. See it in action with our simple quick start, or browse the examples to jumpstart your next project. You can also
+ choose to include Popper and our JS separately.
+
+Bootstrap utilizes Sass for a modular and customizable architecture. Import only the components you need, enable
+ global options like gradients and shadows, and write your own CSS with our variables, maps, functions, and mixins.
+
+Bootstrap 5 is evolving with each release to better utilize CSS variables for global theme styles, individual
+ components, and even utilities. We provide dozens of variables for colors, font styles, and more at a :root level for use anywhere. On components and utilities, CSS variables are scoped to the relevant class and can easily
+ be modified.
+
+Use any of our global :root variables to write new styles. CSS variables use the var(--bs-variableName) syntax and can be inherited by children
+ elements.
+
+Override global, component, or utility class variables to customize Bootstrap just how you like. No need to
+ redeclare each rule, just a new variable value.
+
+New in Bootstrap 5, our utilities are now generated by our Utility API. We built it as a feature-packed Sass map that can be quickly and easily customized. It's never been easier to
+ add, remove, or modify any utility classes. Make utilities responsive, add pseudo-class variants, and give them
+ custom names.
+
Quickly customize components
+Apply any of our included utility classes to our components to customize their appearance, like the navigation
+ example below. There are hundreds of classes available—from positioning and sizing to colors and effects. Mix them with CSS variable overrides for
+ even more control.
+
+Use Bootstrap's utility API to modify any of our included utilities or create your own custom utilities for any
+ project. Import Bootstrap first, then use Sass map functions to modify, add, or remove utilities.
+
- Powerful, extensible, and feature-packed frontend toolkit. Build and customize with Sass, utilize prebuilt grid system and components, and bring projects to life with powerful JavaScript plugins.
-
- Install Bootstrap’s source Sass and JavaScript files via npm, RubyGems, Composer, or Meteor. Package-managed installs don’t include documentation or our full build scripts. You can also use any demo from our Examples repo to quickly jumpstart Bootstrap projects.
-
- When you only need to include Bootstrap’s compiled CSS or JS, you can use jsDelivr. See it in action with our simple quick start, or browse the examples to jumpstart your next project. You can also choose to include Popper and our JS separately.
-
- Bootstrap utilizes Sass for a modular and customizable architecture. Import only the components you need, enable global options like gradients and shadows, and write your own CSS with our variables, maps, functions, and mixins.
-
- Bootstrap 5 is evolving with each release to better utilize CSS variables for global theme styles, individual components, and even utilities. We provide dozens of variables for colors, font styles, and more at a :root level for use anywhere. On components and utilities, CSS variables are scoped to the relevant class and can easily be modified.
-
Use any of our global :root variables to write new styles. CSS variables use the var(--bs-variableName) syntax and can be inherited by children elements.
Override global, component, or utility class variables to customize Bootstrap just how you like. No need to redeclare each rule, just a new variable value.
- New in Bootstrap 5, our utilities are now generated by our Utility API. We built it as a feature-packed Sass map that can be quickly and easily customized. It's never been easier to add, remove, or modify any utility classes. Make utilities responsive, add pseudo-class variants, and give them custom names.
-
-
-
-
-
Quickly customize components
-
Apply any of our included utility classes to our components to customize their appearance, like the navigation example below. There are hundreds of classes available—from positioning and sizing to colors and effects. Mix them with CSS variable overrides for even more control.
Use Bootstrap's utility API to modify any of our included utilities or create your own custom utilities for any project. Import Bootstrap first, then use Sass map functions to modify, add, or remove utilities.
- Add toggleable hidden elements, modals and offcanvas menus, popovers and tooltips, and so much more—all without jQuery. Bootstrap's JavaScript is HTML-first, meaning most plugins are added with data attributes in your HTML. Need more control? Include individual plugins programmatically.
-
Why write more JavaScript when you can write HTML? Nearly all of Bootstrap's JavaScript plugins feature a first-class data API, allowing you to use JavaScript just by adding data attributes.
- Bootstrap Icons is an open source SVG icon library featuring over 1,800 glyphs, with more added every release. They're designed to work in any project, whether you use Bootstrap itself or not. Use them as SVGs or icon fonts—both options give you vector scaling and easy customization via CSS.
-
- Take Bootstrap to the next level with premium themes from the official Bootstrap Themes marketplace. Themes are built on Bootstrap as their own extended frameworks, rich with new components and plugins, documentation, and powerful build tools.
-
+Add toggleable hidden elements, modals and offcanvas menus, popovers and tooltips, and so much more—all without
+ jQuery. Bootstrap's JavaScript is HTML-first, meaning most plugins are added with data attributes in your
+ HTML. Need more control? Include individual plugins programmatically.
+
+Why write more JavaScript when you can write HTML? Nearly all of Bootstrap's JavaScript plugins feature a
+ first-class data API, allowing you to use JavaScript just by adding data attributes.
+
Bootstrap Icons is an open source SVG icon library featuring over 1,800 glyphs, with
+ more added every release. They're designed to work in any project, whether you use Bootstrap itself or not. Use them
+ as SVGs or icon fonts—both options give you vector scaling and easy customization via CSS.
+
+Take Bootstrap to the next level with premium themes from the official Bootstrap Themes marketplace. Themes are built on Bootstrap as their own extended frameworks, rich with new components and plugins,
+ documentation, and powerful build tools.
+