mirror of https://github.com/twbs/bootstrap.git
docs: migration to Astro
BrowserStack / browserstack (push) Waiting to run
Details
BrowserStack / browserstack (push) Waiting to run
Details
Co-authored-by: HiDeoo <494699+HiDeoo@users.noreply.github.com> Co-authored-by: Mark Otto <markdotto@gmail.com>
This commit is contained in:
parent
99a0dc628a
commit
349e0bd45a
|
@ -2,6 +2,8 @@
|
||||||
**/dist/
|
**/dist/
|
||||||
**/vendor/
|
**/vendor/
|
||||||
/_site/
|
/_site/
|
||||||
|
/site/public/
|
||||||
/js/coverage/
|
/js/coverage/
|
||||||
/site/static/sw.js
|
/site/static/sw.js
|
||||||
|
/site/static/docs/**/assets/sw.js
|
||||||
/site/layouts/partials/
|
/site/layouts/partials/
|
||||||
|
|
|
@ -202,7 +202,12 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"files": [
|
"files": [
|
||||||
"site/assets/js/**"
|
"site/src/assets/application.js",
|
||||||
|
"site/src/assets/partials/*.js",
|
||||||
|
"site/src/assets/search.js",
|
||||||
|
"site/src/assets/snippets.js",
|
||||||
|
"site/src/assets/stackblitz.js",
|
||||||
|
"site/src/plugins/*.js"
|
||||||
],
|
],
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"sourceType": "module",
|
"sourceType": "module",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Contributing to Bootstrap
|
# Contributing to Bootstrap
|
||||||
|
|
||||||
Looking to contribute something to Bootstrap? **Here's how you can help.**
|
Looking to contribute something to Bootstrap? **Here’s how you can help.**
|
||||||
|
|
||||||
Please take a moment to review this document in order to make the contribution
|
Please take a moment to review this document in order to make the contribution
|
||||||
process easy and effective for everyone involved.
|
process easy and effective for everyone involved.
|
||||||
|
@ -33,14 +33,14 @@ restrictions:
|
||||||
|
|
||||||
## Issues assignment
|
## Issues assignment
|
||||||
|
|
||||||
The core team will be looking at the open issues, analyze them, and provide guidance on how to proceed. **Issues won't be assigned to anyone outside the core team.** However, contributors are welcome to participate in the discussion and provide their input on how to best solve the issue, and even submit a PR if they want to. Please wait that the issue is ready to be worked on before submitting a PR, we don't want to waste your time.
|
The core team will be looking at the open issues, analyze them, and provide guidance on how to proceed. **Issues won’t be assigned to anyone outside the core team.** However, contributors are welcome to participate in the discussion and provide their input on how to best solve the issue, and even submit a PR if they want to. Please wait that the issue is ready to be worked on before submitting a PR, we don’t want to waste your time.
|
||||||
|
|
||||||
Please keep in mind that the core team is small, has limited resources and that we are not always able to respond immediately. We will try to provide feedback as soon as possible, but please be patient. If you don't get a response immediately, it doesn't mean that we are ignoring you or that we don't care about your issue or PR. We will get back to you as soon as we can.
|
Please keep in mind that the core team is small, has limited resources and that we are not always able to respond immediately. We will try to provide feedback as soon as possible, but please be patient. If you don’t get a response immediately, it doesn’t mean that we are ignoring you or that we don’t care about your issue or PR. We will get back to you as soon as we can.
|
||||||
|
|
||||||
|
|
||||||
## Issues and labels
|
## Issues and labels
|
||||||
|
|
||||||
Our bug tracker utilizes several labels to help organize and identify issues. Here's what they represent and how we use them:
|
Our bug tracker utilizes several labels to help organize and identify issues. Here’s what they represent and how we use them:
|
||||||
|
|
||||||
- `browser bug` - Issues that are reported to us, but actually are the result of a browser-specific bug. These are diagnosed with reduced test cases and result in an issue opened on that browser's own bug tracker.
|
- `browser bug` - Issues that are reported to us, but actually are the result of a browser-specific bug. These are diagnosed with reduced test cases and result in an issue opened on that browser's own bug tracker.
|
||||||
- `confirmed` - Issues that have been confirmed with a reduced test case and identify a bug in Bootstrap.
|
- `confirmed` - Issues that have been confirmed with a reduced test case and identify a bug in Bootstrap.
|
||||||
|
@ -64,7 +64,7 @@ Good bug reports are extremely helpful, so thanks!
|
||||||
Guidelines for bug reports:
|
Guidelines for bug reports:
|
||||||
|
|
||||||
0. **[Validate your HTML](https://html5.validator.nu/)** to ensure your
|
0. **[Validate your HTML](https://html5.validator.nu/)** to ensure your
|
||||||
problem isn't caused by a simple error in your own code.
|
problem isn’t caused by a simple error in your own code.
|
||||||
|
|
||||||
1. **Use the GitHub issue search** — check if the issue has already been
|
1. **Use the GitHub issue search** — check if the issue has already been
|
||||||
reported.
|
reported.
|
||||||
|
@ -77,7 +77,7 @@ Guidelines for bug reports:
|
||||||
These [v4 CodePen](https://codepen.io/team/bootstrap/pen/yLabNQL) and [v5 CodePen](https://codepen.io/team/bootstrap/pen/qBamdLj) are helpful templates.
|
These [v4 CodePen](https://codepen.io/team/bootstrap/pen/yLabNQL) and [v5 CodePen](https://codepen.io/team/bootstrap/pen/qBamdLj) are helpful templates.
|
||||||
|
|
||||||
|
|
||||||
A good bug report shouldn't leave others needing to chase you up for more
|
A good bug report shouldn’t leave others needing to chase you up for more
|
||||||
information. Please try to be as detailed as possible in your report. What is
|
information. Please try to be as detailed as possible in your report. What is
|
||||||
your environment? What steps will reproduce the issue? What browser(s) and OS
|
your environment? What steps will reproduce the issue? What browser(s) and OS
|
||||||
experience the problem? Do other browsers show the bug differently? What
|
experience the problem? Do other browsers show the bug differently? What
|
||||||
|
@ -109,7 +109,7 @@ Sometimes bugs reported to us are actually caused by bugs in the browser(s) them
|
||||||
| Vendor(s) | Browser(s) | Rendering engine | Bug reporting website(s) | Notes |
|
| Vendor(s) | Browser(s) | Rendering engine | Bug reporting website(s) | Notes |
|
||||||
| ------------- | ---------------------------- | ---------------- | ------------------------------------------------------ | -------------------------------------------------------- |
|
| ------------- | ---------------------------- | ---------------- | ------------------------------------------------------ | -------------------------------------------------------- |
|
||||||
| Mozilla | Firefox | Gecko | <https://bugzilla.mozilla.org/enter_bug.cgi> | "Core" is normally the right product option to choose. |
|
| Mozilla | Firefox | Gecko | <https://bugzilla.mozilla.org/enter_bug.cgi> | "Core" is normally the right product option to choose. |
|
||||||
| Apple | Safari | WebKit | <https://bugs.webkit.org/enter_bug.cgi?product=WebKit> | In Apple's bug reporter, choose "Safari" as the product. |
|
| Apple | Safari | WebKit | <https://bugs.webkit.org/enter_bug.cgi?product=WebKit> | In Apple’s bug reporter, choose "Safari" as the product. |
|
||||||
| Google, Opera | Chrome, Chromium, Opera v15+ | Blink | <https://bugs.chromium.org/p/chromium/issues/list> | Click the "New issue" button. |
|
| Google, Opera | Chrome, Chromium, Opera v15+ | Blink | <https://bugs.chromium.org/p/chromium/issues/list> | Click the "New issue" button. |
|
||||||
| Microsoft | Edge | Blink | <https://developer.microsoft.com/en-us/microsoft-edge/> | Go to "Help > Send Feedback" from the browser |
|
| Microsoft | Edge | Blink | <https://developer.microsoft.com/en-us/microsoft-edge/> | Go to "Help > Send Feedback" from the browser |
|
||||||
|
|
||||||
|
@ -117,8 +117,8 @@ Sometimes bugs reported to us are actually caused by bugs in the browser(s) them
|
||||||
## Feature requests
|
## Feature requests
|
||||||
|
|
||||||
Feature requests are welcome. But take a moment to find out whether your idea
|
Feature requests are welcome. But take a moment to find out whether your idea
|
||||||
fits with the scope and aims of the project. It's up to _you_ to make a strong
|
fits with the scope and aims of the project. It’s up to _you_ to make a strong
|
||||||
case to convince the project's developers of the merits of this feature. Please
|
case to convince the project’s developers of the merits of this feature. Please
|
||||||
provide as much detail and context as possible.
|
provide as much detail and context as possible.
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,8 +131,8 @@ commits.
|
||||||
**Please ask first** before embarking on any **significant** pull request (e.g.
|
**Please ask first** before embarking on any **significant** pull request (e.g.
|
||||||
implementing features, refactoring code, porting to a different language),
|
implementing features, refactoring code, porting to a different language),
|
||||||
otherwise you risk spending a lot of time working on something that the
|
otherwise you risk spending a lot of time working on something that the
|
||||||
project's developers might not want to merge into the project. For trivial
|
project’s developers might not want to merge into the project. For trivial
|
||||||
things, or things that don't require a lot of your time, you can go ahead and
|
things, or things that don’t require a lot of your time, you can go ahead and
|
||||||
make a PR.
|
make a PR.
|
||||||
|
|
||||||
Please adhere to the [coding guidelines](#code-guidelines) used throughout the
|
Please adhere to the [coding guidelines](#code-guidelines) used throughout the
|
||||||
|
@ -144,7 +144,7 @@ any dist files (`dist/` or `js/dist`).** Those files are automatically generated
|
||||||
edit the source files in [`/bootstrap/scss/`](https://github.com/twbs/bootstrap/tree/main/scss)
|
edit the source files in [`/bootstrap/scss/`](https://github.com/twbs/bootstrap/tree/main/scss)
|
||||||
and/or [`/bootstrap/js/src/`](https://github.com/twbs/bootstrap/tree/main/js/src) instead.
|
and/or [`/bootstrap/js/src/`](https://github.com/twbs/bootstrap/tree/main/js/src) instead.
|
||||||
|
|
||||||
Similarly, when contributing to Bootstrap's documentation, you should edit the
|
Similarly, when contributing to Bootstrap’s documentation, you should edit the
|
||||||
documentation source files in
|
documentation source files in
|
||||||
[the `/bootstrap/site/content/docs/` directory of the `main` branch](https://github.com/twbs/bootstrap/tree/main/site/content/docs).
|
[the `/bootstrap/site/content/docs/` directory of the `main` branch](https://github.com/twbs/bootstrap/tree/main/site/content/docs).
|
||||||
**Do not edit the `gh-pages` branch.** That branch is generated from the
|
**Do not edit the `gh-pages` branch.** That branch is generated from the
|
||||||
|
@ -187,7 +187,7 @@ included in the project:
|
||||||
|
|
||||||
5. Commit your changes in logical chunks. Please adhere to these [git commit
|
5. Commit your changes in logical chunks. Please adhere to these [git commit
|
||||||
message guidelines](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
|
message guidelines](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
|
||||||
or your code is unlikely be merged into the main project. Use Git's
|
or your code is unlikely be merged into the main project. Use Git’s
|
||||||
[interactive rebase](https://help.github.com/articles/about-git-rebase/)
|
[interactive rebase](https://help.github.com/articles/about-git-rebase/)
|
||||||
feature to tidy up your commits before making them public.
|
feature to tidy up your commits before making them public.
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ includes code changes) and under the terms of the
|
||||||
[Adhere to the Code Guide.](https://codeguide.co/#html)
|
[Adhere to the Code Guide.](https://codeguide.co/#html)
|
||||||
|
|
||||||
- Use tags and elements appropriate for an HTML5 doctype (e.g., self-closing tags).
|
- Use tags and elements appropriate for an HTML5 doctype (e.g., self-closing tags).
|
||||||
- Use CDNs and HTTPS for third-party JS when possible. We don't use protocol-relative URLs in this case because they break when viewing the page locally via `file://`.
|
- Use CDNs and HTTPS for third-party JS when possible. We don’t use protocol-relative URLs in this case because they break when viewing the page locally via `file://`.
|
||||||
- Use [WAI-ARIA](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) attributes in documentation examples to promote accessibility.
|
- Use [WAI-ARIA](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) attributes in documentation examples to promote accessibility.
|
||||||
|
|
||||||
### CSS
|
### CSS
|
||||||
|
@ -236,7 +236,7 @@ includes code changes) and under the terms of the
|
||||||
[Adhere to the Code Guide.](https://codeguide.co/#css)
|
[Adhere to the Code Guide.](https://codeguide.co/#css)
|
||||||
|
|
||||||
- When feasible, default color palettes should comply with [WCAG color contrast guidelines](https://www.w3.org/TR/WCAG/#distinguishable).
|
- When feasible, default color palettes should comply with [WCAG color contrast guidelines](https://www.w3.org/TR/WCAG/#distinguishable).
|
||||||
- Except in rare cases, don't remove default `:focus` styles (via e.g. `outline: none;`) without providing alternative styles. See [this A11Y Project post](https://www.a11yproject.com/posts/2013-01-25-never-remove-css-outlines/) for more details.
|
- Except in rare cases, don’t remove default `:focus` styles (via e.g. `outline: none;`) without providing alternative styles. See [this A11Y Project post](https://www.a11yproject.com/posts/2013-01-25-never-remove-css-outlines/) for more details.
|
||||||
|
|
||||||
### JS
|
### JS
|
||||||
|
|
||||||
|
@ -255,4 +255,4 @@ Run `npm run test` before committing to ensure your changes follow our coding st
|
||||||
By contributing your code, you agree to license your contribution under the [MIT License](../LICENSE).
|
By contributing your code, you agree to license your contribution under the [MIT License](../LICENSE).
|
||||||
By contributing to the documentation, you agree to license your contribution under the [Creative Commons Attribution 3.0 Unported License](https://creativecommons.org/licenses/by/3.0/).
|
By contributing to the documentation, you agree to license your contribution under the [Creative Commons Attribution 3.0 Unported License](https://creativecommons.org/licenses/by/3.0/).
|
||||||
|
|
||||||
Prior to v3.1.0, Bootstrap's code was released under the Apache License v2.0.
|
Prior to v3.1.0, Bootstrap’s code was released under the Apache License v2.0.
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
### Checklist
|
### Checklist
|
||||||
|
|
||||||
<!-- Go over all the following points, and put an `x` in all the boxes that apply. -->
|
<!-- Go over all the following points, and put an `x` in all the boxes that apply. -->
|
||||||
<!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
|
<!-- If you’re unsure about any of these, don’t hesitate to ask. We’re here to help! -->
|
||||||
|
|
||||||
- [ ] I have read the [contributing guidelines](https://github.com/twbs/bootstrap/blob/main/.github/CONTRIBUTING.md)
|
- [ ] I have read the [contributing guidelines](https://github.com/twbs/bootstrap/blob/main/.github/CONTRIBUTING.md)
|
||||||
- [ ] My code follows the code style of the project _(using `npm run lint`)_
|
- [ ] My code follows the code style of the project _(using `npm run lint`)_
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
# Ignore docs files
|
# Ignore docs files
|
||||||
/_site/
|
/_site/
|
||||||
# Hugo files
|
|
||||||
/resources/
|
|
||||||
/.hugo_build.lock
|
|
||||||
|
|
||||||
# Numerous always-ignore extensions
|
# Numerous always-ignore extensions
|
||||||
*.diff
|
*.diff
|
||||||
|
@ -41,3 +38,13 @@ Thumbs.db
|
||||||
/dist-sass/
|
/dist-sass/
|
||||||
/js/coverage/
|
/js/coverage/
|
||||||
/node_modules/
|
/node_modules/
|
||||||
|
|
||||||
|
# Site
|
||||||
|
/site/dist
|
||||||
|
/site/node_modules
|
||||||
|
/site/.astro
|
||||||
|
/site/public
|
||||||
|
|
||||||
|
# TODO(Astro migration): temporary files and directories during the migration
|
||||||
|
resources/
|
||||||
|
.hugo_build.lock
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
# Prettier is only used for the website
|
||||||
|
|
||||||
|
site/.astro
|
||||||
|
site/dist
|
||||||
|
site/public
|
||||||
|
site/src/assets
|
||||||
|
site/src/scss
|
||||||
|
site/src/pages/**/*.md
|
||||||
|
site/src/pages/**/*.mdx
|
||||||
|
site/src/content/**/*.mdx
|
||||||
|
site/src/layouts/RedirectLayout.astro
|
||||||
|
site/static
|
|
@ -2,4 +2,5 @@
|
||||||
**/dist/
|
**/dist/
|
||||||
**/vendor/
|
**/vendor/
|
||||||
/_site/
|
/_site/
|
||||||
|
/site/public/
|
||||||
/js/coverage/
|
/js/coverage/
|
||||||
|
|
|
@ -31,7 +31,7 @@ Examples of unacceptable behavior include:
|
||||||
any kind
|
any kind
|
||||||
- Trolling, insulting or derogatory comments, and personal or political attacks
|
- Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
- Public or private harassment
|
- Public or private harassment
|
||||||
- Publishing others' private information, such as a physical or email address,
|
- Publishing others’ private information, such as a physical or email address,
|
||||||
without their explicit permission
|
without their explicit permission
|
||||||
- Other conduct which could reasonably be considered inappropriate in a
|
- Other conduct which could reasonably be considered inappropriate in a
|
||||||
professional setting
|
professional setting
|
||||||
|
|
16
README.md
16
README.md
|
@ -31,7 +31,7 @@ Our default branch is for development of our Bootstrap 5 release. Head to the [`
|
||||||
|
|
||||||
- [Quick start](#quick-start)
|
- [Quick start](#quick-start)
|
||||||
- [Status](#status)
|
- [Status](#status)
|
||||||
- [What's included](#whats-included)
|
- [What’s included](#whats-included)
|
||||||
- [Bugs and feature requests](#bugs-and-feature-requests)
|
- [Bugs and feature requests](#bugs-and-feature-requests)
|
||||||
- [Documentation](#documentation)
|
- [Documentation](#documentation)
|
||||||
- [Contributing](#contributing)
|
- [Contributing](#contributing)
|
||||||
|
@ -74,9 +74,9 @@ Read the [Getting started page](https://getbootstrap.com/docs/5.3/getting-starte
|
||||||
[](#sponsors)
|
[](#sponsors)
|
||||||
|
|
||||||
|
|
||||||
## What's included
|
## What’s included
|
||||||
|
|
||||||
Within the download you'll find the following directories and files, logically grouping common assets and providing both compiled and minified variations.
|
Within the download you’ll find the following directories and files, logically grouping common assets and providing both compiled and minified variations.
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Download contents</summary>
|
<summary>Download contents</summary>
|
||||||
|
@ -132,7 +132,7 @@ Within the download you'll find the following directories and files, logically g
|
||||||
```
|
```
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
We provide compiled CSS and JS (`bootstrap.*`), as well as compiled and minified CSS and JS (`bootstrap.min.*`). [Source maps](https://web.dev/articles/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](https://popper.js.org/docs/v2/).
|
We provide compiled CSS and JS (`bootstrap.*`), as well as compiled and minified CSS and JS (`bootstrap.min.*`). [Source maps](https://web.dev/articles/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](https://popper.js.org/docs/v2/).
|
||||||
|
|
||||||
|
|
||||||
## Bugs and feature requests
|
## Bugs and feature requests
|
||||||
|
@ -142,18 +142,18 @@ Have a bug or a feature request? Please first read the [issue guidelines](https:
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
Bootstrap's documentation, included in this repo in the root directory, is built with [Hugo](https://gohugo.io/) and publicly hosted on GitHub Pages at <https://getbootstrap.com/>. The docs may also be run locally.
|
Bootstrap’s documentation, included in this repo in the root directory, is built with [Astro](https://astro.build/) and publicly hosted on GitHub Pages at <https://getbootstrap.com/>. The docs may also be run locally.
|
||||||
|
|
||||||
Documentation search is powered by [Algolia's DocSearch](https://docsearch.algolia.com/).
|
Documentation search is powered by [Algolia's DocSearch](https://docsearch.algolia.com/).
|
||||||
|
|
||||||
### Running documentation locally
|
### Running documentation locally
|
||||||
|
|
||||||
1. Run `npm install` to install the Node.js dependencies, including Hugo (the site builder).
|
1. Run `npm install` to install the Node.js dependencies, including Astro (the site builder).
|
||||||
2. Run `npm run test` (or a specific npm script) to rebuild distributed CSS and JavaScript files, as well as our docs assets.
|
2. Run `npm run test` (or a specific npm script) to rebuild distributed CSS and JavaScript files, as well as our docs assets.
|
||||||
3. From the root `/bootstrap` directory, run `npm run docs-serve` in the command line.
|
3. From the root `/bootstrap` directory, run `npm run docs-serve` in the command line.
|
||||||
4. Open `http://localhost:9001/` in your browser, and voilà.
|
4. Open `http://localhost:9001/` in your browser, and voilà.
|
||||||
|
|
||||||
Learn more about using Hugo by reading its [documentation](https://gohugo.io/documentation/).
|
Learn more about using Astro by reading its [documentation](https://docs.astro.build/en/getting-started/).
|
||||||
|
|
||||||
### Documentation for previous releases
|
### Documentation for previous releases
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ Editor preferences are available in the [editor config](https://github.com/twbs/
|
||||||
|
|
||||||
## Community
|
## Community
|
||||||
|
|
||||||
Get updates on Bootstrap's development and chat with the project maintainers and community members.
|
Get updates on Bootstrap’s development and chat with the project maintainers and community members.
|
||||||
|
|
||||||
- Follow [@getbootstrap on X](https://x.com/getbootstrap).
|
- Follow [@getbootstrap on X](https://x.com/getbootstrap).
|
||||||
- Read and subscribe to [The Official Bootstrap Blog](https://blog.getbootstrap.com/).
|
- Read and subscribe to [The Official Bootstrap Blog](https://blog.getbootstrap.com/).
|
||||||
|
|
|
@ -16,7 +16,7 @@ const DRY_RUN = process.argv.includes('--dry') || process.argv.includes('--dry-r
|
||||||
// These are the files we only care about replacing the version
|
// These are the files we only care about replacing the version
|
||||||
const FILES = [
|
const FILES = [
|
||||||
'README.md',
|
'README.md',
|
||||||
'hugo.yml',
|
'config.yml',
|
||||||
'js/src/base-component.js',
|
'js/src/base-component.js',
|
||||||
'package.js',
|
'package.js',
|
||||||
'scss/mixins/_banner.scss',
|
'scss/mixins/_banner.scss',
|
||||||
|
|
|
@ -19,11 +19,11 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||||
|
|
||||||
sh.config.fatal = true
|
sh.config.fatal = true
|
||||||
|
|
||||||
const configFile = path.join(__dirname, '../hugo.yml')
|
const configFile = path.join(__dirname, '../config.yml')
|
||||||
|
|
||||||
// Array of objects which holds the files to generate SRI hashes for.
|
// Array of objects which holds the files to generate SRI hashes for.
|
||||||
// `file` is the path from the root folder
|
// `file` is the path from the root folder
|
||||||
// `configPropertyName` is the hugo.yml variable's name of the file
|
// `configPropertyName` is the config.yml variable's name of the file
|
||||||
const files = [
|
const files = [
|
||||||
{
|
{
|
||||||
file: 'dist/css/bootstrap.min.css',
|
file: 'dist/css/bootstrap.min.css',
|
||||||
|
|
|
@ -30,7 +30,12 @@ execFile('java', ['-version'], (error, stdout, stderr) => {
|
||||||
// Per https://www.w3.org/TR/html-aria/#docconformance having "aria-disabled" on a link is
|
// Per https://www.w3.org/TR/html-aria/#docconformance having "aria-disabled" on a link is
|
||||||
// NOT RECOMMENDED, but it's still valid - we explain in the docs that it's not ideal,
|
// NOT RECOMMENDED, but it's still valid - we explain in the docs that it's not ideal,
|
||||||
// and offer more robust alternatives, but also need to show a less-than-ideal example
|
// and offer more robust alternatives, but also need to show a less-than-ideal example
|
||||||
'An “aria-disabled” attribute whose value is “true” should not be specified on an “a” element that has an “href” attribute.'
|
'An “aria-disabled” attribute whose value is “true” should not be specified on an “a” element that has an “href” attribute.',
|
||||||
|
// A `code` element with the `is:raw` attribute coming from remark-prismjs (Astro upstream possible bug)
|
||||||
|
'Attribute “is:raw” is not serializable as XML 1.0.',
|
||||||
|
'Attribute “is:raw” not allowed on element “code” at this point.',
|
||||||
|
// Astro's expecting trailing slashes on HTML tags such as <br />
|
||||||
|
'Trailing slash on void elements has no effect and interacts badly with unquoted attribute values.'
|
||||||
].join('|')
|
].join('|')
|
||||||
|
|
||||||
const args = [
|
const args = [
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
title: "Bootstrap"
|
||||||
|
baseURL: "https://getbootstrap.com"
|
||||||
|
|
||||||
|
docsDir: "site"
|
||||||
|
|
||||||
|
subtitle: "The most popular HTML, CSS, and JS library in the world."
|
||||||
|
description: "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."
|
||||||
|
authors: "Mark Otto, Jacob Thornton, and Bootstrap contributors"
|
||||||
|
|
||||||
|
current_version: "5.3.5"
|
||||||
|
current_ruby_version: "5.3.5"
|
||||||
|
docs_version: "5.3"
|
||||||
|
rfs_version: "v10.0.0"
|
||||||
|
github_org: "https://github.com/twbs"
|
||||||
|
repo: "https://github.com/twbs/bootstrap"
|
||||||
|
x: "getbootstrap"
|
||||||
|
opencollective: "https://opencollective.com/bootstrap"
|
||||||
|
blog: "https://blog.getbootstrap.com/"
|
||||||
|
themes: "https://themes.getbootstrap.com/"
|
||||||
|
icons: "https://icons.getbootstrap.com/"
|
||||||
|
swag: "https://cottonbureau.com/people/bootstrap"
|
||||||
|
|
||||||
|
analytics:
|
||||||
|
fathom_site: "ITUSEYJG"
|
||||||
|
|
||||||
|
algolia:
|
||||||
|
app_id: "AK7KMZKZHQ"
|
||||||
|
api_key: "3151f502c7b9e9dafd5e6372b691a24e"
|
||||||
|
index_name: "bootstrap"
|
||||||
|
|
||||||
|
download:
|
||||||
|
source: "https://github.com/twbs/bootstrap/archive/v5.3.5.zip"
|
||||||
|
dist: "https://github.com/twbs/bootstrap/releases/download/v5.3.5/bootstrap-5.3.5-dist.zip"
|
||||||
|
dist_examples: "https://github.com/twbs/bootstrap/releases/download/v5.3.5/bootstrap-5.3.5-examples.zip"
|
||||||
|
|
||||||
|
cdn:
|
||||||
|
# See https://www.srihash.org for info on how to generate the hashes
|
||||||
|
css: "https://cdn.jsdelivr.net/npm/bootstrap@5.3.5/dist/css/bootstrap.min.css"
|
||||||
|
css_hash: "sha384-SgOJa3DmI69IUzQ2PVdRZhwQ+dy64/BUtbMJw1MZ8t5HZApcHrRKUc4W0kG879m7"
|
||||||
|
css_rtl: "https://cdn.jsdelivr.net/npm/bootstrap@5.3.5/dist/css/bootstrap.rtl.min.css"
|
||||||
|
css_rtl_hash: "sha384-q8+l9TmX3RaSz3HKGBmqP2u5MkgeN7HrfOJBLcTgZsQsbrx8WqqxdA5PuwUV9WIx"
|
||||||
|
js: "https://cdn.jsdelivr.net/npm/bootstrap@5.3.5/dist/js/bootstrap.min.js"
|
||||||
|
js_hash: "sha384-VQqxDN0EQCkWoxt/0vsQvZswzTHUVOImccYmSyhJTp7kGtPed0Qcx8rK9h9YEgx+"
|
||||||
|
js_bundle: "https://cdn.jsdelivr.net/npm/bootstrap@5.3.5/dist/js/bootstrap.bundle.min.js"
|
||||||
|
js_bundle_hash: "sha384-k6d4wzSIapyDyv1kpU366/PK5hCdSbCRGRCMv+eplOQJWyd1fbcAu9OCUj5zNLiq"
|
||||||
|
popper: "https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js"
|
||||||
|
popper_hash: "sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r"
|
||||||
|
popper_esm: "https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/esm/popper.min.js"
|
||||||
|
|
||||||
|
anchors:
|
||||||
|
min: 2
|
||||||
|
max: 5
|
||||||
|
|
||||||
|
toc:
|
||||||
|
min: 2
|
||||||
|
max: 6
|
102
hugo.yml
102
hugo.yml
|
@ -1,102 +0,0 @@
|
||||||
languageCode: "en"
|
|
||||||
title: "Bootstrap"
|
|
||||||
baseURL: "https://getbootstrap.com"
|
|
||||||
|
|
||||||
security:
|
|
||||||
enableInlineShortcodes: true
|
|
||||||
funcs:
|
|
||||||
getenv:
|
|
||||||
- ^HUGO_
|
|
||||||
- NETLIFY
|
|
||||||
|
|
||||||
markup:
|
|
||||||
goldmark:
|
|
||||||
renderer:
|
|
||||||
unsafe: true
|
|
||||||
highlight:
|
|
||||||
noClasses: false
|
|
||||||
tableOfContents:
|
|
||||||
startLevel: 2
|
|
||||||
endLevel: 6
|
|
||||||
|
|
||||||
build:
|
|
||||||
noJSConfigInAssets: true
|
|
||||||
|
|
||||||
buildDrafts: true
|
|
||||||
buildFuture: true
|
|
||||||
|
|
||||||
enableRobotsTXT: true
|
|
||||||
metaDataFormat: "yaml"
|
|
||||||
disableKinds: ["404", "taxonomy", "term", "RSS"]
|
|
||||||
|
|
||||||
publishDir: "_site"
|
|
||||||
|
|
||||||
module:
|
|
||||||
mounts:
|
|
||||||
- source: dist
|
|
||||||
target: static/docs/5.3/dist
|
|
||||||
- source: site/assets
|
|
||||||
target: assets
|
|
||||||
- source: site/content
|
|
||||||
target: content
|
|
||||||
- source: site/data
|
|
||||||
target: data
|
|
||||||
- source: site/layouts
|
|
||||||
target: layouts
|
|
||||||
- source: site/static
|
|
||||||
target: static
|
|
||||||
- source: node_modules/@docsearch/css
|
|
||||||
target: assets/scss/@docsearch/css
|
|
||||||
- source: site/static/docs/5.3/assets/img/favicons/apple-touch-icon.png
|
|
||||||
target: static/apple-touch-icon.png
|
|
||||||
- source: site/static/docs/5.3/assets/img/favicons/favicon.ico
|
|
||||||
target: static/favicon.ico
|
|
||||||
|
|
||||||
params:
|
|
||||||
subtitle: "The most popular HTML, CSS, and JS library in the world."
|
|
||||||
description: "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."
|
|
||||||
authors: "Mark Otto, Jacob Thornton, and Bootstrap contributors"
|
|
||||||
|
|
||||||
current_version: "5.3.5"
|
|
||||||
current_ruby_version: "5.3.5"
|
|
||||||
docs_version: "5.3"
|
|
||||||
rfs_version: "v10.0.0"
|
|
||||||
github_org: "https://github.com/twbs"
|
|
||||||
repo: "https://github.com/twbs/bootstrap"
|
|
||||||
x: "getbootstrap"
|
|
||||||
opencollective: "https://opencollective.com/bootstrap"
|
|
||||||
blog: "https://blog.getbootstrap.com/"
|
|
||||||
themes: "https://themes.getbootstrap.com/"
|
|
||||||
icons: "https://icons.getbootstrap.com/"
|
|
||||||
swag: "https://cottonbureau.com/people/bootstrap"
|
|
||||||
|
|
||||||
analytics:
|
|
||||||
fathom_site: "ITUSEYJG"
|
|
||||||
|
|
||||||
algolia:
|
|
||||||
appId: "AK7KMZKZHQ"
|
|
||||||
apiKey: "3151f502c7b9e9dafd5e6372b691a24e"
|
|
||||||
indexName: "bootstrap"
|
|
||||||
|
|
||||||
download:
|
|
||||||
source: "https://github.com/twbs/bootstrap/archive/v5.3.5.zip"
|
|
||||||
dist: "https://github.com/twbs/bootstrap/releases/download/v5.3.5/bootstrap-5.3.5-dist.zip"
|
|
||||||
dist_examples: "https://github.com/twbs/bootstrap/releases/download/v5.3.5/bootstrap-5.3.5-examples.zip"
|
|
||||||
|
|
||||||
cdn:
|
|
||||||
# See https://www.srihash.org for info on how to generate the hashes
|
|
||||||
css: "https://cdn.jsdelivr.net/npm/bootstrap@5.3.5/dist/css/bootstrap.min.css"
|
|
||||||
css_hash: "sha384-SgOJa3DmI69IUzQ2PVdRZhwQ+dy64/BUtbMJw1MZ8t5HZApcHrRKUc4W0kG879m7"
|
|
||||||
css_rtl: "https://cdn.jsdelivr.net/npm/bootstrap@5.3.5/dist/css/bootstrap.rtl.min.css"
|
|
||||||
css_rtl_hash: "sha384-q8+l9TmX3RaSz3HKGBmqP2u5MkgeN7HrfOJBLcTgZsQsbrx8WqqxdA5PuwUV9WIx"
|
|
||||||
js: "https://cdn.jsdelivr.net/npm/bootstrap@5.3.5/dist/js/bootstrap.min.js"
|
|
||||||
js_hash: "sha384-VQqxDN0EQCkWoxt/0vsQvZswzTHUVOImccYmSyhJTp7kGtPed0Qcx8rK9h9YEgx+"
|
|
||||||
js_bundle: "https://cdn.jsdelivr.net/npm/bootstrap@5.3.5/dist/js/bootstrap.bundle.min.js"
|
|
||||||
js_bundle_hash: "sha384-k6d4wzSIapyDyv1kpU366/PK5hCdSbCRGRCMv+eplOQJWyd1fbcAu9OCUj5zNLiq"
|
|
||||||
popper: "https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js"
|
|
||||||
popper_hash: "sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r"
|
|
||||||
popper_esm: "https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/esm/popper.min.js"
|
|
||||||
|
|
||||||
anchors:
|
|
||||||
min: 2
|
|
||||||
max: 5
|
|
|
@ -1,4 +1,4 @@
|
||||||
## How does Bootstrap's test suite work?
|
## How does Bootstrap’s test suite work?
|
||||||
|
|
||||||
Bootstrap uses [Jasmine](https://jasmine.github.io/). Each plugin has a file dedicated to its tests in `tests/unit/<plugin-name>.spec.js`.
|
Bootstrap uses [Jasmine](https://jasmine.github.io/). Each plugin has a file dedicated to its tests in `tests/unit/<plugin-name>.spec.js`.
|
||||||
|
|
||||||
|
@ -22,11 +22,11 @@ To run the unit test suite via [Karma](https://karma-runner.github.io/) and debu
|
||||||
- Each test should be in the corresponding `describe`.
|
- Each test should be in the corresponding `describe`.
|
||||||
- Each test should test only one unit per test, although one test can include several assertions. Create multiple tests for multiple units of functionality.
|
- Each test should test only one unit per test, although one test can include several assertions. Create multiple tests for multiple units of functionality.
|
||||||
- Each test should use [`expect`](https://jasmine.github.io/api/edge/matchers.html) to ensure something is expected.
|
- Each test should use [`expect`](https://jasmine.github.io/api/edge/matchers.html) to ensure something is expected.
|
||||||
- Each test should follow the project's [JavaScript Code Guidelines](https://github.com/twbs/bootstrap/blob/main/.github/CONTRIBUTING.md#js)
|
- Each test should follow the project’s [JavaScript Code Guidelines](https://github.com/twbs/bootstrap/blob/main/.github/CONTRIBUTING.md#js)
|
||||||
|
|
||||||
## Code coverage
|
## Code coverage
|
||||||
|
|
||||||
Currently we're aiming for at least 90% test coverage for our code. To ensure your changes meet or exceed this limit, run `npm run js-test-karma` and open the file in `js/coverage/lcov-report/index.html` to see the code coverage for each plugin. See more details when you select a plugin and ensure your change is fully covered by unit tests.
|
Currently we’re aiming for at least 90% test coverage for our code. To ensure your changes meet or exceed this limit, run `npm run js-test-karma` and open the file in `js/coverage/lcov-report/index.html` to see the code coverage for each plugin. See more details when you select a plugin and ensure your change is fully covered by unit tests.
|
||||||
|
|
||||||
### Example tests
|
### Example tests
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
52
package.json
52
package.json
|
@ -46,14 +46,14 @@
|
||||||
"css-rtl": "cross-env NODE_ENV=RTL postcss --config build/postcss.config.mjs --dir \"dist/css\" --ext \".rtl.css\" \"dist/css/*.css\" \"!dist/css/*.min.css\" \"!dist/css/*.rtl.css\"",
|
"css-rtl": "cross-env NODE_ENV=RTL postcss --config build/postcss.config.mjs --dir \"dist/css\" --ext \".rtl.css\" \"dist/css/*.css\" \"!dist/css/*.min.css\" \"!dist/css/*.rtl.css\"",
|
||||||
"css-lint": "npm-run-all --aggregate-output --continue-on-error --parallel css-lint-*",
|
"css-lint": "npm-run-all --aggregate-output --continue-on-error --parallel css-lint-*",
|
||||||
"css-lint-stylelint": "stylelint \"**/*.{css,scss}\" --cache --cache-location .cache/.stylelintcache",
|
"css-lint-stylelint": "stylelint \"**/*.{css,scss}\" --cache --cache-location .cache/.stylelintcache",
|
||||||
"css-lint-vars": "fusv scss/ site/assets/scss/",
|
"css-lint-vars": "fusv scss/ site/src/scss/",
|
||||||
"css-minify": "npm-run-all --aggregate-output --parallel css-minify-*",
|
"css-minify": "npm-run-all --aggregate-output --parallel css-minify-*",
|
||||||
"css-minify-main": "cleancss -O1 --format breakWith=lf --with-rebase --source-map --source-map-inline-sources --output dist/css/ --batch --batch-suffix \".min\" \"dist/css/*.css\" \"!dist/css/*.min.css\" \"!dist/css/*rtl*.css\"",
|
"css-minify-main": "cleancss -O1 --format breakWith=lf --with-rebase --source-map --source-map-inline-sources --output dist/css/ --batch --batch-suffix \".min\" \"dist/css/*.css\" \"!dist/css/*.min.css\" \"!dist/css/*rtl*.css\"",
|
||||||
"css-minify-rtl": "cleancss -O1 --format breakWith=lf --with-rebase --source-map --source-map-inline-sources --output dist/css/ --batch --batch-suffix \".min\" \"dist/css/*rtl.css\" \"!dist/css/*.min.css\"",
|
"css-minify-rtl": "cleancss -O1 --format breakWith=lf --with-rebase --source-map --source-map-inline-sources --output dist/css/ --batch --batch-suffix \".min\" \"dist/css/*rtl.css\" \"!dist/css/*.min.css\"",
|
||||||
"css-prefix": "npm-run-all --aggregate-output --parallel css-prefix-*",
|
"css-prefix": "npm-run-all --aggregate-output --parallel css-prefix-*",
|
||||||
"css-prefix-main": "postcss --config build/postcss.config.mjs --replace \"dist/css/*.css\" \"!dist/css/*.rtl*.css\" \"!dist/css/*.min.css\"",
|
"css-prefix-main": "postcss --config build/postcss.config.mjs --replace \"dist/css/*.css\" \"!dist/css/*.rtl*.css\" \"!dist/css/*.min.css\"",
|
||||||
"css-prefix-examples": "postcss --config build/postcss.config.mjs --replace \"site/content/**/*.css\"",
|
"css-prefix-examples": "postcss --config build/postcss.config.mjs --replace \"site/src/assets/examples/**/*.css\"",
|
||||||
"css-prefix-examples-rtl": "cross-env-shell NODE_ENV=RTL postcss --config build/postcss.config.mjs --dir \"site/content/docs/$npm_package_config_version_short/examples/\" --ext \".rtl.css\" --base \"site/content/docs/$npm_package_config_version_short/examples/\" \"site/content/docs/$npm_package_config_version_short/examples/{blog,carousel,dashboard,cheatsheet}/*.css\" \"!site/content/docs/$npm_package_config_version_short/examples/{blog,carousel,dashboard,cheatsheet}/*.rtl.css\"",
|
"css-prefix-examples-rtl": "cross-env-shell NODE_ENV=RTL postcss --config build/postcss.config.mjs --dir \"site/src/assets/examples/\" --ext \".rtl.css\" --base \"site/src/assets/examples/\" \"site/src/assets/examples/{blog,carousel,dashboard,cheatsheet}/*.css\" \"!site/src/assets/examples/{blog,carousel,dashboard,cheatsheet}/*.rtl.css\"",
|
||||||
"css-test": "jasmine --config=scss/tests/jasmine.js",
|
"css-test": "jasmine --config=scss/tests/jasmine.js",
|
||||||
"js": "npm-run-all js-compile js-minify",
|
"js": "npm-run-all js-compile js-minify",
|
||||||
"js-compile": "npm-run-all --aggregate-output --parallel js-compile-*",
|
"js-compile": "npm-run-all --aggregate-output --parallel js-compile-*",
|
||||||
|
@ -75,11 +75,13 @@
|
||||||
"js-test-jquery": "cross-env JQUERY=true npm run js-test-karma",
|
"js-test-jquery": "cross-env JQUERY=true npm run js-test-karma",
|
||||||
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel js-lint css-lint lockfile-lint",
|
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel js-lint css-lint lockfile-lint",
|
||||||
"docs": "npm-run-all docs-build docs-lint",
|
"docs": "npm-run-all docs-build docs-lint",
|
||||||
"docs-build": "hugo --cleanDestinationDir --printUnusedTemplates",
|
"docs-build": "npm run astro-build",
|
||||||
"docs-compile": "npm run docs-build",
|
"docs-compile": "npm run docs-build",
|
||||||
"docs-vnu": "node build/vnu-jar.mjs",
|
"docs-vnu": "node build/vnu-jar.mjs",
|
||||||
"docs-lint": "npm run docs-vnu",
|
"docs-lint": "npm-run-all docs-prettier-check docs-vnu",
|
||||||
"docs-serve": "hugo server --port 9001 --disableFastRender --noHTTPCache --renderToMemory --printPathWarnings --printUnusedTemplates",
|
"docs-prettier-check": "prettier --config site/.prettierrc.json -c --cache site",
|
||||||
|
"docs-prettier-format": "prettier --config site/.prettierrc.json --write --cache site",
|
||||||
|
"docs-serve": "npm run astro-dev",
|
||||||
"docs-serve-only": "npx sirv-cli _site --port 9001",
|
"docs-serve-only": "npx sirv-cli _site --port 9001",
|
||||||
"lockfile-lint": "lockfile-lint --allowed-hosts npm --allowed-schemes https: --empty-hostname false --type npm --path package-lock.json",
|
"lockfile-lint": "lockfile-lint --allowed-hosts npm --allowed-schemes https: --empty-hostname false --type npm --path package-lock.json",
|
||||||
"update-deps": "ncu -u -x eslint,eslint-config-xo,karma-browserstack-launcher,karma-rollup-preprocessor,sass",
|
"update-deps": "ncu -u -x eslint,eslint-config-xo,karma-browserstack-launcher,karma-rollup-preprocessor,sass",
|
||||||
|
@ -90,19 +92,27 @@
|
||||||
"release-zip-examples": "node build/zip-examples.mjs",
|
"release-zip-examples": "node build/zip-examples.mjs",
|
||||||
"dist": "npm-run-all --aggregate-output --parallel css js",
|
"dist": "npm-run-all --aggregate-output --parallel css js",
|
||||||
"test": "npm-run-all lint dist js-test docs-build docs-lint",
|
"test": "npm-run-all lint dist js-test docs-build docs-lint",
|
||||||
"netlify": "cross-env-shell HUGO_BASEURL=$DEPLOY_PRIME_URL npm-run-all dist release-sri docs-build",
|
"netlify": "npm-run-all dist release-sri astro-build",
|
||||||
"watch": "npm-run-all --parallel watch-*",
|
"watch": "npm-run-all --parallel watch-*",
|
||||||
"watch-css-main": "nodemon --watch scss/ --ext scss --exec \"npm-run-all css-lint css-compile css-prefix\"",
|
"watch-css-main": "nodemon --watch scss/ --ext scss --exec \"npm-run-all css-lint css-compile css-prefix\"",
|
||||||
"watch-css-dist": "nodemon --watch dist/css/ --ext css --ignore \"dist/css/*.rtl.*\" --exec \"npm run css-rtl\"",
|
"watch-css-dist": "nodemon --watch dist/css/ --ext css --ignore \"dist/css/*.rtl.*\" --exec \"npm run css-rtl\"",
|
||||||
"watch-css-docs": "nodemon --watch site/assets/scss/ --ext scss --exec \"npm run css-lint\"",
|
"watch-css-docs": "nodemon --watch site/src/scss/ --ext scss --exec \"npm run css-lint\"",
|
||||||
"watch-css-test": "nodemon --watch scss/ --ext scss,js --exec \"npm run css-test\"",
|
"watch-css-test": "nodemon --watch scss/ --ext scss,js --exec \"npm run css-test\"",
|
||||||
"watch-js-main": "nodemon --watch js/src/ --ext js --exec \"npm-run-all js-lint js-compile\"",
|
"watch-js-main": "nodemon --watch js/src/ --ext js --exec \"npm-run-all js-lint js-compile\"",
|
||||||
"watch-js-docs": "nodemon --watch site/assets/js/ --ext js --exec \"npm run js-lint\""
|
"watch-js-docs": "nodemon --watch site/src/assets/ --ext js --exec \"npm run js-lint\"",
|
||||||
|
"astro-dev": "astro dev --root site",
|
||||||
|
"astro-build": "astro build --root site && rm -rf _site && cp -r site/dist _site",
|
||||||
|
"astro-preview": "astro preview --root site"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@popperjs/core": "^2.11.8"
|
"@popperjs/core": "^2.11.8"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@astrojs/check": "^0.9.4",
|
||||||
|
"@astrojs/markdown-remark": "^6.3.1",
|
||||||
|
"@astrojs/mdx": "^4.2.3",
|
||||||
|
"@astrojs/prism": "^3.2.0",
|
||||||
|
"@astrojs/sitemap": "^3.3.0",
|
||||||
"@babel/cli": "^7.27.0",
|
"@babel/cli": "^7.27.0",
|
||||||
"@babel/core": "^7.26.10",
|
"@babel/core": "^7.26.10",
|
||||||
"@babel/preset-env": "^7.26.9",
|
"@babel/preset-env": "^7.26.9",
|
||||||
|
@ -113,6 +123,12 @@
|
||||||
"@rollup/plugin-node-resolve": "^16.0.1",
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
||||||
"@rollup/plugin-replace": "^6.0.2",
|
"@rollup/plugin-replace": "^6.0.2",
|
||||||
"@stackblitz/sdk": "^1.11.0",
|
"@stackblitz/sdk": "^1.11.0",
|
||||||
|
"@types/google.analytics": "^0.0.42",
|
||||||
|
"@types/js-yaml": "^4.0.5",
|
||||||
|
"@types/mime": "^3.0.1",
|
||||||
|
"@types/prismjs": "^1.26.0",
|
||||||
|
"astro": "^5.6.1",
|
||||||
|
"astro-auto-import": "^0.4.4",
|
||||||
"autoprefixer": "^10.4.21",
|
"autoprefixer": "^10.4.21",
|
||||||
"bundlewatch": "^0.4.0",
|
"bundlewatch": "^0.4.0",
|
||||||
"clean-css-cli": "^5.6.3",
|
"clean-css-cli": "^5.6.3",
|
||||||
|
@ -125,12 +141,15 @@
|
||||||
"eslint-plugin-markdown": "^5.1.0",
|
"eslint-plugin-markdown": "^5.1.0",
|
||||||
"eslint-plugin-unicorn": "^55.0.0",
|
"eslint-plugin-unicorn": "^55.0.0",
|
||||||
"find-unused-sass-variables": "^6.1.0",
|
"find-unused-sass-variables": "^6.1.0",
|
||||||
|
"github-slugger": "^2.0.0",
|
||||||
"globby": "^14.1.0",
|
"globby": "^14.1.0",
|
||||||
"hammer-simulator": "0.0.1",
|
"hammer-simulator": "0.0.1",
|
||||||
"hugo-bin": "^0.142.0",
|
"htmlparser2": "^8.0.1",
|
||||||
|
"image-size": "^1.0.2",
|
||||||
"ip": "^2.0.1",
|
"ip": "^2.0.1",
|
||||||
"jasmine": "^5.6.0",
|
"jasmine": "^5.6.0",
|
||||||
"jquery": "^3.7.1",
|
"jquery": "^3.7.1",
|
||||||
|
"js-yaml": "^4.1.0",
|
||||||
"karma": "^6.4.4",
|
"karma": "^6.4.4",
|
||||||
"karma-browserstack-launcher": "1.4.0",
|
"karma-browserstack-launcher": "1.4.0",
|
||||||
"karma-chrome-launcher": "^3.2.0",
|
"karma-chrome-launcher": "^3.2.0",
|
||||||
|
@ -141,10 +160,16 @@
|
||||||
"karma-jasmine-html-reporter": "^2.1.0",
|
"karma-jasmine-html-reporter": "^2.1.0",
|
||||||
"karma-rollup-preprocessor": "7.0.7",
|
"karma-rollup-preprocessor": "7.0.7",
|
||||||
"lockfile-lint": "^4.14.0",
|
"lockfile-lint": "^4.14.0",
|
||||||
|
"mime": "^3.0.0",
|
||||||
"nodemon": "^3.1.9",
|
"nodemon": "^3.1.9",
|
||||||
"npm-run-all2": "^7.0.2",
|
"npm-run-all2": "^7.0.2",
|
||||||
"postcss": "^8.5.3",
|
"postcss": "^8.5.3",
|
||||||
"postcss-cli": "^11.0.1",
|
"postcss-cli": "^11.0.1",
|
||||||
|
"prettier": "^2.8.4",
|
||||||
|
"prettier-plugin-astro": "^0.8.0",
|
||||||
|
"rehype-autolink-headings": "^6.1.1",
|
||||||
|
"remark": "^15.0.1",
|
||||||
|
"remark-html": "^16.0.1",
|
||||||
"rollup": "^4.38.0",
|
"rollup": "^4.38.0",
|
||||||
"rollup-plugin-istanbul": "^5.0.0",
|
"rollup-plugin-istanbul": "^5.0.0",
|
||||||
"rtlcss": "^4.3.0",
|
"rtlcss": "^4.3.0",
|
||||||
|
@ -154,7 +179,9 @@
|
||||||
"stylelint": "^16.17.0",
|
"stylelint": "^16.17.0",
|
||||||
"stylelint-config-twbs-bootstrap": "^16.0.0",
|
"stylelint-config-twbs-bootstrap": "^16.0.0",
|
||||||
"terser": "^5.39.0",
|
"terser": "^5.39.0",
|
||||||
"vnu-jar": "24.10.17"
|
"unist-util-visit": "^4.1.2",
|
||||||
|
"vnu-jar": "24.10.17",
|
||||||
|
"zod": "^3.20.6"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist/{css,js}/*.{css,js,map}",
|
"dist/{css,js}/*.{css,js,map}",
|
||||||
|
@ -163,9 +190,6 @@
|
||||||
"scss/**/*.scss",
|
"scss/**/*.scss",
|
||||||
"!scss/tests/**"
|
"!scss/tests/**"
|
||||||
],
|
],
|
||||||
"hugo-bin": {
|
|
||||||
"buildTags": "extended"
|
|
||||||
},
|
|
||||||
"jspm": {
|
"jspm": {
|
||||||
"registry": "npm",
|
"registry": "npm",
|
||||||
"main": "js/bootstrap",
|
"main": "js/bootstrap",
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"$schema": "http://json.schemastore.org/prettierrc",
|
||||||
|
"arrowParens": "always",
|
||||||
|
"printWidth": 120,
|
||||||
|
"semi": false,
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "none"
|
||||||
|
}
|
|
@ -1,95 +0,0 @@
|
||||||
// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
|
|
||||||
// IT'S ALL JUST JUNK FOR OUR DOCS!
|
|
||||||
// ++++++++++++++++++++++++++++++++++++++++++
|
|
||||||
|
|
||||||
/*
|
|
||||||
* JavaScript for Bootstrap's docs (https://getbootstrap.com/)
|
|
||||||
* Copyright 2011-2025 The Bootstrap Authors
|
|
||||||
* Licensed under the Creative Commons Attribution 3.0 Unported License.
|
|
||||||
* For details, see https://creativecommons.org/licenses/by/3.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* global bootstrap: false */
|
|
||||||
|
|
||||||
import ClipboardJS from 'clipboard'
|
|
||||||
|
|
||||||
export default () => {
|
|
||||||
// Insert copy to clipboard button before .highlight
|
|
||||||
const btnTitle = 'Copy to clipboard'
|
|
||||||
const btnEdit = 'Edit on StackBlitz'
|
|
||||||
|
|
||||||
const btnHtml = [
|
|
||||||
'<div class="bd-code-snippet">',
|
|
||||||
' <div class="bd-clipboard">',
|
|
||||||
' <button type="button" class="btn-clipboard">',
|
|
||||||
' <svg class="bi" role="img" aria-label="Copy"><use xlink:href="#clipboard"/></svg>',
|
|
||||||
' </button>',
|
|
||||||
' </div>',
|
|
||||||
'</div>'
|
|
||||||
].join('')
|
|
||||||
|
|
||||||
// Wrap programmatically code blocks and add copy btn.
|
|
||||||
document.querySelectorAll('.highlight')
|
|
||||||
.forEach(element => {
|
|
||||||
// Ignore examples made by shortcode
|
|
||||||
if (!element.closest('.bd-example-snippet')) {
|
|
||||||
element.insertAdjacentHTML('beforebegin', btnHtml)
|
|
||||||
element.previousElementSibling.append(element)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {string} selector
|
|
||||||
* @param {string} title
|
|
||||||
*/
|
|
||||||
function snippetButtonTooltip(selector, title) {
|
|
||||||
document.querySelectorAll(selector).forEach(btn => {
|
|
||||||
bootstrap.Tooltip.getOrCreateInstance(btn, { title })
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
snippetButtonTooltip('.btn-clipboard', btnTitle)
|
|
||||||
snippetButtonTooltip('.btn-edit', btnEdit)
|
|
||||||
|
|
||||||
const clipboard = new ClipboardJS('.btn-clipboard', {
|
|
||||||
target: trigger => trigger.closest('.bd-code-snippet').querySelector('.highlight'),
|
|
||||||
text: trigger => trigger.closest('.bd-code-snippet').querySelector('.highlight').textContent.trimEnd()
|
|
||||||
})
|
|
||||||
|
|
||||||
clipboard.on('success', event => {
|
|
||||||
const iconFirstChild = event.trigger.querySelector('.bi').firstElementChild
|
|
||||||
const tooltipBtn = bootstrap.Tooltip.getInstance(event.trigger)
|
|
||||||
const namespace = 'http://www.w3.org/1999/xlink'
|
|
||||||
const originalXhref = iconFirstChild.getAttributeNS(namespace, 'href')
|
|
||||||
const originalTitle = event.trigger.title
|
|
||||||
const isCheckIconVisible = originalXhref === '#check2'
|
|
||||||
|
|
||||||
if (isCheckIconVisible) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
tooltipBtn.setContent({ '.tooltip-inner': 'Copied!' })
|
|
||||||
event.trigger.addEventListener('hidden.bs.tooltip', () => {
|
|
||||||
tooltipBtn.setContent({ '.tooltip-inner': btnTitle })
|
|
||||||
}, { once: true })
|
|
||||||
event.clearSelection()
|
|
||||||
iconFirstChild.setAttributeNS(namespace, 'href', originalXhref.replace('clipboard', 'check2'))
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
iconFirstChild.setAttributeNS(namespace, 'href', originalXhref)
|
|
||||||
event.trigger.title = originalTitle
|
|
||||||
}, 2000)
|
|
||||||
})
|
|
||||||
|
|
||||||
clipboard.on('error', event => {
|
|
||||||
const modifierKey = /mac/i.test(navigator.userAgent) ? '\u2318' : 'Ctrl-'
|
|
||||||
const fallbackMsg = `Press ${modifierKey}C to copy`
|
|
||||||
const tooltipBtn = bootstrap.Tooltip.getInstance(event.trigger)
|
|
||||||
|
|
||||||
tooltipBtn.setContent({ '.tooltip-inner': fallbackMsg })
|
|
||||||
event.trigger.addEventListener('hidden.bs.tooltip', () => {
|
|
||||||
tooltipBtn.setContent({ '.tooltip-inner': btnTitle })
|
|
||||||
}, { once: true })
|
|
||||||
})
|
|
||||||
}
|
|
|
@ -1,142 +0,0 @@
|
||||||
:root,
|
|
||||||
[data-bs-theme="light"] {
|
|
||||||
// --base00: #fff;
|
|
||||||
// --base01: #f5f5f5;
|
|
||||||
--base02: #c8c8fa;
|
|
||||||
--base03: #565c64;
|
|
||||||
--base04: #666;
|
|
||||||
--base05: #333;
|
|
||||||
--base06: #fff;
|
|
||||||
--base07: #{$teal-700}; // #9a6700
|
|
||||||
--base08: #{mix($red-500, $red-600, 50%)}; // #bc4c00
|
|
||||||
--base09: #{$cyan-700}; // #087990
|
|
||||||
--base0A: #{$purple-500}; // #795da3
|
|
||||||
--base0B: #{$blue-700}; // #183691
|
|
||||||
--base0C: #{$blue-700}; // #183691
|
|
||||||
--base0D: #{$purple-500}; // #795da3
|
|
||||||
--base0E: #{$pink-600}; // #a71d5d
|
|
||||||
--base0F: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
@include color-mode(dark, true) {
|
|
||||||
// --base00: #282c34;
|
|
||||||
// --base01: #353b45;
|
|
||||||
--base02: #3e4451;
|
|
||||||
--base03: #868e96;
|
|
||||||
--base04: #868e96;
|
|
||||||
--base05: #abb2bf;
|
|
||||||
--base06: #b6bdca;
|
|
||||||
--base07: #{$orange-300}; // #d19a66
|
|
||||||
--base08: #{$cyan-300};
|
|
||||||
--base09: #{$orange-300}; // #d19a66
|
|
||||||
--base0A: #{$yellow-200}; // #e5c07b
|
|
||||||
--base0B: #{$teal-300}; // #98c379
|
|
||||||
--base0C: #{$teal-300}; // #56b6c2
|
|
||||||
--base0D: #{$blue-300}; // #61afef
|
|
||||||
--base0E: #{$indigo-200}; // #c678dd
|
|
||||||
--base0F: #{$red-300}; // #be5046
|
|
||||||
|
|
||||||
.language-diff .gd {
|
|
||||||
color: $red-400;
|
|
||||||
}
|
|
||||||
.language-diff .gi {
|
|
||||||
color: $green-400;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.hl { background-color: var(--base02); }
|
|
||||||
.c { color: var(--base03); }
|
|
||||||
.err { color: var(--base08); }
|
|
||||||
.k { color: var(--base0E); }
|
|
||||||
.l { color: var(----base09); }
|
|
||||||
.n { color: var(--base08); }
|
|
||||||
.o { color: var(--base05); }
|
|
||||||
.p { color: var(--base05); }
|
|
||||||
.cm { color: var(--base04); }
|
|
||||||
.cp { color: var(--base08); }
|
|
||||||
.c1 { color: var(--base03); }
|
|
||||||
.cs { color: var(--base04); }
|
|
||||||
.gd { color: var(--base08); }
|
|
||||||
.ge { font-style: italic; }
|
|
||||||
.gh {
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--base0A);
|
|
||||||
}
|
|
||||||
.gi { color: var(--bs-success); }
|
|
||||||
.gp {
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--base04);
|
|
||||||
}
|
|
||||||
.gs { font-weight: 600; }
|
|
||||||
.gu {
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--base0C);
|
|
||||||
}
|
|
||||||
.kc { color: var(--base0E); }
|
|
||||||
.kd { color: var(--base0E); }
|
|
||||||
.kn { color: var(--base0C); }
|
|
||||||
.kp { color: var(--base0E); }
|
|
||||||
.kr { color: var(--base0E); }
|
|
||||||
.kt { color: var(--base0A); }
|
|
||||||
.ld { color: var(--base0C); }
|
|
||||||
.m { color: var(--base09); }
|
|
||||||
.s { color: var(--base0C); }
|
|
||||||
.na { color: var(--base0A); }
|
|
||||||
.nb { color: var(--base05); }
|
|
||||||
.nc { color: var(--base07); }
|
|
||||||
.no { color: var(--base08); }
|
|
||||||
.nd { color: var(--base07); }
|
|
||||||
.ni { color: var(--base08); }
|
|
||||||
.ne { color: var(--base08); }
|
|
||||||
.nf { color: var(--base0B); }
|
|
||||||
.nl { color: var(--base05); }
|
|
||||||
.nn { color: var(--base0A); }
|
|
||||||
.nx { color: var(--base0A); }
|
|
||||||
.py { color: var(--base08); }
|
|
||||||
.nt { color: var(--base08); }
|
|
||||||
.nv { color: var(--base08); }
|
|
||||||
.ow { color: var(--base0C); }
|
|
||||||
.w { color: #fff; }
|
|
||||||
.mf { color: var(--base09); }
|
|
||||||
.mh { color: var(--base09); }
|
|
||||||
.mi { color: var(--base09); }
|
|
||||||
.mo { color: var(--base09); }
|
|
||||||
.sb { color: var(--base0C); }
|
|
||||||
.sc { color: #fff; }
|
|
||||||
.sd { color: var(--base04); }
|
|
||||||
.s2 { color: var(--base0C); }
|
|
||||||
.se { color: var(--base09); }
|
|
||||||
.sh { color: var(--base0C); }
|
|
||||||
.si { color: var(--base09); }
|
|
||||||
.sx { color: var(--base0C); }
|
|
||||||
.sr { color: var(--base0C); }
|
|
||||||
.s1 { color: var(--base0C); }
|
|
||||||
.ss { color: var(--base0C); }
|
|
||||||
.bp { color: var(--base05); }
|
|
||||||
.vc { color: var(--base08); }
|
|
||||||
.vg { color: var(--base08); }
|
|
||||||
.vi { color: var(--base08); }
|
|
||||||
.il { color: var(--base09); }
|
|
||||||
|
|
||||||
// Color commas in rgba() values
|
|
||||||
.m + .o { color: var(--base03); }
|
|
||||||
|
|
||||||
// Fix bash
|
|
||||||
.language-sh .c { color: var(--base03); }
|
|
||||||
|
|
||||||
.chroma {
|
|
||||||
.language-bash,
|
|
||||||
.language-sh {
|
|
||||||
.line::before {
|
|
||||||
color: var(--base03);
|
|
||||||
content: "$ ";
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.language-powershell::before {
|
|
||||||
color: var(--base0C);
|
|
||||||
content: "PM> ";
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
import { defineConfig } from 'astro/config'
|
||||||
|
|
||||||
|
import { bootstrap } from './src/libs/astro'
|
||||||
|
import { getConfig } from './src/libs/config'
|
||||||
|
import { algoliaPlugin } from './src/plugins/algolia-plugin'
|
||||||
|
import { stackblitzPlugin } from './src/plugins/stackblitz-plugin'
|
||||||
|
|
||||||
|
const isDev = process.env.NODE_ENV === 'development'
|
||||||
|
|
||||||
|
const site = isDev
|
||||||
|
? // In development mode, use the local dev server.
|
||||||
|
'http://localhost:4321'
|
||||||
|
: process.env.DEPLOY_PRIME_URL !== undefined
|
||||||
|
? // If deploying on Netlify, use the `DEPLOY_PRIME_URL` environment variable.
|
||||||
|
process.env.DEPLOY_PRIME_URL
|
||||||
|
: // Otherwise, use the `baseURL` value defined in the `config.yml` file.
|
||||||
|
getConfig().baseURL
|
||||||
|
|
||||||
|
// https://astro.build/config
|
||||||
|
export default defineConfig({
|
||||||
|
integrations: [bootstrap()],
|
||||||
|
markdown: {
|
||||||
|
smartypants: false,
|
||||||
|
syntaxHighlight: 'prism'
|
||||||
|
},
|
||||||
|
site,
|
||||||
|
vite: {
|
||||||
|
plugins: [algoliaPlugin(), stackblitzPlugin()]
|
||||||
|
}
|
||||||
|
})
|
|
@ -1,14 +0,0 @@
|
||||||
---
|
|
||||||
title: "404 - File not found"
|
|
||||||
layout: 404
|
|
||||||
description: ""
|
|
||||||
url: /404.html
|
|
||||||
robots: noindex,follow
|
|
||||||
sitemap:
|
|
||||||
disable: true
|
|
||||||
---
|
|
||||||
|
|
||||||
<div class="text-center py-5">
|
|
||||||
<h1 class="display-1">404</h1>
|
|
||||||
<h2>File not found</h2>
|
|
||||||
</div>
|
|
|
@ -1,6 +0,0 @@
|
||||||
---
|
|
||||||
layout: redirect
|
|
||||||
sitemap:
|
|
||||||
disable: true
|
|
||||||
redirect: "/docs/5.3/getting-started/introduction/"
|
|
||||||
---
|
|
|
@ -1,23 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Team
|
|
||||||
description: An overview of the founding team and core contributors to Bootstrap.
|
|
||||||
group: about
|
|
||||||
---
|
|
||||||
|
|
||||||
Bootstrap is maintained by the founding team and a small group of invaluable core contributors, with the massive support and involvement of our community.
|
|
||||||
|
|
||||||
{{< team.inline >}}
|
|
||||||
<div class="list-group mb-3">
|
|
||||||
{{- range (index $.Site.Data "core-team") }}
|
|
||||||
<a class="list-group-item list-group-item-action d-flex align-items-center" href="https://github.com/{{ .user }}">
|
|
||||||
<img src="https://github.com/{{ .user }}.png" alt="@{{ .user }}" width="32" height="32" class="rounded me-2" loading="lazy">
|
|
||||||
<span>
|
|
||||||
<strong>{{ .name }}</strong> @{{ .user }}
|
|
||||||
</span>
|
|
||||||
</a>
|
|
||||||
{{ end -}}
|
|
||||||
</div>
|
|
||||||
{{< /team.inline >}}
|
|
||||||
|
|
||||||
Get involved with Bootstrap development by [opening an issue]({{< param repo >}}/issues/new/choose) or submitting a pull request. Read our [contributing guidelines]({{< param repo >}}/blob/v{{< param current_version >}}/.github/CONTRIBUTING.md) for information on how we develop.
|
|
|
@ -1,20 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Translations
|
|
||||||
description: Links to community-translated Bootstrap documentation sites.
|
|
||||||
group: about
|
|
||||||
---
|
|
||||||
|
|
||||||
Community members have translated Bootstrap's documentation into various languages. None are officially supported and they may not always be up-to-date.
|
|
||||||
|
|
||||||
{{< translations.inline >}}
|
|
||||||
<ul>
|
|
||||||
{{ range .Site.Data.translations -}}
|
|
||||||
<li><a href="{{ .url }}" hreflang="{{ .code }}" lang="{{ .code }}">{{ .description }} ({{ .name }})</a></li>
|
|
||||||
{{ end -}}
|
|
||||||
</ul>
|
|
||||||
{{< /translations.inline >}}
|
|
||||||
|
|
||||||
**We don't help organize or host translations, we just link to them.**
|
|
||||||
|
|
||||||
Finished a new or better translation? Open a pull request to add it to our list.
|
|
|
@ -1,169 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Accordion
|
|
||||||
description: Build vertically collapsing accordions in combination with our Collapse JavaScript plugin.
|
|
||||||
group: components
|
|
||||||
aliases:
|
|
||||||
- "/components/"
|
|
||||||
- "/docs/5.3/components/"
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## How it works
|
|
||||||
|
|
||||||
The accordion uses [collapse]({{< docsref "/components/collapse" >}}) internally to make it collapsible.
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
{{< partial "callouts/info-prefersreducedmotion.md" >}}
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
Click the accordions below to expand/collapse the accordion content.
|
|
||||||
|
|
||||||
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`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="accordion" id="accordionExample">
|
|
||||||
<div class="accordion-item">
|
|
||||||
<h2 class="accordion-header">
|
|
||||||
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
|
|
||||||
Accordion Item #1
|
|
||||||
</button>
|
|
||||||
</h2>
|
|
||||||
<div id="collapseOne" class="accordion-collapse collapse show" data-bs-parent="#accordionExample">
|
|
||||||
<div class="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>
|
|
||||||
<div class="accordion-item">
|
|
||||||
<h2 class="accordion-header">
|
|
||||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
|
|
||||||
Accordion Item #2
|
|
||||||
</button>
|
|
||||||
</h2>
|
|
||||||
<div id="collapseTwo" class="accordion-collapse collapse" data-bs-parent="#accordionExample">
|
|
||||||
<div class="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>
|
|
||||||
<div class="accordion-item">
|
|
||||||
<h2 class="accordion-header">
|
|
||||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
|
|
||||||
Accordion Item #3
|
|
||||||
</button>
|
|
||||||
</h2>
|
|
||||||
<div id="collapseThree" class="accordion-collapse collapse" data-bs-parent="#accordionExample">
|
|
||||||
<div class="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>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Flush
|
|
||||||
|
|
||||||
Add `.accordion-flush` to remove some borders and rounded corners to render accordions edge-to-edge with their parent container.
|
|
||||||
|
|
||||||
{{< example class="bg-body-secondary" >}}
|
|
||||||
<div class="accordion accordion-flush" id="accordionFlushExample">
|
|
||||||
<div class="accordion-item">
|
|
||||||
<h2 class="accordion-header">
|
|
||||||
<button class="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>
|
|
||||||
<div id="flush-collapseOne" class="accordion-collapse collapse" data-bs-parent="#accordionFlushExample">
|
|
||||||
<div class="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>
|
|
||||||
<div class="accordion-item">
|
|
||||||
<h2 class="accordion-header">
|
|
||||||
<button class="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>
|
|
||||||
<div id="flush-collapseTwo" class="accordion-collapse collapse" data-bs-parent="#accordionFlushExample">
|
|
||||||
<div class="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>
|
|
||||||
<div class="accordion-item">
|
|
||||||
<h2 class="accordion-header">
|
|
||||||
<button class="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>
|
|
||||||
<div id="flush-collapseThree" class="accordion-collapse collapse" data-bs-parent="#accordionFlushExample">
|
|
||||||
<div class="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>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Always open
|
|
||||||
|
|
||||||
Omit the `data-bs-parent` attribute on each `.accordion-collapse` to make accordion items stay open when another item is opened.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="accordion" id="accordionPanelsStayOpenExample">
|
|
||||||
<div class="accordion-item">
|
|
||||||
<h2 class="accordion-header">
|
|
||||||
<button class="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>
|
|
||||||
<div id="panelsStayOpen-collapseOne" class="accordion-collapse collapse show">
|
|
||||||
<div class="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>
|
|
||||||
<div class="accordion-item">
|
|
||||||
<h2 class="accordion-header">
|
|
||||||
<button class="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>
|
|
||||||
<div id="panelsStayOpen-collapseTwo" class="accordion-collapse collapse">
|
|
||||||
<div class="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>
|
|
||||||
<div class="accordion-item">
|
|
||||||
<h2 class="accordion-header">
|
|
||||||
<button class="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>
|
|
||||||
<div id="panelsStayOpen-collapseThree" class="accordion-collapse collapse">
|
|
||||||
<div class="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>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Accessibility
|
|
||||||
|
|
||||||
Please read the [collapse accessibility section]({{< docsref "/components/collapse#accessibility" >}}) for more information.
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Variables
|
|
||||||
|
|
||||||
{{< added-in "5.2.0" >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< scss-docs name="accordion-css-vars" file="scss/_accordion.scss" >}}
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
{{< scss-docs name="accordion-variables" file="scss/_variables.scss" >}}
|
|
|
@ -1,240 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Alerts
|
|
||||||
description: Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages.
|
|
||||||
group: components
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## 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](#dismissing).
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
**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](#sass-loops).
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
{{< alerts.inline >}}
|
|
||||||
{{- range (index $.Site.Data "theme-colors") }}
|
|
||||||
<div class="alert alert-{{ .name }}" role="alert">
|
|
||||||
A simple {{ .name }} alert—check it out!
|
|
||||||
</div>{{- end -}}
|
|
||||||
{{< /alerts.inline >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
{{< partial "callouts/warning-color-assistive-technologies.md" >}}
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
### 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.
|
|
||||||
|
|
||||||
{{< example stackblitz_add_js="true" >}}
|
|
||||||
<div id="liveAlertPlaceholder"></div>
|
|
||||||
<button type="button" class="btn btn-primary" id="liveAlertBtn">Show live alert</button>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
We use the following JavaScript to trigger our live alert demo:
|
|
||||||
|
|
||||||
{{< js-docs name="live-alert" file="site/assets/js/partials/snippets.js" >}}
|
|
||||||
|
|
||||||
### Link color
|
|
||||||
|
|
||||||
Use the `.alert-link` utility class to quickly provide matching colored links within any alert.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
{{< alerts.inline >}}
|
|
||||||
{{- range (index $.Site.Data "theme-colors") }}
|
|
||||||
<div class="alert alert-{{ .name }}" role="alert">
|
|
||||||
A simple {{ .name }} alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
|
|
||||||
</div>{{ end -}}
|
|
||||||
{{< /alerts.inline >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Additional content
|
|
||||||
|
|
||||||
Alerts can also contain additional HTML elements like headings, paragraphs and dividers.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="alert alert-success" role="alert">
|
|
||||||
<h4 class="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>
|
|
||||||
<p class="mb-0">Whenever you need to, be sure to use margin utilities to keep things nice and tidy.</p>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Icons
|
|
||||||
|
|
||||||
Similarly, you can use [flexbox utilities]({{< docsref "/utilities/flex" >}}) and [Bootstrap Icons]({{< param icons >}}) to create alerts with icons. Depending on your icons and content, you may want to add more utilities or custom styles.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="alert alert-primary d-flex align-items-center" role="alert">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="bi flex-shrink-0 me-2" viewBox="0 0 16 16" role="img" aria-label="Warning:">
|
|
||||||
<path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
|
|
||||||
</svg>
|
|
||||||
<div>
|
|
||||||
An example alert with an icon
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="d-none">
|
|
||||||
<symbol id="check-circle-fill" viewBox="0 0 16 16">
|
|
||||||
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
|
|
||||||
</symbol>
|
|
||||||
<symbol id="info-fill" viewBox="0 0 16 16">
|
|
||||||
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
|
|
||||||
</symbol>
|
|
||||||
<symbol id="exclamation-triangle-fill" viewBox="0 0 16 16">
|
|
||||||
<path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
|
|
||||||
</symbol>
|
|
||||||
</svg>
|
|
||||||
|
|
||||||
<div class="alert alert-primary d-flex align-items-center" role="alert">
|
|
||||||
<svg class="bi flex-shrink-0 me-2" role="img" aria-label="Info:"><use xlink:href="#info-fill"/></svg>
|
|
||||||
<div>
|
|
||||||
An example alert with an icon
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="alert alert-success d-flex align-items-center" role="alert">
|
|
||||||
<svg class="bi flex-shrink-0 me-2" role="img" aria-label="Success:"><use xlink:href="#check-circle-fill"/></svg>
|
|
||||||
<div>
|
|
||||||
An example success alert with an icon
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="alert alert-warning d-flex align-items-center" role="alert">
|
|
||||||
<svg class="bi flex-shrink-0 me-2" role="img" aria-label="Warning:"><use xlink:href="#exclamation-triangle-fill"/></svg>
|
|
||||||
<div>
|
|
||||||
An example warning alert with an icon
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="alert alert-danger d-flex align-items-center" role="alert">
|
|
||||||
<svg class="bi flex-shrink-0 me-2" role="img" aria-label="Danger:"><use xlink:href="#exclamation-triangle-fill"/></svg>
|
|
||||||
<div>
|
|
||||||
An example danger alert with an icon
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### 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]({{< docsref "/components/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:
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="alert alert-warning alert-dismissible fade show" role="alert">
|
|
||||||
<strong>Holy guacamole!</strong> You should check in on some of those fields below.
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< callout warning >}}
|
|
||||||
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.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Variables
|
|
||||||
|
|
||||||
{{< added-in "5.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.
|
|
||||||
|
|
||||||
{{< scss-docs name="alert-css-vars" file="scss/_alert.scss" >}}
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
{{< scss-docs name="alert-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
### Sass mixins
|
|
||||||
|
|
||||||
{{< deprecated-in "5.3.0" >}}
|
|
||||||
|
|
||||||
{{< scss-docs name="alert-variant-mixin" file="scss/mixins/_alert.scss" >}}
|
|
||||||
|
|
||||||
### Sass loops
|
|
||||||
|
|
||||||
Loop that generates the modifier classes with an overriding of CSS variables.
|
|
||||||
|
|
||||||
{{< scss-docs name="alert-modifiers" file="scss/_alert.scss" >}}
|
|
||||||
|
|
||||||
## JavaScript behavior
|
|
||||||
|
|
||||||
### Initialize
|
|
||||||
|
|
||||||
Initialize elements as alerts
|
|
||||||
|
|
||||||
```js
|
|
||||||
const alertList = document.querySelectorAll('.alert')
|
|
||||||
const alerts = [...alertList].map(element => new bootstrap.Alert(element))
|
|
||||||
```
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
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.
|
|
||||||
|
|
||||||
See the [triggers](#triggers) section for more details.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
### Triggers
|
|
||||||
|
|
||||||
{{% js-dismiss "alert" %}}
|
|
||||||
|
|
||||||
**Note that closing an alert will remove it from the DOM.**
|
|
||||||
|
|
||||||
### Methods
|
|
||||||
|
|
||||||
You can create an alert instance with the alert constructor, for example:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const bsAlert = new bootstrap.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.)
|
|
||||||
|
|
||||||
{{< bs-table >}}
|
|
||||||
| 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)`. |
|
|
||||||
{{< /bs-table >}}
|
|
||||||
|
|
||||||
Basic usage:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const alert = bootstrap.Alert.getOrCreateInstance('#myAlert')
|
|
||||||
alert.close()
|
|
||||||
```
|
|
||||||
|
|
||||||
### Events
|
|
||||||
|
|
||||||
Bootstrap's alert plugin exposes a few events for hooking into alert functionality.
|
|
||||||
|
|
||||||
{{< bs-table >}}
|
|
||||||
| 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. |
|
|
||||||
{{< /bs-table >}}
|
|
||||||
|
|
||||||
```js
|
|
||||||
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()
|
|
||||||
})
|
|
||||||
```
|
|
|
@ -1,103 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Badges
|
|
||||||
description: Documentation and examples for badges, our small count and labeling component.
|
|
||||||
group: components
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
### Headings
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<h1>Example heading <span class="badge text-bg-secondary">New</span></h1>
|
|
||||||
<h2>Example heading <span class="badge text-bg-secondary">New</span></h2>
|
|
||||||
<h3>Example heading <span class="badge text-bg-secondary">New</span></h3>
|
|
||||||
<h4>Example heading <span class="badge text-bg-secondary">New</span></h4>
|
|
||||||
<h5>Example heading <span class="badge text-bg-secondary">New</span></h5>
|
|
||||||
<h6>Example heading <span class="badge text-bg-secondary">New</span></h6>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Buttons
|
|
||||||
|
|
||||||
Badges can be used as part of links or buttons to provide a counter.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<button type="button" class="btn btn-primary">
|
|
||||||
Notifications <span class="badge text-bg-secondary">4</span>
|
|
||||||
</button>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
Use utilities to modify a `.badge` and position it in the corner of a link or button.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<button type="button" class="btn btn-primary position-relative">
|
|
||||||
Inbox
|
|
||||||
<span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger">
|
|
||||||
99+
|
|
||||||
<span class="visually-hidden">unread messages</span>
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
You can also replace the `.badge` class with a few more utilities without a count for a more generic indicator.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<button type="button" class="btn btn-primary position-relative">
|
|
||||||
Profile
|
|
||||||
<span class="position-absolute top-0 start-100 translate-middle p-2 bg-danger border border-light rounded-circle">
|
|
||||||
<span class="visually-hidden">New alerts</span>
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Background colors
|
|
||||||
|
|
||||||
{{< added-in "5.2.0" >}}
|
|
||||||
|
|
||||||
Set a `background-color` with contrasting foreground `color` with [our `.text-bg-{color}` helpers]({{< docsref "helpers/color-background" >}}). Previously it was required to manually pair your choice of [`.text-{color}`]({{< docsref "/utilities/colors" >}}) and [`.bg-{color}`]({{< docsref "/utilities/background" >}}) utilities for styling, which you still may use if you prefer.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
{{< badge.inline >}}
|
|
||||||
{{- range (index $.Site.Data "theme-colors") }}
|
|
||||||
<span class="badge text-bg-{{ .name }}">{{ .name | title }}</span>{{- end -}}
|
|
||||||
{{< /badge.inline >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
{{< partial "callouts/warning-color-assistive-technologies.md" >}}
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## Pill badges
|
|
||||||
|
|
||||||
Use the `.rounded-pill` utility class to make badges more rounded with a larger `border-radius`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
{{< badge.inline >}}
|
|
||||||
{{- range (index $.Site.Data "theme-colors") }}
|
|
||||||
<span class="badge rounded-pill text-bg-{{ .name }}">{{ .name | title }}</span>{{- end -}}
|
|
||||||
{{< /badge.inline >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Variables
|
|
||||||
|
|
||||||
{{< added-in "5.2.0" >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< scss-docs name="badge-css-vars" file="scss/_badge.scss" >}}
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
{{< scss-docs name="badge-variables" file="scss/_variables.scss" >}}
|
|
|
@ -1,108 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Breadcrumb
|
|
||||||
description: Indicate the current page's location within a navigational hierarchy that automatically adds separators via CSS.
|
|
||||||
group: components
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav aria-label="breadcrumb">
|
|
||||||
<ol class="breadcrumb">
|
|
||||||
<li class="breadcrumb-item active" aria-current="page">Home</li>
|
|
||||||
</ol>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<nav aria-label="breadcrumb">
|
|
||||||
<ol class="breadcrumb">
|
|
||||||
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
|
||||||
<li class="breadcrumb-item active" aria-current="page">Library</li>
|
|
||||||
</ol>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<nav aria-label="breadcrumb">
|
|
||||||
<ol class="breadcrumb">
|
|
||||||
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
|
||||||
<li class="breadcrumb-item"><a href="#">Library</a></li>
|
|
||||||
<li class="breadcrumb-item active" aria-current="page">Data</li>
|
|
||||||
</ol>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Dividers
|
|
||||||
|
|
||||||
Dividers are automatically added in CSS through [`::before`](https://developer.mozilla.org/en-US/docs/Web/CSS/::before) and [`content`](https://developer.mozilla.org/en-US/docs/Web/CSS/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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb">
|
|
||||||
<ol class="breadcrumb">
|
|
||||||
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
|
||||||
<li class="breadcrumb-item active" aria-current="page">Library</li>
|
|
||||||
</ol>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
When modifying via Sass, the [quote](https://sass-lang.com/documentation/modules/string/#quote) function is required to generate the quotes around a string. For example, using `>` as the divider, you can use this:
|
|
||||||
|
|
||||||
```scss
|
|
||||||
$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.
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
**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]({{< docsref "/customize/sass#escape-svg" >}}). When customizing the CSS variable, you must handle this yourself. Read [Kevin Weber's explanations on CodePen](https://codepen.io/kevinweber/pen/dXWoRw ) for more info.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav style="--bs-breadcrumb-divider: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M2.5 0L1 1.5 3.5 4 1 6.5 2.5 8l4-4-4-4z' fill='%236c757d'/%3E%3C/svg%3E");" aria-label="breadcrumb">
|
|
||||||
<ol class="breadcrumb">
|
|
||||||
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
|
||||||
<li class="breadcrumb-item active" aria-current="page">Library</li>
|
|
||||||
</ol>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
```scss
|
|
||||||
$breadcrumb-divider: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8'><path d='M2.5 0L1 1.5 3.5 4 1 6.5 2.5 8l4-4-4-4z' fill='#{$breadcrumb-divider-color}'/></svg>");
|
|
||||||
```
|
|
||||||
|
|
||||||
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;`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav style="--bs-breadcrumb-divider: '';" aria-label="breadcrumb">
|
|
||||||
<ol class="breadcrumb">
|
|
||||||
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
|
||||||
<li class="breadcrumb-item active" aria-current="page">Library</li>
|
|
||||||
</ol>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
|
|
||||||
```scss
|
|
||||||
$breadcrumb-divider: none;
|
|
||||||
```
|
|
||||||
|
|
||||||
## Accessibility
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
For more information, see the [ARIA Authoring Practices Guide breadcrumb pattern](https://www.w3.org/WAI/ARIA/apg/patterns/breadcrumb/).
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Variables
|
|
||||||
|
|
||||||
{{< added-in "5.2.0" >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< scss-docs name="breadcrumb-css-vars" file="scss/_breadcrumb.scss" >}}
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
{{< scss-docs name="breadcrumb-variables" file="scss/_variables.scss" >}}
|
|
|
@ -1,248 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Button group
|
|
||||||
description: Group a series of buttons together on a single line or stack them in a vertical column.
|
|
||||||
group: components
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## Basic example
|
|
||||||
|
|
||||||
Wrap a series of buttons with `.btn` in `.btn-group`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="btn-group" role="group" aria-label="Basic example">
|
|
||||||
<button type="button" class="btn btn-primary">Left</button>
|
|
||||||
<button type="button" class="btn btn-primary">Middle</button>
|
|
||||||
<button type="button" class="btn btn-primary">Right</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
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.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
These classes can also be added to groups of links, as an alternative to the [`.nav` navigation components]({{< docsref "/components/navs-tabs" >}}).
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="btn-group">
|
|
||||||
<a href="#" class="btn btn-primary active" aria-current="page">Active link</a>
|
|
||||||
<a href="#" class="btn btn-primary">Link</a>
|
|
||||||
<a href="#" class="btn btn-primary">Link</a>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Mixed styles
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="btn-group" role="group" aria-label="Basic mixed styles example">
|
|
||||||
<button type="button" class="btn btn-danger">Left</button>
|
|
||||||
<button type="button" class="btn btn-warning">Middle</button>
|
|
||||||
<button type="button" class="btn btn-success">Right</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Outlined styles
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="btn-group" role="group" aria-label="Basic outlined example">
|
|
||||||
<button type="button" class="btn btn-outline-primary">Left</button>
|
|
||||||
<button type="button" class="btn btn-outline-primary">Middle</button>
|
|
||||||
<button type="button" class="btn btn-outline-primary">Right</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Checkbox and radio button groups
|
|
||||||
|
|
||||||
Combine button-like checkbox and radio [toggle buttons]({{< docsref "/forms/checks-radios" >}}) into a seamless looking button group.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="btn-group" role="group" aria-label="Basic checkbox toggle button group">
|
|
||||||
<input type="checkbox" class="btn-check" id="btncheck1" autocomplete="off">
|
|
||||||
<label class="btn btn-outline-primary" for="btncheck1">Checkbox 1</label>
|
|
||||||
|
|
||||||
<input type="checkbox" class="btn-check" id="btncheck2" autocomplete="off">
|
|
||||||
<label class="btn btn-outline-primary" for="btncheck2">Checkbox 2</label>
|
|
||||||
|
|
||||||
<input type="checkbox" class="btn-check" id="btncheck3" autocomplete="off">
|
|
||||||
<label class="btn btn-outline-primary" for="btncheck3">Checkbox 3</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="btn-group" role="group" aria-label="Basic radio toggle button group">
|
|
||||||
<input type="radio" class="btn-check" name="btnradio" id="btnradio1" autocomplete="off" checked>
|
|
||||||
<label class="btn btn-outline-primary" for="btnradio1">Radio 1</label>
|
|
||||||
|
|
||||||
<input type="radio" class="btn-check" name="btnradio" id="btnradio2" autocomplete="off">
|
|
||||||
<label class="btn btn-outline-primary" for="btnradio2">Radio 2</label>
|
|
||||||
|
|
||||||
<input type="radio" class="btn-check" name="btnradio" id="btnradio3" autocomplete="off">
|
|
||||||
<label class="btn btn-outline-primary" for="btnradio3">Radio 3</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Button toolbar
|
|
||||||
|
|
||||||
Combine sets of button groups into button toolbars for more complex components. Use utility classes as needed to space out groups, buttons, and more.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="btn-toolbar" role="toolbar" aria-label="Toolbar with button groups">
|
|
||||||
<div class="btn-group me-2" role="group" aria-label="First group">
|
|
||||||
<button type="button" class="btn btn-primary">1</button>
|
|
||||||
<button type="button" class="btn btn-primary">2</button>
|
|
||||||
<button type="button" class="btn btn-primary">3</button>
|
|
||||||
<button type="button" class="btn btn-primary">4</button>
|
|
||||||
</div>
|
|
||||||
<div class="btn-group me-2" role="group" aria-label="Second group">
|
|
||||||
<button type="button" class="btn btn-secondary">5</button>
|
|
||||||
<button type="button" class="btn btn-secondary">6</button>
|
|
||||||
<button type="button" class="btn btn-secondary">7</button>
|
|
||||||
</div>
|
|
||||||
<div class="btn-group" role="group" aria-label="Third group">
|
|
||||||
<button type="button" class="btn btn-info">8</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="btn-toolbar mb-3" role="toolbar" aria-label="Toolbar with button groups">
|
|
||||||
<div class="btn-group me-2" role="group" aria-label="First group">
|
|
||||||
<button type="button" class="btn btn-outline-secondary">1</button>
|
|
||||||
<button type="button" class="btn btn-outline-secondary">2</button>
|
|
||||||
<button type="button" class="btn btn-outline-secondary">3</button>
|
|
||||||
<button type="button" class="btn btn-outline-secondary">4</button>
|
|
||||||
</div>
|
|
||||||
<div class="input-group">
|
|
||||||
<div class="input-group-text" id="btnGroupAddon">@</div>
|
|
||||||
<input type="text" class="form-control" placeholder="Input group example" aria-label="Input group example" aria-describedby="btnGroupAddon">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="btn-toolbar justify-content-between" role="toolbar" aria-label="Toolbar with button groups">
|
|
||||||
<div class="btn-group" role="group" aria-label="First group">
|
|
||||||
<button type="button" class="btn btn-outline-secondary">1</button>
|
|
||||||
<button type="button" class="btn btn-outline-secondary">2</button>
|
|
||||||
<button type="button" class="btn btn-outline-secondary">3</button>
|
|
||||||
<button type="button" class="btn btn-outline-secondary">4</button>
|
|
||||||
</div>
|
|
||||||
<div class="input-group">
|
|
||||||
<div class="input-group-text" id="btnGroupAddon2">@</div>
|
|
||||||
<input type="text" class="form-control" placeholder="Input group example" aria-label="Input group example" aria-describedby="btnGroupAddon2">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Sizing
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="btn-group btn-group-lg" role="group" aria-label="Large button group">
|
|
||||||
<button type="button" class="btn btn-outline-primary">Left</button>
|
|
||||||
<button type="button" class="btn btn-outline-primary">Middle</button>
|
|
||||||
<button type="button" class="btn btn-outline-primary">Right</button>
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
<div class="btn-group" role="group" aria-label="Default button group">
|
|
||||||
<button type="button" class="btn btn-outline-primary">Left</button>
|
|
||||||
<button type="button" class="btn btn-outline-primary">Middle</button>
|
|
||||||
<button type="button" class="btn btn-outline-primary">Right</button>
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
<div class="btn-group btn-group-sm" role="group" aria-label="Small button group">
|
|
||||||
<button type="button" class="btn btn-outline-primary">Left</button>
|
|
||||||
<button type="button" class="btn btn-outline-primary">Middle</button>
|
|
||||||
<button type="button" class="btn btn-outline-primary">Right</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Nesting
|
|
||||||
|
|
||||||
Place a `.btn-group` within another `.btn-group` when you want dropdown menus mixed with a series of buttons.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="btn-group" role="group" aria-label="Button group with nested dropdown">
|
|
||||||
<button type="button" class="btn btn-primary">1</button>
|
|
||||||
<button type="button" class="btn btn-primary">2</button>
|
|
||||||
|
|
||||||
<div class="btn-group" role="group">
|
|
||||||
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
|
||||||
Dropdown
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Vertical variation
|
|
||||||
|
|
||||||
Make a set of buttons appear vertically stacked rather than horizontally. **Split button dropdowns are not supported here.**
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="btn-group-vertical" role="group" aria-label="Vertical button group">
|
|
||||||
<button type="button" class="btn btn-primary">Button</button>
|
|
||||||
<button type="button" class="btn btn-primary">Button</button>
|
|
||||||
<button type="button" class="btn btn-primary">Button</button>
|
|
||||||
<button type="button" class="btn btn-primary">Button</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="btn-group-vertical" role="group" aria-label="Vertical button group">
|
|
||||||
<div class="btn-group" role="group">
|
|
||||||
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
|
||||||
Dropdown
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<button type="button" class="btn btn-primary">Button</button>
|
|
||||||
<button type="button" class="btn btn-primary">Button</button>
|
|
||||||
<div class="btn-group dropstart" role="group">
|
|
||||||
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
|
||||||
Dropdown
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="btn-group dropend" role="group">
|
|
||||||
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
|
||||||
Dropdown
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="btn-group dropup" role="group">
|
|
||||||
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
|
||||||
Dropdown
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="btn-group-vertical" role="group" aria-label="Vertical radio toggle button group">
|
|
||||||
<input type="radio" class="btn-check" name="vbtn-radio" id="vbtn-radio1" autocomplete="off" checked>
|
|
||||||
<label class="btn btn-outline-danger" for="vbtn-radio1">Radio 1</label>
|
|
||||||
<input type="radio" class="btn-check" name="vbtn-radio" id="vbtn-radio2" autocomplete="off">
|
|
||||||
<label class="btn btn-outline-danger" for="vbtn-radio2">Radio 2</label>
|
|
||||||
<input type="radio" class="btn-check" name="vbtn-radio" id="vbtn-radio3" autocomplete="off">
|
|
||||||
<label class="btn btn-outline-danger" for="vbtn-radio3">Radio 3</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
|
@ -1,270 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Buttons
|
|
||||||
description: Use Bootstrap's custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more.
|
|
||||||
group: components
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## Base class
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<button type="button" class="btn">Base class</button>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
The `.btn` class is intended to be used in conjunction with our button variants, or to serve as a basis for your own custom styles.
|
|
||||||
|
|
||||||
{{< callout warning >}}
|
|
||||||
If you are using the `.btn` class on its own, remember to at least define some explicit `:focus` and/or `:focus-visible` styles.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## Variants
|
|
||||||
|
|
||||||
Bootstrap includes several button variants, each serving its own semantic purpose, with a few extras thrown in for more control.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
{{< buttons.inline >}}
|
|
||||||
{{- range (index $.Site.Data "theme-colors") }}
|
|
||||||
<button type="button" class="btn btn-{{ .name }}">{{ .name | title }}</button>
|
|
||||||
{{- end -}}
|
|
||||||
{{< /buttons.inline >}}
|
|
||||||
|
|
||||||
<button type="button" class="btn btn-link">Link</button>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
{{< partial "callouts/warning-color-assistive-technologies.md" >}}
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<a class="btn btn-primary" href="#" role="button">Link</a>
|
|
||||||
<button class="btn btn-primary" type="submit">Button</button>
|
|
||||||
<input class="btn btn-primary" type="button" value="Input">
|
|
||||||
<input class="btn btn-primary" type="submit" value="Submit">
|
|
||||||
<input class="btn btn-primary" type="reset" value="Reset">
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Outline buttons
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
{{< buttons.inline >}}
|
|
||||||
{{- range (index $.Site.Data "theme-colors") }}
|
|
||||||
<button type="button" class="btn btn-outline-{{ .name }}">{{ .name | title }}</button>
|
|
||||||
{{- end -}}
|
|
||||||
{{< /buttons.inline >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
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.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## Sizes
|
|
||||||
|
|
||||||
Fancy larger or smaller buttons? Add `.btn-lg` or `.btn-sm` for additional sizes.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<button type="button" class="btn btn-primary btn-lg">Large button</button>
|
|
||||||
<button type="button" class="btn btn-secondary btn-lg">Large button</button>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<button type="button" class="btn btn-primary btn-sm">Small button</button>
|
|
||||||
<button type="button" class="btn btn-secondary btn-sm">Small button</button>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
You can even roll your own custom sizing with CSS variables:
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<button type="button" class="btn btn-primary"
|
|
||||||
style="--bs-btn-padding-y: .25rem; --bs-btn-padding-x: .5rem; --bs-btn-font-size: .75rem;">
|
|
||||||
Custom button
|
|
||||||
</button>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Disabled state
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<button type="button" class="btn btn-primary" disabled>Primary button</button>
|
|
||||||
<button type="button" class="btn btn-secondary" disabled>Button</button>
|
|
||||||
<button type="button" class="btn btn-outline-primary" disabled>Primary button</button>
|
|
||||||
<button type="button" class="btn btn-outline-secondary" disabled>Button</button>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Disabled buttons using the `<a>` element behave a bit different:
|
|
||||||
|
|
||||||
- `<a>`s don't support the `disabled` attribute, so you must add the `.disabled` class to make it visually appear disabled.
|
|
||||||
- Some future-friendly styles are included to disable all `pointer-events` on anchor buttons.
|
|
||||||
- Disabled buttons using `<a>` should include the `aria-disabled="true"` attribute to indicate the state of the element to assistive technologies.
|
|
||||||
- Disabled buttons using `<a>` *should not* include the `href` attribute.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<a class="btn btn-primary disabled" role="button" aria-disabled="true">Primary link</a>
|
|
||||||
<a class="btn btn-secondary disabled" role="button" aria-disabled="true">Link</a>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Link functionality caveat
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<a href="#" class="btn btn-primary disabled" tabindex="-1" role="button" aria-disabled="true">Primary link</a>
|
|
||||||
<a href="#" class="btn btn-secondary disabled" tabindex="-1" role="button" aria-disabled="true">Link</a>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Block buttons
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="d-grid gap-2">
|
|
||||||
<button class="btn btn-primary" type="button">Button</button>
|
|
||||||
<button class="btn btn-primary" type="button">Button</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="d-grid gap-2 d-md-block">
|
|
||||||
<button class="btn btn-primary" type="button">Button</button>
|
|
||||||
<button class="btn btn-primary" type="button">Button</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="d-grid gap-2 col-6 mx-auto">
|
|
||||||
<button class="btn btn-primary" type="button">Button</button>
|
|
||||||
<button class="btn btn-primary" type="button">Button</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
|
|
||||||
<button class="btn btn-primary me-md-2" type="button">Button</button>
|
|
||||||
<button class="btn btn-primary" type="button">Button</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Button plugin
|
|
||||||
|
|
||||||
The button plugin allows you to create simple on/off toggle buttons.
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
Visually, these toggle buttons are identical to the [checkbox toggle buttons]({{< docsref "/forms/checks-radios#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.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
### 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 **and** `aria-pressed="true"` to ensure that it is conveyed appropriately to assistive technologies.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<p class="d-inline-flex gap-1">
|
|
||||||
<button type="button" class="btn" data-bs-toggle="button">Toggle button</button>
|
|
||||||
<button type="button" class="btn active" data-bs-toggle="button" aria-pressed="true">Active toggle button</button>
|
|
||||||
<button type="button" class="btn" disabled data-bs-toggle="button">Disabled toggle button</button>
|
|
||||||
</p>
|
|
||||||
<p class="d-inline-flex gap-1">
|
|
||||||
<button type="button" class="btn btn-primary" data-bs-toggle="button">Toggle button</button>
|
|
||||||
<button type="button" class="btn btn-primary active" data-bs-toggle="button" aria-pressed="true">Active toggle button</button>
|
|
||||||
<button type="button" class="btn btn-primary" disabled data-bs-toggle="button">Disabled toggle button</button>
|
|
||||||
</p>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<p class="d-inline-flex gap-1">
|
|
||||||
<a href="#" class="btn" role="button" data-bs-toggle="button">Toggle link</a>
|
|
||||||
<a href="#" class="btn active" role="button" data-bs-toggle="button" aria-pressed="true">Active toggle link</a>
|
|
||||||
<a class="btn disabled" aria-disabled="true" role="button" data-bs-toggle="button">Disabled toggle link</a>
|
|
||||||
</p>
|
|
||||||
<p class="d-inline-flex gap-1">
|
|
||||||
<a href="#" class="btn btn-primary" role="button" data-bs-toggle="button">Toggle link</a>
|
|
||||||
<a href="#" class="btn btn-primary active" role="button" data-bs-toggle="button" aria-pressed="true">Active toggle link</a>
|
|
||||||
<a class="btn btn-primary disabled" aria-disabled="true" role="button" data-bs-toggle="button">Disabled toggle link</a>
|
|
||||||
</p>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Methods
|
|
||||||
|
|
||||||
You can create a button instance with the button constructor, for example:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const bsButton = new bootstrap.Button('#myButton')
|
|
||||||
```
|
|
||||||
|
|
||||||
{{< bs-table "table" >}}
|
|
||||||
| 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. |
|
|
||||||
{{< /bs-table >}}
|
|
||||||
|
|
||||||
For example, to toggle all buttons
|
|
||||||
|
|
||||||
```js
|
|
||||||
document.querySelectorAll('.btn').forEach(buttonElement => {
|
|
||||||
const button = bootstrap.Button.getOrCreateInstance(buttonElement)
|
|
||||||
button.toggle()
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Variables
|
|
||||||
|
|
||||||
{{< added-in "5.2.0" >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< scss-docs name="btn-css-vars" file="scss/_buttons.scss" >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
<div class="bd-example">
|
|
||||||
<button type="button" class="btn btn-bd-primary">Custom button</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{< scss-docs name="btn-css-vars-example" file="site/assets/scss/_buttons.scss" >}}
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
{{< scss-docs name="btn-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
### Sass mixins
|
|
||||||
|
|
||||||
There are three mixins for buttons: button and button outline variant mixins (both based on `$theme-colors`), plus a button size mixin.
|
|
||||||
|
|
||||||
{{< scss-docs name="btn-variant-mixin" file="scss/mixins/_buttons.scss" >}}
|
|
||||||
|
|
||||||
{{< scss-docs name="btn-outline-variant-mixin" file="scss/mixins/_buttons.scss" >}}
|
|
||||||
|
|
||||||
{{< scss-docs name="btn-size-mixin" file="scss/mixins/_buttons.scss" >}}
|
|
||||||
|
|
||||||
### Sass loops
|
|
||||||
|
|
||||||
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`.
|
|
||||||
|
|
||||||
{{< scss-docs name="btn-variant-loops" file="scss/_buttons.scss" >}}
|
|
|
@ -1,743 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Cards
|
|
||||||
description: Bootstrap's cards provide a flexible and extensible content container with multiple variants and options.
|
|
||||||
group: components
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## About
|
|
||||||
|
|
||||||
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]({{< docsref "/utilities/spacing" >}}) 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](#sizing).
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card" style="width: 18rem;">
|
|
||||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
|
|
||||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
|
||||||
This is some text within a card body.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card" style="width: 18rem;">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<h6 class="card-subtitle mb-2 text-body-secondary">Card subtitle</h6>
|
|
||||||
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
|
|
||||||
<a href="#" class="card-link">Card link</a>
|
|
||||||
<a href="#" class="card-link">Another link</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card" style="width: 18rem;">
|
|
||||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<p class="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>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### List groups
|
|
||||||
|
|
||||||
Create lists of content in a card with a flush list group.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card" style="width: 18rem;">
|
|
||||||
<ul class="list-group list-group-flush">
|
|
||||||
<li class="list-group-item">An item</li>
|
|
||||||
<li class="list-group-item">A second item</li>
|
|
||||||
<li class="list-group-item">A third item</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card" style="width: 18rem;">
|
|
||||||
<div class="card-header">
|
|
||||||
Featured
|
|
||||||
</div>
|
|
||||||
<ul class="list-group list-group-flush">
|
|
||||||
<li class="list-group-item">An item</li>
|
|
||||||
<li class="list-group-item">A second item</li>
|
|
||||||
<li class="list-group-item">A third item</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card" style="width: 18rem;">
|
|
||||||
<ul class="list-group list-group-flush">
|
|
||||||
<li class="list-group-item">An item</li>
|
|
||||||
<li class="list-group-item">A second item</li>
|
|
||||||
<li class="list-group-item">A third item</li>
|
|
||||||
</ul>
|
|
||||||
<div class="card-footer">
|
|
||||||
Card footer
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Kitchen sink
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card" style="width: 18rem;">
|
|
||||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
|
|
||||||
</div>
|
|
||||||
<ul class="list-group list-group-flush">
|
|
||||||
<li class="list-group-item">An item</li>
|
|
||||||
<li class="list-group-item">A second item</li>
|
|
||||||
<li class="list-group-item">A third item</li>
|
|
||||||
</ul>
|
|
||||||
<div class="card-body">
|
|
||||||
<a href="#" class="card-link">Card link</a>
|
|
||||||
<a href="#" class="card-link">Another link</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Header and footer
|
|
||||||
|
|
||||||
Add an optional header and/or footer within a card.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
Featured
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Special title treatment</h5>
|
|
||||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
|
||||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Card headers can be styled by adding `.card-header` to `<h*>` elements.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card">
|
|
||||||
<h5 class="card-header">Featured</h5>
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Special title treatment</h5>
|
|
||||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
|
||||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
Quote
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<figure>
|
|
||||||
<blockquote class="blockquote">
|
|
||||||
<p>A well-known quote, contained in a blockquote element.</p>
|
|
||||||
</blockquote>
|
|
||||||
<figcaption class="blockquote-footer">
|
|
||||||
Someone famous in <cite title="Source Title">Source Title</cite>
|
|
||||||
</figcaption>
|
|
||||||
</figure>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card text-center">
|
|
||||||
<div class="card-header">
|
|
||||||
Featured
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Special title treatment</h5>
|
|
||||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
|
||||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
|
||||||
</div>
|
|
||||||
<div class="card-footer text-body-secondary">
|
|
||||||
2 days ago
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-6 mb-3 mb-sm-0">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Special title treatment</h5>
|
|
||||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
|
||||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-6">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Special title treatment</h5>
|
|
||||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
|
||||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Using utilities
|
|
||||||
|
|
||||||
Use our handful of [available sizing utilities]({{< docsref "/utilities/sizing" >}}) to quickly set a card's width.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card w-75 mb-3">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
|
||||||
<a href="#" class="btn btn-primary">Button</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="card w-50">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
|
||||||
<a href="#" class="btn btn-primary">Button</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Using custom CSS
|
|
||||||
|
|
||||||
Use custom CSS in your stylesheets or as inline styles to set a width.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card" style="width: 18rem;">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Special title treatment</h5>
|
|
||||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
|
||||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Text alignment
|
|
||||||
|
|
||||||
You can quickly change the text alignment of any card—in its entirety or specific parts—with our [text align classes]({{< docsref "/utilities/text#text-alignment" >}}).
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card mb-3" style="width: 18rem;">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Special title treatment</h5>
|
|
||||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
|
||||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="card text-center mb-3" style="width: 18rem;">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Special title treatment</h5>
|
|
||||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
|
||||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="card text-end" style="width: 18rem;">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Special title treatment</h5>
|
|
||||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
|
||||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Navigation
|
|
||||||
|
|
||||||
Add some navigation to a card's header (or block) with Bootstrap's [nav components]({{< docsref "/components/navs-tabs" >}}).
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card text-center">
|
|
||||||
<div class="card-header">
|
|
||||||
<ul class="nav nav-tabs card-header-tabs">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link active" aria-current="true" href="#">Active</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Link</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Special title treatment</h5>
|
|
||||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
|
||||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card text-center">
|
|
||||||
<div class="card-header">
|
|
||||||
<ul class="nav nav-pills card-header-pills">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link active" href="#">Active</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Link</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Special title treatment</h5>
|
|
||||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
|
||||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card mb-3">
|
|
||||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="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>
|
|
||||||
<p class="card-text"><small class="text-body-secondary">Last updated 3 mins ago</small></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="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>
|
|
||||||
<p class="card-text"><small class="text-body-secondary">Last updated 3 mins ago</small></p>
|
|
||||||
</div>
|
|
||||||
{{< placeholder width="100%" height="180" class="card-img-bottom" text="Image cap" >}}
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card text-bg-dark">
|
|
||||||
{{< placeholder width="100%" height="270" class="bd-placeholder-img-lg card-img" text="Card image" >}}
|
|
||||||
<div class="card-img-overlay">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="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>
|
|
||||||
<p class="card-text"><small>Last updated 3 mins ago</small></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
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.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card mb-3" style="max-width: 540px;">
|
|
||||||
<div class="row g-0">
|
|
||||||
<div class="col-md-4">
|
|
||||||
{{< placeholder width="100%" height="250" text="Image" class="img-fluid rounded-start" >}}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-8">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="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>
|
|
||||||
<p class="card-text"><small class="text-body-secondary">Last updated 3 mins ago</small></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Card styles
|
|
||||||
|
|
||||||
Cards include various options for customizing their backgrounds, borders, and color.
|
|
||||||
|
|
||||||
### Background and color
|
|
||||||
|
|
||||||
{{< added-in "5.2.0" >}}
|
|
||||||
|
|
||||||
Set a `background-color` with contrasting foreground `color` with [our `.text-bg-{color}` helpers]({{< docsref "helpers/color-background" >}}). Previously it was required to manually pair your choice of [`.text-{color}`]({{< docsref "/utilities/colors" >}}) and [`.bg-{color}`]({{< docsref "/utilities/background" >}}) utilities for styling, which you still may use if you prefer.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
{{< card.inline >}}
|
|
||||||
{{- range (index $.Site.Data "theme-colors") }}
|
|
||||||
<div class="card text-bg-{{ .name }} mb-3" style="max-width: 18rem;">
|
|
||||||
<div class="card-header">Header</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">{{ .name | title }} card title</h5>
|
|
||||||
<p class="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>
|
|
||||||
{{- end -}}
|
|
||||||
{{< /card.inline >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
{{< partial "callouts/warning-color-assistive-technologies.md" >}}
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
### Border
|
|
||||||
|
|
||||||
Use [border utilities]({{< docsref "/utilities/borders" >}}) 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
{{< card.inline >}}
|
|
||||||
{{- range (index $.Site.Data "theme-colors") }}
|
|
||||||
<div class="card border-{{ .name }} mb-3" style="max-width: 18rem;">
|
|
||||||
<div class="card-header">Header</div>
|
|
||||||
<div class="card-body{{ if not .contrast_color }} text-{{ .name }}{{ end }}">
|
|
||||||
<h5 class="card-title">{{ .name | title }} card title</h5>
|
|
||||||
<p class="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>
|
|
||||||
{{- end -}}
|
|
||||||
{{< /card.inline >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### 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`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card border-success mb-3" style="max-width: 18rem;">
|
|
||||||
<div class="card-header bg-transparent border-success">Header</div>
|
|
||||||
<div class="card-body text-success">
|
|
||||||
<h5 class="card-title">Success card title</h5>
|
|
||||||
<p class="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 class="card-footer bg-transparent border-success">Footer</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## 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
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card-group">
|
|
||||||
<div class="card">
|
|
||||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="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>
|
|
||||||
<p class="card-text"><small class="text-body-secondary">Last updated 3 mins ago</small></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card">
|
|
||||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
|
|
||||||
<p class="card-text"><small class="text-body-secondary">Last updated 3 mins ago</small></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card">
|
|
||||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="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>
|
|
||||||
<p class="card-text"><small class="text-body-secondary">Last updated 3 mins ago</small></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
When using card groups with footers, their content will automatically line up.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card-group">
|
|
||||||
<div class="card">
|
|
||||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="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>
|
|
||||||
<div class="card-footer">
|
|
||||||
<small class="text-body-secondary">Last updated 3 mins ago</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card">
|
|
||||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
|
|
||||||
</div>
|
|
||||||
<div class="card-footer">
|
|
||||||
<small class="text-body-secondary">Last updated 3 mins ago</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card">
|
|
||||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="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>
|
|
||||||
<div class="card-footer">
|
|
||||||
<small class="text-body-secondary">Last updated 3 mins ago</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Grid cards
|
|
||||||
|
|
||||||
Use the Bootstrap grid system and its [`.row-cols` classes]({{< docsref "/layout/grid#row-columns" >}}) 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="row row-cols-1 row-cols-md-2 g-4">
|
|
||||||
<div class="col">
|
|
||||||
<div class="card">
|
|
||||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="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 class="col">
|
|
||||||
<div class="card">
|
|
||||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="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 class="col">
|
|
||||||
<div class="card">
|
|
||||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="card">
|
|
||||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="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>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Change it to `.row-cols-3` and you'll see the fourth card wrap.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="row row-cols-1 row-cols-md-3 g-4">
|
|
||||||
<div class="col">
|
|
||||||
<div class="card">
|
|
||||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="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 class="col">
|
|
||||||
<div class="card">
|
|
||||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="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 class="col">
|
|
||||||
<div class="card">
|
|
||||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="card">
|
|
||||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="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>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="row row-cols-1 row-cols-md-3 g-4">
|
|
||||||
<div class="col">
|
|
||||||
<div class="card h-100">
|
|
||||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="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 class="col">
|
|
||||||
<div class="card h-100">
|
|
||||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="card-text">This is a short card.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="card h-100">
|
|
||||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="card h-100">
|
|
||||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="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>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Just like with card groups, card footers will automatically line up.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="row row-cols-1 row-cols-md-3 g-4">
|
|
||||||
<div class="col">
|
|
||||||
<div class="card h-100">
|
|
||||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="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>
|
|
||||||
<div class="card-footer">
|
|
||||||
<small class="text-body-secondary">Last updated 3 mins ago</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="card h-100">
|
|
||||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
|
|
||||||
</div>
|
|
||||||
<div class="card-footer">
|
|
||||||
<small class="text-body-secondary">Last updated 3 mins ago</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="card h-100">
|
|
||||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card title</h5>
|
|
||||||
<p class="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>
|
|
||||||
<div class="card-footer">
|
|
||||||
<small class="text-body-secondary">Last updated 3 mins ago</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Masonry
|
|
||||||
|
|
||||||
In `v4` we used a CSS-only technique to mimic the behavior of [Masonry](https://masonry.desandro.com/)-like columns, but this technique came with lots of unpleasant [side effects](https://github.com/twbs/bootstrap/pull/28922). 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]({{< docsref "/examples/masonry" >}}) to help you get started.
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Variables
|
|
||||||
|
|
||||||
{{< added-in "5.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.
|
|
||||||
|
|
||||||
{{< scss-docs name="card-css-vars" file="scss/_card.scss" >}}
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
{{< scss-docs name="card-variables" file="scss/_variables.scss" >}}
|
|
|
@ -1,448 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Carousel
|
|
||||||
description: A slideshow component for cycling through elements—images or slides of text—like a carousel.
|
|
||||||
group: components
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## How it works
|
|
||||||
|
|
||||||
- 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](#methods). 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](#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.
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
{{< partial "callouts/info-prefersreducedmotion.md" >}}
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## Basic examples
|
|
||||||
|
|
||||||
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"`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div id="carouselExample" class="carousel slide">
|
|
||||||
<div class="carousel-inner">
|
|
||||||
<div class="carousel-item active">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" >}}
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" >}}
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExample" data-bs-slide="prev">
|
|
||||||
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden">Previous</span>
|
|
||||||
</button>
|
|
||||||
<button class="carousel-control-next" type="button" data-bs-target="#carouselExample" data-bs-slide="next">
|
|
||||||
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden">Next</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div id="carouselExampleIndicators" class="carousel slide">
|
|
||||||
<div class="carousel-indicators">
|
|
||||||
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
|
|
||||||
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
|
|
||||||
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
|
|
||||||
</div>
|
|
||||||
<div class="carousel-inner">
|
|
||||||
<div class="carousel-item active">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" >}}
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" >}}
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
|
|
||||||
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden">Previous</span>
|
|
||||||
</button>
|
|
||||||
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
|
|
||||||
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden">Next</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Captions
|
|
||||||
|
|
||||||
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]({{< docsref "/utilities/display" >}}). We hide them initially with `.d-none` and bring them back on medium-sized devices with `.d-md-block`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div id="carouselExampleCaptions" class="carousel slide">
|
|
||||||
<div class="carousel-indicators">
|
|
||||||
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
|
|
||||||
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="1" aria-label="Slide 2"></button>
|
|
||||||
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="2" aria-label="Slide 3"></button>
|
|
||||||
</div>
|
|
||||||
<div class="carousel-inner">
|
|
||||||
<div class="carousel-item active">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" >}}
|
|
||||||
<div class="carousel-caption d-none d-md-block">
|
|
||||||
<h5>First slide label</h5>
|
|
||||||
<p>Some representative placeholder content for the first slide.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" >}}
|
|
||||||
<div class="carousel-caption d-none d-md-block">
|
|
||||||
<h5>Second slide label</h5>
|
|
||||||
<p>Some representative placeholder content for the second slide.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
|
|
||||||
<div class="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>
|
|
||||||
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide="prev">
|
|
||||||
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden">Previous</span>
|
|
||||||
</button>
|
|
||||||
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide="next">
|
|
||||||
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden">Next</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Crossfade
|
|
||||||
|
|
||||||
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-item`s for proper crossfading.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div id="carouselExampleFade" class="carousel slide carousel-fade">
|
|
||||||
<div class="carousel-inner">
|
|
||||||
<div class="carousel-item active">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" >}}
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" >}}
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleFade" data-bs-slide="prev">
|
|
||||||
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden">Previous</span>
|
|
||||||
</button>
|
|
||||||
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleFade" data-bs-slide="next">
|
|
||||||
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden">Next</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Autoplaying carousels
|
|
||||||
|
|
||||||
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](https://www.w3.org/TR/page-visibility/), 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).
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
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.
|
|
||||||
|
|
||||||
See [WCAG 2.2 Success Criterion 2.2.2 Pause, Stop, Hide](https://www.w3.org/TR/WCAG/#pause-stop-hide).
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div id="carouselExampleAutoplaying" class="carousel slide" data-bs-ride="carousel">
|
|
||||||
<div class="carousel-inner">
|
|
||||||
<div class="carousel-item active">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" >}}
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" >}}
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleAutoplaying" data-bs-slide="prev">
|
|
||||||
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden">Previous</span>
|
|
||||||
</button>
|
|
||||||
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleAutoplaying" data-bs-slide="next">
|
|
||||||
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden">Next</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div id="carouselExampleRide" class="carousel slide" data-bs-ride="true">
|
|
||||||
<div class="carousel-inner">
|
|
||||||
<div class="carousel-item active">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" >}}
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" >}}
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleRide" data-bs-slide="prev">
|
|
||||||
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden">Previous</span>
|
|
||||||
</button>
|
|
||||||
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleRide" data-bs-slide="next">
|
|
||||||
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden">Next</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Individual `.carousel-item` interval
|
|
||||||
|
|
||||||
Add `data-bs-interval=""` to a `.carousel-item` to change the amount of time to delay between automatically cycling to the next item.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div id="carouselExampleInterval" class="carousel slide" data-bs-ride="carousel">
|
|
||||||
<div class="carousel-inner">
|
|
||||||
<div class="carousel-item active" data-bs-interval="10000">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" >}}
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item" data-bs-interval="2000">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" >}}
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleInterval" data-bs-slide="prev">
|
|
||||||
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden">Previous</span>
|
|
||||||
</button>
|
|
||||||
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleInterval" data-bs-slide="next">
|
|
||||||
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden">Next</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Autoplaying carousels without controls
|
|
||||||
|
|
||||||
Here's a carousel with slides only. Note the presence of the `.d-block` and `.w-100` on carousel images to prevent browser default image alignment.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div id="carouselExampleSlidesOnly" class="carousel slide" data-bs-ride="carousel">
|
|
||||||
<div class="carousel-inner">
|
|
||||||
<div class="carousel-item active">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" >}}
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" >}}
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Disable touch swiping
|
|
||||||
|
|
||||||
Carousels support swiping left/right on touchscreen devices to move between slides. This can be disabled by setting the `touch` option to `false`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div id="carouselExampleControlsNoTouching" class="carousel slide" data-bs-touch="false">
|
|
||||||
<div class="carousel-inner">
|
|
||||||
<div class="carousel-item active">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" >}}
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" >}}
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleControlsNoTouching" data-bs-slide="prev">
|
|
||||||
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden">Previous</span>
|
|
||||||
</button>
|
|
||||||
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleControlsNoTouching" data-bs-slide="next">
|
|
||||||
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden">Next</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Dark variant
|
|
||||||
|
|
||||||
{{< deprecated-in "5.3.0" >}}
|
|
||||||
|
|
||||||
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`.
|
|
||||||
|
|
||||||
{{< callout-deprecated-dark-variants "carousel" >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div id="carouselExampleDark" class="carousel carousel-dark slide">
|
|
||||||
<div class="carousel-indicators">
|
|
||||||
<button type="button" data-bs-target="#carouselExampleDark" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
|
|
||||||
<button type="button" data-bs-target="#carouselExampleDark" data-bs-slide-to="1" aria-label="Slide 2"></button>
|
|
||||||
<button type="button" data-bs-target="#carouselExampleDark" data-bs-slide-to="2" aria-label="Slide 3"></button>
|
|
||||||
</div>
|
|
||||||
<div class="carousel-inner">
|
|
||||||
<div class="carousel-item active" data-bs-interval="10000">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#aaa" background="#f5f5f5" text="First slide" >}}
|
|
||||||
<div class="carousel-caption d-none d-md-block">
|
|
||||||
<h5>First slide label</h5>
|
|
||||||
<p>Some representative placeholder content for the first slide.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item" data-bs-interval="2000">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#bbb" background="#eee" text="Second slide" >}}
|
|
||||||
<div class="carousel-caption d-none d-md-block">
|
|
||||||
<h5>Second slide label</h5>
|
|
||||||
<p>Some representative placeholder content for the second slide.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="carousel-item">
|
|
||||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#999" background="#e5e5e5" text="Third slide" >}}
|
|
||||||
<div class="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>
|
|
||||||
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleDark" data-bs-slide="prev">
|
|
||||||
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden">Previous</span>
|
|
||||||
</button>
|
|
||||||
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleDark" data-bs-slide="next">
|
|
||||||
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden">Next</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## 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`).
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
Variables for all carousels:
|
|
||||||
|
|
||||||
{{< scss-docs name="carousel-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
Variables for the [dark carousel](#dark-variant):
|
|
||||||
|
|
||||||
{{< scss-docs name="carousel-dark-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
## 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`.
|
|
||||||
|
|
||||||
### Via JavaScript
|
|
||||||
|
|
||||||
Call carousel manually with:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const carousel = new bootstrap.Carousel('#myCarousel')
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
{{< markdown >}}
|
|
||||||
{{< partial "js-data-attributes.md" >}}
|
|
||||||
{{< /markdown >}}
|
|
||||||
|
|
||||||
{{< bs-table >}}
|
|
||||||
| 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. |
|
|
||||||
{{< /bs-table >}}
|
|
||||||
|
|
||||||
### Methods
|
|
||||||
|
|
||||||
{{< callout danger >}}
|
|
||||||
{{< partial "callouts/danger-async-methods.md" >}}
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const myCarouselElement = document.querySelector('#myCarousel')
|
|
||||||
|
|
||||||
const carousel = new bootstrap.Carousel(myCarouselElement, {
|
|
||||||
interval: 2000,
|
|
||||||
touch: false
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
{{< bs-table >}}
|
|
||||||
| Method | Description |
|
|
||||||
| --- | --- |
|
|
||||||
| `cycle` | 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). |
|
|
||||||
{{< /bs-table >}}
|
|
||||||
|
|
||||||
### 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.
|
|
||||||
- `from`: The index of the current item
|
|
||||||
- `to`: The index of the next item
|
|
||||||
|
|
||||||
All carousel events are fired at the carousel itself (i.e. at the `<div class="carousel">`).
|
|
||||||
|
|
||||||
{{< bs-table >}}
|
|
||||||
| 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. |
|
|
||||||
{{< /bs-table >}}
|
|
||||||
|
|
||||||
```js
|
|
||||||
const myCarousel = document.getElementById('myCarousel')
|
|
||||||
|
|
||||||
myCarousel.addEventListener('slide.bs.carousel', event => {
|
|
||||||
// do something...
|
|
||||||
})
|
|
||||||
```
|
|
|
@ -1,54 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Close button
|
|
||||||
description: A generic close button for dismissing content like modals and alerts.
|
|
||||||
group: components
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
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`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<button type="button" class="btn-close" aria-label="Close"></button>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Disabled state
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<button type="button" class="btn-close" disabled aria-label="Close"></button>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Dark variant
|
|
||||||
|
|
||||||
{{< deprecated-in "5.3.0" >}}
|
|
||||||
|
|
||||||
{{< callout warning >}}
|
|
||||||
**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.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example class="bg-dark" >}}
|
|
||||||
<div data-bs-theme="dark">
|
|
||||||
<button type="button" class="btn-close" aria-label="Close"></button>
|
|
||||||
<button type="button" class="btn-close" disabled aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Variables
|
|
||||||
|
|
||||||
{{< added-in "5.3.0" >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< scss-docs name="close-css-vars" file="scss/_close.scss" >}}
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
{{< scss-docs name="close-variables" file="scss/_variables.scss" >}}
|
|
|
@ -1,817 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Navbar
|
|
||||||
description: 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.
|
|
||||||
group: components
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## How it works
|
|
||||||
|
|
||||||
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](#color-schemes) classes.
|
|
||||||
- Navbars and their contents are fluid by default. Change the [container](#containers) to limit their horizontal width in different ways.
|
|
||||||
- Use our [spacing]({{< docsref "/utilities/spacing" >}}) and [flex]({{< docsref "/utilities/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.
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
{{< partial "callouts/info-prefersreducedmotion.md" >}}
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## Supported content
|
|
||||||
|
|
||||||
Navbars come with built-in support for a handful of sub-components. Choose from the following as needed:
|
|
||||||
|
|
||||||
- `.navbar-brand` for your company, product, or project name.
|
|
||||||
- `.navbar-nav` for a full-height and lightweight navigation (including support for dropdowns).
|
|
||||||
- `.navbar-toggler` for use with our collapse plugin and other [navigation toggling](#responsive-behaviors) behaviors.
|
|
||||||
- Flex and spacing utilities for any form controls and actions.
|
|
||||||
- `.navbar-text` for adding vertically centered strings of text.
|
|
||||||
- `.collapse.navbar-collapse` for grouping and hiding navbar contents by a parent breakpoint.
|
|
||||||
- Add an optional `.navbar-nav-scroll` to set a `max-height` and [scroll expanded navbar content](#scrolling).
|
|
||||||
|
|
||||||
Here's an example of all the sub-components included in a responsive light-themed navbar that automatically collapses at the `lg` (large) breakpoint.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar navbar-expand-lg bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">Navbar</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
|
||||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Link</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item dropdown">
|
|
||||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
||||||
Dropdown
|
|
||||||
</a>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
|
||||||
<li><hr class="dropdown-divider"></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<form class="d-flex" role="search">
|
|
||||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
|
||||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
This example uses [background]({{< docsref "/utilities/background" >}}) (`bg-body-tertiary`) and [spacing]({{< docsref "/utilities/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
|
|
||||||
|
|
||||||
Add your text within an element with the `.navbar-brand` class.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<!-- As a link -->
|
|
||||||
<nav class="navbar bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">Navbar</a>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<!-- As a heading -->
|
|
||||||
<nav class="navbar bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<span class="navbar-brand mb-0 h1">Navbar</span>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
#### Image
|
|
||||||
|
|
||||||
You can replace the text within the `.navbar-brand` with an `<img>`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar bg-body-tertiary">
|
|
||||||
<div class="container">
|
|
||||||
<a class="navbar-brand" href="#">
|
|
||||||
<img src="/docs/{{< param docs_version >}}/assets/brand/bootstrap-logo.svg" alt="Bootstrap" width="30" height="24">
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
#### Image and text
|
|
||||||
|
|
||||||
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>`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">
|
|
||||||
<img src="/docs/{{< param docs_version >}}/assets/brand/bootstrap-logo.svg" alt="Logo" width="30" height="24" class="d-inline-block align-text-top">
|
|
||||||
Bootstrap
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Nav
|
|
||||||
|
|
||||||
Navbar navigation links build on our `.nav` options with their own modifier class and require the use of [toggler classes](#toggler) 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`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar navbar-expand-lg bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">Navbar</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
|
||||||
<ul class="navbar-nav">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Features</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Pricing</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
And because we use classes for our navs, you can avoid the list-based approach entirely if you like.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar navbar-expand-lg bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">Navbar</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
|
|
||||||
<div class="navbar-nav">
|
|
||||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
|
||||||
<a class="nav-link" href="#">Features</a>
|
|
||||||
<a class="nav-link" href="#">Pricing</a>
|
|
||||||
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar navbar-expand-lg bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">Navbar</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarNavDropdown">
|
|
||||||
<ul class="navbar-nav">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Features</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Pricing</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item dropdown">
|
|
||||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
||||||
Dropdown link
|
|
||||||
</a>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Forms
|
|
||||||
|
|
||||||
Place various form controls and components within a navbar:
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<form class="d-flex" role="search">
|
|
||||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
|
||||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Immediate child elements of `.navbar` use flex layout and will default to `justify-content: space-between`. Use additional [flex utilities]({{< docsref "/utilities/flex" >}}) as needed to adjust this behavior.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand">Navbar</a>
|
|
||||||
<form class="d-flex" role="search">
|
|
||||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
|
||||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Input groups work, too. If your navbar is an entire form, or mostly a form, you can use the `<form>` element as the container and save some HTML.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar bg-body-tertiary">
|
|
||||||
<form class="container-fluid">
|
|
||||||
<div class="input-group">
|
|
||||||
<span class="input-group-text" id="basic-addon1">@</span>
|
|
||||||
<input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar bg-body-tertiary">
|
|
||||||
<form class="container-fluid justify-content-start">
|
|
||||||
<button class="btn btn-outline-success me-2" type="button">Main button</button>
|
|
||||||
<button class="btn btn-sm btn-outline-secondary" type="button">Smaller button</button>
|
|
||||||
</form>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Text
|
|
||||||
|
|
||||||
Navbars may contain bits of text with the help of `.navbar-text`. This class adjusts vertical alignment and horizontal spacing for strings of text.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<span class="navbar-text">
|
|
||||||
Navbar text with an inline element
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Mix and match with other components and utilities as needed.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar navbar-expand-lg bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">Navbar w/ text</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarText">
|
|
||||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Features</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Pricing</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<span class="navbar-text">
|
|
||||||
Navbar text with an inline element
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Color schemes
|
|
||||||
|
|
||||||
{{< callout warning >}}
|
|
||||||
**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.]({{< docsref "/customize/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`.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
<div class="bd-example">
|
|
||||||
<nav class="navbar navbar-expand-lg bg-dark border-bottom border-body" data-bs-theme="dark">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">Navbar</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarColor01">
|
|
||||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Features</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Pricing</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">About</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<form class="d-flex" role="search">
|
|
||||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
|
||||||
<button class="btn btn-outline-light" type="submit">Search</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<nav class="navbar navbar-expand-lg bg-primary" data-bs-theme="dark">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">Navbar</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor02" aria-controls="navbarColor02" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarColor02">
|
|
||||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Features</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Pricing</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">About</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<form class="d-flex" role="search">
|
|
||||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
|
||||||
<button class="btn btn-outline-light" type="submit">Search</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<nav class="navbar navbar-expand-lg" style="background-color: #e3f2fd;" data-bs-theme="light">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">Navbar</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor03" aria-controls="navbarColor03" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarColor03">
|
|
||||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Features</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Pricing</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">About</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<form class="d-flex" role="search">
|
|
||||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
|
||||||
<button class="btn btn-outline-primary" type="submit">Search</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
```html
|
|
||||||
<nav class="navbar bg-dark border-bottom border-body" data-bs-theme="dark">
|
|
||||||
<!-- Navbar content -->
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<nav class="navbar bg-primary" data-bs-theme="dark">
|
|
||||||
<!-- Navbar content -->
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<nav class="navbar" style="background-color: #e3f2fd;" data-bs-theme="light">
|
|
||||||
<!-- Navbar content -->
|
|
||||||
</nav>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Containers
|
|
||||||
|
|
||||||
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](#placement).
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="container">
|
|
||||||
<nav class="navbar navbar-expand-lg bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">Navbar</a>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Use any of the responsive containers to change how wide the content in your navbar is presented.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar navbar-expand-lg bg-body-tertiary">
|
|
||||||
<div class="container-md">
|
|
||||||
<a class="navbar-brand" href="#">Navbar</a>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Placement
|
|
||||||
|
|
||||||
Use our [position utilities]({{< docsref "/utilities/position" >}}) 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">Default</a>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar fixed-top bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">Fixed top</a>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar fixed-bottom bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">Fixed bottom</a>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar sticky-top bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">Sticky top</a>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar sticky-bottom bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">Sticky bottom</a>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Scrolling
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar navbar-expand-lg bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">Navbar scroll</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarScroll" aria-controls="navbarScroll" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarScroll">
|
|
||||||
<ul class="navbar-nav me-auto my-2 my-lg-0 navbar-nav-scroll" style="--bs-scroll-height: 100px;">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Link</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item dropdown">
|
|
||||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
||||||
Link
|
|
||||||
</a>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
|
||||||
<li><hr class="dropdown-divider"></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link disabled" aria-disabled="true">Link</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<form class="d-flex" role="search">
|
|
||||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
|
||||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Responsive behaviors
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
With no `.navbar-brand` shown at the smallest breakpoint:
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar navbar-expand-lg bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
|
|
||||||
<a class="navbar-brand" href="#">Hidden brand</a>
|
|
||||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Link</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<form class="d-flex" role="search">
|
|
||||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
|
||||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
With a brand name shown on the left and toggler on the right:
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar navbar-expand-lg bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">Navbar</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarTogglerDemo02">
|
|
||||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Link</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<form class="d-flex" role="search">
|
|
||||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
|
||||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
With a toggler on the left and brand name on the right:
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar navbar-expand-lg bg-body-tertiary">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<a class="navbar-brand" href="#">Navbar</a>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarTogglerDemo03">
|
|
||||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Link</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<form class="d-flex" role="search">
|
|
||||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
|
||||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### External content
|
|
||||||
|
|
||||||
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!
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="collapse" id="navbarToggleExternalContent" data-bs-theme="dark">
|
|
||||||
<div class="bg-dark p-4">
|
|
||||||
<h5 class="text-body-emphasis h4">Collapsed content</h5>
|
|
||||||
<span class="text-body-secondary">Toggleable via the navbar brand.</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<nav class="navbar navbar-dark bg-dark">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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]({{< docsref "/components/offcanvas" >}}). 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar bg-body-tertiary fixed-top">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">Offcanvas navbar</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasNavbar" aria-controls="offcanvasNavbar" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasNavbar" aria-labelledby="offcanvasNavbarLabel">
|
|
||||||
<div class="offcanvas-header">
|
|
||||||
<h5 class="offcanvas-title" id="offcanvasNavbarLabel">Offcanvas</h5>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="offcanvas-body">
|
|
||||||
<ul class="navbar-nav justify-content-end flex-grow-1 pe-3">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Link</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item dropdown">
|
|
||||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
||||||
Dropdown
|
|
||||||
</a>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
|
||||||
<li>
|
|
||||||
<hr class="dropdown-divider">
|
|
||||||
</li>
|
|
||||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<form class="d-flex mt-3" role="search">
|
|
||||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
|
||||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
To create an offcanvas navbar that expands into a normal navbar at a specific breakpoint like `lg`, use `.navbar-expand-lg`.
|
|
||||||
|
|
||||||
```html
|
|
||||||
<nav class="navbar navbar-expand-lg bg-body-tertiary fixed-top">
|
|
||||||
<a class="navbar-brand" href="#">Offcanvas navbar</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#navbarOffcanvasLg" aria-controls="navbarOffcanvasLg" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="offcanvas offcanvas-end" tabindex="-1" id="navbarOffcanvasLg" aria-labelledby="navbarOffcanvasLgLabel">
|
|
||||||
...
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
```
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav class="navbar navbar-dark bg-dark fixed-top">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<a class="navbar-brand" href="#">Offcanvas dark navbar</a>
|
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasDarkNavbar" aria-controls="offcanvasDarkNavbar" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="offcanvas offcanvas-end text-bg-dark" tabindex="-1" id="offcanvasDarkNavbar" aria-labelledby="offcanvasDarkNavbarLabel">
|
|
||||||
<div class="offcanvas-header">
|
|
||||||
<h5 class="offcanvas-title" id="offcanvasDarkNavbarLabel">Dark offcanvas</h5>
|
|
||||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="offcanvas-body">
|
|
||||||
<ul class="navbar-nav justify-content-end flex-grow-1 pe-3">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Link</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item dropdown">
|
|
||||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
||||||
Dropdown
|
|
||||||
</a>
|
|
||||||
<ul class="dropdown-menu dropdown-menu-dark">
|
|
||||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
|
||||||
<li>
|
|
||||||
<hr class="dropdown-divider">
|
|
||||||
</li>
|
|
||||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<form class="d-flex mt-3" role="search">
|
|
||||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
|
||||||
<button class="btn btn-success" type="submit">Search</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Variables
|
|
||||||
|
|
||||||
{{< added-in "5.2.0" >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< scss-docs name="navbar-css-vars" file="scss/_navbar.scss" >}}
|
|
||||||
|
|
||||||
Some additional CSS variables are also present on `.navbar-nav`:
|
|
||||||
|
|
||||||
{{< scss-docs name="navbar-nav-css-vars" file="scss/_navbar.scss" >}}
|
|
||||||
|
|
||||||
Customization through CSS variables can be seen on the `.navbar-dark` class where we override specific values without adding duplicate CSS selectors.
|
|
||||||
|
|
||||||
{{< scss-docs name="navbar-dark-css-vars" file="scss/_navbar.scss" >}}
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
Variables for all navbars:
|
|
||||||
|
|
||||||
{{< scss-docs name="navbar-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
Variables for the [dark navbar](#color-schemes):
|
|
||||||
|
|
||||||
{{< scss-docs name="navbar-dark-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
### Sass loops
|
|
||||||
|
|
||||||
[Responsive navbar expand/collapse classes](#responsive-behaviors) (e.g., `.navbar-expand-lg`) are combined with the `$breakpoints` map and generated through a loop in `scss/_navbar.scss`.
|
|
||||||
|
|
||||||
{{< scss-docs name="navbar-expand-loop" file="scss/_navbar.scss" >}}
|
|
|
@ -1,358 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Offcanvas
|
|
||||||
description: Build hidden sidebars into your project for navigation, shopping carts, and more with a few classes and our JavaScript plugin.
|
|
||||||
group: components
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## How it works
|
|
||||||
|
|
||||||
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](#sass-variables) 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.
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
{{< partial "callouts/info-prefersreducedmotion.md" >}}
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
### Offcanvas components
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example class="bd-example-offcanvas p-0 bg-body-tertiary overflow-hidden" >}}
|
|
||||||
<div class="offcanvas offcanvas-start show" tabindex="-1" id="offcanvas" aria-labelledby="offcanvasLabel">
|
|
||||||
<div class="offcanvas-header">
|
|
||||||
<h5 class="offcanvas-title" id="offcanvasLabel">Offcanvas</h5>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="offcanvas-body">
|
|
||||||
Content for the offcanvas goes here. You can place just about any Bootstrap component or custom elements here.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<a class="btn btn-primary" data-bs-toggle="offcanvas" href="#offcanvasExample" role="button" aria-controls="offcanvasExample">
|
|
||||||
Link with href
|
|
||||||
</a>
|
|
||||||
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasExample" aria-controls="offcanvasExample">
|
|
||||||
Button with data-bs-target
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div class="offcanvas offcanvas-start" tabindex="-1" id="offcanvasExample" aria-labelledby="offcanvasExampleLabel">
|
|
||||||
<div class="offcanvas-header">
|
|
||||||
<h5 class="offcanvas-title" id="offcanvasExampleLabel">Offcanvas</h5>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="offcanvas-body">
|
|
||||||
<div class="">
|
|
||||||
Some text as placeholder. In real life you can have the elements you have chosen. Like, text, images, lists, etc.
|
|
||||||
</div>
|
|
||||||
<div class="dropdown mt-3">
|
|
||||||
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown">
|
|
||||||
Dropdown button
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasScrolling" aria-controls="offcanvasScrolling">Enable body scrolling</button>
|
|
||||||
|
|
||||||
<div class="offcanvas offcanvas-start" data-bs-scroll="true" data-bs-backdrop="false" tabindex="-1" id="offcanvasScrolling" aria-labelledby="offcanvasScrollingLabel">
|
|
||||||
<div class="offcanvas-header">
|
|
||||||
<h5 class="offcanvas-title" id="offcanvasScrollingLabel">Offcanvas with body scrolling</h5>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="offcanvas-body">
|
|
||||||
<p>Try scrolling the rest of the page to see this option in action.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Body scrolling and backdrop
|
|
||||||
|
|
||||||
You can also enable `<body>` scrolling with a visible backdrop.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasWithBothOptions" aria-controls="offcanvasWithBothOptions">Enable both scrolling & backdrop</button>
|
|
||||||
|
|
||||||
<div class="offcanvas offcanvas-start" data-bs-scroll="true" tabindex="-1" id="offcanvasWithBothOptions" aria-labelledby="offcanvasWithBothOptionsLabel">
|
|
||||||
<div class="offcanvas-header">
|
|
||||||
<h5 class="offcanvas-title" id="offcanvasWithBothOptionsLabel">Backdrop with scrolling</h5>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="offcanvas-body">
|
|
||||||
<p>Try scrolling the rest of the page to see this option in action.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Static backdrop
|
|
||||||
|
|
||||||
When backdrop is set to static, the offcanvas will not close when clicking outside of it.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#staticBackdrop" aria-controls="staticBackdrop">
|
|
||||||
Toggle static offcanvas
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div class="offcanvas offcanvas-start" data-bs-backdrop="static" tabindex="-1" id="staticBackdrop" aria-labelledby="staticBackdropLabel">
|
|
||||||
<div class="offcanvas-header">
|
|
||||||
<h5 class="offcanvas-title" id="staticBackdropLabel">Offcanvas</h5>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="offcanvas-body">
|
|
||||||
<div>
|
|
||||||
I will not close if you click outside of me.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Dark offcanvas
|
|
||||||
|
|
||||||
{{< deprecated-in "5.3.0" >}} {{< added-in "5.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`.
|
|
||||||
|
|
||||||
{{< callout warning >}}
|
|
||||||
**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.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
{{< example class="bd-example-offcanvas p-0 bg-body-secondary overflow-hidden" >}}
|
|
||||||
<div class="offcanvas offcanvas-start show text-bg-dark" tabindex="-1" id="offcanvasDark" aria-labelledby="offcanvasDarkLabel">
|
|
||||||
<div class="offcanvas-header">
|
|
||||||
<h5 class="offcanvas-title" id="offcanvasDarkLabel">Offcanvas</h5>
|
|
||||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="offcanvasDark" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="offcanvas-body">
|
|
||||||
<p>Place offcanvas content here.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Responsive
|
|
||||||
|
|
||||||
{{< added-in "5.2.0" >}}
|
|
||||||
|
|
||||||
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`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<button class="btn btn-primary d-lg-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasResponsive" aria-controls="offcanvasResponsive">Toggle offcanvas</button>
|
|
||||||
|
|
||||||
<div class="alert alert-info d-none d-lg-block">Resize your browser to show the responsive offcanvas toggle.</div>
|
|
||||||
|
|
||||||
<div class="offcanvas-lg offcanvas-end" tabindex="-1" id="offcanvasResponsive" aria-labelledby="offcanvasResponsiveLabel">
|
|
||||||
<div class="offcanvas-header">
|
|
||||||
<h5 class="offcanvas-title" id="offcanvasResponsiveLabel">Responsive offcanvas</h5>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#offcanvasResponsive" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="offcanvas-body">
|
|
||||||
<p class="mb-0">This is content within an <code>.offcanvas-lg</code>.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## 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
|
|
||||||
- `.offcanvas-top` places offcanvas on the top of the viewport
|
|
||||||
- `.offcanvas-bottom` places offcanvas on the bottom of the viewport
|
|
||||||
|
|
||||||
Try the top, right, and bottom examples out below.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasTop" aria-controls="offcanvasTop">Toggle top offcanvas</button>
|
|
||||||
|
|
||||||
<div class="offcanvas offcanvas-top" tabindex="-1" id="offcanvasTop" aria-labelledby="offcanvasTopLabel">
|
|
||||||
<div class="offcanvas-header">
|
|
||||||
<h5 class="offcanvas-title" id="offcanvasTopLabel">Offcanvas top</h5>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="offcanvas-body">
|
|
||||||
...
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasRight" aria-controls="offcanvasRight">Toggle right offcanvas</button>
|
|
||||||
|
|
||||||
<div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasRight" aria-labelledby="offcanvasRightLabel">
|
|
||||||
<div class="offcanvas-header">
|
|
||||||
<h5 class="offcanvas-title" id="offcanvasRightLabel">Offcanvas right</h5>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="offcanvas-body">
|
|
||||||
...
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasBottom" aria-controls="offcanvasBottom">Toggle bottom offcanvas</button>
|
|
||||||
|
|
||||||
<div class="offcanvas offcanvas-bottom" tabindex="-1" id="offcanvasBottom" aria-labelledby="offcanvasBottomLabel">
|
|
||||||
<div class="offcanvas-header">
|
|
||||||
<h5 class="offcanvas-title" id="offcanvasBottomLabel">Offcanvas bottom</h5>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="offcanvas-body small">
|
|
||||||
...
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Accessibility
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
{{< added-in "5.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.
|
|
||||||
|
|
||||||
{{< scss-docs name="offcanvas-css-vars" file="scss/_offcanvas.scss" >}}
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
{{< scss-docs name="offcanvas-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
The offcanvas plugin utilizes a few classes and attributes to handle the heavy lifting:
|
|
||||||
|
|
||||||
- `.offcanvas` hides the content
|
|
||||||
- `.offcanvas.show` shows the content
|
|
||||||
- `.offcanvas-start` hides the offcanvas on the left
|
|
||||||
- `.offcanvas-end` hides the offcanvas on the right
|
|
||||||
- `.offcanvas-top` hides the offcanvas on the top
|
|
||||||
- `.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
|
|
||||||
|
|
||||||
{{% js-dismiss "offcanvas" %}}
|
|
||||||
|
|
||||||
{{< callout warning >}}
|
|
||||||
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](https://www.w3.org/WAI/ARIA/apg/patterns/dialogmodal/). Do this at your own risk.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
### Via JavaScript
|
|
||||||
|
|
||||||
Enable manually with:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const offcanvasElementList = document.querySelectorAll('.offcanvas')
|
|
||||||
const offcanvasList = [...offcanvasElementList].map(offcanvasEl => new bootstrap.Offcanvas(offcanvasEl))
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
{{< markdown >}}
|
|
||||||
{{< partial "js-data-attributes.md" >}}
|
|
||||||
{{< /markdown >}}
|
|
||||||
|
|
||||||
{{< bs-table "table" >}}
|
|
||||||
| 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. |
|
|
||||||
{{< /bs-table >}}
|
|
||||||
|
|
||||||
### Methods
|
|
||||||
|
|
||||||
{{< callout danger >}}
|
|
||||||
{{< partial "callouts/danger-async-methods.md" >}}
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
Activates your content as an offcanvas element. Accepts an optional options `object`.
|
|
||||||
|
|
||||||
You can create an offcanvas instance with the constructor, for example:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const bsOffcanvas = new bootstrap.Offcanvas('#myOffcanvas')
|
|
||||||
```
|
|
||||||
|
|
||||||
{{< bs-table "table" >}}
|
|
||||||
| Method | Description |
|
|
||||||
| --- | --- |
|
|
||||||
| `dispose` | Destroys an element's offcanvas. |
|
|
||||||
| `getInstance` | *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). |
|
|
||||||
{{< /bs-table >}}
|
|
||||||
|
|
||||||
### Events
|
|
||||||
|
|
||||||
Bootstrap's offcanvas class exposes a few events for hooking into offcanvas functionality.
|
|
||||||
|
|
||||||
{{< bs-table "table" >}}
|
|
||||||
| 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). |
|
|
||||||
{{< /bs-table >}}
|
|
||||||
|
|
||||||
```js
|
|
||||||
const myOffcanvas = document.getElementById('myOffcanvas')
|
|
||||||
myOffcanvas.addEventListener('hidden.bs.offcanvas', event => {
|
|
||||||
// do something...
|
|
||||||
})
|
|
||||||
```
|
|
|
@ -1,177 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Pagination
|
|
||||||
description: Documentation and examples for showing pagination to indicate a series of related content exists across multiple pages.
|
|
||||||
group: components
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
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"`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav aria-label="Page navigation example">
|
|
||||||
<ul class="pagination">
|
|
||||||
<li class="page-item"><a class="page-link" href="#">Previous</a></li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">Next</a></li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Working with icons
|
|
||||||
|
|
||||||
Looking to use an icon or symbol in place of text for some pagination links? Be sure to provide proper screen reader support with `aria` attributes.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav aria-label="Page navigation example">
|
|
||||||
<ul class="pagination">
|
|
||||||
<li class="page-item">
|
|
||||||
<a class="page-link" href="#" aria-label="Previous">
|
|
||||||
<span aria-hidden="true">«</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
|
||||||
<li class="page-item">
|
|
||||||
<a class="page-link" href="#" aria-label="Next">
|
|
||||||
<span aria-hidden="true">»</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Disabled and active states
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav aria-label="...">
|
|
||||||
<ul class="pagination">
|
|
||||||
<li class="page-item disabled">
|
|
||||||
<a class="page-link">Previous</a>
|
|
||||||
</li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
|
||||||
<li class="page-item active" aria-current="page">
|
|
||||||
<a class="page-link" href="#">2</a>
|
|
||||||
</li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
|
||||||
<li class="page-item">
|
|
||||||
<a class="page-link" href="#">Next</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav aria-label="...">
|
|
||||||
<ul class="pagination">
|
|
||||||
<li class="page-item disabled">
|
|
||||||
<span class="page-link">Previous</span>
|
|
||||||
</li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
|
||||||
<li class="page-item active" aria-current="page">
|
|
||||||
<span class="page-link">2</span>
|
|
||||||
</li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
|
||||||
<li class="page-item">
|
|
||||||
<a class="page-link" href="#">Next</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Sizing
|
|
||||||
|
|
||||||
Fancy larger or smaller pagination? Add `.pagination-lg` or `.pagination-sm` for additional sizes.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav aria-label="...">
|
|
||||||
<ul class="pagination pagination-lg">
|
|
||||||
<li class="page-item active" aria-current="page">
|
|
||||||
<span class="page-link">1</span>
|
|
||||||
</li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav aria-label="...">
|
|
||||||
<ul class="pagination pagination-sm">
|
|
||||||
<li class="page-item active" aria-current="page">
|
|
||||||
<span class="page-link">1</span>
|
|
||||||
</li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Alignment
|
|
||||||
|
|
||||||
Change the alignment of pagination components with [flexbox utilities]({{< docsref "/utilities/flex" >}}). For example, with `.justify-content-center`:
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav aria-label="Page navigation example">
|
|
||||||
<ul class="pagination justify-content-center">
|
|
||||||
<li class="page-item disabled">
|
|
||||||
<a class="page-link">Previous</a>
|
|
||||||
</li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
|
||||||
<li class="page-item">
|
|
||||||
<a class="page-link" href="#">Next</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Or with `.justify-content-end`:
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<nav aria-label="Page navigation example">
|
|
||||||
<ul class="pagination justify-content-end">
|
|
||||||
<li class="page-item disabled">
|
|
||||||
<a class="page-link">Previous</a>
|
|
||||||
</li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
|
||||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
|
||||||
<li class="page-item">
|
|
||||||
<a class="page-link" href="#">Next</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Variables
|
|
||||||
|
|
||||||
{{< added-in "5.2.0" >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< scss-docs name="pagination-css-vars" file="scss/_pagination.scss" >}}
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
{{< scss-docs name="pagination-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
### Sass mixins
|
|
||||||
|
|
||||||
{{< scss-docs name="pagination-mixin" file="scss/mixins/_pagination.scss" >}}
|
|
|
@ -1,196 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Progress
|
|
||||||
description: Documentation and examples for using Bootstrap custom progress bars featuring support for stacked bars, animated backgrounds, and text labels.
|
|
||||||
group: components
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
**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.]({{< docsref "/migration#improved-markup-for-progress-bars" >}})
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## 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](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/progress), 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).
|
|
||||||
- We use the inner `.progress-bar` purely for the visual bar and label.
|
|
||||||
- The `.progress-bar` requires an inline style, utility class, or custom CSS to set its width.
|
|
||||||
- We provide a special `.progress-stacked` class to create multiple/stacked progress bars.
|
|
||||||
|
|
||||||
Put that all together, and you have the following examples.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="progress" role="progressbar" aria-label="Basic example" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar" style="width: 0%"></div>
|
|
||||||
</div>
|
|
||||||
<div class="progress" role="progressbar" aria-label="Basic example" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar" style="width: 25%"></div>
|
|
||||||
</div>
|
|
||||||
<div class="progress" role="progressbar" aria-label="Basic example" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar" style="width: 50%"></div>
|
|
||||||
</div>
|
|
||||||
<div class="progress" role="progressbar" aria-label="Basic example" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar" style="width: 75%"></div>
|
|
||||||
</div>
|
|
||||||
<div class="progress" role="progressbar" aria-label="Basic example" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar" style="width: 100%"></div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Bar sizing
|
|
||||||
|
|
||||||
### Width
|
|
||||||
|
|
||||||
Bootstrap provides a handful of [utilities for setting width]({{< docsref "/utilities/sizing" >}}). Depending on your needs, these may help with quickly configuring the width of the `.progress-bar`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="progress" role="progressbar" aria-label="Basic example" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar w-75"></div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Height
|
|
||||||
|
|
||||||
You only set a `height` value on the `.progress` container, so if you change that value, the inner `.progress-bar` will automatically resize accordingly.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="progress" role="progressbar" aria-label="Example 1px high" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100" style="height: 1px">
|
|
||||||
<div class="progress-bar" style="width: 25%"></div>
|
|
||||||
</div>
|
|
||||||
<div class="progress" role="progressbar" aria-label="Example 20px high" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100" style="height: 20px">
|
|
||||||
<div class="progress-bar" style="width: 25%"></div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Labels
|
|
||||||
|
|
||||||
Add labels to your progress bars by placing text within the `.progress-bar`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="progress" role="progressbar" aria-label="Example with label" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar" style="width: 25%">25%</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### 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]({{< docsref "/utilities/overflow" >}}).
|
|
||||||
|
|
||||||
{{< callout warning >}}
|
|
||||||
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.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## Backgrounds
|
|
||||||
|
|
||||||
Use background utility classes to change the appearance of individual progress bars.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="progress" role="progressbar" aria-label="Success example" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar bg-success" style="width: 25%"></div>
|
|
||||||
</div>
|
|
||||||
<div class="progress" role="progressbar" aria-label="Info example" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar bg-info" style="width: 50%"></div>
|
|
||||||
</div>
|
|
||||||
<div class="progress" role="progressbar" aria-label="Warning example" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar bg-warning" style="width: 75%"></div>
|
|
||||||
</div>
|
|
||||||
<div class="progress" role="progressbar" aria-label="Danger example" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar bg-danger" style="width: 100%"></div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
{{< partial "callouts/warning-color-assistive-technologies.md" >}}
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
If you're adding labels to progress bars with a custom background color, make sure to also set an appropriate [text color]({{< docsref "/utilities/colors#colors" >}}), so the labels remain readable and have sufficient contrast. We recommend using the [color and background]({{< docsref "/helpers/color-background" >}}) helper classes.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="progress" role="progressbar" aria-label="Success example" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar text-bg-success" style="width: 25%">25%</div>
|
|
||||||
</div>
|
|
||||||
<div class="progress" role="progressbar" aria-label="Info example" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar text-bg-info" style="width: 50%">50%</div>
|
|
||||||
</div>
|
|
||||||
<div class="progress" role="progressbar" aria-label="Warning example" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar text-bg-warning" style="width: 75%">75%</div>
|
|
||||||
</div>
|
|
||||||
<div class="progress" role="progressbar" aria-label="Danger example" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar text-bg-danger" style="width: 100%">100%</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Multiple bars
|
|
||||||
|
|
||||||
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-bar`s.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="progress-stacked">
|
|
||||||
<div class="progress" role="progressbar" aria-label="Segment one" aria-valuenow="15" aria-valuemin="0" aria-valuemax="100" style="width: 15%">
|
|
||||||
<div class="progress-bar"></div>
|
|
||||||
</div>
|
|
||||||
<div class="progress" role="progressbar" aria-label="Segment two" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100" style="width: 30%">
|
|
||||||
<div class="progress-bar bg-success"></div>
|
|
||||||
</div>
|
|
||||||
<div class="progress" role="progressbar" aria-label="Segment three" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: 20%">
|
|
||||||
<div class="progress-bar bg-info"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Striped
|
|
||||||
|
|
||||||
Add `.progress-bar-striped` to any `.progress-bar` to apply a stripe via CSS gradient over the progress bar's background color.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="progress" role="progressbar" aria-label="Default striped example" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar progress-bar-striped" style="width: 10%"></div>
|
|
||||||
</div>
|
|
||||||
<div class="progress" role="progressbar" aria-label="Success striped example" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar progress-bar-striped bg-success" style="width: 25%"></div>
|
|
||||||
</div>
|
|
||||||
<div class="progress" role="progressbar" aria-label="Info striped example" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar progress-bar-striped bg-info" style="width: 50%"></div>
|
|
||||||
</div>
|
|
||||||
<div class="progress" role="progressbar" aria-label="Warning striped example" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar progress-bar-striped bg-warning" style="width: 75%"></div>
|
|
||||||
</div>
|
|
||||||
<div class="progress" role="progressbar" aria-label="Danger striped example" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar progress-bar-striped bg-danger" style="width: 100%"></div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Animated stripes
|
|
||||||
|
|
||||||
The striped gradient can also be animated. Add `.progress-bar-animated` to `.progress-bar` to animate the stripes right to left via CSS3 animations.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="progress" role="progressbar" aria-label="Animated striped example" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100">
|
|
||||||
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width: 75%"></div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Variables
|
|
||||||
|
|
||||||
{{< added-in "5.2.0" >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< scss-docs name="progress-css-vars" file="scss/_progress.scss" >}}
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
{{< scss-docs name="progress-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
### Keyframes
|
|
||||||
|
|
||||||
Used for creating the CSS animations for `.progress-bar-animated`. Included in `scss/_progress-bar.scss`.
|
|
||||||
|
|
||||||
{{< scss-docs name="progress-keyframes" file="scss/_progress.scss" >}}
|
|
|
@ -1,211 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Spinners
|
|
||||||
description: Indicate the loading state of a component or page with Bootstrap spinners, built entirely with HTML, CSS, and no JavaScript.
|
|
||||||
group: components
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## About
|
|
||||||
|
|
||||||
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>`.
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
{{< partial "callouts/info-prefersreducedmotion.md" >}}
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## Border spinner
|
|
||||||
|
|
||||||
Use the border spinners for a lightweight loading indicator.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="spinner-border" role="status">
|
|
||||||
<span class="visually-hidden">Loading...</span>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Colors
|
|
||||||
|
|
||||||
The border spinner uses `currentColor` for its `border-color`, meaning you can customize the color with [text color utilities][color]. You can use any of our text color utilities on the standard spinner.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
{{< spinner.inline >}}
|
|
||||||
{{- range (index $.Site.Data "theme-colors") }}
|
|
||||||
<div class="spinner-border text-{{ .name }}" role="status">
|
|
||||||
<span class="visually-hidden">Loading...</span>
|
|
||||||
</div>
|
|
||||||
{{- end -}}
|
|
||||||
{{< /spinner.inline >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
**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.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## 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!
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="spinner-grow" role="status">
|
|
||||||
<span class="visually-hidden">Loading...</span>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Once again, this spinner is built with `currentColor`, so you can easily change its appearance with [text color utilities][color]. Here it is in blue, along with the supported variants.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
{{< spinner.inline >}}
|
|
||||||
{{- range (index $.Site.Data "theme-colors") }}
|
|
||||||
<div class="spinner-grow text-{{ .name }}" role="status">
|
|
||||||
<span class="visually-hidden">Loading...</span>
|
|
||||||
</div>
|
|
||||||
{{- end -}}
|
|
||||||
{{< /spinner.inline >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Alignment
|
|
||||||
|
|
||||||
Spinners in Bootstrap are built with `rem`s, `currentColor`, and `display: inline-flex`. This means they can easily be resized, recolored, and quickly aligned.
|
|
||||||
|
|
||||||
### Margin
|
|
||||||
|
|
||||||
Use [margin utilities][margin] like `.m-5` for easy spacing.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="spinner-border m-5" role="status">
|
|
||||||
<span class="visually-hidden">Loading...</span>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Placement
|
|
||||||
|
|
||||||
Use [flexbox utilities][flex], [float utilities][float], or [text alignment][text] utilities to place spinners exactly where you need them in any situation.
|
|
||||||
|
|
||||||
#### Flex
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="d-flex justify-content-center">
|
|
||||||
<div class="spinner-border" role="status">
|
|
||||||
<span class="visually-hidden">Loading...</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="d-flex align-items-center">
|
|
||||||
<strong role="status">Loading...</strong>
|
|
||||||
<div class="spinner-border ms-auto" aria-hidden="true"></div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
#### Floats
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="clearfix">
|
|
||||||
<div class="spinner-border float-end" role="status">
|
|
||||||
<span class="visually-hidden">Loading...</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
#### Text align
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="text-center">
|
|
||||||
<div class="spinner-border" role="status">
|
|
||||||
<span class="visually-hidden">Loading...</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Size
|
|
||||||
|
|
||||||
Add `.spinner-border-sm` and `.spinner-grow-sm` to make a smaller spinner that can quickly be used within other components.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="spinner-border spinner-border-sm" role="status">
|
|
||||||
<span class="visually-hidden">Loading...</span>
|
|
||||||
</div>
|
|
||||||
<div class="spinner-grow spinner-grow-sm" role="status">
|
|
||||||
<span class="visually-hidden">Loading...</span>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Or, use custom CSS or inline styles to change the dimensions as needed.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="spinner-border" style="width: 3rem; height: 3rem;" role="status">
|
|
||||||
<span class="visually-hidden">Loading...</span>
|
|
||||||
</div>
|
|
||||||
<div class="spinner-grow" style="width: 3rem; height: 3rem;" role="status">
|
|
||||||
<span class="visually-hidden">Loading...</span>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Buttons
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<button class="btn btn-primary" type="button" disabled>
|
|
||||||
<span class="spinner-border spinner-border-sm" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden" role="status">Loading...</span>
|
|
||||||
</button>
|
|
||||||
<button class="btn btn-primary" type="button" disabled>
|
|
||||||
<span class="spinner-border spinner-border-sm" aria-hidden="true"></span>
|
|
||||||
<span role="status">Loading...</span>
|
|
||||||
</button>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<button class="btn btn-primary" type="button" disabled>
|
|
||||||
<span class="spinner-grow spinner-grow-sm" aria-hidden="true"></span>
|
|
||||||
<span class="visually-hidden" role="status">Loading...</span>
|
|
||||||
</button>
|
|
||||||
<button class="btn btn-primary" type="button" disabled>
|
|
||||||
<span class="spinner-grow spinner-grow-sm" aria-hidden="true"></span>
|
|
||||||
<span role="status">Loading...</span>
|
|
||||||
</button>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Variables
|
|
||||||
|
|
||||||
{{< added-in "5.2.0" >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
Border spinner variables:
|
|
||||||
|
|
||||||
{{< scss-docs name="spinner-border-css-vars" file="scss/_spinners.scss" >}}
|
|
||||||
|
|
||||||
Growing spinner variables:
|
|
||||||
|
|
||||||
{{< scss-docs name="spinner-grow-css-vars" file="scss/_spinners.scss" >}}
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
{{< scss-docs name="spinner-border-sm-css-vars" file="scss/_spinners.scss" >}}
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
{{< scss-docs name="spinner-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
### Keyframes
|
|
||||||
|
|
||||||
Used for creating the CSS animations for our spinners. Included in `scss/_spinners.scss`.
|
|
||||||
|
|
||||||
{{< scss-docs name="spinner-border-keyframes" file="scss/_spinners.scss" >}}
|
|
||||||
|
|
||||||
{{< scss-docs name="spinner-grow-keyframes" file="scss/_spinners.scss" >}}
|
|
||||||
|
|
||||||
|
|
||||||
[color]: {{< docsref "/utilities/colors" >}}
|
|
||||||
[flex]: {{< docsref "/utilities/flex" >}}
|
|
||||||
[float]: {{< docsref "/utilities/float" >}}
|
|
||||||
[margin]: {{< docsref "/utilities/spacing" >}}
|
|
||||||
[text]: {{< docsref "/utilities/text" >}}
|
|
|
@ -1,391 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Toasts
|
|
||||||
description: Push notifications to your visitors with a toast, a lightweight and easily customizable alert message.
|
|
||||||
group: components
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
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`.
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
{{< partial "callouts/info-prefersreducedmotion.md" >}}
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
### Basic
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
|
||||||
<div class="toast-header">
|
|
||||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
|
||||||
<strong class="me-auto">Bootstrap</strong>
|
|
||||||
<small>11 mins ago</small>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="toast-body">
|
|
||||||
Hello, world! This is a toast message.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< callout warning >}}
|
|
||||||
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.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
### 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.
|
|
||||||
|
|
||||||
<div class="toast-container position-fixed bottom-0 end-0 p-3">
|
|
||||||
<div id="liveToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
|
||||||
<div class="toast-header">
|
|
||||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
|
||||||
<strong class="me-auto">Bootstrap</strong>
|
|
||||||
<small>11 mins ago</small>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="toast-body">
|
|
||||||
Hello, world! This is a toast message.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="bd-example">
|
|
||||||
<button type="button" class="btn btn-primary" id="liveToastBtn">Show live toast</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
```html
|
|
||||||
<button type="button" class="btn btn-primary" id="liveToastBtn">Show live toast</button>
|
|
||||||
|
|
||||||
<div class="toast-container position-fixed bottom-0 end-0 p-3">
|
|
||||||
<div id="liveToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
|
||||||
<div class="toast-header">
|
|
||||||
<img src="..." class="rounded me-2" alt="...">
|
|
||||||
<strong class="me-auto">Bootstrap</strong>
|
|
||||||
<small>11 mins ago</small>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="toast-body">
|
|
||||||
Hello, world! This is a toast message.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
```
|
|
||||||
|
|
||||||
We use the following JavaScript to trigger our live toast demo:
|
|
||||||
|
|
||||||
{{< js-docs name="live-toast" file="site/assets/js/partials/snippets.js" >}}
|
|
||||||
|
|
||||||
### Translucent
|
|
||||||
|
|
||||||
Toasts are slightly translucent to blend in with what's below them.
|
|
||||||
|
|
||||||
{{< example class="bg-dark" >}}
|
|
||||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
|
||||||
<div class="toast-header">
|
|
||||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
|
||||||
<strong class="me-auto">Bootstrap</strong>
|
|
||||||
<small class="text-body-secondary">11 mins ago</small>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="toast-body">
|
|
||||||
Hello, world! This is a toast message.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Stacking
|
|
||||||
|
|
||||||
You can stack toasts by wrapping them in a toast container, which will vertically add some spacing.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="toast-container position-static">
|
|
||||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
|
||||||
<div class="toast-header">
|
|
||||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
|
||||||
<strong class="me-auto">Bootstrap</strong>
|
|
||||||
<small class="text-body-secondary">just now</small>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="toast-body">
|
|
||||||
See? Just like this.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
|
||||||
<div class="toast-header">
|
|
||||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
|
||||||
<strong class="me-auto">Bootstrap</strong>
|
|
||||||
<small class="text-body-secondary">2 seconds ago</small>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="toast-body">
|
|
||||||
Heads up, toasts will stack automatically
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Custom content
|
|
||||||
|
|
||||||
Customize your toasts by removing sub-components, tweaking them with [utilities]({{< docsref "/utilities/api" >}}), 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]({{< param icons >}}), and using some [flexbox utilities]({{< docsref "/utilities/flex" >}}) to adjust the layout.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="toast align-items-center" role="alert" aria-live="assertive" aria-atomic="true">
|
|
||||||
<div class="d-flex">
|
|
||||||
<div class="toast-body">
|
|
||||||
Hello, world! This is a toast message.
|
|
||||||
</div>
|
|
||||||
<button type="button" class="btn-close me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Alternatively, you can also add additional controls and components to toasts.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
|
||||||
<div class="toast-body">
|
|
||||||
Hello, world! This is a toast message.
|
|
||||||
<div class="mt-2 pt-2 border-top">
|
|
||||||
<button type="button" class="btn btn-primary btn-sm">Take action</button>
|
|
||||||
<button type="button" class="btn btn-secondary btn-sm" data-bs-dismiss="toast">Close</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Color schemes
|
|
||||||
|
|
||||||
Building on the above example, you can create different toast color schemes with our [color]({{< docsref "/utilities/colors" >}}) and [background]({{< docsref "/utilities/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`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="toast align-items-center text-bg-primary border-0" role="alert" aria-live="assertive" aria-atomic="true">
|
|
||||||
<div class="d-flex">
|
|
||||||
<div class="toast-body">
|
|
||||||
Hello, world! This is a toast message.
|
|
||||||
</div>
|
|
||||||
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## 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`.
|
|
||||||
|
|
||||||
{{< example stackblitz_add_js="true" >}}
|
|
||||||
<form>
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="selectToastPlacement">Toast placement</label>
|
|
||||||
<select class="form-select mt-2" id="selectToastPlacement">
|
|
||||||
<option value="" selected>Select a position...</option>
|
|
||||||
<option value="top-0 start-0">Top left</option>
|
|
||||||
<option value="top-0 start-50 translate-middle-x">Top center</option>
|
|
||||||
<option value="top-0 end-0">Top right</option>
|
|
||||||
<option value="top-50 start-0 translate-middle-y">Middle left</option>
|
|
||||||
<option value="top-50 start-50 translate-middle">Middle center</option>
|
|
||||||
<option value="top-50 end-0 translate-middle-y">Middle right</option>
|
|
||||||
<option value="bottom-0 start-0">Bottom left</option>
|
|
||||||
<option value="bottom-0 start-50 translate-middle-x">Bottom center</option>
|
|
||||||
<option value="bottom-0 end-0">Bottom right</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<div aria-live="polite" aria-atomic="true" class="bg-body-secondary position-relative bd-example-toasts rounded-3">
|
|
||||||
<div class="toast-container p-3" id="toastPlacement">
|
|
||||||
<div class="toast">
|
|
||||||
<div class="toast-header">
|
|
||||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
|
||||||
<strong class="me-auto">Bootstrap</strong>
|
|
||||||
<small>11 mins ago</small>
|
|
||||||
</div>
|
|
||||||
<div class="toast-body">
|
|
||||||
Hello, world! This is a toast message.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
For systems that generate more notifications, consider using a wrapping element so they can easily stack.
|
|
||||||
|
|
||||||
{{< example class="bd-example-toasts p-0" >}}
|
|
||||||
<div aria-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 -->
|
|
||||||
<div class="toast-container top-0 end-0 p-3">
|
|
||||||
|
|
||||||
<!-- Then put toasts within -->
|
|
||||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
|
||||||
<div class="toast-header">
|
|
||||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
|
||||||
<strong class="me-auto">Bootstrap</strong>
|
|
||||||
<small class="text-body-secondary">just now</small>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="toast-body">
|
|
||||||
See? Just like this.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
|
||||||
<div class="toast-header">
|
|
||||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
|
||||||
<strong class="me-auto">Bootstrap</strong>
|
|
||||||
<small class="text-body-secondary">2 seconds ago</small>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="toast-body">
|
|
||||||
Heads up, toasts will stack automatically
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
You can also get fancy with flexbox utilities to align toasts horizontally and/or vertically.
|
|
||||||
|
|
||||||
{{< example class="bd-example-toasts d-flex" >}}
|
|
||||||
<!-- Flexbox container for aligning the toasts -->
|
|
||||||
<div aria-live="polite" aria-atomic="true" class="d-flex justify-content-center align-items-center w-100">
|
|
||||||
|
|
||||||
<!-- Then put toasts within -->
|
|
||||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
|
||||||
<div class="toast-header">
|
|
||||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
|
||||||
<strong class="me-auto">Bootstrap</strong>
|
|
||||||
<small>11 mins ago</small>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="toast-body">
|
|
||||||
Hello, world! This is a toast message.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## 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](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions). 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]({{< docsref "/components/alerts" >}}) 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](#options) so that users have enough time to read the toast.
|
|
||||||
|
|
||||||
```html
|
|
||||||
<div class="toast" role="alert" aria-live="polite" aria-atomic="true" data-bs-delay="10000">
|
|
||||||
<div role="alert" aria-live="assertive" aria-atomic="true">...</div>
|
|
||||||
</div>
|
|
||||||
```
|
|
||||||
|
|
||||||
When using `autohide: false`, you must add a close button to allow users to dismiss the toast.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div role="alert" aria-live="assertive" aria-atomic="true" class="toast" data-bs-autohide="false">
|
|
||||||
<div class="toast-header">
|
|
||||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
|
||||||
<strong class="me-auto">Bootstrap</strong>
|
|
||||||
<small>11 mins ago</small>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="toast-body">
|
|
||||||
Hello, world! This is a toast message.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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](#options), 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 "5.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.
|
|
||||||
|
|
||||||
{{< scss-docs name="toast-css-vars" file="scss/_toasts.scss" >}}
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
{{< scss-docs name="toast-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
Initialize toasts via JavaScript:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const toastElList = document.querySelectorAll('.toast')
|
|
||||||
const toastList = [...toastElList].map(toastEl => new bootstrap.Toast(toastEl, option))
|
|
||||||
```
|
|
||||||
|
|
||||||
### Triggers
|
|
||||||
|
|
||||||
{{% js-dismiss "toast" %}}
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
{{< markdown >}}
|
|
||||||
{{< partial "js-data-attributes.md" >}}
|
|
||||||
{{< /markdown >}}
|
|
||||||
|
|
||||||
{{< bs-table "table" >}}
|
|
||||||
| 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. |
|
|
||||||
{{< /bs-table >}}
|
|
||||||
|
|
||||||
### Methods
|
|
||||||
|
|
||||||
{{< callout danger >}}
|
|
||||||
{{< partial "callouts/danger-async-methods.md" >}}
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
{{< bs-table "table" >}}
|
|
||||||
| 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. <br> 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. <br>`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. |
|
|
||||||
{{< /bs-table >}}
|
|
||||||
|
|
||||||
### Events
|
|
||||||
|
|
||||||
{{< bs-table "table" >}}
|
|
||||||
| 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. |
|
|
||||||
{{< /bs-table >}}
|
|
||||||
|
|
||||||
```js
|
|
||||||
const myToastEl = document.getElementById('myToast')
|
|
||||||
myToastEl.addEventListener('hidden.bs.toast', () => {
|
|
||||||
// do something...
|
|
||||||
})
|
|
||||||
```
|
|
|
@ -1,33 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Figures
|
|
||||||
description: Documentation and examples for displaying related images and text with the figure component in Bootstrap.
|
|
||||||
group: content
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<figure class="figure">
|
|
||||||
{{< placeholder width="400" height="300" class="figure-img img-fluid rounded" >}}
|
|
||||||
<figcaption class="figure-caption">A caption for the above image.</figcaption>
|
|
||||||
</figure>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Aligning the figure's caption is easy with our [text utilities]({{< docsref "/utilities/text#text-alignment" >}}).
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<figure class="figure">
|
|
||||||
{{< placeholder width="400" height="300" class="figure-img img-fluid rounded" >}}
|
|
||||||
<figcaption class="figure-caption text-end">A caption for the above image.</figcaption>
|
|
||||||
</figure>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
{{< scss-docs name="figure-variables" file="scss/_variables.scss" >}}
|
|
|
@ -1,63 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Images
|
|
||||||
description: 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.
|
|
||||||
group: content
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## Responsive images
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
{{< placeholder width="100%" height="250" class="bd-placeholder-img-lg img-fluid" text="Responsive image" >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Image thumbnails
|
|
||||||
|
|
||||||
In addition to our [border-radius utilities]({{< docsref "/utilities/borders" >}}), you can use `.img-thumbnail` to give an image a rounded 1px border appearance.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
{{< placeholder width="200" height="200" class="img-thumbnail" title="A generic square placeholder image with a white border around it, making it resemble a photograph taken with an old instant camera" >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Aligning images
|
|
||||||
|
|
||||||
Align images with the [helper float classes]({{< docsref "/utilities/float" >}}) or [text alignment classes]({{< docsref "/utilities/text#text-alignment" >}}). `block`-level images can be centered using [the `.mx-auto` margin utility class]({{< docsref "/utilities/spacing#horizontal-centering" >}}).
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
{{< placeholder width="200" height="200" class="rounded float-start" >}}
|
|
||||||
{{< placeholder width="200" height="200" class="rounded float-end" >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
{{< placeholder width="200" height="200" class="rounded mx-auto d-block" >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="text-center">
|
|
||||||
{{< placeholder width="200" height="200" class="rounded" >}}
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
|
|
||||||
## Picture
|
|
||||||
|
|
||||||
If you are using the `<picture>` element to specify multiple `<source>` elements for a specific `<img>`, make sure to add the `.img-*` classes to the `<img>` and not to the `<picture>` tag.
|
|
||||||
|
|
||||||
```html
|
|
||||||
<picture>
|
|
||||||
<source srcset="..." type="image/svg+xml">
|
|
||||||
<img src="..." class="img-fluid img-thumbnail" alt="...">
|
|
||||||
</picture>
|
|
||||||
```
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
Variables are available for image thumbnails.
|
|
||||||
|
|
||||||
{{< scss-docs name="thumbnail-variables" file="scss/_variables.scss" >}}
|
|
|
@ -1,77 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Components
|
|
||||||
description: Learn how and why we build nearly all our components responsively and with base and modifier classes.
|
|
||||||
group: customize
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## Base 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]({{< docsref "/customize/sass#maps-and-loops" >}}) 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.
|
|
||||||
|
|
||||||
{{< scss-docs name="alert-modifiers" file="scss/_alert.scss" >}}
|
|
||||||
|
|
||||||
{{< scss-docs name="list-group-modifiers" file="scss/_list-group.scss" >}}
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
{{< scss-docs name="responsive-breakpoints" file="scss/_dropdown.scss" >}}
|
|
||||||
|
|
||||||
Should you modify your `$grid-breakpoints`, your changes will apply to all the loops iterating over that map.
|
|
||||||
|
|
||||||
{{< scss-docs name="grid-breakpoints" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
For more information and examples on how to modify our Sass maps and variables, please refer to [the CSS section of the Grid documentation]({{< docsref "/layout/grid#css" >}}).
|
|
||||||
|
|
||||||
## Creating your own
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
<div class="bd-example">
|
|
||||||
<div class="bd-callout my-0">
|
|
||||||
<strong>This is a callout.</strong> We built it custom for our docs so our messages to you stand out. It has three variants via modifier classes.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
```html
|
|
||||||
<div class="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.
|
|
||||||
|
|
||||||
```scss
|
|
||||||
// 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:
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
**This is an info callout.** Example text to show it in action.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
{{< callout warning >}}
|
|
||||||
**This is a warning callout.** Example text to show it in action.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
{{< callout danger >}}
|
|
||||||
**This is a danger callout.** Example text to show it in action.
|
|
||||||
{{< /callout >}}
|
|
|
@ -1,6 +0,0 @@
|
||||||
---
|
|
||||||
layout: single
|
|
||||||
title: Examples
|
|
||||||
description: Quickly get a project started with any of our examples ranging from using parts of the framework to custom components and layouts.
|
|
||||||
aliases: "/examples/"
|
|
||||||
---
|
|
|
@ -1,40 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Icons
|
|
||||||
description: Guidance and suggestions for using external icon libraries with Bootstrap.
|
|
||||||
group: extend
|
|
||||||
---
|
|
||||||
|
|
||||||
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](https://github.com/mdo) and maintained by [the Bootstrap Team](https://github.com/orgs/twbs/people). 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.
|
|
||||||
|
|
||||||
[Learn more about Bootstrap Icons]({{< param icons >}}), including how to install them and recommended usage.
|
|
||||||
|
|
||||||
## Alternatives
|
|
||||||
|
|
||||||
We've tested and used these icon sets ourselves as preferred alternatives to Bootstrap Icons.
|
|
||||||
|
|
||||||
{{< markdown >}}
|
|
||||||
{{< icons.inline >}}
|
|
||||||
{{- $type := .Get "type" | default "preferred" -}}
|
|
||||||
|
|
||||||
{{- range (index .Site.Data.icons $type) }}
|
|
||||||
- [{{ .name }}]({{ .website }})
|
|
||||||
{{- end }}
|
|
||||||
{{< /icons.inline >}}
|
|
||||||
{{< /markdown >}}
|
|
||||||
|
|
||||||
## More options
|
|
||||||
|
|
||||||
While we haven't tried these out ourselves, they do look promising and provide multiple formats, including SVG.
|
|
||||||
|
|
||||||
{{< markdown >}}
|
|
||||||
{{< icons.inline type="more" />}}
|
|
||||||
{{< /markdown >}}
|
|
|
@ -1,334 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Checks and radios
|
|
||||||
description: Create consistent cross-browser and cross-device checkboxes and radios with our completely rewritten checks component.
|
|
||||||
group: forms
|
|
||||||
aliases: "/docs/5.3/forms/checks/"
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## Approach
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
Our checks use custom Bootstrap icons to indicate checked or indeterminate states.
|
|
||||||
|
|
||||||
## Checks
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" value="" id="checkDefault">
|
|
||||||
<label class="form-check-label" for="checkDefault">
|
|
||||||
Default checkbox
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" value="" id="checkChecked" checked>
|
|
||||||
<label class="form-check-label" for="checkChecked">
|
|
||||||
Checked checkbox
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Indeterminate
|
|
||||||
|
|
||||||
Checkboxes can utilize the `:indeterminate` pseudo class when manually set via JavaScript (there is no available HTML attribute for specifying it).
|
|
||||||
|
|
||||||
{{< example class="bd-example-indeterminate" stackblitz_add_js="true" >}}
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" value="" id="checkIndeterminate">
|
|
||||||
<label class="form-check-label" for="checkIndeterminate">
|
|
||||||
Indeterminate checkbox
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Disabled
|
|
||||||
|
|
||||||
Add the `disabled` attribute and the associated `<label>`s are automatically styled to match with a lighter color to help indicate the input's state.
|
|
||||||
|
|
||||||
{{< example class="bd-example-indeterminate" stackblitz_add_js="true" >}}
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" value="" id="checkIndeterminateDisabled" disabled>
|
|
||||||
<label class="form-check-label" for="checkIndeterminateDisabled">
|
|
||||||
Disabled indeterminate checkbox
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" value="" id="checkDisabled" disabled>
|
|
||||||
<label class="form-check-label" for="checkDisabled">
|
|
||||||
Disabled checkbox
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" value="" id="checkCheckedDisabled" checked disabled>
|
|
||||||
<label class="form-check-label" for="checkCheckedDisabled">
|
|
||||||
Disabled checked checkbox
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Radios
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="radio" name="radioDefault" id="radioDefault1">
|
|
||||||
<label class="form-check-label" for="radioDefault1">
|
|
||||||
Default radio
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="radio" name="radioDefault" id="radioDefault2" checked>
|
|
||||||
<label class="form-check-label" for="radioDefault2">
|
|
||||||
Default checked radio
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Disabled
|
|
||||||
|
|
||||||
Add the `disabled` attribute and the associated `<label>`s are automatically styled to match with a lighter color to help indicate the input's state.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="radio" name="radioDisabled" id="radioDisabled" disabled>
|
|
||||||
<label class="form-check-label" for="radioDisabled">
|
|
||||||
Disabled radio
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="radio" name="radioDisabled" id="radioCheckedDisabled" checked disabled>
|
|
||||||
<label class="form-check-label" for="radioCheckedDisabled">
|
|
||||||
Disabled checked radio
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Switches
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="form-check form-switch">
|
|
||||||
<input class="form-check-input" type="checkbox" role="switch" id="switchCheckDefault">
|
|
||||||
<label class="form-check-label" for="switchCheckDefault">Default switch checkbox input</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check form-switch">
|
|
||||||
<input class="form-check-input" type="checkbox" role="switch" id="switchCheckChecked" checked>
|
|
||||||
<label class="form-check-label" for="switchCheckChecked">Checked switch checkbox input</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check form-switch">
|
|
||||||
<input class="form-check-input" type="checkbox" role="switch" id="switchCheckDisabled" disabled>
|
|
||||||
<label class="form-check-label" for="switchCheckDisabled">Disabled switch checkbox input</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check form-switch">
|
|
||||||
<input class="form-check-input" type="checkbox" role="switch" id="switchCheckCheckedDisabled" checked disabled>
|
|
||||||
<label class="form-check-label" for="switchCheckCheckedDisabled">Disabled checked switch checkbox input</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Default (stacked)
|
|
||||||
|
|
||||||
By default, any number of checkboxes and radios that are immediate sibling will be vertically stacked and appropriately spaced with `.form-check`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" value="" id="defaultCheck1">
|
|
||||||
<label class="form-check-label" for="defaultCheck1">
|
|
||||||
Default checkbox
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" value="" id="defaultCheck2" disabled>
|
|
||||||
<label class="form-check-label" for="defaultCheck2">
|
|
||||||
Disabled checkbox
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios1" value="option1" checked>
|
|
||||||
<label class="form-check-label" for="exampleRadios1">
|
|
||||||
Default radio
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios2" value="option2">
|
|
||||||
<label class="form-check-label" for="exampleRadios2">
|
|
||||||
Second default radio
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios3" value="option3" disabled>
|
|
||||||
<label class="form-check-label" for="exampleRadios3">
|
|
||||||
Disabled radio
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Inline
|
|
||||||
|
|
||||||
Group checkboxes or radios on the same horizontal row by adding `.form-check-inline` to any `.form-check`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="form-check form-check-inline">
|
|
||||||
<input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option1">
|
|
||||||
<label class="form-check-label" for="inlineCheckbox1">1</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check form-check-inline">
|
|
||||||
<input class="form-check-input" type="checkbox" id="inlineCheckbox2" value="option2">
|
|
||||||
<label class="form-check-label" for="inlineCheckbox2">2</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check form-check-inline">
|
|
||||||
<input class="form-check-input" type="checkbox" id="inlineCheckbox3" value="option3" disabled>
|
|
||||||
<label class="form-check-label" for="inlineCheckbox3">3 (disabled)</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="form-check form-check-inline">
|
|
||||||
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
|
|
||||||
<label class="form-check-label" for="inlineRadio1">1</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check form-check-inline">
|
|
||||||
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2">
|
|
||||||
<label class="form-check-label" for="inlineRadio2">2</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check form-check-inline">
|
|
||||||
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3" disabled>
|
|
||||||
<label class="form-check-label" for="inlineRadio3">3 (disabled)</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Reverse
|
|
||||||
|
|
||||||
Put your checkboxes, radios, and switches on the opposite side with the `.form-check-reverse` modifier class.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="form-check form-check-reverse">
|
|
||||||
<input class="form-check-input" type="checkbox" value="" id="reverseCheck1">
|
|
||||||
<label class="form-check-label" for="reverseCheck1">
|
|
||||||
Reverse checkbox
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check form-check-reverse">
|
|
||||||
<input class="form-check-input" type="checkbox" value="" id="reverseCheck2" disabled>
|
|
||||||
<label class="form-check-label" for="reverseCheck2">
|
|
||||||
Disabled reverse checkbox
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-check form-switch form-check-reverse">
|
|
||||||
<input class="form-check-input" type="checkbox" id="switchCheckReverse">
|
|
||||||
<label class="form-check-label" for="switchCheckReverse">Reverse switch checkbox input</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Without labels
|
|
||||||
|
|
||||||
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]({{< docsref "/forms/overview#accessibility" >}}) section for details.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div>
|
|
||||||
<input class="form-check-input" type="checkbox" id="checkboxNoLabel" value="" aria-label="...">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<input class="form-check-input" type="radio" name="radioNoLabel" id="radioNoLabel1" value="" aria-label="...">
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Toggle buttons
|
|
||||||
|
|
||||||
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]({{< docsref "/components/button-group" >}}) if needed.
|
|
||||||
|
|
||||||
### Checkbox toggle buttons
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<input type="checkbox" class="btn-check" id="btn-check" autocomplete="off">
|
|
||||||
<label class="btn btn-primary" for="btn-check">Single toggle</label>
|
|
||||||
|
|
||||||
<input type="checkbox" class="btn-check" id="btn-check-2" checked autocomplete="off">
|
|
||||||
<label class="btn btn-primary" for="btn-check-2">Checked</label>
|
|
||||||
|
|
||||||
<input type="checkbox" class="btn-check" id="btn-check-3" autocomplete="off" disabled>
|
|
||||||
<label class="btn btn-primary" for="btn-check-3">Disabled</label>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<input type="checkbox" class="btn-check" id="btn-check-4" autocomplete="off">
|
|
||||||
<label class="btn" for="btn-check-4">Single toggle</label>
|
|
||||||
|
|
||||||
<input type="checkbox" class="btn-check" id="btn-check-5" checked autocomplete="off">
|
|
||||||
<label class="btn" for="btn-check-5">Checked</label>
|
|
||||||
|
|
||||||
<input type="checkbox" class="btn-check" id="btn-check-6" autocomplete="off" disabled>
|
|
||||||
<label class="btn" for="btn-check-6">Disabled</label>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
Visually, these checkbox toggle buttons are identical to the [button plugin toggle buttons]({{< docsref "/components/buttons#button-plugin" >}}). 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.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
### Radio toggle buttons
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<input type="radio" class="btn-check" name="options" id="option1" autocomplete="off" checked>
|
|
||||||
<label class="btn btn-secondary" for="option1">Checked</label>
|
|
||||||
|
|
||||||
<input type="radio" class="btn-check" name="options" id="option2" autocomplete="off">
|
|
||||||
<label class="btn btn-secondary" for="option2">Radio</label>
|
|
||||||
|
|
||||||
<input type="radio" class="btn-check" name="options" id="option3" autocomplete="off" disabled>
|
|
||||||
<label class="btn btn-secondary" for="option3">Disabled</label>
|
|
||||||
|
|
||||||
<input type="radio" class="btn-check" name="options" id="option4" autocomplete="off">
|
|
||||||
<label class="btn btn-secondary" for="option4">Radio</label>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<input type="radio" class="btn-check" name="options-base" id="option5" autocomplete="off" checked>
|
|
||||||
<label class="btn" for="option5">Checked</label>
|
|
||||||
|
|
||||||
<input type="radio" class="btn-check" name="options-base" id="option6" autocomplete="off">
|
|
||||||
<label class="btn" for="option6">Radio</label>
|
|
||||||
|
|
||||||
<input type="radio" class="btn-check" name="options-base" id="option7" autocomplete="off" disabled>
|
|
||||||
<label class="btn" for="option7">Disabled</label>
|
|
||||||
|
|
||||||
<input type="radio" class="btn-check" name="options-base" id="option8" autocomplete="off">
|
|
||||||
<label class="btn" for="option8">Radio</label>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Outlined styles
|
|
||||||
|
|
||||||
Different variants of `.btn`, such as the various outlined styles, are supported.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<input type="checkbox" class="btn-check" id="btn-check-outlined" autocomplete="off">
|
|
||||||
<label class="btn btn-outline-primary" for="btn-check-outlined">Single toggle</label><br>
|
|
||||||
|
|
||||||
<input type="checkbox" class="btn-check" id="btn-check-2-outlined" checked autocomplete="off">
|
|
||||||
<label class="btn btn-outline-secondary" for="btn-check-2-outlined">Checked</label><br>
|
|
||||||
|
|
||||||
<input type="radio" class="btn-check" name="options-outlined" id="success-outlined" autocomplete="off" checked>
|
|
||||||
<label class="btn btn-outline-success" for="success-outlined">Checked success radio</label>
|
|
||||||
|
|
||||||
<input type="radio" class="btn-check" name="options-outlined" id="danger-outlined" autocomplete="off">
|
|
||||||
<label class="btn btn-outline-danger" for="danger-outlined">Danger radio</label>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
Variables for checks:
|
|
||||||
|
|
||||||
{{< scss-docs name="form-check-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
Variables for switches:
|
|
||||||
|
|
||||||
{{< scss-docs name="form-switch-variables" file="scss/_variables.scss" >}}
|
|
|
@ -1,180 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Floating labels
|
|
||||||
description: Create beautifully simple form labels that float over your input fields.
|
|
||||||
group: forms
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
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., `~`).
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="form-floating mb-3">
|
|
||||||
<input type="email" class="form-control" id="floatingInput" placeholder="name@example.com">
|
|
||||||
<label for="floatingInput">Email address</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-floating">
|
|
||||||
<input type="password" class="form-control" id="floatingPassword" placeholder="Password">
|
|
||||||
<label for="floatingPassword">Password</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
When there's a `value` already defined, `<label>`s will automatically adjust to their floated position.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<form class="form-floating">
|
|
||||||
<input type="email" class="form-control" id="floatingInputValue" placeholder="name@example.com" value="test@example.com">
|
|
||||||
<label for="floatingInputValue">Input with value</label>
|
|
||||||
</form>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Form validation styles also work as expected.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<form class="form-floating">
|
|
||||||
<input type="email" class="form-control is-invalid" id="floatingInputInvalid" placeholder="name@example.com" value="test@example.com">
|
|
||||||
<label for="floatingInputInvalid">Invalid input</label>
|
|
||||||
</form>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Textareas
|
|
||||||
|
|
||||||
By default, `<textarea>`s with `.form-control` will be the same height as `<input>`s.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="form-floating">
|
|
||||||
<textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea"></textarea>
|
|
||||||
<label for="floatingTextarea">Comments</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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).
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="form-floating">
|
|
||||||
<textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea2" style="height: 100px"></textarea>
|
|
||||||
<label for="floatingTextarea2">Comments</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Selects
|
|
||||||
|
|
||||||
Other than `.form-control`, floating labels are only available on `.form-select`s. 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.**
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="form-floating">
|
|
||||||
<select class="form-select" id="floatingSelect" aria-label="Floating label select example">
|
|
||||||
<option selected>Open this select menu</option>
|
|
||||||
<option value="1">One</option>
|
|
||||||
<option value="2">Two</option>
|
|
||||||
<option value="3">Three</option>
|
|
||||||
</select>
|
|
||||||
<label for="floatingSelect">Works with selects</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Disabled
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="form-floating mb-3">
|
|
||||||
<input type="email" class="form-control" id="floatingInputDisabled" placeholder="name@example.com" disabled>
|
|
||||||
<label for="floatingInputDisabled">Email address</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-floating mb-3">
|
|
||||||
<textarea class="form-control" placeholder="Leave a comment here" id="floatingTextareaDisabled" disabled></textarea>
|
|
||||||
<label for="floatingTextareaDisabled">Comments</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-floating mb-3">
|
|
||||||
<textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea2Disabled" style="height: 100px" disabled>Disabled textarea with some text inside</textarea>
|
|
||||||
<label for="floatingTextarea2Disabled">Comments</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-floating">
|
|
||||||
<select class="form-select" id="floatingSelectDisabled" aria-label="Floating label disabled select example" disabled>
|
|
||||||
<option selected>Open this select menu</option>
|
|
||||||
<option value="1">One</option>
|
|
||||||
<option value="2">Two</option>
|
|
||||||
<option value="3">Three</option>
|
|
||||||
</select>
|
|
||||||
<label for="floatingSelectDisabled">Works with selects</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="form-floating mb-3">
|
|
||||||
<input type="email" readonly class="form-control-plaintext" id="floatingEmptyPlaintextInput" placeholder="name@example.com">
|
|
||||||
<label for="floatingEmptyPlaintextInput">Empty input</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-floating mb-3">
|
|
||||||
<input type="email" readonly class="form-control-plaintext" id="floatingPlaintextInput" placeholder="name@example.com" value="name@example.com">
|
|
||||||
<label for="floatingPlaintextInput">Input with value</label>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Input groups
|
|
||||||
|
|
||||||
Floating labels also support `.input-group`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<span class="input-group-text">@</span>
|
|
||||||
<div class="form-floating">
|
|
||||||
<input type="text" class="form-control" id="floatingInputGroup1" placeholder="Username">
|
|
||||||
<label for="floatingInputGroup1">Username</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="input-group has-validation">
|
|
||||||
<span class="input-group-text">@</span>
|
|
||||||
<div class="form-floating is-invalid">
|
|
||||||
<input type="text" class="form-control is-invalid" id="floatingInputGroup2" placeholder="Username" required>
|
|
||||||
<label for="floatingInputGroup2">Username</label>
|
|
||||||
</div>
|
|
||||||
<div class="invalid-feedback">
|
|
||||||
Please choose a username.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Layout
|
|
||||||
|
|
||||||
When working with the Bootstrap grid system, be sure to place form elements within column classes.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="row g-2">
|
|
||||||
<div class="col-md">
|
|
||||||
<div class="form-floating">
|
|
||||||
<input type="email" class="form-control" id="floatingInputGrid" placeholder="name@example.com" value="mdo@example.com">
|
|
||||||
<label for="floatingInputGrid">Email address</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md">
|
|
||||||
<div class="form-floating">
|
|
||||||
<select class="form-select" id="floatingSelectGrid">
|
|
||||||
<option selected>Open this select menu</option>
|
|
||||||
<option value="1">One</option>
|
|
||||||
<option value="2">Two</option>
|
|
||||||
<option value="3">Three</option>
|
|
||||||
</select>
|
|
||||||
<label for="floatingSelectGrid">Works with selects</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
{{< scss-docs name="form-floating-variables" file="scss/_variables.scss" >}}
|
|
|
@ -1,190 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Form controls
|
|
||||||
description: Give textual form controls like `<input>`s and `<textarea>`s an upgrade with custom styles, sizing, focus states, and more.
|
|
||||||
group: forms
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
Form controls are styled with a mix of Sass and CSS variables, allowing them to adapt to color modes and support any customization method.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="exampleFormControlInput1" class="form-label">Email address</label>
|
|
||||||
<input type="email" class="form-control" id="exampleFormControlInput1" placeholder="name@example.com">
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="exampleFormControlTextarea1" class="form-label">Example textarea</label>
|
|
||||||
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Sizing
|
|
||||||
|
|
||||||
Set heights using classes like `.form-control-lg` and `.form-control-sm`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<input class="form-control form-control-lg" type="text" placeholder=".form-control-lg" aria-label=".form-control-lg example">
|
|
||||||
<input class="form-control" type="text" placeholder="Default input" aria-label="default input example">
|
|
||||||
<input class="form-control form-control-sm" type="text" placeholder=".form-control-sm" aria-label=".form-control-sm example">
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Form text
|
|
||||||
|
|
||||||
Block-level or inline-level form text can be created using `.form-text`.
|
|
||||||
|
|
||||||
{{< callout warning >}}
|
|
||||||
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.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<label for="inputPassword5" class="form-label">Password</label>
|
|
||||||
<input type="password" id="inputPassword5" class="form-control" aria-describedby="passwordHelpBlock">
|
|
||||||
<div id="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>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="row g-3 align-items-center">
|
|
||||||
<div class="col-auto">
|
|
||||||
<label for="inputPassword6" class="col-form-label">Password</label>
|
|
||||||
</div>
|
|
||||||
<div class="col-auto">
|
|
||||||
<input type="password" id="inputPassword6" class="form-control" aria-describedby="passwordHelpInline">
|
|
||||||
</div>
|
|
||||||
<div class="col-auto">
|
|
||||||
<span id="passwordHelpInline" class="form-text">
|
|
||||||
Must be 8-20 characters long.
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Disabled
|
|
||||||
|
|
||||||
Add the `disabled` boolean attribute on an input to give it a grayed out appearance, remove pointer events, and prevent focusing.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<input class="form-control" type="text" placeholder="Disabled input" aria-label="Disabled input example" disabled>
|
|
||||||
<input class="form-control" type="text" value="Disabled readonly input" aria-label="Disabled input example" disabled readonly>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Readonly
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<input class="form-control" type="text" value="Readonly input here..." aria-label="readonly input example" readonly>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Readonly plain text
|
|
||||||
|
|
||||||
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`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="mb-3 row">
|
|
||||||
<label for="staticEmail" class="col-sm-2 col-form-label">Email</label>
|
|
||||||
<div class="col-sm-10">
|
|
||||||
<input type="text" readonly class="form-control-plaintext" id="staticEmail" value="email@example.com">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="mb-3 row">
|
|
||||||
<label for="inputPassword" class="col-sm-2 col-form-label">Password</label>
|
|
||||||
<div class="col-sm-10">
|
|
||||||
<input type="password" class="form-control" id="inputPassword">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<form class="row g-3">
|
|
||||||
<div class="col-auto">
|
|
||||||
<label for="staticEmail2" class="visually-hidden">Email</label>
|
|
||||||
<input type="text" readonly class="form-control-plaintext" id="staticEmail2" value="email@example.com">
|
|
||||||
</div>
|
|
||||||
<div class="col-auto">
|
|
||||||
<label for="inputPassword2" class="visually-hidden">Password</label>
|
|
||||||
<input type="password" class="form-control" id="inputPassword2" placeholder="Password">
|
|
||||||
</div>
|
|
||||||
<div class="col-auto">
|
|
||||||
<button type="submit" class="btn btn-primary mb-3">Confirm identity</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## File input
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="formFile" class="form-label">Default file input example</label>
|
|
||||||
<input class="form-control" type="file" id="formFile">
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="formFileMultiple" class="form-label">Multiple files input example</label>
|
|
||||||
<input class="form-control" type="file" id="formFileMultiple" multiple>
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="formFileDisabled" class="form-label">Disabled file input example</label>
|
|
||||||
<input class="form-control" type="file" id="formFileDisabled" disabled>
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="formFileSm" class="form-label">Small file input example</label>
|
|
||||||
<input class="form-control form-control-sm" id="formFileSm" type="file">
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="formFileLg" class="form-label">Large file input example</label>
|
|
||||||
<input class="form-control form-control-lg" id="formFileLg" type="file">
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Color
|
|
||||||
|
|
||||||
Set the `type="color"` and add `.form-control-color` to the `<input>`. We use the modifier class to set fixed `height`s and override some inconsistencies between browsers.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<label for="exampleColorInput" class="form-label">Color picker</label>
|
|
||||||
<input type="color" class="form-control form-control-color" id="exampleColorInput" value="#563d7c" title="Choose your color">
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
Learn more about [support for datalist elements](https://caniuse.com/datalist).
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<label for="exampleDataList" class="form-label">Datalist example</label>
|
|
||||||
<input class="form-control" list="datalistOptions" id="exampleDataList" placeholder="Type to search...">
|
|
||||||
<datalist id="datalistOptions">
|
|
||||||
<option value="San Francisco">
|
|
||||||
<option value="New York">
|
|
||||||
<option value="Seattle">
|
|
||||||
<option value="Los Angeles">
|
|
||||||
<option value="Chicago">
|
|
||||||
</datalist>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
`$input-*` are shared across most of our form controls (and not buttons).
|
|
||||||
|
|
||||||
{{< scss-docs name="form-input-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
`$form-label-*` and `$form-text-*` are for our `<label>`s and `.form-text` component.
|
|
||||||
|
|
||||||
{{< scss-docs name="form-label-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
{{< scss-docs name="form-text-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
`$form-file-*` are for file input.
|
|
||||||
|
|
||||||
{{< scss-docs name="form-file-variables" file="scss/_variables.scss" >}}
|
|
|
@ -1,331 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Input group
|
|
||||||
description: Easily extend form controls by adding text, buttons, or button groups on either side of textual inputs, custom selects, and custom file inputs.
|
|
||||||
group: forms
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## Basic example
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<span class="input-group-text" id="basic-addon1">@</span>
|
|
||||||
<input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="basic-addon2">
|
|
||||||
<span class="input-group-text" id="basic-addon2">@example.com</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="basic-url" class="form-label">Your vanity URL</label>
|
|
||||||
<div class="input-group">
|
|
||||||
<span class="input-group-text" id="basic-addon3">https://example.com/users/</span>
|
|
||||||
<input type="text" class="form-control" id="basic-url" aria-describedby="basic-addon3 basic-addon4">
|
|
||||||
</div>
|
|
||||||
<div class="form-text" id="basic-addon4">Example help text goes outside the input group.</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<span class="input-group-text">$</span>
|
|
||||||
<input type="text" class="form-control" aria-label="Amount (to the nearest dollar)">
|
|
||||||
<span class="input-group-text">.00</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<input type="text" class="form-control" placeholder="Username" aria-label="Username">
|
|
||||||
<span class="input-group-text">@</span>
|
|
||||||
<input type="text" class="form-control" placeholder="Server" aria-label="Server">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group">
|
|
||||||
<span class="input-group-text">With textarea</span>
|
|
||||||
<textarea class="form-control" aria-label="With textarea"></textarea>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Wrapping
|
|
||||||
|
|
||||||
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`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="input-group flex-nowrap">
|
|
||||||
<span class="input-group-text" id="addon-wrapping">@</span>
|
|
||||||
<input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="addon-wrapping">
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Border radius
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="input-group">
|
|
||||||
<span class="input-group-text" id="visible-addon">@</span>
|
|
||||||
<input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="visible-addon">
|
|
||||||
<input type="text" class="form-control d-none" placeholder="Hidden input" aria-label="Hidden input" aria-describedby="visible-addon">
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Sizing
|
|
||||||
|
|
||||||
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.**
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="input-group input-group-sm mb-3">
|
|
||||||
<span class="input-group-text" id="inputGroup-sizing-sm">Small</span>
|
|
||||||
<input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<span class="input-group-text" id="inputGroup-sizing-default">Default</span>
|
|
||||||
<input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-default">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group input-group-lg">
|
|
||||||
<span class="input-group-text" id="inputGroup-sizing-lg">Large</span>
|
|
||||||
<input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-lg">
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<div class="input-group-text">
|
|
||||||
<input class="form-check-input mt-0" type="checkbox" value="" aria-label="Checkbox for following text input">
|
|
||||||
</div>
|
|
||||||
<input type="text" class="form-control" aria-label="Text input with checkbox">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group">
|
|
||||||
<div class="input-group-text">
|
|
||||||
<input class="form-check-input mt-0" type="radio" value="" aria-label="Radio button for following text input">
|
|
||||||
</div>
|
|
||||||
<input type="text" class="form-control" aria-label="Text input with radio button">
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Multiple inputs
|
|
||||||
|
|
||||||
While multiple `<input>`s are supported visually, validation styles are only available for input groups with a single `<input>`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="input-group">
|
|
||||||
<span class="input-group-text">First and last name</span>
|
|
||||||
<input type="text" aria-label="First name" class="form-control">
|
|
||||||
<input type="text" aria-label="Last name" class="form-control">
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Multiple addons
|
|
||||||
|
|
||||||
Multiple add-ons are supported and can be mixed with checkbox and radio input versions.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<span class="input-group-text">$</span>
|
|
||||||
<span class="input-group-text">0.00</span>
|
|
||||||
<input type="text" class="form-control" aria-label="Dollar amount (with dot and two decimal places)">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group">
|
|
||||||
<input type="text" class="form-control" aria-label="Dollar amount (with dot and two decimal places)">
|
|
||||||
<span class="input-group-text">$</span>
|
|
||||||
<span class="input-group-text">0.00</span>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Button addons
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<button class="btn btn-outline-secondary" type="button" id="button-addon1">Button</button>
|
|
||||||
<input type="text" class="form-control" placeholder="" aria-label="Example text with button addon" aria-describedby="button-addon1">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="button-addon2">
|
|
||||||
<button class="btn btn-outline-secondary" type="button" id="button-addon2">Button</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<button class="btn btn-outline-secondary" type="button">Button</button>
|
|
||||||
<button class="btn btn-outline-secondary" type="button">Button</button>
|
|
||||||
<input type="text" class="form-control" placeholder="" aria-label="Example text with two button addons">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group">
|
|
||||||
<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username with two button addons">
|
|
||||||
<button class="btn btn-outline-secondary" type="button">Button</button>
|
|
||||||
<button class="btn btn-outline-secondary" type="button">Button</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Buttons with dropdowns
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</button>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
|
||||||
<li><hr class="dropdown-divider"></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Separated link</a></li>
|
|
||||||
</ul>
|
|
||||||
<input type="text" class="form-control" aria-label="Text input with dropdown button">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<input type="text" class="form-control" aria-label="Text input with dropdown button">
|
|
||||||
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</button>
|
|
||||||
<ul class="dropdown-menu dropdown-menu-end">
|
|
||||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
|
||||||
<li><hr class="dropdown-divider"></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Separated link</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group">
|
|
||||||
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</button>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li><a class="dropdown-item" href="#">Action before</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Another action before</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
|
||||||
<li><hr class="dropdown-divider"></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Separated link</a></li>
|
|
||||||
</ul>
|
|
||||||
<input type="text" class="form-control" aria-label="Text input with 2 dropdown buttons">
|
|
||||||
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</button>
|
|
||||||
<ul class="dropdown-menu dropdown-menu-end">
|
|
||||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
|
||||||
<li><hr class="dropdown-divider"></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Separated link</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Segmented buttons
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<button type="button" class="btn btn-outline-secondary">Action</button>
|
|
||||||
<button type="button" class="btn btn-outline-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
|
|
||||||
<span class="visually-hidden">Toggle Dropdown</span>
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
|
||||||
<li><hr class="dropdown-divider"></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Separated link</a></li>
|
|
||||||
</ul>
|
|
||||||
<input type="text" class="form-control" aria-label="Text input with segmented dropdown button">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group">
|
|
||||||
<input type="text" class="form-control" aria-label="Text input with segmented dropdown button">
|
|
||||||
<button type="button" class="btn btn-outline-secondary">Action</button>
|
|
||||||
<button type="button" class="btn btn-outline-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
|
|
||||||
<span class="visually-hidden">Toggle Dropdown</span>
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu dropdown-menu-end">
|
|
||||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
|
||||||
<li><hr class="dropdown-divider"></li>
|
|
||||||
<li><a class="dropdown-item" href="#">Separated link</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Custom forms
|
|
||||||
|
|
||||||
Input groups include support for custom selects and custom file inputs. Browser default versions of these are not supported.
|
|
||||||
|
|
||||||
### Custom select
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<label class="input-group-text" for="inputGroupSelect01">Options</label>
|
|
||||||
<select class="form-select" id="inputGroupSelect01">
|
|
||||||
<option selected>Choose...</option>
|
|
||||||
<option value="1">One</option>
|
|
||||||
<option value="2">Two</option>
|
|
||||||
<option value="3">Three</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<select class="form-select" id="inputGroupSelect02">
|
|
||||||
<option selected>Choose...</option>
|
|
||||||
<option value="1">One</option>
|
|
||||||
<option value="2">Two</option>
|
|
||||||
<option value="3">Three</option>
|
|
||||||
</select>
|
|
||||||
<label class="input-group-text" for="inputGroupSelect02">Options</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<button class="btn btn-outline-secondary" type="button">Button</button>
|
|
||||||
<select class="form-select" id="inputGroupSelect03" aria-label="Example select with button addon">
|
|
||||||
<option selected>Choose...</option>
|
|
||||||
<option value="1">One</option>
|
|
||||||
<option value="2">Two</option>
|
|
||||||
<option value="3">Three</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group">
|
|
||||||
<select class="form-select" id="inputGroupSelect04" aria-label="Example select with button addon">
|
|
||||||
<option selected>Choose...</option>
|
|
||||||
<option value="1">One</option>
|
|
||||||
<option value="2">Two</option>
|
|
||||||
<option value="3">Three</option>
|
|
||||||
</select>
|
|
||||||
<button class="btn btn-outline-secondary" type="button">Button</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Custom file input
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<label class="input-group-text" for="inputGroupFile01">Upload</label>
|
|
||||||
<input type="file" class="form-control" id="inputGroupFile01">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<input type="file" class="form-control" id="inputGroupFile02">
|
|
||||||
<label class="input-group-text" for="inputGroupFile02">Upload</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<button class="btn btn-outline-secondary" type="button" id="inputGroupFileAddon03">Button</button>
|
|
||||||
<input type="file" class="form-control" id="inputGroupFile03" aria-describedby="inputGroupFileAddon03" aria-label="Upload">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input-group">
|
|
||||||
<input type="file" class="form-control" id="inputGroupFile04" aria-describedby="inputGroupFileAddon04" aria-label="Upload">
|
|
||||||
<button class="btn btn-outline-secondary" type="button" id="inputGroupFileAddon04">Button</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
{{< scss-docs name="input-group-variables" file="scss/_variables.scss" >}}
|
|
|
@ -1,329 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Layout
|
|
||||||
description: Give your forms some structure—from inline to horizontal to custom grid implementations—with our form layout options.
|
|
||||||
group: forms
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## Forms
|
|
||||||
|
|
||||||
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](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) 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]({{< docsref "/utilities/spacing" >}}) 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="formGroupExampleInput" class="form-label">Example label</label>
|
|
||||||
<input type="text" class="form-control" id="formGroupExampleInput" placeholder="Example input placeholder">
|
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="formGroupExampleInput2" class="form-label">Another label</label>
|
|
||||||
<input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Another input placeholder">
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Form grid
|
|
||||||
|
|
||||||
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).
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<input type="text" class="form-control" placeholder="First name" aria-label="First name">
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<input type="text" class="form-control" placeholder="Last name" aria-label="Last name">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Gutters
|
|
||||||
|
|
||||||
By adding [gutter modifier classes]({{< docsref "/layout/gutters" >}}), 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).
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="row g-3">
|
|
||||||
<div class="col">
|
|
||||||
<input type="text" class="form-control" placeholder="First name" aria-label="First name">
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<input type="text" class="form-control" placeholder="Last name" aria-label="Last name">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
More complex layouts can also be created with the grid system.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<form class="row g-3">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<label for="inputEmail4" class="form-label">Email</label>
|
|
||||||
<input type="email" class="form-control" id="inputEmail4">
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6">
|
|
||||||
<label for="inputPassword4" class="form-label">Password</label>
|
|
||||||
<input type="password" class="form-control" id="inputPassword4">
|
|
||||||
</div>
|
|
||||||
<div class="col-12">
|
|
||||||
<label for="inputAddress" class="form-label">Address</label>
|
|
||||||
<input type="text" class="form-control" id="inputAddress" placeholder="1234 Main St">
|
|
||||||
</div>
|
|
||||||
<div class="col-12">
|
|
||||||
<label for="inputAddress2" class="form-label">Address 2</label>
|
|
||||||
<input type="text" class="form-control" id="inputAddress2" placeholder="Apartment, studio, or floor">
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6">
|
|
||||||
<label for="inputCity" class="form-label">City</label>
|
|
||||||
<input type="text" class="form-control" id="inputCity">
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<label for="inputState" class="form-label">State</label>
|
|
||||||
<select id="inputState" class="form-select">
|
|
||||||
<option selected>Choose...</option>
|
|
||||||
<option>...</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-2">
|
|
||||||
<label for="inputZip" class="form-label">Zip</label>
|
|
||||||
<input type="text" class="form-control" id="inputZip">
|
|
||||||
</div>
|
|
||||||
<div class="col-12">
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" id="gridCheck">
|
|
||||||
<label class="form-check-label" for="gridCheck">
|
|
||||||
Check me out
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-12">
|
|
||||||
<button type="submit" class="btn btn-primary">Sign in</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Horizontal form
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<form>
|
|
||||||
<div class="row mb-3">
|
|
||||||
<label for="inputEmail3" class="col-sm-2 col-form-label">Email</label>
|
|
||||||
<div class="col-sm-10">
|
|
||||||
<input type="email" class="form-control" id="inputEmail3">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-3">
|
|
||||||
<label for="inputPassword3" class="col-sm-2 col-form-label">Password</label>
|
|
||||||
<div class="col-sm-10">
|
|
||||||
<input type="password" class="form-control" id="inputPassword3">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<fieldset class="row mb-3">
|
|
||||||
<legend class="col-form-label col-sm-2 pt-0">Radios</legend>
|
|
||||||
<div class="col-sm-10">
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="radio" name="gridRadios" id="gridRadios1" value="option1" checked>
|
|
||||||
<label class="form-check-label" for="gridRadios1">
|
|
||||||
First radio
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="radio" name="gridRadios" id="gridRadios2" value="option2">
|
|
||||||
<label class="form-check-label" for="gridRadios2">
|
|
||||||
Second radio
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check disabled">
|
|
||||||
<input class="form-check-input" type="radio" name="gridRadios" id="gridRadios3" value="option3" disabled>
|
|
||||||
<label class="form-check-label" for="gridRadios3">
|
|
||||||
Third disabled radio
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col-sm-10 offset-sm-2">
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" id="gridCheck1">
|
|
||||||
<label class="form-check-label" for="gridCheck1">
|
|
||||||
Example checkbox
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="btn btn-primary">Sign in</button>
|
|
||||||
</form>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Horizontal form label sizing
|
|
||||||
|
|
||||||
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`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="row mb-3">
|
|
||||||
<label for="colFormLabelSm" class="col-sm-2 col-form-label col-form-label-sm">Email</label>
|
|
||||||
<div class="col-sm-10">
|
|
||||||
<input type="email" class="form-control form-control-sm" id="colFormLabelSm" placeholder="col-form-label-sm">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-3">
|
|
||||||
<label for="colFormLabel" class="col-sm-2 col-form-label">Email</label>
|
|
||||||
<div class="col-sm-10">
|
|
||||||
<input type="email" class="form-control" id="colFormLabel" placeholder="col-form-label">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<label for="colFormLabelLg" class="col-sm-2 col-form-label col-form-label-lg">Email</label>
|
|
||||||
<div class="col-sm-10">
|
|
||||||
<input type="email" class="form-control form-control-lg" id="colFormLabelLg" placeholder="col-form-label-lg">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Column sizing
|
|
||||||
|
|
||||||
As shown in the previous examples, our grid system allows you to place any number of `.col`s 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 `.col`s equally split the rest, with specific column classes like `.col-sm-7`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="row g-3">
|
|
||||||
<div class="col-sm-7">
|
|
||||||
<input type="text" class="form-control" placeholder="City" aria-label="City">
|
|
||||||
</div>
|
|
||||||
<div class="col-sm">
|
|
||||||
<input type="text" class="form-control" placeholder="State" aria-label="State">
|
|
||||||
</div>
|
|
||||||
<div class="col-sm">
|
|
||||||
<input type="text" class="form-control" placeholder="Zip" aria-label="Zip">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Auto-sizing
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<form class="row gy-2 gx-3 align-items-center">
|
|
||||||
<div class="col-auto">
|
|
||||||
<label class="visually-hidden" for="autoSizingInput">Name</label>
|
|
||||||
<input type="text" class="form-control" id="autoSizingInput" placeholder="Jane Doe">
|
|
||||||
</div>
|
|
||||||
<div class="col-auto">
|
|
||||||
<label class="visually-hidden" for="autoSizingInputGroup">Username</label>
|
|
||||||
<div class="input-group">
|
|
||||||
<div class="input-group-text">@</div>
|
|
||||||
<input type="text" class="form-control" id="autoSizingInputGroup" placeholder="Username">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-auto">
|
|
||||||
<label class="visually-hidden" for="autoSizingSelect">Preference</label>
|
|
||||||
<select class="form-select" id="autoSizingSelect">
|
|
||||||
<option selected>Choose...</option>
|
|
||||||
<option value="1">One</option>
|
|
||||||
<option value="2">Two</option>
|
|
||||||
<option value="3">Three</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="col-auto">
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" id="autoSizingCheck">
|
|
||||||
<label class="form-check-label" for="autoSizingCheck">
|
|
||||||
Remember me
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-auto">
|
|
||||||
<button type="submit" class="btn btn-primary">Submit</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
You can then remix that once again with size-specific column classes.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<form class="row gx-3 gy-2 align-items-center">
|
|
||||||
<div class="col-sm-3">
|
|
||||||
<label class="visually-hidden" for="specificSizeInputName">Name</label>
|
|
||||||
<input type="text" class="form-control" id="specificSizeInputName" placeholder="Jane Doe">
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-3">
|
|
||||||
<label class="visually-hidden" for="specificSizeInputGroupUsername">Username</label>
|
|
||||||
<div class="input-group">
|
|
||||||
<div class="input-group-text">@</div>
|
|
||||||
<input type="text" class="form-control" id="specificSizeInputGroupUsername" placeholder="Username">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-3">
|
|
||||||
<label class="visually-hidden" for="specificSizeSelect">Preference</label>
|
|
||||||
<select class="form-select" id="specificSizeSelect">
|
|
||||||
<option selected>Choose...</option>
|
|
||||||
<option value="1">One</option>
|
|
||||||
<option value="2">Two</option>
|
|
||||||
<option value="3">Three</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="col-auto">
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" id="autoSizingCheck2">
|
|
||||||
<label class="form-check-label" for="autoSizingCheck2">
|
|
||||||
Remember me
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-auto">
|
|
||||||
<button type="submit" class="btn btn-primary">Submit</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Inline forms
|
|
||||||
|
|
||||||
Use the `.row-cols-*` classes to create responsive horizontal layouts. By adding [gutter modifier classes]({{< docsref "/layout/gutters" >}}), 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<form class="row row-cols-lg-auto g-3 align-items-center">
|
|
||||||
<div class="col-12">
|
|
||||||
<label class="visually-hidden" for="inlineFormInputGroupUsername">Username</label>
|
|
||||||
<div class="input-group">
|
|
||||||
<div class="input-group-text">@</div>
|
|
||||||
<input type="text" class="form-control" id="inlineFormInputGroupUsername" placeholder="Username">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-12">
|
|
||||||
<label class="visually-hidden" for="inlineFormSelectPref">Preference</label>
|
|
||||||
<select class="form-select" id="inlineFormSelectPref">
|
|
||||||
<option selected>Choose...</option>
|
|
||||||
<option value="1">One</option>
|
|
||||||
<option value="2">Two</option>
|
|
||||||
<option value="3">Three</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-12">
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" id="inlineFormCheck">
|
|
||||||
<label class="form-check-label" for="inlineFormCheck">
|
|
||||||
Remember me
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-12">
|
|
||||||
<button type="submit" class="btn btn-primary">Submit</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
{{< /example >}}
|
|
|
@ -1,81 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Select
|
|
||||||
description: Customize the native `<select>`s with custom CSS that changes the element's initial appearance.
|
|
||||||
group: forms
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<select class="form-select" aria-label="Default select example">
|
|
||||||
<option selected>Open this select menu</option>
|
|
||||||
<option value="1">One</option>
|
|
||||||
<option value="2">Two</option>
|
|
||||||
<option value="3">Three</option>
|
|
||||||
</select>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Sizing
|
|
||||||
|
|
||||||
You may also choose from small and large custom selects to match our similarly sized text inputs.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<select class="form-select form-select-lg mb-3" aria-label="Large select example">
|
|
||||||
<option selected>Open this select menu</option>
|
|
||||||
<option value="1">One</option>
|
|
||||||
<option value="2">Two</option>
|
|
||||||
<option value="3">Three</option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select class="form-select form-select-sm" aria-label="Small select example">
|
|
||||||
<option selected>Open this select menu</option>
|
|
||||||
<option value="1">One</option>
|
|
||||||
<option value="2">Two</option>
|
|
||||||
<option value="3">Three</option>
|
|
||||||
</select>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
The `multiple` attribute is also supported:
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<select class="form-select" multiple aria-label="Multiple select example">
|
|
||||||
<option selected>Open this select menu</option>
|
|
||||||
<option value="1">One</option>
|
|
||||||
<option value="2">Two</option>
|
|
||||||
<option value="3">Three</option>
|
|
||||||
</select>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
As is the `size` attribute:
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<select class="form-select" size="3" aria-label="Size 3 select example">
|
|
||||||
<option selected>Open this select menu</option>
|
|
||||||
<option value="1">One</option>
|
|
||||||
<option value="2">Two</option>
|
|
||||||
<option value="3">Three</option>
|
|
||||||
</select>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Disabled
|
|
||||||
|
|
||||||
Add the `disabled` boolean attribute on a select to give it a grayed out appearance and remove pointer events.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<select class="form-select" aria-label="Disabled select example" disabled>
|
|
||||||
<option selected>Open this select menu</option>
|
|
||||||
<option value="1">One</option>
|
|
||||||
<option value="2">Two</option>
|
|
||||||
<option value="3">Three</option>
|
|
||||||
</select>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
{{< scss-docs name="form-select-variables" file="scss/_variables.scss" >}}
|
|
|
@ -1,394 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Validation
|
|
||||||
description: Provide valuable, actionable feedback to your users with HTML5 form validation, via browser default behaviors or custom styles and JavaScript.
|
|
||||||
group: forms
|
|
||||||
toc: true
|
|
||||||
extra_js:
|
|
||||||
- src: "/docs/5.3/assets/js/validate-forms.js"
|
|
||||||
async: true
|
|
||||||
---
|
|
||||||
|
|
||||||
{{< callout warning >}}
|
|
||||||
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.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
- 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](#server-side). They do not require a `.was-validated` parent class.
|
|
||||||
- Due to constraints in how CSS works, we cannot (at present) apply styles to a `<label>` that comes before a form control in the DOM without the help of custom JavaScript.
|
|
||||||
- All modern browsers support the [constraint validation API](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#the-constraint-validation-api), a series of JavaScript methods for validating form controls.
|
|
||||||
- Feedback messages may utilize the [browser defaults](#browser-defaults) (different for each browser, and unstylable via CSS) or our custom feedback styles with additional HTML and CSS.
|
|
||||||
- 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 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`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<form class="row g-3 needs-validation" novalidate>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<label for="validationCustom01" class="form-label">First name</label>
|
|
||||||
<input type="text" class="form-control" id="validationCustom01" value="Mark" required>
|
|
||||||
<div class="valid-feedback">
|
|
||||||
Looks good!
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<label for="validationCustom02" class="form-label">Last name</label>
|
|
||||||
<input type="text" class="form-control" id="validationCustom02" value="Otto" required>
|
|
||||||
<div class="valid-feedback">
|
|
||||||
Looks good!
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<label for="validationCustomUsername" class="form-label">Username</label>
|
|
||||||
<div class="input-group has-validation">
|
|
||||||
<span class="input-group-text" id="inputGroupPrepend">@</span>
|
|
||||||
<input type="text" class="form-control" id="validationCustomUsername" aria-describedby="inputGroupPrepend" required>
|
|
||||||
<div class="invalid-feedback">
|
|
||||||
Please choose a username.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6">
|
|
||||||
<label for="validationCustom03" class="form-label">City</label>
|
|
||||||
<input type="text" class="form-control" id="validationCustom03" required>
|
|
||||||
<div class="invalid-feedback">
|
|
||||||
Please provide a valid city.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3">
|
|
||||||
<label for="validationCustom04" class="form-label">State</label>
|
|
||||||
<select class="form-select" id="validationCustom04" required>
|
|
||||||
<option selected disabled value="">Choose...</option>
|
|
||||||
<option>...</option>
|
|
||||||
</select>
|
|
||||||
<div class="invalid-feedback">
|
|
||||||
Please select a valid state.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3">
|
|
||||||
<label for="validationCustom05" class="form-label">Zip</label>
|
|
||||||
<input type="text" class="form-control" id="validationCustom05" required>
|
|
||||||
<div class="invalid-feedback">
|
|
||||||
Please provide a valid zip.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-12">
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" value="" id="invalidCheck" required>
|
|
||||||
<label class="form-check-label" for="invalidCheck">
|
|
||||||
Agree to terms and conditions
|
|
||||||
</label>
|
|
||||||
<div class="invalid-feedback">
|
|
||||||
You must agree before submitting.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-12">
|
|
||||||
<button class="btn btn-primary" type="submit">Submit form</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example lang="js" show_preview="false" >}}
|
|
||||||
{{< js.inline >}}
|
|
||||||
{{- readFile (path.Join "site/static/docs" .Site.Params.docs_version "assets/js/validate-forms.js") -}}
|
|
||||||
{{< /js.inline >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
While these feedback styles cannot be styled with CSS, you can still customize the feedback text through JavaScript.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<form class="row g-3">
|
|
||||||
<div class="col-md-4">
|
|
||||||
<label for="validationDefault01" class="form-label">First name</label>
|
|
||||||
<input type="text" class="form-control" id="validationDefault01" value="Mark" required>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<label for="validationDefault02" class="form-label">Last name</label>
|
|
||||||
<input type="text" class="form-control" id="validationDefault02" value="Otto" required>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<label for="validationDefaultUsername" class="form-label">Username</label>
|
|
||||||
<div class="input-group">
|
|
||||||
<span class="input-group-text" id="inputGroupPrepend2">@</span>
|
|
||||||
<input type="text" class="form-control" id="validationDefaultUsername" aria-describedby="inputGroupPrepend2" required>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6">
|
|
||||||
<label for="validationDefault03" class="form-label">City</label>
|
|
||||||
<input type="text" class="form-control" id="validationDefault03" required>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3">
|
|
||||||
<label for="validationDefault04" class="form-label">State</label>
|
|
||||||
<select class="form-select" id="validationDefault04" required>
|
|
||||||
<option selected disabled value="">Choose...</option>
|
|
||||||
<option>...</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3">
|
|
||||||
<label for="validationDefault05" class="form-label">Zip</label>
|
|
||||||
<input type="text" class="form-control" id="validationDefault05" required>
|
|
||||||
</div>
|
|
||||||
<div class="col-12">
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input" type="checkbox" value="" id="invalidCheck2" required>
|
|
||||||
<label class="form-check-label" for="invalidCheck2">
|
|
||||||
Agree to terms and conditions
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-12">
|
|
||||||
<button class="btn btn-primary" type="submit">Submit form</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Server-side
|
|
||||||
|
|
||||||
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).
|
|
||||||
|
|
||||||
To fix [issues with border radius](https://github.com/twbs/bootstrap/issues/25110), input groups require an additional `.has-validation` class.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<form class="row g-3">
|
|
||||||
<div class="col-md-4">
|
|
||||||
<label for="validationServer01" class="form-label">First name</label>
|
|
||||||
<input type="text" class="form-control is-valid" id="validationServer01" value="Mark" required>
|
|
||||||
<div class="valid-feedback">
|
|
||||||
Looks good!
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<label for="validationServer02" class="form-label">Last name</label>
|
|
||||||
<input type="text" class="form-control is-valid" id="validationServer02" value="Otto" required>
|
|
||||||
<div class="valid-feedback">
|
|
||||||
Looks good!
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4">
|
|
||||||
<label for="validationServerUsername" class="form-label">Username</label>
|
|
||||||
<div class="input-group has-validation">
|
|
||||||
<span class="input-group-text" id="inputGroupPrepend3">@</span>
|
|
||||||
<input type="text" class="form-control is-invalid" id="validationServerUsername" aria-describedby="inputGroupPrepend3 validationServerUsernameFeedback" required>
|
|
||||||
<div id="validationServerUsernameFeedback" class="invalid-feedback">
|
|
||||||
Please choose a username.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6">
|
|
||||||
<label for="validationServer03" class="form-label">City</label>
|
|
||||||
<input type="text" class="form-control is-invalid" id="validationServer03" aria-describedby="validationServer03Feedback" required>
|
|
||||||
<div id="validationServer03Feedback" class="invalid-feedback">
|
|
||||||
Please provide a valid city.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3">
|
|
||||||
<label for="validationServer04" class="form-label">State</label>
|
|
||||||
<select class="form-select is-invalid" id="validationServer04" aria-describedby="validationServer04Feedback" required>
|
|
||||||
<option selected disabled value="">Choose...</option>
|
|
||||||
<option>...</option>
|
|
||||||
</select>
|
|
||||||
<div id="validationServer04Feedback" class="invalid-feedback">
|
|
||||||
Please select a valid state.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3">
|
|
||||||
<label for="validationServer05" class="form-label">Zip</label>
|
|
||||||
<input type="text" class="form-control is-invalid" id="validationServer05" aria-describedby="validationServer05Feedback" required>
|
|
||||||
<div id="validationServer05Feedback" class="invalid-feedback">
|
|
||||||
Please provide a valid zip.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-12">
|
|
||||||
<div class="form-check">
|
|
||||||
<input class="form-check-input is-invalid" type="checkbox" value="" id="invalidCheck3" aria-describedby="invalidCheck3Feedback" required>
|
|
||||||
<label class="form-check-label" for="invalidCheck3">
|
|
||||||
Agree to terms and conditions
|
|
||||||
</label>
|
|
||||||
<div id="invalidCheck3Feedback" class="invalid-feedback">
|
|
||||||
You must agree before submitting.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-12">
|
|
||||||
<button class="btn btn-primary" type="submit">Submit form</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Supported elements
|
|
||||||
|
|
||||||
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-check`s
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<form class="was-validated">
|
|
||||||
<div class="mb-3">
|
|
||||||
<label for="validationTextarea" class="form-label">Textarea</label>
|
|
||||||
<textarea class="form-control" id="validationTextarea" placeholder="Required example textarea" required></textarea>
|
|
||||||
<div class="invalid-feedback">
|
|
||||||
Please enter a message in the textarea.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-check mb-3">
|
|
||||||
<input type="checkbox" class="form-check-input" id="validationFormCheck1" required>
|
|
||||||
<label class="form-check-label" for="validationFormCheck1">Check this checkbox</label>
|
|
||||||
<div class="invalid-feedback">Example invalid feedback text</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-check">
|
|
||||||
<input type="radio" class="form-check-input" id="validationFormCheck2" name="radio-stacked" required>
|
|
||||||
<label class="form-check-label" for="validationFormCheck2">Toggle this radio</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check mb-3">
|
|
||||||
<input type="radio" class="form-check-input" id="validationFormCheck3" name="radio-stacked" required>
|
|
||||||
<label class="form-check-label" for="validationFormCheck3">Or toggle this other radio</label>
|
|
||||||
<div class="invalid-feedback">More example invalid feedback text</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<select class="form-select" required aria-label="select example">
|
|
||||||
<option value="">Open this select menu</option>
|
|
||||||
<option value="1">One</option>
|
|
||||||
<option value="2">Two</option>
|
|
||||||
<option value="3">Three</option>
|
|
||||||
</select>
|
|
||||||
<div class="invalid-feedback">Example invalid select feedback</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<input type="file" class="form-control" aria-label="file example" required>
|
|
||||||
<div class="invalid-feedback">Example invalid form file feedback</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<button class="btn btn-primary" type="submit" disabled>Submit form</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Tooltips
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<form class="row g-3 needs-validation" novalidate>
|
|
||||||
<div class="col-md-4 position-relative">
|
|
||||||
<label for="validationTooltip01" class="form-label">First name</label>
|
|
||||||
<input type="text" class="form-control" id="validationTooltip01" value="Mark" required>
|
|
||||||
<div class="valid-tooltip">
|
|
||||||
Looks good!
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4 position-relative">
|
|
||||||
<label for="validationTooltip02" class="form-label">Last name</label>
|
|
||||||
<input type="text" class="form-control" id="validationTooltip02" value="Otto" required>
|
|
||||||
<div class="valid-tooltip">
|
|
||||||
Looks good!
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-4 position-relative">
|
|
||||||
<label for="validationTooltipUsername" class="form-label">Username</label>
|
|
||||||
<div class="input-group has-validation">
|
|
||||||
<span class="input-group-text" id="validationTooltipUsernamePrepend">@</span>
|
|
||||||
<input type="text" class="form-control" id="validationTooltipUsername" aria-describedby="validationTooltipUsernamePrepend" required>
|
|
||||||
<div class="invalid-tooltip">
|
|
||||||
Please choose a unique and valid username.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6 position-relative">
|
|
||||||
<label for="validationTooltip03" class="form-label">City</label>
|
|
||||||
<input type="text" class="form-control" id="validationTooltip03" required>
|
|
||||||
<div class="invalid-tooltip">
|
|
||||||
Please provide a valid city.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3 position-relative">
|
|
||||||
<label for="validationTooltip04" class="form-label">State</label>
|
|
||||||
<select class="form-select" id="validationTooltip04" required>
|
|
||||||
<option selected disabled value="">Choose...</option>
|
|
||||||
<option>...</option>
|
|
||||||
</select>
|
|
||||||
<div class="invalid-tooltip">
|
|
||||||
Please select a valid state.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3 position-relative">
|
|
||||||
<label for="validationTooltip05" class="form-label">Zip</label>
|
|
||||||
<input type="text" class="form-control" id="validationTooltip05" required>
|
|
||||||
<div class="invalid-tooltip">
|
|
||||||
Please provide a valid zip.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-12">
|
|
||||||
<button class="btn btn-primary" type="submit">Submit form</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Variables
|
|
||||||
|
|
||||||
{{< added-in "5.3.0" >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< scss-docs name="root-form-validation-variables" file="scss/_root.scss" >}}
|
|
||||||
|
|
||||||
These variables are also color mode adaptive, meaning they change color while in dark mode.
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
{{< scss-docs name="form-feedback-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
{{< scss-docs name="form-validation-colors" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
{{< scss-docs name="form-validation-colors-dark" file="scss/_variables-dark.scss" >}}
|
|
||||||
|
|
||||||
### Sass mixins
|
|
||||||
|
|
||||||
Two mixins are combined, through our [loop](#sass-loops), to generate our form validation feedback styles.
|
|
||||||
|
|
||||||
{{< scss-docs name="form-validation-mixins" file="scss/mixins/_forms.scss" >}}
|
|
||||||
|
|
||||||
### Sass maps
|
|
||||||
|
|
||||||
This is the validation Sass map from `_variables.scss`. Override or extend this to generate different or additional states.
|
|
||||||
|
|
||||||
{{< scss-docs name="form-validation-states" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
Maps of `$form-validation-states` can contain three optional parameters to override tooltips and focus styles.
|
|
||||||
|
|
||||||
### 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.
|
|
||||||
|
|
||||||
{{< scss-docs name="form-validation-states-loop" file="scss/forms/_validation.scss" >}}
|
|
||||||
|
|
||||||
### 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.
|
|
|
@ -1,20 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Best practices
|
|
||||||
description: Learn about some of the best practices we've gathered from years of working on and using Bootstrap.
|
|
||||||
group: getting-started
|
|
||||||
---
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
**Heads up!** This copy is a work in progress.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
### General outline
|
|
||||||
|
|
||||||
- Working with CSS
|
|
||||||
- Working with Sass files
|
|
||||||
- Building new CSS components
|
|
||||||
- Working with flexbox
|
|
||||||
- Ask in [our GitHub Discussions](https://github.com/twbs/bootstrap/discussions)
|
|
|
@ -1,156 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Download
|
|
||||||
description: Download Bootstrap to get the compiled CSS and JavaScript, source code, or include it with your favorite package managers like npm, RubyGems, and more.
|
|
||||||
group: getting-started
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## Compiled CSS and JS
|
|
||||||
|
|
||||||
Download ready-to-use compiled code for **Bootstrap v{{< param current_version >}}** to easily drop into your project, which includes:
|
|
||||||
|
|
||||||
- Compiled and minified CSS bundles (see [CSS files comparison]({{< docsref "/getting-started/contents#css-files" >}}))
|
|
||||||
- Compiled and minified JavaScript plugins (see [JS files comparison]({{< docsref "/getting-started/contents#js-files" >}}))
|
|
||||||
|
|
||||||
This doesn't include documentation, source files, or any optional JavaScript dependencies like Popper.
|
|
||||||
|
|
||||||
<a href="{{< param "download.dist" >}}" class="btn btn-bd-primary">Download</a>
|
|
||||||
|
|
||||||
## Source files
|
|
||||||
|
|
||||||
Compile Bootstrap with your own asset pipeline by downloading our source Sass, JavaScript, and documentation files. This option requires some additional tooling:
|
|
||||||
|
|
||||||
- [Sass compiler]({{< docsref "/getting-started/contribute#sass" >}}) for compiling Sass source files into CSS files
|
|
||||||
- [Autoprefixer](https://github.com/postcss/autoprefixer) for CSS vendor prefixing
|
|
||||||
|
|
||||||
Should you require our full set of [build tools]({{< docsref "/getting-started/contribute#tooling-setup" >}}), they are included for developing Bootstrap and its docs, but they're likely unsuitable for your own purposes.
|
|
||||||
|
|
||||||
<a href="{{< param "download.source" >}}" class="btn btn-bd-primary">Download source</a>
|
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
If you want to download and examine our [examples]({{< docsref "/examples" >}}), you can grab the already built examples:
|
|
||||||
|
|
||||||
<a href="{{< param "download.dist_examples" >}}" class="btn btn-bd-primary">Download Examples</a>
|
|
||||||
|
|
||||||
## CDN via jsDelivr
|
|
||||||
|
|
||||||
Skip the download with [jsDelivr](https://www.jsdelivr.com/) to deliver cached version of Bootstrap's compiled CSS and JS to your project.
|
|
||||||
|
|
||||||
```html
|
|
||||||
<link href="{{< param "cdn.css" >}}" rel="stylesheet" integrity="{{< param "cdn.css_hash" >}}" crossorigin="anonymous">
|
|
||||||
<script src="{{< param "cdn.js_bundle" >}}" integrity="{{< param "cdn.js_bundle_hash" >}}" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
If you're using our compiled JavaScript and prefer to include Popper separately, add Popper before our JS, via a CDN preferably.
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script src="{{< param "cdn.popper" >}}" integrity="{{< param "cdn.popper_hash" >}}" crossorigin="anonymous"></script>
|
|
||||||
<script src="{{< param "cdn.js" >}}" integrity="{{< param "cdn.js_hash" >}}" crossorigin="anonymous"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
### Alternative CDNs
|
|
||||||
|
|
||||||
We recommend [jsDelivr](https://www.jsdelivr.com/) 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](https://cdnjs.com/) or [unpkg](https://unpkg.com/).
|
|
||||||
|
|
||||||
You'll find the same files on these CDN providers, albeit with different URLs. With cdnjs, you can [use this direct Bootstrap package link](https://cdnjs.com/libraries/bootstrap) to copy and paste ready-to-use HTML snippets for each dist file from any version of Bootstrap.
|
|
||||||
|
|
||||||
{{< callout warning>}}
|
|
||||||
**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.**
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
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](https://www.srihash.org/) 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:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
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]({{< docsref "/getting-started/contribute#sass" >}}) and [Autoprefixer](https://github.com/postcss/autoprefixer)** for a setup that matches our official compiled versions.
|
|
||||||
|
|
||||||
### npm
|
|
||||||
|
|
||||||
Install Bootstrap in your Node.js powered apps with [the npm package](https://www.npmjs.com/package/bootstrap):
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install bootstrap@{{< param "current_version" >}}
|
|
||||||
```
|
|
||||||
|
|
||||||
`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:
|
|
||||||
|
|
||||||
- `sass` - path to Bootstrap's main [Sass](https://sass-lang.com/) source file
|
|
||||||
- `style` - path to Bootstrap's non-minified CSS that's been compiled using the default settings (no customization)
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
{{< partial "callouts/info-npm-starter.md" >}}
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
### yarn
|
|
||||||
|
|
||||||
Install Bootstrap in your Node.js powered apps with [the yarn package](https://yarnpkg.com/en/package/bootstrap):
|
|
||||||
|
|
||||||
```sh
|
|
||||||
yarn add bootstrap@{{< param "current_version" >}}
|
|
||||||
```
|
|
||||||
|
|
||||||
{{< callout warning >}}
|
|
||||||
**Yarn 2+ (aka Yarn Berry) doesn't support the `node_modules` directory by default**: using our [Sass & JS example](https://github.com/twbs/examples/tree/main/sass-js) needs some adjustments:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
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
|
|
||||||
```
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
### Bun
|
|
||||||
|
|
||||||
Install Bootstrap in your Bun or Node.js powered apps with [the Bun CLI](https://bun.sh/):
|
|
||||||
|
|
||||||
```sh
|
|
||||||
bun add bootstrap@{{< param "current_version" >}}
|
|
||||||
```
|
|
||||||
|
|
||||||
### RubyGems
|
|
||||||
|
|
||||||
Install Bootstrap in your Ruby apps using [Bundler](https://bundler.io/) (**recommended**) and [RubyGems](https://rubygems.org/) by adding the following line to your [`Gemfile`](https://bundler.io/guides/gemfile.html):
|
|
||||||
|
|
||||||
```ruby
|
|
||||||
gem 'bootstrap', '~> {{< param current_ruby_version >}}'
|
|
||||||
```
|
|
||||||
|
|
||||||
Alternatively, if you're not using Bundler, you can install the gem by running this command:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
gem install bootstrap -v {{< param current_ruby_version >}}
|
|
||||||
```
|
|
||||||
|
|
||||||
[See the gem's README](https://github.com/twbs/bootstrap-rubygem/blob/main/README.md) for further details.
|
|
||||||
|
|
||||||
### Composer
|
|
||||||
|
|
||||||
You can also install and manage Bootstrap's Sass and JavaScript using [Composer](https://getcomposer.org/):
|
|
||||||
|
|
||||||
```sh
|
|
||||||
composer require twbs/bootstrap:{{< param current_version >}}
|
|
||||||
```
|
|
||||||
|
|
||||||
### NuGet
|
|
||||||
|
|
||||||
If you develop in .NET Framework, you can also install and manage Bootstrap's [CSS](https://www.nuget.org/packages/bootstrap/) or [Sass](https://www.nuget.org/packages/bootstrap.sass/) and JavaScript using [NuGet](https://www.nuget.org/). Newer projects should use [libman](https://learn.microsoft.com/en-us/aspnet/core/client-side/libman/) or another method as NuGet is designed for compiled code, not frontend assets.
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
Install-Package bootstrap
|
|
||||||
```
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
Install-Package bootstrap.sass
|
|
||||||
```
|
|
|
@ -1,55 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Color and background
|
|
||||||
description: Set a background color with contrasting foreground color.
|
|
||||||
group: helpers
|
|
||||||
toc: true
|
|
||||||
added:
|
|
||||||
version: "5.2"
|
|
||||||
---
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
Color and background helpers combine the power of our [`.text-*` utilities]({{< docsref "/utilities/colors" >}}) and [`.bg-*` utilities]({{< docsref "/utilities/background" >}}) in one class. Using our Sass `color-contrast()` function, we automatically determine a contrasting `color` for a particular `background-color`.
|
|
||||||
|
|
||||||
{{< callout warning >}}
|
|
||||||
**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.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
{{< text-bg.inline >}}
|
|
||||||
{{- range (index $.Site.Data "theme-colors") }}
|
|
||||||
<div class="text-bg-{{ .name }} p-3">{{ .name | title }} with contrasting color</div>
|
|
||||||
{{- end -}}
|
|
||||||
{{< /text-bg.inline >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
{{< partial "callouts/warning-color-assistive-technologies.md" >}}
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## With components
|
|
||||||
|
|
||||||
Use them in place of combined `.text-*` and `.bg-*` classes, like on [badges]({{< docsref "/components/badge#background-colors" >}}):
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<span class="badge text-bg-primary">Primary</span>
|
|
||||||
<span class="badge text-bg-info">Info</span>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Or on [cards]({{< docsref "/components/card#background-and-color" >}}):
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card text-bg-primary mb-3" style="max-width: 18rem;">
|
|
||||||
<div class="card-header">Header</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<p class="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>
|
|
||||||
<div class="card text-bg-info mb-3" style="max-width: 18rem;">
|
|
||||||
<div class="card-header">Header</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<p class="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>
|
|
||||||
{{< /example >}}
|
|
|
@ -1,43 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Colored links
|
|
||||||
description: Colored links with hover states
|
|
||||||
group: helpers
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## Link colors
|
|
||||||
|
|
||||||
You can use the `.link-*` classes to colorize links. Unlike the [`.text-*` classes]({{< docsref "/utilities/colors" >}}), 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.
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
**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.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
{{< colored-links.inline >}}
|
|
||||||
{{- range (index $.Site.Data "theme-colors") }}
|
|
||||||
<p><a href="#" class="link-{{ .name }}">{{ .name | title }} link</a></p>
|
|
||||||
{{- end -}}
|
|
||||||
{{< /colored-links.inline >}}
|
|
||||||
<p><a href="#" class="link-body-emphasis">Emphasis link</a></p>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
{{< partial "callouts/warning-color-assistive-technologies.md" >}}
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## Link utilities
|
|
||||||
|
|
||||||
{{< added-in "5.3.0" >}}
|
|
||||||
|
|
||||||
Colored links can also be modified by our [link utilities]({{< docsref "/utilities/link/" >}}).
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
{{< colored-links.inline >}}
|
|
||||||
{{- range (index $.Site.Data "theme-colors") }}
|
|
||||||
<p><a href="#" class="link-{{ .name }} link-offset-2 link-underline-opacity-25 link-underline-opacity-100-hover">{{ .name | title }} link</a></p>
|
|
||||||
{{- end -}}
|
|
||||||
{{< /colored-links.inline >}}
|
|
||||||
<p><a href="#" class="link-body-emphasis link-offset-2 link-underline-opacity-25 link-underline-opacity-75-hover">Emphasis link</a></p>
|
|
||||||
{{< /example >}}
|
|
|
@ -1,102 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Icon link
|
|
||||||
description: Quickly create stylized hyperlinks with Bootstrap Icons or other icons.
|
|
||||||
group: helpers
|
|
||||||
toc: true
|
|
||||||
added:
|
|
||||||
version: "5.3"
|
|
||||||
---
|
|
||||||
|
|
||||||
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](https://icons.getbootstrap.com) are being used, but you can use any icon or image you like.
|
|
||||||
|
|
||||||
{{< callout >}}
|
|
||||||
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.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<a class="icon-link" href="#">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="bi" viewBox="0 0 16 16" aria-hidden="true">
|
|
||||||
<path d="M8.186 1.113a.5.5 0 0 0-.372 0L1.846 3.5l2.404.961L10.404 2l-2.218-.887zm3.564 1.426L5.596 5 8 5.961 14.154 3.5l-2.404-.961zm3.25 1.7-6.5 2.6v7.922l6.5-2.6V4.24zM7.5 14.762V6.838L1 4.239v7.923l6.5 2.6zM7.443.184a1.5 1.5 0 0 1 1.114 0l7.129 2.852A.5.5 0 0 1 16 3.5v8.662a1 1 0 0 1-.629.928l-7.185 2.874a.5.5 0 0 1-.372 0L.63 13.09a1 1 0 0 1-.63-.928V3.5a.5.5 0 0 1 .314-.464L7.443.184z"/>
|
|
||||||
</svg>
|
|
||||||
Icon link
|
|
||||||
</a>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<a class="icon-link" href="#">
|
|
||||||
Icon link
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="bi" viewBox="0 0 16 16" aria-hidden="true">
|
|
||||||
<path d="M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8z"/>
|
|
||||||
</svg>
|
|
||||||
</a>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Style on hover
|
|
||||||
|
|
||||||
Add `.icon-link-hover` to move the icon to the right on hover.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<a class="icon-link icon-link-hover" href="#">
|
|
||||||
Icon link
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="bi" viewBox="0 0 16 16" aria-hidden="true">
|
|
||||||
<path d="M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8z"/>
|
|
||||||
</svg>
|
|
||||||
</a>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Customize
|
|
||||||
|
|
||||||
Modify the styling of an icon link with our link CSS variables, Sass variables, utilities, or custom styles.
|
|
||||||
|
|
||||||
### CSS variables
|
|
||||||
|
|
||||||
Modify the `--bs-link-*` and `--bs-icon-link-*` CSS variables as needed to change the default appearance.
|
|
||||||
|
|
||||||
Customize the hover `transform` by overriding the `--bs-icon-link-transform` CSS variable:
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<a class="icon-link icon-link-hover" style="--bs-icon-link-transform: translate3d(0, -.125rem, 0);" href="#">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="bi" viewBox="0 0 16 16" aria-hidden="true">
|
|
||||||
<path d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1v-1z"/>
|
|
||||||
<path d="M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5h3zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3z"/>
|
|
||||||
</svg>
|
|
||||||
Icon link
|
|
||||||
</a>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Customize the color by overriding the `--bs-link-*` CSS variable:
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<a class="icon-link icon-link-hover" style="--bs-link-hover-color-rgb: 25, 135, 84;" href="#">
|
|
||||||
Icon link
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="bi" viewBox="0 0 16 16" aria-hidden="true">
|
|
||||||
<path d="M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8z"/>
|
|
||||||
</svg>
|
|
||||||
</a>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
Customize the icon link Sass variables to modify all icon link styles across your Bootstrap-powered project.
|
|
||||||
|
|
||||||
{{< scss-docs name="icon-link-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
### Sass utilities API
|
|
||||||
|
|
||||||
Modify icon links with any of [our link utilities]({{< docsref "/utilities/link/" >}}) for modifying underline color and offset.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<a class="icon-link icon-link-hover link-success link-underline-success link-underline-opacity-25" href="#">
|
|
||||||
Icon link
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="bi" viewBox="0 0 16 16" aria-hidden="true">
|
|
||||||
<path d="M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8z"/>
|
|
||||||
</svg>
|
|
||||||
</a>
|
|
||||||
{{< /example >}}
|
|
|
@ -1,86 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Stacks
|
|
||||||
description: Shorthand helpers that build on top of our flexbox utilities to make component layout faster and easier than ever.
|
|
||||||
group: helpers
|
|
||||||
toc: true
|
|
||||||
added:
|
|
||||||
version: "5.1"
|
|
||||||
---
|
|
||||||
|
|
||||||
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](https://almonk.github.io/pylon/).
|
|
||||||
|
|
||||||
{{< callout warning >}}
|
|
||||||
**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](https://caniuse.com/flexbox-gap).
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## Vertical
|
|
||||||
|
|
||||||
Use `.vstack` to create vertical layouts. Stacked items are full-width by default. Use `.gap-*` utilities to add space between items.
|
|
||||||
|
|
||||||
{{< example class="bd-example-flex" >}}
|
|
||||||
<div class="vstack gap-3">
|
|
||||||
<div class="p-2">First item</div>
|
|
||||||
<div class="p-2">Second item</div>
|
|
||||||
<div class="p-2">Third item</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Horizontal
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example class="bd-example-flex" >}}
|
|
||||||
<div class="hstack gap-3">
|
|
||||||
<div class="p-2">First item</div>
|
|
||||||
<div class="p-2">Second item</div>
|
|
||||||
<div class="p-2">Third item</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Using horizontal margin utilities like `.ms-auto` as spacers:
|
|
||||||
|
|
||||||
{{< example class="bd-example-flex" >}}
|
|
||||||
<div class="hstack gap-3">
|
|
||||||
<div class="p-2">First item</div>
|
|
||||||
<div class="p-2 ms-auto">Second item</div>
|
|
||||||
<div class="p-2">Third item</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
And with [vertical rules]({{< docsref "/helpers/vertical-rule" >}}):
|
|
||||||
|
|
||||||
{{< example class="bd-example-flex" >}}
|
|
||||||
<div class="hstack gap-3">
|
|
||||||
<div class="p-2">First item</div>
|
|
||||||
<div class="p-2 ms-auto">Second item</div>
|
|
||||||
<div class="vr"></div>
|
|
||||||
<div class="p-2">Third item</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
Use `.vstack` to stack buttons and other elements:
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="vstack gap-2 col-md-5 mx-auto">
|
|
||||||
<button type="button" class="btn btn-secondary">Save changes</button>
|
|
||||||
<button type="button" class="btn btn-outline-secondary">Cancel</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Create an inline form with `.hstack`:
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="hstack gap-3">
|
|
||||||
<input class="form-control me-auto" type="text" placeholder="Add your item here..." aria-label="Add your item here...">
|
|
||||||
<button type="button" class="btn btn-secondary">Submit</button>
|
|
||||||
<div class="vr"></div>
|
|
||||||
<button type="button" class="btn btn-outline-danger">Reset</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
{{< scss-docs name="stacks" file="scss/helpers/_stacks.scss" >}}
|
|
|
@ -1,74 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Stretched link
|
|
||||||
description: Make any HTML element or Bootstrap component clickable by "stretching" a nested link via CSS.
|
|
||||||
group: helpers
|
|
||||||
---
|
|
||||||
|
|
||||||
Add `.stretched-link` to a link to make its [containing block](https://developer.mozilla.org/en-US/docs/Web/CSS/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](https://www.w3.org/TR/CSS21/visuren.html#propdef-position), `.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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card" style="width: 18rem;">
|
|
||||||
{{< placeholder width="100%" height="180" class="card-img-top" text="false" title="Card image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card with stretched link</h5>
|
|
||||||
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
|
|
||||||
<a href="#" class="btn btn-primary stretched-link">Go somewhere</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="d-flex position-relative">
|
|
||||||
{{< placeholder width="144" height="144" class="flex-shrink-0 me-3" text="false" title="Generic placeholder image" >}}
|
|
||||||
<div>
|
|
||||||
<h5 class="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>
|
|
||||||
<a href="#" class="stretched-link">Go somewhere</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="row g-0 bg-body-secondary position-relative">
|
|
||||||
<div class="col-md-6 mb-md-0 p-md-4">
|
|
||||||
{{< placeholder width="100%" height="200" class="w-100" text="false" title="Generic placeholder image" >}}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6 p-4 ps-md-0">
|
|
||||||
<h5 class="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>
|
|
||||||
<a href="#" class="stretched-link">Go somewhere</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Identifying the containing block
|
|
||||||
|
|
||||||
If the stretched link doesn't seem to work, the [containing block](https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#Identifying_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)
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="card" style="width: 18rem;">
|
|
||||||
{{< placeholder width="100%" height="180" class="card-img-top" text="false" title="Card image cap" >}}
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Card with stretched links</h5>
|
|
||||||
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
|
|
||||||
<p class="card-text">
|
|
||||||
<a href="#" 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>
|
|
||||||
<p class="card-text bg-body-tertiary" style="transform: rotate(0);">
|
|
||||||
This <a href="#" 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>
|
|
||||||
{{< /example >}}
|
|
|
@ -1,54 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Vertical rule
|
|
||||||
description: Use the custom vertical rule helper to create vertical dividers like the `<hr>` element.
|
|
||||||
group: helpers
|
|
||||||
toc: true
|
|
||||||
added:
|
|
||||||
version: "5.1"
|
|
||||||
---
|
|
||||||
|
|
||||||
## How it works
|
|
||||||
|
|
||||||
Vertical rules are inspired by the `<hr>` element, allowing you to create vertical dividers in common layouts. They're styled just like `<hr>` elements:
|
|
||||||
|
|
||||||
- They're `1px` wide
|
|
||||||
- They have `min-height` of `1em`
|
|
||||||
- Their color is set via `currentColor` and `opacity`
|
|
||||||
|
|
||||||
Customize them with additional styles as needed.
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="vr"></div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Vertical rules scale their height in flex layouts:
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="d-flex" style="height: 200px;">
|
|
||||||
<div class="vr"></div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## With stacks
|
|
||||||
|
|
||||||
They can also be used in [stacks]({{< docsref "/helpers/stacks" >}}):
|
|
||||||
|
|
||||||
{{< example class="bd-example-flex" >}}
|
|
||||||
<div class="hstack gap-3">
|
|
||||||
<div class="p-2">First item</div>
|
|
||||||
<div class="p-2 ms-auto">Second item</div>
|
|
||||||
<div class="vr"></div>
|
|
||||||
<div class="p-2">Third item</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
Customize the vertical rule Sass variable to change its width.
|
|
||||||
|
|
||||||
{{< scss-docs name="vr-variables" file="scss/_variables.scss" >}}
|
|
|
@ -1,29 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Visually hidden
|
|
||||||
description: Use these helpers to visually hide elements but keep them accessible to assistive technologies.
|
|
||||||
group: helpers
|
|
||||||
aliases: "/docs/5.3/helpers/screen-readers/"
|
|
||||||
---
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<h2 class="visually-hidden">Title for screen readers</h2>
|
|
||||||
<a class="visually-hidden-focusable" href="#content">Skip to main content</a>
|
|
||||||
<div class="visually-hidden-focusable">A container with a <a href="#">focusable element</a>.</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Both `visually-hidden` and `visually-hidden-focusable` can also be used as mixins.
|
|
||||||
|
|
||||||
```scss
|
|
||||||
// Usage as a mixin
|
|
||||||
|
|
||||||
.visually-hidden-title {
|
|
||||||
@include visually-hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.skip-navigation {
|
|
||||||
@include visually-hidden-focusable;
|
|
||||||
}
|
|
||||||
```
|
|
|
@ -1,356 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Columns
|
|
||||||
description: 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.
|
|
||||||
group: layout
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
**Heads up!** Be sure to [read the Grid page]({{< docsref "/layout/grid" >}}) first before diving into how to modify and customize your grid columns.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## 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]({{< docsref "/layout/grid#row-columns" >}}). 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]({{< docsref "/layout/containers" >}}) 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]({{< docsref "/layout/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
|
|
||||||
|
|
||||||
Use flexbox alignment utilities to vertically and horizontally align columns.
|
|
||||||
|
|
||||||
### Vertical alignment
|
|
||||||
|
|
||||||
Change the vertical alignment with any of the responsive `align-items-*` classes.
|
|
||||||
|
|
||||||
{{< example class="bd-example-row bd-example-row-flex-cols" >}}
|
|
||||||
<div class="container text-center">
|
|
||||||
<div class="row align-items-start">
|
|
||||||
<div class="col">
|
|
||||||
One of three columns
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
One of three columns
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
One of three columns
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example class="bd-example-row bd-example-row-flex-cols" >}}
|
|
||||||
<div class="container text-center">
|
|
||||||
<div class="row align-items-center">
|
|
||||||
<div class="col">
|
|
||||||
One of three columns
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
One of three columns
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
One of three columns
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example class="bd-example-row bd-example-row-flex-cols" >}}
|
|
||||||
<div class="container text-center">
|
|
||||||
<div class="row align-items-end">
|
|
||||||
<div class="col">
|
|
||||||
One of three columns
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
One of three columns
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
One of three columns
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Or, change the alignment of each column individually with any of the responsive `.align-self-*` classes.
|
|
||||||
|
|
||||||
{{< example class="bd-example-row bd-example-row-flex-cols" >}}
|
|
||||||
<div class="container text-center">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col align-self-start">
|
|
||||||
One of three columns
|
|
||||||
</div>
|
|
||||||
<div class="col align-self-center">
|
|
||||||
One of three columns
|
|
||||||
</div>
|
|
||||||
<div class="col align-self-end">
|
|
||||||
One of three columns
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Horizontal alignment
|
|
||||||
|
|
||||||
Change the horizontal alignment with any of the responsive `justify-content-*` classes.
|
|
||||||
|
|
||||||
{{< example class="bd-example-row" >}}
|
|
||||||
<div class="container text-center">
|
|
||||||
<div class="row justify-content-start">
|
|
||||||
<div class="col-4">
|
|
||||||
One of two columns
|
|
||||||
</div>
|
|
||||||
<div class="col-4">
|
|
||||||
One of two columns
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-4">
|
|
||||||
One of two columns
|
|
||||||
</div>
|
|
||||||
<div class="col-4">
|
|
||||||
One of two columns
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row justify-content-end">
|
|
||||||
<div class="col-4">
|
|
||||||
One of two columns
|
|
||||||
</div>
|
|
||||||
<div class="col-4">
|
|
||||||
One of two columns
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row justify-content-around">
|
|
||||||
<div class="col-4">
|
|
||||||
One of two columns
|
|
||||||
</div>
|
|
||||||
<div class="col-4">
|
|
||||||
One of two columns
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row justify-content-between">
|
|
||||||
<div class="col-4">
|
|
||||||
One of two columns
|
|
||||||
</div>
|
|
||||||
<div class="col-4">
|
|
||||||
One of two columns
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row justify-content-evenly">
|
|
||||||
<div class="col-4">
|
|
||||||
One of two columns
|
|
||||||
</div>
|
|
||||||
<div class="col-4">
|
|
||||||
One of two columns
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### 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.
|
|
||||||
|
|
||||||
{{< example class="bd-example-row" >}}
|
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-9">.col-9</div>
|
|
||||||
<div class="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>
|
|
||||||
<div class="col-6">.col-6<br>Subsequent columns continue along the new line.</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### 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 `.row`s, but not every implementation method can account for this.
|
|
||||||
|
|
||||||
{{< example class="bd-example-row" >}}
|
|
||||||
<div class="container text-center">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
|
|
||||||
<div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
|
|
||||||
|
|
||||||
<!-- Force next columns to break to new line -->
|
|
||||||
<div class="w-100"></div>
|
|
||||||
|
|
||||||
<div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
|
|
||||||
<div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
You may also apply this break at specific breakpoints with our [responsive display utilities]({{< docsref "/utilities/display" >}}).
|
|
||||||
|
|
||||||
{{< example class="bd-example-row" >}}
|
|
||||||
<div class="container text-center">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
|
|
||||||
<div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
|
|
||||||
|
|
||||||
<!-- Force next columns to break to new line at md breakpoint and up -->
|
|
||||||
<div class="w-100 d-none d-md-block"></div>
|
|
||||||
|
|
||||||
<div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
|
|
||||||
<div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Reordering
|
|
||||||
|
|
||||||
### Order classes
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example class="bd-example-row" >}}
|
|
||||||
<div class="container text-center">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
First in DOM, no order applied
|
|
||||||
</div>
|
|
||||||
<div class="col order-5">
|
|
||||||
Second in DOM, with a larger order
|
|
||||||
</div>
|
|
||||||
<div class="col order-1">
|
|
||||||
Third in DOM, with an order of 1
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example class="bd-example-row" >}}
|
|
||||||
<div class="container text-center">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col order-last">
|
|
||||||
First in DOM, ordered last
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
Second in DOM, unordered
|
|
||||||
</div>
|
|
||||||
<div class="col order-first">
|
|
||||||
Third in DOM, ordered first
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
If you need more `.order-*` classes, you can add new ones by modifying our `$utilities` Sass map. [Read our Sass maps and loops docs]({{< docsref "/customize/sass#maps-and-loops" >}}) or [our Modify utilities docs]({{< docsref "/utilities/api#modify-utilities" >}}) for details.
|
|
||||||
|
|
||||||
```scss
|
|
||||||
$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]({{< docsref "/utilities/spacing" >}}). 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.
|
|
||||||
|
|
||||||
{{< example class="bd-example-row" >}}
|
|
||||||
<div class="container text-center">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-4">.col-md-4</div>
|
|
||||||
<div class="col-md-4 offset-md-4">.col-md-4 .offset-md-4</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-3 offset-md-3">.col-md-3 .offset-md-3</div>
|
|
||||||
<div class="col-md-3 offset-md-3">.col-md-3 .offset-md-3</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-6 offset-md-3">.col-md-6 .offset-md-3</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
In addition to column clearing at responsive breakpoints, you may need to reset offsets. See this in action in [the grid example]({{< docsref "/examples/grid" >}}).
|
|
||||||
|
|
||||||
{{< example class="bd-example-row" >}}
|
|
||||||
<div class="container text-center">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-5 col-md-6">.col-sm-5 .col-md-6</div>
|
|
||||||
<div class="col-sm-5 offset-sm-2 col-md-6 offset-md-0">.col-sm-5 .offset-sm-2 .col-md-6 .offset-md-0</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-6 col-md-5 col-lg-6">.col-sm-6 .col-md-5 .col-lg-6</div>
|
|
||||||
<div class="col-sm-6 col-md-5 offset-md-2 col-lg-6 offset-lg-0">.col-sm-6 .col-md-5 .offset-md-2 .col-lg-6 .offset-lg-0</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
#### Margin utilities
|
|
||||||
|
|
||||||
With the move to flexbox in v4, you can use margin utilities like `.me-auto` to force sibling columns away from one another.
|
|
||||||
|
|
||||||
{{< example class="bd-example-row" >}}
|
|
||||||
<div class="container text-center">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-4">.col-md-4</div>
|
|
||||||
<div class="col-md-4 ms-auto">.col-md-4 .ms-auto</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-3 ms-md-auto">.col-md-3 .ms-md-auto</div>
|
|
||||||
<div class="col-md-3 ms-md-auto">.col-md-3 .ms-md-auto</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-auto me-auto">.col-auto .me-auto</div>
|
|
||||||
<div class="col-auto">.col-auto</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Standalone column classes
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example class="bd-example-row" >}}
|
|
||||||
<div class="col-3 p-3 mb-2">
|
|
||||||
.col-3: width of 25%
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-sm-9 p-3">
|
|
||||||
.col-sm-9: width of 75% above sm breakpoint
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
The classes can be used together with utilities to create responsive floated images. Make sure to wrap the content in a [`.clearfix`]({{< docsref "/helpers/clearfix" >}}) wrapper to clear the float if the text is shorter.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="clearfix">
|
|
||||||
{{< placeholder width="100%" height="210" class="col-md-6 float-md-end mb-3 ms-md-3" text="Responsive floated image" >}}
|
|
||||||
|
|
||||||
<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>
|
|
||||||
{{< /example >}}
|
|
|
@ -1,268 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: CSS Grid
|
|
||||||
description: Learn how to enable, use, and customize our alternate layout system built on CSS Grid with examples and code snippets.
|
|
||||||
group: layout
|
|
||||||
toc: true
|
|
||||||
added:
|
|
||||||
version: "5.1"
|
|
||||||
---
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< callout warning >}}
|
|
||||||
**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.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
- **Replace instances of `.row` with `.grid`.** The `.grid` class sets `display: grid` and creates a `grid-template` that you build on with your HTML.
|
|
||||||
|
|
||||||
- **Replace `.col-*` classes with `.g-col-*` classes.** This is because our CSS Grid columns use the `grid-column` property instead of `width`.
|
|
||||||
|
|
||||||
- **Columns and gutter sizes are set via CSS variables.** Set these on the parent `.grid` and customize however you want, inline or in a stylesheet, with `--bs-columns` and `--bs-gap`.
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
Compared to the default grid system:
|
|
||||||
|
|
||||||
- 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`.
|
|
||||||
|
|
||||||
- As such, unlike `.row`s, `.grid`s have no negative margins and margin utilities cannot be used to change the grid gutters. Grid gaps are applied horizontally and vertically by default. See the [customizing section](#customizing) for more details.
|
|
||||||
|
|
||||||
- Inline and custom styles should be viewed as replacements for modifier classes (e.g., `style="--bs-columns: 3;"` vs `class="row-cols-3"`).
|
|
||||||
|
|
||||||
- Nesting works similarly, but may require you to reset your column counts on each instance of a nested `.grid`. See the [nesting section](#nesting) for details.
|
|
||||||
|
|
||||||
## 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](#responsive) to change the layout by viewport size.
|
|
||||||
|
|
||||||
{{< example class="bd-example-cssgrid" >}}
|
|
||||||
<div class="grid text-center">
|
|
||||||
<div class="g-col-4">.g-col-4</div>
|
|
||||||
<div class="g-col-4">.g-col-4</div>
|
|
||||||
<div class="g-col-4">.g-col-4</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Responsive
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example class="bd-example-cssgrid" >}}
|
|
||||||
<div class="grid text-center">
|
|
||||||
<div class="g-col-6 g-col-md-4">.g-col-6 .g-col-md-4</div>
|
|
||||||
<div class="g-col-6 g-col-md-4">.g-col-6 .g-col-md-4</div>
|
|
||||||
<div class="g-col-6 g-col-md-4">.g-col-6 .g-col-md-4</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Compare that to this two column layout at all viewports.
|
|
||||||
|
|
||||||
{{< example class="bd-example-cssgrid" >}}
|
|
||||||
<div class="grid text-center">
|
|
||||||
<div class="g-col-6">.g-col-6</div>
|
|
||||||
<div class="g-col-6">.g-col-6</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Wrapping
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example class="bd-example-cssgrid" >}}
|
|
||||||
<div class="grid text-center">
|
|
||||||
<div class="g-col-6">.g-col-6</div>
|
|
||||||
<div class="g-col-6">.g-col-6</div>
|
|
||||||
|
|
||||||
<div class="g-col-6">.g-col-6</div>
|
|
||||||
<div class="g-col-6">.g-col-6</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Starts
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example class="bd-example-cssgrid" >}}
|
|
||||||
<div class="grid text-center">
|
|
||||||
<div class="g-col-3 g-start-2">.g-col-3 .g-start-2</div>
|
|
||||||
<div class="g-col-4 g-start-6">.g-col-4 .g-start-6</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Auto columns
|
|
||||||
|
|
||||||
When there are no classes on the grid items (the immediate children of a `.grid`), each grid item will automatically be sized to one column.
|
|
||||||
|
|
||||||
{{< example class="bd-example-cssgrid" >}}
|
|
||||||
<div class="grid text-center">
|
|
||||||
<div>1</div>
|
|
||||||
<div>1</div>
|
|
||||||
<div>1</div>
|
|
||||||
<div>1</div>
|
|
||||||
<div>1</div>
|
|
||||||
<div>1</div>
|
|
||||||
<div>1</div>
|
|
||||||
<div>1</div>
|
|
||||||
<div>1</div>
|
|
||||||
<div>1</div>
|
|
||||||
<div>1</div>
|
|
||||||
<div>1</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
This behavior can be mixed with grid column classes.
|
|
||||||
|
|
||||||
{{< example class="bd-example-cssgrid" >}}
|
|
||||||
<div class="grid text-center">
|
|
||||||
<div class="g-col-6">.g-col-6</div>
|
|
||||||
<div>1</div>
|
|
||||||
<div>1</div>
|
|
||||||
<div>1</div>
|
|
||||||
<div>1</div>
|
|
||||||
<div>1</div>
|
|
||||||
<div>1</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Nesting
|
|
||||||
|
|
||||||
Similar to our default grid system, our CSS Grid allows for easy nesting of `.grid`s. 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).
|
|
||||||
- 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.
|
|
||||||
|
|
||||||
{{< example class="bd-example-cssgrid" >}}
|
|
||||||
<div class="grid text-center overflow-x-auto" style="--bs-columns: 3;">
|
|
||||||
<div>
|
|
||||||
First auto-column
|
|
||||||
<div class="grid">
|
|
||||||
<div>Auto-column</div>
|
|
||||||
<div>Auto-column</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
Second auto-column
|
|
||||||
<div class="grid" style="--bs-columns: 12;">
|
|
||||||
<div class="g-col-6">6 of 12</div>
|
|
||||||
<div class="g-col-4">4 of 12</div>
|
|
||||||
<div class="g-col-2">2 of 12</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div>Third auto-column</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Customizing
|
|
||||||
|
|
||||||
Customize the number of columns, the number of rows, and the width of the gaps with local CSS variables.
|
|
||||||
|
|
||||||
{{< bs-table "table" >}}
|
|
||||||
| 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) |
|
|
||||||
{{< /bs-table >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example class="bd-example-cssgrid" >}}
|
|
||||||
<div class="grid text-center" style="--bs-columns: 3;">
|
|
||||||
<div>Auto-column</div>
|
|
||||||
<div>Auto-column</div>
|
|
||||||
<div>Auto-column</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Columns and gaps
|
|
||||||
|
|
||||||
Adjust the number of columns and the gap.
|
|
||||||
|
|
||||||
{{< example class="bd-example-cssgrid" >}}
|
|
||||||
<div class="grid text-center" style="--bs-columns: 4; --bs-gap: 5rem;">
|
|
||||||
<div class="g-col-2">.g-col-2</div>
|
|
||||||
<div class="g-col-2">.g-col-2</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example class="bd-example-cssgrid" >}}
|
|
||||||
<div class="grid text-center" style="--bs-columns: 10; --bs-gap: 1rem;">
|
|
||||||
<div class="g-col-6">.g-col-6</div>
|
|
||||||
<div class="g-col-4">.g-col-4</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Adding rows
|
|
||||||
|
|
||||||
Adding more rows and changing the placement of columns:
|
|
||||||
|
|
||||||
{{< example class="bd-example-cssgrid" >}}
|
|
||||||
<div class="grid text-center" style="--bs-rows: 3; --bs-columns: 3;">
|
|
||||||
<div>Auto-column</div>
|
|
||||||
<div class="g-start-2" style="grid-row: 2">Auto-column</div>
|
|
||||||
<div class="g-start-3" style="grid-row: 3">Auto-column</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Gaps
|
|
||||||
|
|
||||||
Change the vertical gaps only by modifying the `row-gap`. Note that we use `gap` on `.grid`s, but `row-gap` and `column-gap` can be modified as needed.
|
|
||||||
|
|
||||||
{{< example class="bd-example-cssgrid" >}}
|
|
||||||
<div class="grid text-center" style="row-gap: 0;">
|
|
||||||
<div class="g-col-6">.g-col-6</div>
|
|
||||||
<div class="g-col-6">.g-col-6</div>
|
|
||||||
|
|
||||||
<div class="g-col-6">.g-col-6</div>
|
|
||||||
<div class="g-col-6">.g-col-6</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Because of that, you can have different vertical and horizontal `gap`s, 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.
|
|
||||||
|
|
||||||
{{< example class="bd-example-cssgrid" >}}
|
|
||||||
<div class="grid text-center" style="--bs-gap: .25rem 1rem;">
|
|
||||||
<div class="g-col-6">.g-col-6</div>
|
|
||||||
<div class="g-col-6">.g-col-6</div>
|
|
||||||
|
|
||||||
<div class="g-col-6">.g-col-6</div>
|
|
||||||
<div class="g-col-6">.g-col-6</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Sass
|
|
||||||
|
|
||||||
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`).
|
|
||||||
|
|
||||||
{{< example class="bd-example-cssgrid" >}}
|
|
||||||
<div class="grid text-center" style="--bs-columns: 18; --bs-gap: .5rem;">
|
|
||||||
<div style="grid-column: span 14;">14 columns</div>
|
|
||||||
<div class="g-col-4">.g-col-4</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
|
@ -1,165 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Gutters
|
|
||||||
description: Gutters are the padding between your columns, used to responsively space and align content in the Bootstrap grid system.
|
|
||||||
group: layout
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## How they work
|
|
||||||
|
|
||||||
- **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]({{< docsref "/utilities/spacing" >}}) 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`:
|
|
||||||
|
|
||||||
{{< example class="bd-example-cols" >}}
|
|
||||||
<div class="container px-4 text-center">
|
|
||||||
<div class="row gx-5">
|
|
||||||
<div class="col">
|
|
||||||
<div class="p-3">Custom column padding</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="p-3">Custom column padding</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
An alternative solution is to add a wrapper around the `.row` with the `.overflow-hidden` class:
|
|
||||||
|
|
||||||
{{< example class="bd-example-cols" >}}
|
|
||||||
<div class="container overflow-hidden text-center">
|
|
||||||
<div class="row gx-5">
|
|
||||||
<div class="col">
|
|
||||||
<div class="p-3">Custom column padding</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="p-3">Custom column padding</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Vertical gutters
|
|
||||||
|
|
||||||
`.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:
|
|
||||||
|
|
||||||
{{< example class="bd-example-cols" >}}
|
|
||||||
<div class="container overflow-hidden text-center">
|
|
||||||
<div class="row gy-5">
|
|
||||||
<div class="col-6">
|
|
||||||
<div class="p-3">Custom column padding</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-6">
|
|
||||||
<div class="p-3">Custom column padding</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-6">
|
|
||||||
<div class="p-3">Custom column padding</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-6">
|
|
||||||
<div class="p-3">Custom column padding</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Horizontal & vertical gutters
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example class="bd-example-cols" >}}
|
|
||||||
<div class="container text-center">
|
|
||||||
<div class="row g-2">
|
|
||||||
<div class="col-6">
|
|
||||||
<div class="p-3">Custom column padding</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-6">
|
|
||||||
<div class="p-3">Custom column padding</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-6">
|
|
||||||
<div class="p-3">Custom column padding</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-6">
|
|
||||||
<div class="p-3">Custom column padding</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Row columns gutters
|
|
||||||
|
|
||||||
Gutter classes can also be added to [row columns]({{< docsref "/layout/grid#row-columns" >}}). In the following example, we use responsive row columns and responsive gutter classes.
|
|
||||||
|
|
||||||
{{< example class="bd-example-cols" >}}
|
|
||||||
<div class="container text-center">
|
|
||||||
<div class="row row-cols-2 row-cols-lg-5 g-2 g-lg-3">
|
|
||||||
<div class="col">
|
|
||||||
<div class="p-3">Row column</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="p-3">Row column</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="p-3">Row column</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="p-3">Row column</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="p-3">Row column</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="p-3">Row column</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="p-3">Row column</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="p-3">Row column</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="p-3">Row column</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="p-3">Row column</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## No gutters
|
|
||||||
|
|
||||||
The gutters between columns in our predefined grid classes can be removed with `.g-0`. This removes the negative `margin`s 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).
|
|
||||||
|
|
||||||
{{< example class="bd-example-row" >}}
|
|
||||||
<div class="row g-0 text-center">
|
|
||||||
<div class="col-sm-6 col-md-8">.col-sm-6 .col-md-8</div>
|
|
||||||
<div class="col-6 col-md-4">.col-6 .col-md-4</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Change the gutters
|
|
||||||
|
|
||||||
Classes are built from the `$gutters` Sass map which is inherited from the `$spacers` Sass map.
|
|
||||||
|
|
||||||
```scss
|
|
||||||
$grid-gutter-width: 1.5rem;
|
|
||||||
$gutters: (
|
|
||||||
0: 0,
|
|
||||||
1: $spacer * .25,
|
|
||||||
2: $spacer * .5,
|
|
||||||
3: $spacer,
|
|
||||||
4: $spacer * 1.5,
|
|
||||||
5: $spacer * 3,
|
|
||||||
);
|
|
||||||
```
|
|
|
@ -1,25 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Utilities for layout
|
|
||||||
description: For faster mobile-friendly and responsive development, Bootstrap includes dozens of utility classes for showing, hiding, aligning, and spacing content.
|
|
||||||
group: layout
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## Changing `display`
|
|
||||||
|
|
||||||
Use our [display utilities]({{< docsref "/utilities/display" >}}) 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]({{< docsref "/components/alerts" >}}) 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]({{< docsref "/utilities/flex" >}}) for sizing, alignment, spacing, and more.
|
|
||||||
|
|
||||||
## Margin and padding
|
|
||||||
|
|
||||||
Use the `margin` and `padding` [spacing utilities]({{< docsref "/utilities/spacing" >}}) 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]({{< docsref "/utilities/visibility" >}}). Invisible elements will still affect the layout of the page, but are visually hidden from visitors.
|
|
|
@ -1,194 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Borders
|
|
||||||
description: Use border utilities to quickly style the border and border-radius of an element. Great for images, buttons, or any other element.
|
|
||||||
group: utilities
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## Border
|
|
||||||
|
|
||||||
Use border utilities to add or remove an element's borders. Choose from all borders or one at a time.
|
|
||||||
|
|
||||||
### Additive
|
|
||||||
|
|
||||||
Add borders to custom elements:
|
|
||||||
|
|
||||||
{{< example class="bd-example-border-utils" >}}
|
|
||||||
<span class="border"></span>
|
|
||||||
<span class="border-top"></span>
|
|
||||||
<span class="border-end"></span>
|
|
||||||
<span class="border-bottom"></span>
|
|
||||||
<span class="border-start"></span>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Subtractive
|
|
||||||
|
|
||||||
Or remove borders:
|
|
||||||
|
|
||||||
{{< example class="bd-example-border-utils" >}}
|
|
||||||
<span class="border border-0"></span>
|
|
||||||
<span class="border border-top-0"></span>
|
|
||||||
<span class="border border-end-0"></span>
|
|
||||||
<span class="border border-bottom-0"></span>
|
|
||||||
<span class="border border-start-0"></span>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Color
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
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.
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
Change the border color using utilities built on our theme colors.
|
|
||||||
|
|
||||||
{{< example class="bd-example-border-utils" >}}
|
|
||||||
{{< border.inline >}}
|
|
||||||
{{- range (index $.Site.Data "theme-colors") }}
|
|
||||||
<span class="border border-{{ .name }}"></span>
|
|
||||||
<span class="border border-{{ .name }}-subtle"></span>
|
|
||||||
{{- end -}}
|
|
||||||
{{< /border.inline >}}
|
|
||||||
<span class="border border-black"></span>
|
|
||||||
<span class="border border-white"></span>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Or modify the default `border-color` of a component:
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="mb-4">
|
|
||||||
<label for="exampleFormControlInput1" class="form-label">Email address</label>
|
|
||||||
<input type="email" class="form-control border-success" id="exampleFormControlInput1" placeholder="name@example.com">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="h4 pb-2 mb-4 text-danger border-bottom border-danger">
|
|
||||||
Dangerous heading
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="p-3 bg-info bg-opacity-10 border border-info border-start-0 rounded-end">
|
|
||||||
Changing border color and width
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Opacity
|
|
||||||
|
|
||||||
{{< added-in "5.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.
|
|
||||||
|
|
||||||
### How it works
|
|
||||||
|
|
||||||
Consider our default `.border-success` utility.
|
|
||||||
|
|
||||||
```css
|
|
||||||
.border-success {
|
|
||||||
--bs-border-opacity: 1;
|
|
||||||
border-color: rgba(var(--bs-success-rgb), var(--bs-border-opacity)) !important;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="border border-success p-2 mb-2">This is default success border</div>
|
|
||||||
<div class="border border-success p-2" style="--bs-border-opacity: .5;">This is 50% opacity success border</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
Or, choose from any of the `.border-opacity` utilities:
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<div class="border border-success p-2 mb-2">This is default success border</div>
|
|
||||||
<div class="border border-success p-2 mb-2 border-opacity-75">This is 75% opacity success border</div>
|
|
||||||
<div class="border border-success p-2 mb-2 border-opacity-50">This is 50% opacity success border</div>
|
|
||||||
<div class="border border-success p-2 mb-2 border-opacity-25">This is 25% opacity success border</div>
|
|
||||||
<div class="border border-success p-2 border-opacity-10">This is 10% opacity success border</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Width
|
|
||||||
|
|
||||||
{{< example class="bd-example-border-utils" >}}
|
|
||||||
<span class="border border-1"></span>
|
|
||||||
<span class="border border-2"></span>
|
|
||||||
<span class="border border-3"></span>
|
|
||||||
<span class="border border-4"></span>
|
|
||||||
<span class="border border-5"></span>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Radius
|
|
||||||
|
|
||||||
Add classes to an element to easily round its corners.
|
|
||||||
|
|
||||||
{{< example class="bd-example-rounded-utils" >}}
|
|
||||||
{{< placeholder width="75" height="75" class="rounded" title="Example rounded image" >}}
|
|
||||||
{{< placeholder width="75" height="75" class="rounded-top" title="Example top rounded image" >}}
|
|
||||||
{{< placeholder width="75" height="75" class="rounded-end" title="Example right rounded image" >}}
|
|
||||||
{{< placeholder width="75" height="75" class="rounded-bottom" title="Example bottom rounded image" >}}
|
|
||||||
{{< placeholder width="75" height="75" class="rounded-start" title="Example left rounded image" >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Sizes
|
|
||||||
|
|
||||||
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 class="bd-example-rounded-utils" >}}
|
|
||||||
{{< placeholder width="75" height="75" class="rounded-0" title="Example non-rounded image" >}}
|
|
||||||
{{< placeholder width="75" height="75" class="rounded-1" title="Example small rounded image" >}}
|
|
||||||
{{< placeholder width="75" height="75" class="rounded-2" title="Example default rounded image" >}}
|
|
||||||
{{< placeholder width="75" height="75" class="rounded-3" title="Example large rounded image" >}}
|
|
||||||
{{< placeholder width="75" height="75" class="rounded-4" title="Example larger rounded image" >}}
|
|
||||||
{{< placeholder width="75" height="75" class="rounded-5" title="Example extra large rounded image" >}}
|
|
||||||
{{< placeholder width="75" height="75" class="rounded-circle" title="Completely round image" >}}
|
|
||||||
{{< placeholder width="150" height="75" class="rounded-pill" title="Rounded pill image" >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example class="bd-example-rounded-utils" >}}
|
|
||||||
{{< placeholder width="75" height="75" class="rounded-bottom-1" title="Example small rounded image" >}}
|
|
||||||
{{< placeholder width="75" height="75" class="rounded-start-2" title="Example default left rounded image" >}}
|
|
||||||
{{< placeholder width="75" height="75" class="rounded-end-circle" title="Example right completely round image" >}}
|
|
||||||
{{< placeholder width="75" height="75" class="rounded-start-pill" title="Example left rounded pill image" >}}
|
|
||||||
{{< placeholder width="75" height="75" class="rounded-5 rounded-top-0" title="Example extra large bottom rounded image" >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Variables
|
|
||||||
|
|
||||||
{{< added-in "5.2.0" >}}
|
|
||||||
|
|
||||||
{{< scss-docs name="root-border-var" file="scss/_root.scss" >}}
|
|
||||||
|
|
||||||
### Sass variables
|
|
||||||
|
|
||||||
{{< scss-docs name="border-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
{{< scss-docs name="border-radius-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
Variables for setting `border-color` in `.border-*-subtle` utilities in light and dark mode:
|
|
||||||
|
|
||||||
{{< scss-docs name="theme-border-subtle-variables" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
{{< scss-docs name="theme-border-subtle-dark-variables" file="scss/_variables-dark.scss" >}}
|
|
||||||
|
|
||||||
### Sass maps
|
|
||||||
|
|
||||||
Color mode adaptive border colors are also available as a Sass map:
|
|
||||||
|
|
||||||
{{< scss-docs name="theme-border-subtle-map" file="scss/_maps.scss" >}}
|
|
||||||
|
|
||||||
{{< scss-docs name="theme-border-subtle-dark-map" file="scss/_maps.scss" >}}
|
|
||||||
|
|
||||||
### Sass mixins
|
|
||||||
|
|
||||||
{{< scss-docs name="border-radius-mixins" file="scss/mixins/_border-radius.scss" >}}
|
|
||||||
|
|
||||||
### Sass utilities API
|
|
||||||
|
|
||||||
Border utilities are declared in our utilities API in `scss/_utilities.scss`. [Learn how to use the utilities API.]({{< docsref "/utilities/api#using-the-api" >}})
|
|
||||||
|
|
||||||
{{< scss-docs name="utils-borders" file="scss/_utilities.scss" >}}
|
|
||||||
|
|
||||||
{{< scss-docs name="utils-border-radius" file="scss/_utilities.scss" >}}
|
|
|
@ -1,106 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Link
|
|
||||||
description: Link utilities are used to stylize your anchors to adjust their color, opacity, underline offset, underline color, and more.
|
|
||||||
group: utilities
|
|
||||||
toc: true
|
|
||||||
added:
|
|
||||||
version: "5.3"
|
|
||||||
---
|
|
||||||
|
|
||||||
## Link opacity
|
|
||||||
|
|
||||||
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]({{< docsref "getting-started/accessibility#color-contrast" >}}).
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<p><a class="link-opacity-10" href="#">Link opacity 10</a></p>
|
|
||||||
<p><a class="link-opacity-25" href="#">Link opacity 25</a></p>
|
|
||||||
<p><a class="link-opacity-50" href="#">Link opacity 50</a></p>
|
|
||||||
<p><a class="link-opacity-75" href="#">Link opacity 75</a></p>
|
|
||||||
<p><a class="link-opacity-100" href="#">Link opacity 100</a></p>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
You can even change the opacity level on hover.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<p><a class="link-opacity-10-hover" href="#">Link hover opacity 10</a></p>
|
|
||||||
<p><a class="link-opacity-25-hover" href="#">Link hover opacity 25</a></p>
|
|
||||||
<p><a class="link-opacity-50-hover" href="#">Link hover opacity 50</a></p>
|
|
||||||
<p><a class="link-opacity-75-hover" href="#">Link hover opacity 75</a></p>
|
|
||||||
<p><a class="link-opacity-100-hover" href="#">Link hover opacity 100</a></p>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Link underlines
|
|
||||||
|
|
||||||
### Underline color
|
|
||||||
|
|
||||||
Change the underline's color independent of the link text color.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
{{< link-underline-colors.inline >}}
|
|
||||||
{{- range (index $.Site.Data "theme-colors") }}
|
|
||||||
<p><a href="#" class="link-underline-{{ .name }}">{{ .name | title }} underline</a></p>
|
|
||||||
{{- end -}}
|
|
||||||
{{< /link-underline-colors.inline >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Underline offset
|
|
||||||
|
|
||||||
Change the underline's distance from your text. Offset is set in `em` units to automatically scale with the element's current `font-size`.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<p><a href="#">Default link</a></p>
|
|
||||||
<p><a class="link-offset-1" href="#">Offset 1 link</a></p>
|
|
||||||
<p><a class="link-offset-2" href="#">Offset 2 link</a></p>
|
|
||||||
<p><a class="link-offset-3" href="#">Offset 3 link</a></p>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Underline opacity
|
|
||||||
|
|
||||||
Change the underline's opacity. Requires adding `.link-underline` to first set an `rgba()` color we use to then modify the alpha opacity.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<p><a class="link-offset-2 link-underline link-underline-opacity-0" href="#">Underline opacity 0</a></p>
|
|
||||||
<p><a class="link-offset-2 link-underline link-underline-opacity-10" href="#">Underline opacity 10</a></p>
|
|
||||||
<p><a class="link-offset-2 link-underline link-underline-opacity-25" href="#">Underline opacity 25</a></p>
|
|
||||||
<p><a class="link-offset-2 link-underline link-underline-opacity-50" href="#">Underline opacity 50</a></p>
|
|
||||||
<p><a class="link-offset-2 link-underline link-underline-opacity-75" href="#">Underline opacity 75</a></p>
|
|
||||||
<p><a class="link-offset-2 link-underline link-underline-opacity-100" href="#">Underline opacity 100</a></p>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
### Hover variants
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
<a class="link-offset-2 link-offset-3-hover link-underline link-underline-opacity-0 link-underline-opacity-75-hover" href="#">
|
|
||||||
Underline opacity 0
|
|
||||||
</a>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Colored links
|
|
||||||
|
|
||||||
[Colored link helpers]({{< docsref "/helpers/colored-links/" >}}) have been updated to pair with our link utilities. Use the new utilities to modify the link opacity, underline opacity, and underline offset.
|
|
||||||
|
|
||||||
{{< example >}}
|
|
||||||
{{< colored-links.inline >}}
|
|
||||||
{{- range (index $.Site.Data "theme-colors") }}
|
|
||||||
<p><a href="#" class="link-{{ .name }} link-offset-2 link-underline-opacity-25 link-underline-opacity-100-hover">{{ .name | title }} link</a></p>
|
|
||||||
{{- end -}}
|
|
||||||
{{< /colored-links.inline >}}
|
|
||||||
<p><a href="#" class="link-body-emphasis link-offset-2 link-underline-opacity-25 link-underline-opacity-75-hover">Emphasis link</a></p>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< callout info >}}
|
|
||||||
{{< partial "callouts/warning-color-assistive-technologies.md" >}}
|
|
||||||
{{< /callout >}}
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
In addition to the following Sass functionality, consider reading about our included [CSS custom properties]({{< docsref "/customize/css-variables" >}}) (aka CSS variables) for colors and more.
|
|
||||||
|
|
||||||
### Sass utilities API
|
|
||||||
|
|
||||||
Link utilities are declared in our utilities API in `scss/_utilities.scss`. [Learn how to use the utilities API.]({{< docsref "/utilities/api#using-the-api" >}})
|
|
||||||
|
|
||||||
{{< scss-docs name="utils-links" file="scss/_utilities.scss" >}}
|
|
|
@ -1,65 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Object fit
|
|
||||||
description: Use the object fit utilities to modify how the content of a [replaced element](https://developer.mozilla.org/en-US/docs/Web/CSS/Replaced_element), such as an `<img>` or `<video>`, should be resized to fit its container.
|
|
||||||
group: utilities
|
|
||||||
toc: true
|
|
||||||
added:
|
|
||||||
version: "5.3"
|
|
||||||
---
|
|
||||||
|
|
||||||
## How it works
|
|
||||||
|
|
||||||
Change the value of the [`object-fit` property](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) 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:
|
|
||||||
|
|
||||||
- `contain`
|
|
||||||
- `cover`
|
|
||||||
- `fill`
|
|
||||||
- `scale` (for scale-down)
|
|
||||||
- `none`
|
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
Add the `object-fit-{value}` class to the [replaced element](https://developer.mozilla.org/en-US/docs/Web/CSS/Replaced_element):
|
|
||||||
|
|
||||||
{{< example class="d-flex overflow-auto" >}}
|
|
||||||
{{< placeholder width="140" height="120" class="object-fit-contain border rounded" text="Object fit contain" markup="img" color="#868e96" background="#dee2e6" >}}
|
|
||||||
{{< placeholder width="140" height="120" class="object-fit-cover border rounded" text="Object fit cover" markup="img" color="#868e96" background="#dee2e6" >}}
|
|
||||||
{{< placeholder width="140" height="120" class="object-fit-fill border rounded" text="Object fit fill" markup="img" color="#868e96" background="#dee2e6" >}}
|
|
||||||
{{< placeholder width="140" height="120" class="object-fit-scale border rounded" text="Object fit scale down" markup="img" color="#868e96" background="#dee2e6" >}}
|
|
||||||
{{< placeholder width="140" height="120" class="object-fit-none border rounded" text="Object fit none" markup="img" color="#868e96" background="#dee2e6" >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Responsive
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example class="d-flex overflow-auto" >}}
|
|
||||||
{{< placeholder width="140" height="80" class="object-fit-sm-contain border rounded" text="Contain on sm" markup="img" color="#868e96" background="#dee2e6" >}}
|
|
||||||
{{< placeholder width="140" height="80" class="object-fit-md-contain border rounded" text="Contain on md" markup="img" color="#868e96" background="#dee2e6" >}}
|
|
||||||
{{< placeholder width="140" height="80" class="object-fit-lg-contain border rounded" text="Contain on lg" markup="img" color="#868e96" background="#dee2e6" >}}
|
|
||||||
{{< placeholder width="140" height="80" class="object-fit-xl-contain border rounded" text="Contain on xl" markup="img" color="#868e96" background="#dee2e6" >}}
|
|
||||||
{{< placeholder width="140" height="80" class="object-fit-xxl-contain border rounded" text="Contain on xxl" markup="img" color="#868e96" background="#dee2e6" >}}
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Video
|
|
||||||
|
|
||||||
The `.object-fit-{value}` and responsive `.object-fit-{breakpoint}-{value}` utilities also work on `<video>` elements.
|
|
||||||
|
|
||||||
```html
|
|
||||||
<video src="..." class="object-fit-contain" autoplay></video>
|
|
||||||
<video src="..." class="object-fit-cover" autoplay></video>
|
|
||||||
<video src="..." class="object-fit-fill" autoplay></video>
|
|
||||||
<video src="..." class="object-fit-scale" autoplay></video>
|
|
||||||
<video src="..." class="object-fit-none" autoplay></video>
|
|
||||||
```
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Sass utilities API
|
|
||||||
|
|
||||||
Object fit utilities are declared in our utilities API in `scss/_utilities.scss`. [Learn how to use the utilities API.]({{< docsref "/utilities/api#using-the-api" >}})
|
|
||||||
|
|
||||||
{{< scss-docs name="utils-object-fit" file="scss/_utilities.scss" >}}
|
|
|
@ -1,130 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Position
|
|
||||||
description: Use these shorthand utilities for quickly configuring the position of an element.
|
|
||||||
group: utilities
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## Position values
|
|
||||||
|
|
||||||
Quick positioning classes are available, though they are not responsive.
|
|
||||||
|
|
||||||
```html
|
|
||||||
<div class="position-static">...</div>
|
|
||||||
<div class="position-relative">...</div>
|
|
||||||
<div class="position-absolute">...</div>
|
|
||||||
<div class="position-fixed">...</div>
|
|
||||||
<div class="position-sticky">...</div>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Arrange elements
|
|
||||||
|
|
||||||
Arrange elements easily with the edge positioning utilities. The format is `{property}-{position}`.
|
|
||||||
|
|
||||||
Where *property* is one of:
|
|
||||||
|
|
||||||
- `top` - for the vertical `top` position
|
|
||||||
- `start` - for the horizontal `left` position (in LTR)
|
|
||||||
- `bottom` - for the vertical `bottom` position
|
|
||||||
- `end` - for the horizontal `right` position (in LTR)
|
|
||||||
|
|
||||||
Where *position* is one of:
|
|
||||||
|
|
||||||
- `0` - for `0` edge position
|
|
||||||
- `50` - for `50%` edge position
|
|
||||||
- `100` - for `100%` edge position
|
|
||||||
|
|
||||||
(You can add more position values by adding entries to the `$position-values` Sass map variable.)
|
|
||||||
|
|
||||||
{{< example class="bd-example-position-utils" >}}
|
|
||||||
<div class="position-relative">
|
|
||||||
<div class="position-absolute top-0 start-0"></div>
|
|
||||||
<div class="position-absolute top-0 end-0"></div>
|
|
||||||
<div class="position-absolute top-50 start-50"></div>
|
|
||||||
<div class="position-absolute bottom-50 end-50"></div>
|
|
||||||
<div class="position-absolute bottom-0 start-0"></div>
|
|
||||||
<div class="position-absolute bottom-0 end-0"></div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Center elements
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example class="bd-example-position-utils" >}}
|
|
||||||
<div class="position-relative">
|
|
||||||
<div class="position-absolute top-0 start-0 translate-middle"></div>
|
|
||||||
<div class="position-absolute top-0 start-50 translate-middle"></div>
|
|
||||||
<div class="position-absolute top-0 start-100 translate-middle"></div>
|
|
||||||
<div class="position-absolute top-50 start-0 translate-middle"></div>
|
|
||||||
<div class="position-absolute top-50 start-50 translate-middle"></div>
|
|
||||||
<div class="position-absolute top-50 start-100 translate-middle"></div>
|
|
||||||
<div class="position-absolute top-100 start-0 translate-middle"></div>
|
|
||||||
<div class="position-absolute top-100 start-50 translate-middle"></div>
|
|
||||||
<div class="position-absolute top-100 start-100 translate-middle"></div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
By adding `.translate-middle-x` or `.translate-middle-y` classes, elements can be positioned only in horizontal or vertical direction.
|
|
||||||
|
|
||||||
{{< example class="bd-example-position-utils" >}}
|
|
||||||
<div class="position-relative">
|
|
||||||
<div class="position-absolute top-0 start-0"></div>
|
|
||||||
<div class="position-absolute top-0 start-50 translate-middle-x"></div>
|
|
||||||
<div class="position-absolute top-0 end-0"></div>
|
|
||||||
<div class="position-absolute top-50 start-0 translate-middle-y"></div>
|
|
||||||
<div class="position-absolute top-50 start-50 translate-middle"></div>
|
|
||||||
<div class="position-absolute top-50 end-0 translate-middle-y"></div>
|
|
||||||
<div class="position-absolute bottom-0 start-0"></div>
|
|
||||||
<div class="position-absolute bottom-0 start-50 translate-middle-x"></div>
|
|
||||||
<div class="position-absolute bottom-0 end-0"></div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
Here are some real life examples of these classes:
|
|
||||||
|
|
||||||
{{< example class="bd-example-position-examples d-flex justify-content-around align-items-center" >}}
|
|
||||||
<button type="button" class="btn btn-primary position-relative">
|
|
||||||
Mails <span class="position-absolute top-0 start-100 translate-middle badge rounded-pill text-bg-secondary">+99 <span class="visually-hidden">unread messages</span></span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div class="position-relative py-2 px-4 text-bg-secondary border border-secondary rounded-pill">
|
|
||||||
Marker <svg width="1em" height="1em" viewBox="0 0 16 16" class="position-absolute top-100 start-50 translate-middle mt-1" fill="var(--bs-secondary)" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z"/></svg>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button type="button" class="btn btn-primary position-relative">
|
|
||||||
Alerts <span class="position-absolute top-0 start-100 translate-middle badge border border-light rounded-circle bg-danger p-2"><span class="visually-hidden">unread messages</span></span>
|
|
||||||
</button>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example class="bd-example-position-examples" >}}
|
|
||||||
<div class="position-relative m-4">
|
|
||||||
<div class="progress" role="progressbar" aria-label="Progress" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="height: 1px;">
|
|
||||||
<div class="progress-bar" style="width: 50%"></div>
|
|
||||||
</div>
|
|
||||||
<button type="button" class="position-absolute top-0 start-0 translate-middle btn btn-sm btn-primary rounded-pill" style="width: 2rem; height:2rem;">1</button>
|
|
||||||
<button type="button" class="position-absolute top-0 start-50 translate-middle btn btn-sm btn-primary rounded-pill" style="width: 2rem; height:2rem;">2</button>
|
|
||||||
<button type="button" class="position-absolute top-0 start-100 translate-middle btn btn-sm btn-secondary rounded-pill" style="width: 2rem; height:2rem;">3</button>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Sass maps
|
|
||||||
|
|
||||||
Default position utility values are declared in a Sass map, then used to generate our utilities.
|
|
||||||
|
|
||||||
{{< scss-docs name="position-map" file="scss/_variables.scss" >}}
|
|
||||||
|
|
||||||
### Sass utilities API
|
|
||||||
|
|
||||||
Position utilities are declared in our utilities API in `scss/_utilities.scss`. [Learn how to use the utilities API.]({{< docsref "/utilities/api#using-the-api" >}})
|
|
||||||
|
|
||||||
{{< scss-docs name="utils-position" file="scss/_utilities.scss" >}}
|
|
|
@ -1,62 +0,0 @@
|
||||||
---
|
|
||||||
layout: docs
|
|
||||||
title: Sizing
|
|
||||||
description: Easily make an element as wide or as tall with our width and height utilities.
|
|
||||||
group: utilities
|
|
||||||
toc: true
|
|
||||||
---
|
|
||||||
|
|
||||||
## Relative to the parent
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
{{< example class="bd-example-flex" >}}
|
|
||||||
<div class="w-25 p-3">Width 25%</div>
|
|
||||||
<div class="w-50 p-3">Width 50%</div>
|
|
||||||
<div class="w-75 p-3">Width 75%</div>
|
|
||||||
<div class="w-100 p-3">Width 100%</div>
|
|
||||||
<div class="w-auto p-3">Width auto</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example class="bd-example-flex" >}}
|
|
||||||
<div style="height: 100px;">
|
|
||||||
<div class="h-25 d-inline-block" style="width: 120px;">Height 25%</div>
|
|
||||||
<div class="h-50 d-inline-block" style="width: 120px;">Height 50%</div>
|
|
||||||
<div class="h-75 d-inline-block" style="width: 120px;">Height 75%</div>
|
|
||||||
<div class="h-100 d-inline-block" style="width: 120px;">Height 100%</div>
|
|
||||||
<div class="h-auto d-inline-block" style="width: 120px;">Height auto</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
You can also use `max-width: 100%;` and `max-height: 100%;` utilities as needed.
|
|
||||||
|
|
||||||
{{< example class="bd-example-flex" >}}
|
|
||||||
<div style="width: 50%; height: 100px;">
|
|
||||||
<div class="mw-100" style="width: 200%;">Max-width 100%</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
{{< example class="bd-example-flex" >}}
|
|
||||||
<div style="height: 100px;">
|
|
||||||
<div class="mh-100" style="width: 100px; height: 200px;">Max-height 100%</div>
|
|
||||||
</div>
|
|
||||||
{{< /example >}}
|
|
||||||
|
|
||||||
## Relative to the viewport
|
|
||||||
|
|
||||||
You can also use utilities to set the width and height relative to the viewport.
|
|
||||||
|
|
||||||
```html
|
|
||||||
<div class="min-vw-100">Min-width 100vw</div>
|
|
||||||
<div class="min-vh-100">Min-height 100vh</div>
|
|
||||||
<div class="vw-100">Width 100vw</div>
|
|
||||||
<div class="vh-100">Height 100vh</div>
|
|
||||||
```
|
|
||||||
|
|
||||||
## CSS
|
|
||||||
|
|
||||||
### Sass utilities API
|
|
||||||
|
|
||||||
Sizing utilities are declared in our utilities API in `scss/_utilities.scss`. [Learn how to use the utilities API.]({{< docsref "/utilities/api#using-the-api" >}})
|
|
||||||
|
|
||||||
{{< scss-docs name="utils-sizing" file="scss/_utilities.scss" >}}
|
|
|
@ -1,6 +0,0 @@
|
||||||
---
|
|
||||||
layout: redirect
|
|
||||||
sitemap:
|
|
||||||
disable: true
|
|
||||||
redirect: "/docs/5.3/getting-started/introduction/"
|
|
||||||
---
|
|
|
@ -1,27 +0,0 @@
|
||||||
---
|
|
||||||
title: Versions
|
|
||||||
description: An appendix of hosted documentation for nearly every release of Bootstrap, from v1 through v5.
|
|
||||||
---
|
|
||||||
|
|
||||||
{{< list-versions.inline >}}
|
|
||||||
<div class="row">
|
|
||||||
{{- range $release := sort (index $.Site.Data "docs-versions") "group" "desc" }}
|
|
||||||
<div class="col-md-6 col-lg-4 col-xl mb-4">
|
|
||||||
<h2>{{ $release.group }}</h2>
|
|
||||||
<p>{{ $release.description }}</p>
|
|
||||||
{{- $versions := sort $release.versions "" "desc" -}}
|
|
||||||
{{- range $i, $version := $versions }}
|
|
||||||
{{- $len := len $versions -}}
|
|
||||||
{{ if (eq $i 0) }}<div class="list-group">{{ end }}
|
|
||||||
<a class="list-group-item list-group-item-action py-2 text-primary{{ if (eq $version $.Site.Params.docs_version) }} d-flex justify-content-between align-items-center{{ end }}" href="{{ urls.JoinPath $release.baseurl $version "/" }}">
|
|
||||||
{{ $version }}
|
|
||||||
{{ if (eq $version $.Site.Params.docs_version) -}}
|
|
||||||
<span class="badge text-bg-primary">Latest</span>
|
|
||||||
{{- end }}
|
|
||||||
</a>
|
|
||||||
{{ if (eq (add $i 1) $len) }}</div>{{ end }}
|
|
||||||
{{ end -}}
|
|
||||||
</div>
|
|
||||||
{{ end -}}
|
|
||||||
</div>
|
|
||||||
{{< /list-versions.inline >}}
|
|
|
@ -1,8 +1,8 @@
|
||||||
- breakpoint: xs
|
- breakpoint: xs
|
||||||
abbr: ""
|
abbr: ''
|
||||||
name: X-Small
|
name: X-Small
|
||||||
min-width: 0px
|
min-width: 0px
|
||||||
container: ""
|
container: ''
|
||||||
|
|
||||||
- breakpoint: sm
|
- breakpoint: sm
|
||||||
abbr: -sm
|
abbr: -sm
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
- name: blue
|
- name: blue
|
||||||
hex: "#0d6efd"
|
hex: '#0d6efd'
|
||||||
- name: indigo
|
- name: indigo
|
||||||
hex: "#6610f2"
|
hex: '#6610f2'
|
||||||
- name: purple
|
- name: purple
|
||||||
hex: "#6f42c1"
|
hex: '#6f42c1'
|
||||||
- name: pink
|
- name: pink
|
||||||
hex: "#d63384"
|
hex: '#d63384'
|
||||||
- name: red
|
- name: red
|
||||||
hex: "#dc3545"
|
hex: '#dc3545'
|
||||||
- name: orange
|
- name: orange
|
||||||
hex: "#fd7e14"
|
hex: '#fd7e14'
|
||||||
- name: yellow
|
- name: yellow
|
||||||
hex: "#ffc107"
|
hex: '#ffc107'
|
||||||
- name: green
|
- name: green
|
||||||
hex: "#198754"
|
hex: '#198754'
|
||||||
- name: teal
|
- name: teal
|
||||||
hex: "#20c997"
|
hex: '#20c997'
|
||||||
- name: cyan
|
- name: cyan
|
||||||
hex: "#0dcaf0"
|
hex: '#0dcaf0'
|
||||||
- name: white
|
- name: white
|
||||||
hex: "#fff"
|
hex: '#fff'
|
||||||
- name: gray
|
- name: gray
|
||||||
hex: "#6c757d"
|
hex: '#6c757d'
|
||||||
- name: gray-dark
|
- name: gray-dark
|
||||||
hex: "#343a40"
|
hex: '#343a40'
|
||||||
|
|
|
@ -1,56 +1,56 @@
|
||||||
- group: v1.x
|
- group: v1.x
|
||||||
baseurl: "https://getbootstrap.com"
|
baseurl: 'https://getbootstrap.com'
|
||||||
description: "Every minor and patch release from v1 is listed below."
|
description: 'Every minor and patch release from v1 is listed below.'
|
||||||
versions:
|
versions:
|
||||||
- "1.0.0"
|
- '1.0.0'
|
||||||
- "1.1.0"
|
- '1.1.0'
|
||||||
- "1.1.1"
|
- '1.1.1'
|
||||||
- "1.2.0"
|
- '1.2.0'
|
||||||
- "1.3.0"
|
- '1.3.0'
|
||||||
- "1.4.0"
|
- '1.4.0'
|
||||||
|
|
||||||
- group: v2.x
|
- group: v2.x
|
||||||
baseurl: "https://getbootstrap.com"
|
baseurl: 'https://getbootstrap.com'
|
||||||
description: "Every minor and patch release from v2 is listed below."
|
description: 'Every minor and patch release from v2 is listed below.'
|
||||||
versions:
|
versions:
|
||||||
- "2.0.0"
|
- '2.0.0'
|
||||||
- "2.0.1"
|
- '2.0.1'
|
||||||
- "2.0.2"
|
- '2.0.2'
|
||||||
- "2.0.3"
|
- '2.0.3'
|
||||||
- "2.0.4"
|
- '2.0.4'
|
||||||
- "2.1.0"
|
- '2.1.0'
|
||||||
- "2.1.1"
|
- '2.1.1'
|
||||||
- "2.2.0"
|
- '2.2.0'
|
||||||
- "2.2.1"
|
- '2.2.1'
|
||||||
- "2.2.2"
|
- '2.2.2'
|
||||||
- "2.3.0"
|
- '2.3.0'
|
||||||
- "2.3.1"
|
- '2.3.1'
|
||||||
- "2.3.2"
|
- '2.3.2'
|
||||||
|
|
||||||
- group: v3.x
|
- group: v3.x
|
||||||
baseurl: "https://getbootstrap.com/docs"
|
baseurl: 'https://getbootstrap.com/docs'
|
||||||
description: "Every minor release from v3 is listed below. Last update was v3.4.1."
|
description: 'Every minor release from v3 is listed below. Last update was v3.4.1.'
|
||||||
versions:
|
versions:
|
||||||
- "3.3"
|
- '3.3'
|
||||||
- "3.4"
|
- '3.4'
|
||||||
|
|
||||||
- group: v4.x
|
- group: v4.x
|
||||||
baseurl: "https://getbootstrap.com/docs"
|
baseurl: 'https://getbootstrap.com/docs'
|
||||||
description: "Our previous major release with its minor releases. Last update was v4.6.2."
|
description: 'Our previous major release with its minor releases. Last update was v4.6.2.'
|
||||||
versions:
|
versions:
|
||||||
- "4.0"
|
- '4.0'
|
||||||
- "4.1"
|
- '4.1'
|
||||||
- "4.2"
|
- '4.2'
|
||||||
- "4.3"
|
- '4.3'
|
||||||
- "4.4"
|
- '4.4'
|
||||||
- "4.5"
|
- '4.5'
|
||||||
- "4.6"
|
- '4.6'
|
||||||
|
|
||||||
- group: v5.x
|
- group: v5.x
|
||||||
baseurl: "https://getbootstrap.com/docs"
|
baseurl: 'https://getbootstrap.com/docs'
|
||||||
description: "Current major release. Last update was v5.3.5."
|
description: 'Current major release. Last update was v5.3.5.'
|
||||||
versions:
|
versions:
|
||||||
- "5.0"
|
- '5.0'
|
||||||
- "5.1"
|
- '5.1'
|
||||||
- "5.2"
|
- '5.2'
|
||||||
- "5.3"
|
- '5.3'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
- category: Starters
|
- category: Starters
|
||||||
external: true
|
external: true
|
||||||
description: "Functional examples of using Bootstrap in common JS frameworks like Webpack, Parcel, Vite, and more you can edit in StackBlitz."
|
description: 'Functional examples of using Bootstrap in common JS frameworks like Webpack, Parcel, Vite, and more you can edit in StackBlitz.'
|
||||||
examples:
|
examples:
|
||||||
- name: CDN starter
|
- name: CDN starter
|
||||||
description: "Instantly include Bootstrap's compiled CSS and JavaScript via the jsDelivr CDN."
|
description: "Instantly include Bootstrap's compiled CSS and JavaScript via the jsDelivr CDN."
|
||||||
|
@ -21,7 +21,6 @@
|
||||||
description: "Import and bundle Bootstrap's source Sass and JavaScript via Parcel."
|
description: "Import and bundle Bootstrap's source Sass and JavaScript via Parcel."
|
||||||
url: /examples/tree/main/parcel
|
url: /examples/tree/main/parcel
|
||||||
indexPath: src/index.html
|
indexPath: src/index.html
|
||||||
indexPath: src/index.html
|
|
||||||
- name: React
|
- name: React
|
||||||
description: "Import and bundle Bootstrap's source Sass and JavaScript with React, Next.js, and React Bootstrap."
|
description: "Import and bundle Bootstrap's source Sass and JavaScript with React, Next.js, and React Bootstrap."
|
||||||
url: /examples/tree/main/react-nextjs
|
url: /examples/tree/main/react-nextjs
|
||||||
|
@ -38,84 +37,84 @@
|
||||||
indexPath: src/index.html
|
indexPath: src/index.html
|
||||||
|
|
||||||
- category: Snippets
|
- category: Snippets
|
||||||
description: "Common patterns for building sites and apps that build on existing components and utilities with custom CSS and more."
|
description: 'Common patterns for building sites and apps that build on existing components and utilities with custom CSS and more.'
|
||||||
examples:
|
examples:
|
||||||
- name: Headers
|
- name: Headers
|
||||||
description: "Display your branding, navigation, search, and more with these header components"
|
description: 'Display your branding, navigation, search, and more with these header components'
|
||||||
- name: Heroes
|
- name: Heroes
|
||||||
description: "Set the stage on your homepage with heroes that feature clear calls to action."
|
description: 'Set the stage on your homepage with heroes that feature clear calls to action.'
|
||||||
- name: Features
|
- name: Features
|
||||||
description: "Explain the features, benefits, or other details in your marketing content."
|
description: 'Explain the features, benefits, or other details in your marketing content.'
|
||||||
- name: Sidebars
|
- name: Sidebars
|
||||||
description: "Common navigation patterns ideal for offcanvas or multi-column layouts."
|
description: 'Common navigation patterns ideal for offcanvas or multi-column layouts.'
|
||||||
- name: Footers
|
- name: Footers
|
||||||
description: "Finish every page strong with an awesome footer, big or small."
|
description: 'Finish every page strong with an awesome footer, big or small.'
|
||||||
- name: Dropdowns
|
- name: Dropdowns
|
||||||
description: "Enhance your dropdowns with filters, icons, custom styles, and more."
|
description: 'Enhance your dropdowns with filters, icons, custom styles, and more.'
|
||||||
- name: List groups
|
- name: List groups
|
||||||
description: "Extend list groups with utilities and custom styles for any content."
|
description: 'Extend list groups with utilities and custom styles for any content.'
|
||||||
- name: Modals
|
- name: Modals
|
||||||
description: "Transform modals to serve any purpose, from feature tours to dialogs."
|
description: 'Transform modals to serve any purpose, from feature tours to dialogs.'
|
||||||
- name: Badges
|
- name: Badges
|
||||||
description: "Make badges work with custom inner HTML and new looks."
|
description: 'Make badges work with custom inner HTML and new looks.'
|
||||||
- name: Breadcrumbs
|
- name: Breadcrumbs
|
||||||
description: "Integrate custom icons and create stepper components."
|
description: 'Integrate custom icons and create stepper components.'
|
||||||
- name: Buttons
|
- name: Buttons
|
||||||
description: "Create custom buttons for just about any use case with utilities."
|
description: 'Create custom buttons for just about any use case with utilities.'
|
||||||
- name: Jumbotrons
|
- name: Jumbotrons
|
||||||
description: "Create modernized versions of the classic Bootstrap component."
|
description: 'Create modernized versions of the classic Bootstrap component.'
|
||||||
|
|
||||||
- category: Custom Components
|
- category: Custom Components
|
||||||
description: "Brand-new components and templates to help folks quickly get started with Bootstrap and demonstrate best practices for adding onto the framework."
|
description: 'Brand-new components and templates to help folks quickly get started with Bootstrap and demonstrate best practices for adding onto the framework.'
|
||||||
examples:
|
examples:
|
||||||
- name: Album
|
- name: Album
|
||||||
description: "Simple one-page template for photo galleries, portfolios, and more."
|
description: 'Simple one-page template for photo galleries, portfolios, and more.'
|
||||||
- name: Pricing
|
- name: Pricing
|
||||||
description: "Example pricing page built with Cards and featuring a custom header and footer."
|
description: 'Example pricing page built with Cards and featuring a custom header and footer.'
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
description: "Custom checkout form showing our form components and their validation features."
|
description: 'Custom checkout form showing our form components and their validation features.'
|
||||||
- name: Product
|
- name: Product
|
||||||
description: "Lean product-focused marketing page with extensive grid and image work."
|
description: 'Lean product-focused marketing page with extensive grid and image work.'
|
||||||
- name: Cover
|
- name: Cover
|
||||||
description: "A one-page template for building simple and beautiful home pages."
|
description: 'A one-page template for building simple and beautiful home pages.'
|
||||||
- name: Carousel
|
- name: Carousel
|
||||||
description: "Customize the navbar and carousel, then add some new components."
|
description: 'Customize the navbar and carousel, then add some new components.'
|
||||||
- name: Blog
|
- name: Blog
|
||||||
description: "Magazine like blog template with header, navigation, featured content."
|
description: 'Magazine like blog template with header, navigation, featured content.'
|
||||||
- name: Dashboard
|
- name: Dashboard
|
||||||
description: "Basic admin dashboard shell with fixed sidebar and navbar."
|
description: 'Basic admin dashboard shell with fixed sidebar and navbar.'
|
||||||
- name: Sign-in
|
- name: Sign-in
|
||||||
description: "Custom form layout and design for a simple sign in form."
|
description: 'Custom form layout and design for a simple sign in form.'
|
||||||
- name: Sticky footer
|
- name: Sticky footer
|
||||||
description: "Attach a footer to the bottom of the viewport when page content is short."
|
description: 'Attach a footer to the bottom of the viewport when page content is short.'
|
||||||
- name: Sticky footer navbar
|
- name: Sticky footer navbar
|
||||||
description: "Attach a footer to the bottom of the viewport with a fixed top navbar."
|
description: 'Attach a footer to the bottom of the viewport with a fixed top navbar.'
|
||||||
- name: Jumbotron
|
- name: Jumbotron
|
||||||
description: "Use utilities to recreate and enhance Bootstrap 4's jumbotron."
|
description: "Use utilities to recreate and enhance Bootstrap 4's jumbotron."
|
||||||
|
|
||||||
- category: Framework
|
- category: Framework
|
||||||
description: "Examples that focus on implementing uses of built-in components provided by Bootstrap."
|
description: 'Examples that focus on implementing uses of built-in components provided by Bootstrap.'
|
||||||
examples:
|
examples:
|
||||||
- name: "Starter template"
|
- name: 'Starter template'
|
||||||
description: "Nothing but the basics: compiled CSS and JavaScript."
|
description: 'Nothing but the basics: compiled CSS and JavaScript.'
|
||||||
- name: Grid
|
- name: Grid
|
||||||
description: "Multiple examples of grid layouts with all four tiers, nesting, and more."
|
description: 'Multiple examples of grid layouts with all four tiers, nesting, and more.'
|
||||||
- name: Cheatsheet
|
- name: Cheatsheet
|
||||||
description: "Kitchen sink of Bootstrap components."
|
description: 'Kitchen sink of Bootstrap components.'
|
||||||
|
|
||||||
- category: Navbars
|
- category: Navbars
|
||||||
description: "Taking the default navbar component and showing how it can be moved, placed, and extended."
|
description: 'Taking the default navbar component and showing how it can be moved, placed, and extended.'
|
||||||
examples:
|
examples:
|
||||||
- name: Navbars
|
- name: Navbars
|
||||||
description: "Demonstration of all responsive and container options for the navbar."
|
description: 'Demonstration of all responsive and container options for the navbar.'
|
||||||
- name: Navbars offcanvas
|
- name: Navbars offcanvas
|
||||||
description: "Same as the Navbars example, but with our offcanvas component."
|
description: 'Same as the Navbars example, but with our offcanvas component.'
|
||||||
- name: Navbar static
|
- name: Navbar static
|
||||||
description: "Single navbar example of a static top navbar along with some additional content."
|
description: 'Single navbar example of a static top navbar along with some additional content.'
|
||||||
- name: Navbar fixed
|
- name: Navbar fixed
|
||||||
description: "Single navbar example with a fixed top navbar along with some additional content."
|
description: 'Single navbar example with a fixed top navbar along with some additional content.'
|
||||||
- name: Navbar bottom
|
- name: Navbar bottom
|
||||||
description: "Single navbar example with a bottom navbar along with some additional content."
|
description: 'Single navbar example with a bottom navbar along with some additional content.'
|
||||||
- name: Offcanvas navbar
|
- name: Offcanvas navbar
|
||||||
description: "Turn your expandable navbar into a sliding offcanvas menu (doesn't use our offcanvas component)."
|
description: "Turn your expandable navbar into a sliding offcanvas menu (doesn't use our offcanvas component)."
|
||||||
|
|
||||||
|
@ -123,20 +122,20 @@
|
||||||
description: "See Bootstrap's RTL version in action with these modified examples from various categories."
|
description: "See Bootstrap's RTL version in action with these modified examples from various categories."
|
||||||
examples:
|
examples:
|
||||||
- name: Album RTL
|
- name: Album RTL
|
||||||
description: "Simple one-page template for photo galleries, portfolios, and more."
|
description: 'Simple one-page template for photo galleries, portfolios, and more.'
|
||||||
- name: Checkout RTL
|
- name: Checkout RTL
|
||||||
description: "Custom checkout form showing our form components and their validation features."
|
description: 'Custom checkout form showing our form components and their validation features.'
|
||||||
- name: Carousel RTL
|
- name: Carousel RTL
|
||||||
description: "Customize the navbar and carousel, then add some new components."
|
description: 'Customize the navbar and carousel, then add some new components.'
|
||||||
- name: Blog RTL
|
- name: Blog RTL
|
||||||
description: "Magazine like blog template with header, navigation, featured content."
|
description: 'Magazine like blog template with header, navigation, featured content.'
|
||||||
- name: Dashboard RTL
|
- name: Dashboard RTL
|
||||||
description: "Basic admin dashboard shell with fixed sidebar and navbar."
|
description: 'Basic admin dashboard shell with fixed sidebar and navbar.'
|
||||||
- name: Cheatsheet RTL
|
- name: Cheatsheet RTL
|
||||||
description: "Kitchen sink of Bootstrap components, RTL."
|
description: 'Kitchen sink of Bootstrap components, RTL.'
|
||||||
|
|
||||||
- category: Integrations
|
- category: Integrations
|
||||||
description: "Integrations with external libraries."
|
description: 'Integrations with external libraries.'
|
||||||
examples:
|
examples:
|
||||||
- name: "Masonry"
|
- name: 'Masonry'
|
||||||
description: "Combine the powers of the Bootstrap grid and the Masonry layout."
|
description: 'Combine the powers of the Bootstrap grid and the Masonry layout.'
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
- name: 100
|
- name: 100
|
||||||
hex: "#f8f9fa"
|
hex: '#f8f9fa'
|
||||||
- name: 200
|
- name: 200
|
||||||
hex: "#e9ecef"
|
hex: '#e9ecef'
|
||||||
- name: 300
|
- name: 300
|
||||||
hex: "#dee2e6"
|
hex: '#dee2e6'
|
||||||
- name: 400
|
- name: 400
|
||||||
hex: "#ced4da"
|
hex: '#ced4da'
|
||||||
- name: 500
|
- name: 500
|
||||||
hex: "#adb5bd"
|
hex: '#adb5bd'
|
||||||
- name: 600
|
- name: 600
|
||||||
hex: "#868e96"
|
hex: '#868e96'
|
||||||
- name: 700
|
- name: 700
|
||||||
hex: "#495057"
|
hex: '#495057'
|
||||||
- name: 800
|
- name: 800
|
||||||
hex: "#343a40"
|
hex: '#343a40'
|
||||||
- name: 900
|
- name: 900
|
||||||
hex: "#212529"
|
hex: '#212529'
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
- name: primary
|
- name: primary
|
||||||
hex: "#0d6efd"
|
hex: '#0d6efd'
|
||||||
- name: secondary
|
- name: secondary
|
||||||
hex: "#6c757d"
|
hex: '#6c757d'
|
||||||
- name: success
|
- name: success
|
||||||
hex: "#28a745"
|
hex: '#28a745'
|
||||||
- name: danger
|
- name: danger
|
||||||
hex: "#dc3545"
|
hex: '#dc3545'
|
||||||
- name: warning
|
- name: warning
|
||||||
hex: "#ffc107"
|
hex: '#ffc107'
|
||||||
contrast_color: dark
|
contrast_color: dark
|
||||||
- name: info
|
- name: info
|
||||||
hex: "#17a2b8"
|
hex: '#17a2b8'
|
||||||
contrast_color: dark
|
contrast_color: dark
|
||||||
- name: light
|
- name: light
|
||||||
hex: "#f8f9fa"
|
hex: '#f8f9fa'
|
||||||
contrast_color: dark
|
contrast_color: dark
|
||||||
- name: dark
|
- name: dark
|
||||||
hex: "#343a40"
|
hex: '#343a40'
|
||||||
contrast_color: white
|
contrast_color: white
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
{{ define "body_override" }}<body class="d-flex flex-column min-vh-100">{{ end }}
|
|
||||||
{{ define "main" }}
|
|
||||||
<main class="my-auto p-5" id="content">
|
|
||||||
{{ .Content }}
|
|
||||||
</main>
|
|
||||||
{{ end }}
|
|
|
@ -1,7 +0,0 @@
|
||||||
{{- $id := .Anchor | safeURL -}}
|
|
||||||
{{- $text := .Text | safeHTML -}}
|
|
||||||
<h{{ .Level }} id="{{ $id }}">{{ $text }}
|
|
||||||
{{- if and (ge .Level .Page.Site.Params.anchors.min) (le .Level .Page.Site.Params.anchors.max) }}{{" " -}}
|
|
||||||
<a class="anchor-link" href="#{{ $id }}" aria-label="Link to this section: {{ $text }}"></a>
|
|
||||||
{{- end -}}
|
|
||||||
</h{{ .Level }}>
|
|
|
@ -1,8 +0,0 @@
|
||||||
{{- $originalSrc := .Destination | safeURL -}}
|
|
||||||
{{- $localImgPath := path.Join "/site/static/docs" site.Params.docs_version $originalSrc -}}
|
|
||||||
{{- /* This shouldn't be needed but we have a weird folder structure with version included... */ -}}
|
|
||||||
{{- $src := urls.JoinPath "/docs" site.Params.docs_version $originalSrc -}}
|
|
||||||
{{- $config := imageConfig $localImgPath -}}
|
|
||||||
{{- $classes := "d-block img-fluid" -}}
|
|
||||||
|
|
||||||
<img src="{{ $src }}" class="{{ $classes }}" alt="{{ .Text }}" width="{{ $config.Width }}" height="{{ $config.Height }}" loading="lazy">
|
|
|
@ -1,21 +0,0 @@
|
||||||
<!doctype html>
|
|
||||||
<html lang="en" data-bs-theme="auto">
|
|
||||||
<head>
|
|
||||||
{{ partial "header" . }}
|
|
||||||
</head>
|
|
||||||
{{ block "body_override" . }}<body>{{ end }}
|
|
||||||
{{ partial "skippy" . }}
|
|
||||||
{{ partial "icons" . }}
|
|
||||||
|
|
||||||
{{ partial "docs-navbar" . }}
|
|
||||||
|
|
||||||
{{ block "main" . }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ partial "footer" . }}
|
|
||||||
{{ partial "scripts" . }}
|
|
||||||
|
|
||||||
{{ block "footer" . }}
|
|
||||||
{{ end }}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,73 +0,0 @@
|
||||||
{{ define "body_override" }}<body{{ if (eq .Page.Params.toc true) }} data-bs-spy="scroll" data-bs-target="#TableOfContents"{{ end }}>{{ end }}
|
|
||||||
{{ define "main" }}
|
|
||||||
<div class="container-xxl bd-gutter mt-3 my-md-4 bd-layout">
|
|
||||||
<aside class="bd-sidebar">
|
|
||||||
<div class="offcanvas-lg offcanvas-start" tabindex="-1" id="bdSidebar" aria-labelledby="bdSidebarOffcanvasLabel">
|
|
||||||
<div class="offcanvas-header border-bottom">
|
|
||||||
<h5 class="offcanvas-title" id="bdSidebarOffcanvasLabel">Browse docs</h5>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close" data-bs-target="#bdSidebar"></button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="offcanvas-body">
|
|
||||||
{{ partial "docs-sidebar" . }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</aside>
|
|
||||||
|
|
||||||
<main class="bd-main order-1">
|
|
||||||
<div class="bd-intro pt-2 ps-lg-2">
|
|
||||||
<div class="d-md-flex flex-md-row-reverse align-items-center justify-content-between">
|
|
||||||
<div class="mb-3 mb-md-0 d-flex text-nowrap">
|
|
||||||
{{- /* This is needed because we want to show the badge if show_badge isn't present or is set to false */ -}}
|
|
||||||
{{- if (or (and (.Page.Params.added) (not (isset .Page.Params.added "show_badge"))) (and (.Page.Params.added) (isset .Page.Params.added "show_badge") (not (eq .Page.Params.added.show_badge false)))) -}}
|
|
||||||
<small class="d-inline-flex px-2 py-1 fw-semibold text-success-emphasis bg-success-subtle border border-success-subtle rounded-2 me-2">Added in v{{ .Page.Params.added.version }}</small>
|
|
||||||
{{- end -}}
|
|
||||||
<a class="btn btn-sm btn-bd-light rounded-2" href="{{ .Site.Params.repo }}/blob/v{{ .Site.Params.current_version }}/site/content/{{ .Page.File.Path | replaceRE `\\` "/" }}" title="View and edit this file on GitHub" target="_blank" rel="noopener">
|
|
||||||
View on GitHub
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<h1 class="bd-title mb-0" id="content">{{ .Title | markdownify }}</h1>
|
|
||||||
</div>
|
|
||||||
<p class="bd-lead">{{ .Page.Params.Description | markdownify }}</p>
|
|
||||||
{{ partial "ads" . }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{ if (eq .Page.Params.toc true) }}
|
|
||||||
<div class="bd-toc mt-3 mb-5 my-lg-0 mb-lg-5 px-sm-1 text-body-secondary">
|
|
||||||
<button class="btn btn-link p-md-0 mb-2 mb-md-0 text-decoration-none bd-toc-toggle d-md-none" type="button" data-bs-toggle="collapse" data-bs-target="#tocContents" aria-expanded="false" aria-controls="tocContents">
|
|
||||||
On this page
|
|
||||||
<svg class="bi d-md-none ms-2" aria-hidden="true"><use xlink:href="#chevron-expand"></use></svg>
|
|
||||||
</button>
|
|
||||||
<strong class="d-none d-md-block h6 my-2 ms-3">On this page</strong>
|
|
||||||
<hr class="d-none d-md-block my-2 ms-3">
|
|
||||||
<div class="collapse bd-toc-collapse" id="tocContents">
|
|
||||||
{{ .TableOfContents }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
<div class="bd-content ps-lg-2">
|
|
||||||
{{ if .Page.Params.sections }}
|
|
||||||
<div class="row g-3">
|
|
||||||
{{ range .Page.Params.sections }}
|
|
||||||
<div class="col-md-6">
|
|
||||||
<a class="d-block text-decoration-none" href="../{{ urlize .title }}/">
|
|
||||||
<strong class="d-block h5 mb-0">{{ .title }}</strong>
|
|
||||||
<span class="text-secondary">{{ .description }}</span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ .Content }}
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
{{ end }}
|
|
||||||
{{ define "footer" }}
|
|
||||||
{{ range .Page.Params.extra_js -}}
|
|
||||||
<script{{ with .async }} async{{ end }}{{ with .defer }} defer{{ end }} src="{{ .src }}"></script>
|
|
||||||
{{- end -}}
|
|
||||||
<div class="position-fixed" aria-hidden="true"><input type="text" tabindex="-1"></div>
|
|
||||||
{{ end }}
|
|
|
@ -1,131 +0,0 @@
|
||||||
<!doctype html>
|
|
||||||
<html {{ if eq .Page.Params.direction "rtl" }}lang="ar" dir="rtl"{{ else }}lang="en"{{ end }}{{ with .Page.Params.html_class }} class="{{ . }}"{{ end }} data-bs-theme="auto">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<meta name="description" content="">
|
|
||||||
<meta name="author" content="{{ .Site.Params.authors }}">
|
|
||||||
<meta name="generator" content="Hugo {{ hugo.Version }}">
|
|
||||||
<title>{{ .Page.Title | markdownify }} · {{ .Site.Title | markdownify }} v{{ .Site.Params.docs_version }}</title>
|
|
||||||
|
|
||||||
<link rel="canonical" href="{{ .Permalink }}">
|
|
||||||
|
|
||||||
{{ with .Params.robots -}}
|
|
||||||
<meta name="robots" content="{{ . }}">
|
|
||||||
{{- end }}
|
|
||||||
|
|
||||||
{{- $colorModeJS := urls.JoinPath "/docs" $.Site.Params.docs_version "assets/js/color-modes.js" -}}
|
|
||||||
<script src="{{ $colorModeJS }}"></script>
|
|
||||||
|
|
||||||
{{ partial "stylesheet" . }}
|
|
||||||
{{ partial "favicons" . }}
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.bd-placeholder-img {
|
|
||||||
font-size: 1.125rem;
|
|
||||||
text-anchor: middle;
|
|
||||||
-webkit-user-select: none;
|
|
||||||
-moz-user-select: none;
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 768px) {
|
|
||||||
.bd-placeholder-img-lg {
|
|
||||||
font-size: 3.5rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.b-example-divider {
|
|
||||||
width: 100%;
|
|
||||||
height: 3rem;
|
|
||||||
background-color: rgba(0, 0, 0, .1);
|
|
||||||
border: solid rgba(0, 0, 0, .15);
|
|
||||||
border-width: 1px 0;
|
|
||||||
box-shadow: inset 0 .5em 1.5em rgba(0, 0, 0, .1), inset 0 .125em .5em rgba(0, 0, 0, .15);
|
|
||||||
}
|
|
||||||
|
|
||||||
.b-example-vr {
|
|
||||||
flex-shrink: 0;
|
|
||||||
width: 1.5rem;
|
|
||||||
height: 100vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bi {
|
|
||||||
vertical-align: -.125em;
|
|
||||||
fill: currentColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-scroller {
|
|
||||||
position: relative;
|
|
||||||
z-index: 2;
|
|
||||||
height: 2.75rem;
|
|
||||||
overflow-y: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-scroller .nav {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: nowrap;
|
|
||||||
padding-bottom: 1rem;
|
|
||||||
margin-top: -1px;
|
|
||||||
overflow-x: auto;
|
|
||||||
text-align: center;
|
|
||||||
white-space: nowrap;
|
|
||||||
-webkit-overflow-scrolling: touch;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-bd-primary {
|
|
||||||
--bd-violet-bg: #712cf9;
|
|
||||||
--bd-violet-rgb: 112.520718, 44.062154, 249.437846;
|
|
||||||
|
|
||||||
--bs-btn-font-weight: 600;
|
|
||||||
--bs-btn-color: var(--bs-white);
|
|
||||||
--bs-btn-bg: var(--bd-violet-bg);
|
|
||||||
--bs-btn-border-color: var(--bd-violet-bg);
|
|
||||||
--bs-btn-hover-color: var(--bs-white);
|
|
||||||
--bs-btn-hover-bg: #6528e0;
|
|
||||||
--bs-btn-hover-border-color: #6528e0;
|
|
||||||
--bs-btn-focus-shadow-rgb: var(--bd-violet-rgb);
|
|
||||||
--bs-btn-active-color: var(--bs-btn-hover-color);
|
|
||||||
--bs-btn-active-bg: #5a23c8;
|
|
||||||
--bs-btn-active-border-color: #5a23c8;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bd-mode-toggle {
|
|
||||||
z-index: 1500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bd-mode-toggle .bi {
|
|
||||||
width: 1em;
|
|
||||||
height: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bd-mode-toggle .dropdown-menu .active .bi {
|
|
||||||
display: block !important;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
{{ range .Page.Params.extra_css -}}
|
|
||||||
{{ "<!-- Custom styles for this template -->" | safeHTML }}
|
|
||||||
<link href="{{ . }}" rel="stylesheet">
|
|
||||||
{{- end }}
|
|
||||||
</head>
|
|
||||||
<body{{ with .Page.Params.body_class }} class="{{ . }}"{{ end }}>
|
|
||||||
{{ partial "examples/icons" . }}
|
|
||||||
|
|
||||||
<div class="dropdown position-fixed bottom-0 end-0 mb-3 me-3 bd-mode-toggle">
|
|
||||||
{{ partial "theme-toggler" . }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{ .Content }}
|
|
||||||
|
|
||||||
{{- if hugo.IsProduction -}}
|
|
||||||
<script defer src="/docs/{{ .Site.Params.docs_version }}/dist/js/bootstrap.bundle.min.js" {{ printf "integrity=%q" .Site.Params.cdn.js_bundle_hash | safeHTMLAttr }}></script>
|
|
||||||
{{- else -}}
|
|
||||||
<script defer src="/docs/{{ .Site.Params.docs_version }}/dist/js/bootstrap.bundle.js"></script>
|
|
||||||
{{- end }}
|
|
||||||
|
|
||||||
{{ range .Page.Params.extra_js -}}
|
|
||||||
<script{{ with .async }} async{{ end }}{{ with .defer }} defer{{ end }} src="{{ .src }}"{{ with .integrity }} {{ printf "integrity=%q" . | safeHTMLAttr }} crossorigin="anonymous"{{ end }}></script>
|
|
||||||
{{- end -}}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,16 +0,0 @@
|
||||||
{{ define "main" }}
|
|
||||||
<main>
|
|
||||||
{{ partial "home/masthead" . }}
|
|
||||||
<div class="container-xxl bd-gutter masthead-followup">
|
|
||||||
{{ partial "home/get-started" . }}
|
|
||||||
{{ partial "home/customize" . }}
|
|
||||||
{{ partial "home/css-variables" . }}
|
|
||||||
{{ partial "home/components-utilities" . }}
|
|
||||||
{{ partial "home/plugins" . }}
|
|
||||||
{{ partial "home/icons" . }}
|
|
||||||
{{ partial "home/themes" . }}
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
|
|
||||||
{{ .Content }}
|
|
||||||
{{ end }}
|
|
|
@ -1 +0,0 @@
|
||||||
{{ partial "redirect" (.Page.Params.redirect | absURL) }}
|
|
|
@ -1,37 +0,0 @@
|
||||||
{{ define "main" }}
|
|
||||||
<header class="py-5 border-bottom">
|
|
||||||
<div class="container-xxl bd-gutter pt-md-1 pb-md-4">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-xl-8">
|
|
||||||
<h1 class="bd-title mt-0">{{ .Title | markdownify }}</h1>
|
|
||||||
<p class="bd-lead">{{ .Page.Params.Description | markdownify }}</p>
|
|
||||||
{{ if eq .Title "Examples" -}}
|
|
||||||
<div class="d-flex flex-column flex-md-row gap-3">
|
|
||||||
<a href="{{ .Site.Params.download.dist_examples }}" class="btn btn-lg bd-btn-lg btn-bd-primary d-flex align-items-center justify-content-center fw-semibold">
|
|
||||||
<svg class="bi me-2" aria-hidden="true"><use xlink:href="#box-seam"></use></svg>
|
|
||||||
Download examples
|
|
||||||
</a>
|
|
||||||
<a href="{{ .Site.Params.download.source }}" class="btn btn-lg bd-btn-lg btn-outline-secondary">
|
|
||||||
Download source code
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
{{- end }}
|
|
||||||
</div>
|
|
||||||
<div class="col-xl-4 d-lg-flex justify-content-xl-end">
|
|
||||||
{{ partial "ads" . }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<main class="bd-content order-1 py-5" id="content">
|
|
||||||
<div class="container-xxl bd-gutter">
|
|
||||||
{{ .Content }}
|
|
||||||
|
|
||||||
{{ if eq .Title "Examples" -}}
|
|
||||||
{{ partial "examples/main" . }}
|
|
||||||
{{ partial "examples/bs-themes" . }}
|
|
||||||
{{- end }}
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
{{ end }}
|
|
|
@ -1 +0,0 @@
|
||||||
{{ partial "redirect" .Permalink }}
|
|
|
@ -1 +0,0 @@
|
||||||
<script async src="https://cdn.carbonads.com/carbon.js?serve=CKYIKKJL&placement=getbootstrapcom" id="_carbonads_js"></script>
|
|
|
@ -1 +0,0 @@
|
||||||
<script defer src="https://cdn.usefathom.com/script.js" data-site="{{ .Site.Params.analytics.fathom_site }}"></script>
|
|
|
@ -1 +0,0 @@
|
||||||
**Why subtract .02px?** Browsers don't currently support [range context queries](https://www.w3.org/TR/mediaqueries-4/#range-context), so we work around the limitations of [`min-` and `max-` prefixes](https://www.w3.org/TR/mediaqueries-4/#mq-min-max) and viewports with fractional widths (which can occur under certain conditions on high-dpi devices, for instance) by using values with higher precision.
|
|
|
@ -1,92 +0,0 @@
|
||||||
<header class="navbar navbar-expand-lg bd-navbar sticky-top">
|
|
||||||
<nav class="container-xxl bd-gutter flex-wrap flex-lg-nowrap" aria-label="Main navigation">
|
|
||||||
{{- if eq .Layout "docs" }}
|
|
||||||
<div class="bd-navbar-toggle">
|
|
||||||
<button class="navbar-toggler p-2" type="button" data-bs-toggle="offcanvas" data-bs-target="#bdSidebar" aria-controls="bdSidebar" aria-label="Toggle docs navigation">
|
|
||||||
{{ partial "icons/hamburger.svg" (dict "class" "bi" "width" "24" "height" "24") }}
|
|
||||||
<span class="d-none fs-6 pe-1">Browse</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{{- else }}
|
|
||||||
<div class="d-lg-none" style="width: 4.25rem;"></div>
|
|
||||||
{{- end }}
|
|
||||||
|
|
||||||
<a class="navbar-brand p-0 me-0 me-lg-2" href="/" aria-label="Bootstrap">
|
|
||||||
{{ partial "icons/bootstrap-white-fill.svg" (dict "class" "d-block my-1" "width" "40" "height" "32") }}
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<div class="d-flex">
|
|
||||||
<div class="bd-search" id="docsearch" data-bd-docs-version="{{ .Site.Params.docs_version }}"></div>
|
|
||||||
|
|
||||||
<button class="navbar-toggler d-flex d-lg-none order-3 p-2" type="button" data-bs-toggle="offcanvas" data-bs-target="#bdNavbar" aria-controls="bdNavbar" aria-label="Toggle navigation">
|
|
||||||
<svg class="bi" aria-hidden="true"><use xlink:href="#three-dots"></use></svg>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="offcanvas-lg offcanvas-end flex-grow-1" tabindex="-1" id="bdNavbar" aria-labelledby="bdNavbarOffcanvasLabel">
|
|
||||||
<div class="offcanvas-header px-4 pb-0">
|
|
||||||
<h5 class="offcanvas-title text-white" id="bdNavbarOffcanvasLabel">Bootstrap</h5>
|
|
||||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="offcanvas" aria-label="Close" data-bs-target="#bdNavbar"></button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="offcanvas-body p-4 pt-0 p-lg-0">
|
|
||||||
<hr class="d-lg-none text-white-50">
|
|
||||||
<ul class="navbar-nav flex-row flex-wrap bd-navbar-nav">
|
|
||||||
<li class="nav-item col-6 col-lg-auto">
|
|
||||||
<a class="nav-link py-2 px-0 px-lg-2{{ if eq .Page.Layout "docs" }} active" aria-current="true{{ end }}" href="/docs/{{ .Site.Params.docs_version }}/getting-started/introduction/">Docs</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item col-6 col-lg-auto">
|
|
||||||
<a class="nav-link py-2 px-0 px-lg-2{{ if eq .Page.Title "Examples" }} active" aria-current="true{{ end }}" href="/docs/{{ .Site.Params.docs_version }}/examples/">Examples</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item col-6 col-lg-auto">
|
|
||||||
<a class="nav-link py-2 px-0 px-lg-2" href="{{ .Site.Params.icons }}" target="_blank" rel="noopener">Icons</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item col-6 col-lg-auto">
|
|
||||||
<a class="nav-link py-2 px-0 px-lg-2" href="{{ .Site.Params.themes }}" target="_blank" rel="noopener">Themes</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item col-6 col-lg-auto">
|
|
||||||
<a class="nav-link py-2 px-0 px-lg-2" href="{{ .Site.Params.blog }}" target="_blank" rel="noopener">Blog</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<hr class="d-lg-none text-white-50">
|
|
||||||
|
|
||||||
<ul class="navbar-nav flex-row flex-wrap ms-md-auto">
|
|
||||||
<li class="nav-item col-6 col-lg-auto">
|
|
||||||
<a class="nav-link py-2 px-0 px-lg-2" href="{{ .Site.Params.github_org }}" target="_blank" rel="noopener">
|
|
||||||
{{ partial "icons/github.svg" (dict "class" "navbar-nav-svg" "width" "16" "height" "16") }}
|
|
||||||
<small class="d-lg-none ms-2">GitHub</small>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item col-6 col-lg-auto">
|
|
||||||
<a class="nav-link py-2 px-0 px-lg-2" href="https://x.com/{{ .Site.Params.x }}" target="_blank" rel="noopener">
|
|
||||||
{{ partial "icons/x.svg" (dict "class" "navbar-nav-svg" "width" "16" "height" "16") }}
|
|
||||||
<small class="d-lg-none ms-2">X</small>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item col-6 col-lg-auto">
|
|
||||||
<a class="nav-link py-2 px-0 px-lg-2" href="{{ .Site.Params.opencollective }}" target="_blank" rel="noopener">
|
|
||||||
{{ partial "icons/opencollective.svg" (dict "class" "navbar-nav-svg" "width" "16" "height" "16") }}
|
|
||||||
<small class="d-lg-none ms-2">Open Collective</small>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item py-2 py-lg-1 col-12 col-lg-auto">
|
|
||||||
<div class="vr d-none d-lg-flex h-100 mx-lg-2 text-white"></div>
|
|
||||||
<hr class="d-lg-none my-2 text-white-50">
|
|
||||||
</li>
|
|
||||||
|
|
||||||
{{ partial "docs-versions" . }}
|
|
||||||
|
|
||||||
<li class="nav-item py-2 py-lg-1 col-12 col-lg-auto">
|
|
||||||
<div class="vr d-none d-lg-flex h-100 mx-lg-2 text-white"></div>
|
|
||||||
<hr class="d-lg-none my-2 text-white-50">
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li class="nav-item dropdown">
|
|
||||||
{{ partial "theme-toggler" . }}
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
</header>
|
|
|
@ -1,47 +0,0 @@
|
||||||
<nav class="bd-links w-100" id="bd-docs-nav" aria-label="Docs navigation">
|
|
||||||
{{- $url := split .Permalink "/" -}}
|
|
||||||
{{- $page_slug := index $url (sub (len $url) 2) -}}
|
|
||||||
|
|
||||||
<ul class="bd-links-nav list-unstyled mb-0 pb-3 pb-md-2 pe-lg-2">
|
|
||||||
{{- range $group := .Site.Data.sidebar -}}
|
|
||||||
{{- $link := $group.title -}}
|
|
||||||
{{- $link_slug := $link | urlize -}}
|
|
||||||
|
|
||||||
{{- if $group.pages -}}
|
|
||||||
{{- $link = index $group.pages 0 -}}
|
|
||||||
{{- $link_slug = $link.title | urlize -}}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- $group_slug := $group.title | urlize -}}
|
|
||||||
{{- $is_active_group := eq $.Page.Params.group $group_slug -}}
|
|
||||||
|
|
||||||
{{- if $group.pages }}
|
|
||||||
<li class="bd-links-group py-2">
|
|
||||||
<strong class="bd-links-heading d-flex w-100 align-items-center fw-semibold">
|
|
||||||
{{- if $group.icon }}
|
|
||||||
<svg class="bi me-2"{{- if $group.icon_color }} style="color: var(--bs-{{ $group.icon_color }});"{{- end }} aria-hidden="true"><use xlink:href="#{{ $group.icon }}"></use></svg>
|
|
||||||
{{- end }}
|
|
||||||
{{ $group.title }}
|
|
||||||
</strong>
|
|
||||||
|
|
||||||
<ul class="list-unstyled fw-normal pb-2 small">
|
|
||||||
{{- range $doc := $group.pages -}}
|
|
||||||
{{- $doc_slug := $doc.title | urlize -}}
|
|
||||||
{{- $is_active := and $is_active_group (eq $page_slug $doc_slug) -}}
|
|
||||||
{{- $href := urls.JoinPath "/docs" $.Site.Params.docs_version $group_slug $doc_slug "/" }}
|
|
||||||
<li><a href="{{ $href }}" class="bd-links-link d-inline-block rounded{{ if $is_active }} active{{ end }}"{{ if $is_active }} aria-current="page"{{ end }}>{{ $doc.title }}</a></li>
|
|
||||||
{{- end }}
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
{{- else }}
|
|
||||||
<li class="bd-links-span-all mt-1 mb-3 mx-4 border-top"></li>
|
|
||||||
<li class="bd-links-span-all">
|
|
||||||
{{- $href := urls.JoinPath "/docs" $.Site.Params.docs_version $group_slug "/" }}
|
|
||||||
<a href="{{ $href }}" class="bd-links-link d-inline-block rounded small{{ if $is_active_group }} active{{ end }}"{{ if $is_active_group }} aria-current="page"{{ end }}>
|
|
||||||
{{ $group.title }}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
|
@ -1,58 +0,0 @@
|
||||||
{{- $url := split .Permalink "/" -}}
|
|
||||||
{{- $page_version := index $url (sub (len $url) 4) -}}
|
|
||||||
{{- $group_slug := index $url (sub (len $url) 3) -}}
|
|
||||||
{{- $page_slug := index $url (sub (len $url) 2) -}}
|
|
||||||
|
|
||||||
{{- $versions_link := "" -}}
|
|
||||||
{{- if and (eq .Layout "docs") (eq $page_version .Site.Params.docs_version) -}}
|
|
||||||
{{- $versions_link = urls.JoinPath $group_slug $page_slug "/" -}}
|
|
||||||
{{- else if (eq .Layout "single") -}}
|
|
||||||
{{- $versions_link = urls.JoinPath $page_slug "/" -}}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- $added_in_51 := eq (string .Page.Params.added.version) "5.1" -}}
|
|
||||||
{{- $added_in_52 := eq (string .Page.Params.added.version) "5.2" -}}
|
|
||||||
{{- $added_in_53 := eq (string .Page.Params.added.version) "5.3" -}}
|
|
||||||
|
|
||||||
<li class="nav-item dropdown">
|
|
||||||
<button type="button" class="btn btn-link nav-link py-2 px-0 px-lg-2 dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false" data-bs-display="static">
|
|
||||||
<span class="d-lg-none" aria-hidden="true">Bootstrap</span><span class="visually-hidden">Bootstrap </span> v{{ .Site.Params.docs_version }} <span class="visually-hidden">(switch to other versions)</span>
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu dropdown-menu-end">
|
|
||||||
<li><h6 class="dropdown-header">v5 releases</h6></li>
|
|
||||||
<li>
|
|
||||||
<a class="dropdown-item d-flex align-items-center justify-content-between active" aria-current="true" href="{{ if .IsHome }}/{{ else }}/docs/{{ .Site.Params.docs_version }}/{{ $versions_link }}{{ end }}">
|
|
||||||
Latest ({{ .Site.Params.docs_version }}.x)
|
|
||||||
<svg class="bi" aria-hidden="true"><use xlink:href="#check2"></use></svg>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
{{- if ($added_in_53) }}
|
|
||||||
<div class="dropdown-item disabled">v5.2.3</div>
|
|
||||||
{{- else }}
|
|
||||||
<a class="dropdown-item" href="https://getbootstrap.com/docs/5.2/{{ $versions_link }}">v5.2.3</a>
|
|
||||||
{{- end }}
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
{{- if (or $added_in_52 $added_in_53) }}
|
|
||||||
<div class="dropdown-item disabled">v5.1.3</div>
|
|
||||||
{{- else }}
|
|
||||||
<a class="dropdown-item" href="https://getbootstrap.com/docs/5.1/{{ $versions_link }}">v5.1.3</a>
|
|
||||||
{{- end }}
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
{{- if (or $added_in_51 $added_in_52 $added_in_53) }}
|
|
||||||
<div class="dropdown-item disabled">v5.0.2</div>
|
|
||||||
{{- else }}
|
|
||||||
<a class="dropdown-item" href="https://getbootstrap.com/docs/5.0/{{ $versions_link }}">v5.0.2</a>
|
|
||||||
{{- end }}
|
|
||||||
</li>
|
|
||||||
<li><hr class="dropdown-divider"></li>
|
|
||||||
<li><h6 class="dropdown-header">Previous releases</h6></li>
|
|
||||||
<li><a class="dropdown-item" href="https://getbootstrap.com/docs/4.6/">v4.6.x</a></li>
|
|
||||||
<li><a class="dropdown-item" href="https://getbootstrap.com/docs/3.4/">v3.4.1</a></li>
|
|
||||||
<li><a class="dropdown-item" href="https://getbootstrap.com/2.3.2/">v2.3.2</a></li>
|
|
||||||
<li><hr class="dropdown-divider"></li>
|
|
||||||
<li><a class="dropdown-item" href="/docs/versions/">All versions</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
|
@ -1,17 +0,0 @@
|
||||||
<hr class="my-5">
|
|
||||||
<div class="container">
|
|
||||||
<div class="text-center">
|
|
||||||
<div class="masthead-followup-icon d-inline-block mb-2 text-bg-danger">
|
|
||||||
{{ partial "icons/droplet-fill.svg" (dict "width" "32" "height" "32") }}
|
|
||||||
</div>
|
|
||||||
<h2 class="display-6 fw-normal">Go further with Bootstrap Themes</h2>
|
|
||||||
<p class="col-md-10 col-lg-8 mx-auto lead">
|
|
||||||
Need something more than these examples? Take Bootstrap to the next level with premium themes from the <a href="{{ .Site.Params.themes }}">official Bootstrap Themes marketplace</a>. They’re built as their own extended frameworks, rich with new components and plugins, documentation, and powerful build tools.
|
|
||||||
</p>
|
|
||||||
<a href="{{ .Site.Params.themes }}" class="btn btn-lg btn-outline-primary mb-3">Browse themes</a>
|
|
||||||
</div>
|
|
||||||
{{ partial "responsive-img" (dict "context" .
|
|
||||||
"imgPath" "/assets/img/bootstrap-themes-collage.png"
|
|
||||||
"alt" "Bootstrap Themes"
|
|
||||||
"classes" "d-block mt-3") }}
|
|
||||||
</div>
|
|
|
@ -1,15 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="d-none">
|
|
||||||
<symbol id="check2" viewBox="0 0 16 16">
|
|
||||||
<path d="M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z"/>
|
|
||||||
</symbol>
|
|
||||||
<symbol id="circle-half" viewBox="0 0 16 16">
|
|
||||||
<path d="M8 15A7 7 0 1 0 8 1v14zm0 1A8 8 0 1 1 8 0a8 8 0 0 1 0 16z"/>
|
|
||||||
</symbol>
|
|
||||||
<symbol id="moon-stars-fill" viewBox="0 0 16 16">
|
|
||||||
<path d="M6 .278a.768.768 0 0 1 .08.858 7.208 7.208 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277.527 0 1.04-.055 1.533-.16a.787.787 0 0 1 .81.316.733.733 0 0 1-.031.893A8.349 8.349 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.752.752 0 0 1 6 .278z"/>
|
|
||||||
<path d="M10.794 3.148a.217.217 0 0 1 .412 0l.387 1.162c.173.518.579.924 1.097 1.097l1.162.387a.217.217 0 0 1 0 .412l-1.162.387a1.734 1.734 0 0 0-1.097 1.097l-.387 1.162a.217.217 0 0 1-.412 0l-.387-1.162A1.734 1.734 0 0 0 9.31 6.593l-1.162-.387a.217.217 0 0 1 0-.412l1.162-.387a1.734 1.734 0 0 0 1.097-1.097l.387-1.162zM13.863.099a.145.145 0 0 1 .274 0l.258.774c.115.346.386.617.732.732l.774.258a.145.145 0 0 1 0 .274l-.774.258a1.156 1.156 0 0 0-.732.732l-.258.774a.145.145 0 0 1-.274 0l-.258-.774a1.156 1.156 0 0 0-.732-.732l-.774-.258a.145.145 0 0 1 0-.274l.774-.258c.346-.115.617-.386.732-.732L13.863.1z"/>
|
|
||||||
</symbol>
|
|
||||||
<symbol id="sun-fill" viewBox="0 0 16 16">
|
|
||||||
<path d="M8 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0zm0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13zm8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5zM3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8zm10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0zm-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0zm9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707zM4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708z"/>
|
|
||||||
</symbol>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 2.0 KiB |
|
@ -1,63 +0,0 @@
|
||||||
{{ range $entry := $.Site.Data.examples -}}
|
|
||||||
<div class="bd-content">
|
|
||||||
<h2 id="{{ $entry.category | urlize }}">{{ $entry.category }}</h2>
|
|
||||||
<p>{{ $entry.description }}</p>
|
|
||||||
{{ if eq $entry.category "RTL" -}}
|
|
||||||
<div class="bd-callout bd-callout-warning small">
|
|
||||||
<p>
|
|
||||||
<strong>RTL is still experimental</strong> and will evolve with feedback. Spotted something or have an improvement to suggest?
|
|
||||||
</p>
|
|
||||||
<p><a href="{{ urls.JoinPath $.Site.Params.repo "issues/new/choose" }}">Please open an issue.</a></p>
|
|
||||||
</div>
|
|
||||||
{{ end -}}
|
|
||||||
{{ range $i, $example := $entry.examples -}}
|
|
||||||
{{- $len := len $entry.examples -}}
|
|
||||||
{{ if (eq $i 0) }}<div class="row">{{ end }}
|
|
||||||
{{ if $entry.external -}}
|
|
||||||
<article class="col-md-6 col-lg-4 mb-3 d-flex gap-3">
|
|
||||||
<svg class="bi fs-5 flex-shrink-0 mt-1" aria-hidden="true"><use xlink:href="#box-seam"></use></svg>
|
|
||||||
<div>
|
|
||||||
<h3 class="h5 mb-1">
|
|
||||||
<a class="d-block link-offset-1" href="{{ urls.JoinPath $.Site.Params.github_org $example.url }}" target="_blank" rel="noopener" id="starter-{{ $i }}">
|
|
||||||
{{ $example.name }}
|
|
||||||
</a>
|
|
||||||
</h3>
|
|
||||||
<p class="text-body-secondary">{{ $example.description }}</p>
|
|
||||||
<p>
|
|
||||||
{{- $indexPath := default "index.html" $example.indexPath -}}
|
|
||||||
{{- $stackBlitzUrl := printf "%s%s%s" (urls.JoinPath "https://stackblitz.com/github/twbs" $example.url) "?file=" ($indexPath | urlquery) }}
|
|
||||||
<a class="icon-link small link-secondary link-offset-1" href="{{ $stackBlitzUrl }}" target="_blank" rel="noopener" aria-labelledby="edit-{{ $i }} starter-{{ $i }}">
|
|
||||||
<svg class="bi flex-shrink-0" aria-hidden="true"><use xlink:href="#lightning-charge-fill"></use></svg>
|
|
||||||
<span id="edit-{{ $i }}">Edit in StackBlitz</span>
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
{{ else -}}
|
|
||||||
<article class="col-sm-6 col-md-3 mb-3">
|
|
||||||
{{- $exampleNameUrlized := $example.name | urlize -}}
|
|
||||||
{{- $exampleUrl := urls.JoinPath "/docs" $.Site.Params.docs_version "/examples" $exampleNameUrlized "/" }}
|
|
||||||
<a class="d-block link-offset-1" href="{{ $exampleUrl }}"{{ if in $example.name "RTL" }} hreflang="ar"{{ end }}>
|
|
||||||
{{ $imageBasePath := urls.JoinPath "/docs" $.Site.Params.docs_version "assets/img/examples" -}}
|
|
||||||
{{- $imgPath := urls.JoinPath $imageBasePath (printf "%s.png" $exampleNameUrlized) -}}
|
|
||||||
{{- $imgPath2x := urls.JoinPath $imageBasePath (printf "%s@2x.png" $exampleNameUrlized) -}}
|
|
||||||
{{- with (imageConfig (path.Join "/site/static" $imgPath)) -}}
|
|
||||||
<img class="img-thumbnail mb-3"
|
|
||||||
srcset="{{ $imgPath }}, {{ $imgPath2x }} 2x"
|
|
||||||
src="{{ $imgPath }}"
|
|
||||||
alt=""
|
|
||||||
width="{{ .Width }}"
|
|
||||||
height="{{ .Height }}"
|
|
||||||
loading="lazy">
|
|
||||||
{{- end }}
|
|
||||||
<h3 class="h5 mb-1">
|
|
||||||
{{ $example.name }}
|
|
||||||
</h3>
|
|
||||||
</a>
|
|
||||||
<p class="text-body-secondary">{{ $example.description }}</p>
|
|
||||||
</article>
|
|
||||||
{{- end }}
|
|
||||||
{{ if (eq (add $i 1) $len) }}</div>{{ end -}}
|
|
||||||
{{ end -}}
|
|
||||||
</div>
|
|
||||||
{{ end -}}
|
|
|
@ -1,7 +0,0 @@
|
||||||
<link rel="apple-touch-icon" href="/docs/{{ .Site.Params.docs_version }}/assets/img/favicons/apple-touch-icon.png" sizes="180x180">
|
|
||||||
<link rel="icon" href="/docs/{{ .Site.Params.docs_version }}/assets/img/favicons/favicon-32x32.png" sizes="32x32" type="image/png">
|
|
||||||
<link rel="icon" href="/docs/{{ .Site.Params.docs_version }}/assets/img/favicons/favicon-16x16.png" sizes="16x16" type="image/png">
|
|
||||||
<link rel="manifest" href="/docs/{{ .Site.Params.docs_version }}/assets/img/favicons/manifest.json">
|
|
||||||
<link rel="mask-icon" href="/docs/{{ .Site.Params.docs_version }}/assets/img/favicons/safari-pinned-tab.svg" color="#712cf9">
|
|
||||||
<link rel="icon" href="/docs/{{ .Site.Params.docs_version }}/assets/img/favicons/favicon.ico">
|
|
||||||
<meta name="theme-color" content="#712cf9">
|
|
|
@ -1,59 +0,0 @@
|
||||||
<footer class="bd-footer py-4 py-md-5 mt-5 bg-body-tertiary">
|
|
||||||
<div class="container py-4 py-md-5 px-4 px-md-3 text-body-secondary">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-3 mb-3">
|
|
||||||
<a class="d-inline-flex align-items-center mb-2 text-body-emphasis text-decoration-none" href="/" aria-label="Bootstrap">
|
|
||||||
{{ partial "icons/bootstrap-white-fill.svg" (dict "class" "d-block me-2" "width" "40" "height" "32") }}
|
|
||||||
<span class="fs-5">Bootstrap</span>
|
|
||||||
</a>
|
|
||||||
<ul class="list-unstyled small">
|
|
||||||
<li class="mb-2">Designed and built with all the love in the world by the <a href="/docs/{{ .Site.Params.docs_version }}/about/team/">Bootstrap team</a> with the help of <a href="{{ .Site.Params.repo }}/graphs/contributors">our contributors</a>.</li>
|
|
||||||
<li class="mb-2">Code licensed <a href="{{ .Site.Params.repo }}/blob/main/LICENSE" target="_blank" rel="license noopener">MIT</a>, docs <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank" rel="license noopener">CC BY 3.0</a>.</li>
|
|
||||||
<li class="mb-2">Currently v{{ .Site.Params.current_version }}.</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="col-6 col-lg-2 offset-lg-1 mb-3">
|
|
||||||
<h5>Links</h5>
|
|
||||||
<ul class="list-unstyled">
|
|
||||||
<li class="mb-2"><a href="/">Home</a></li>
|
|
||||||
<li class="mb-2"><a href="/docs/{{ .Site.Params.docs_version }}/">Docs</a></li>
|
|
||||||
<li class="mb-2"><a href="/docs/{{ .Site.Params.docs_version }}/examples/">Examples</a></li>
|
|
||||||
<li class="mb-2"><a href="{{ .Site.Params.icons }}">Icons</a></li>
|
|
||||||
<li class="mb-2"><a href="{{ .Site.Params.themes }}">Themes</a></li>
|
|
||||||
<li class="mb-2"><a href="{{ .Site.Params.blog }}">Blog</a></li>
|
|
||||||
<li class="mb-2"><a href="{{ .Site.Params.swag }}" target="_blank" rel="noopener">Swag Store</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="col-6 col-lg-2 mb-3">
|
|
||||||
<h5>Guides</h5>
|
|
||||||
<ul class="list-unstyled">
|
|
||||||
<li class="mb-2"><a href="/docs/{{ .Site.Params.docs_version }}/getting-started/">Getting started</a></li>
|
|
||||||
<li class="mb-2"><a href="/docs/{{ .Site.Params.docs_version }}/examples/starter-template/">Starter template</a></li>
|
|
||||||
<li class="mb-2"><a href="/docs/{{ .Site.Params.docs_version }}/getting-started/webpack/">Webpack</a></li>
|
|
||||||
<li class="mb-2"><a href="/docs/{{ .Site.Params.docs_version }}/getting-started/parcel/">Parcel</a></li>
|
|
||||||
<li class="mb-2"><a href="/docs/{{ .Site.Params.docs_version }}/getting-started/vite/">Vite</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="col-6 col-lg-2 mb-3">
|
|
||||||
<h5>Projects</h5>
|
|
||||||
<ul class="list-unstyled">
|
|
||||||
<li class="mb-2"><a href="{{ .Site.Params.github_org }}/bootstrap" target="_blank" rel="noopener">Bootstrap 5</a></li>
|
|
||||||
<li class="mb-2"><a href="{{ .Site.Params.github_org }}/bootstrap/tree/v4-dev" target="_blank" rel="noopener">Bootstrap 4</a></li>
|
|
||||||
<li class="mb-2"><a href="{{ .Site.Params.github_org }}/icons" target="_blank" rel="noopener">Icons</a></li>
|
|
||||||
<li class="mb-2"><a href="{{ .Site.Params.github_org }}/rfs" target="_blank" rel="noopener">RFS</a></li>
|
|
||||||
<li class="mb-2"><a href="{{ .Site.Params.github_org }}/examples" target="_blank" rel="noopener">Examples repo</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="col-6 col-lg-2 mb-3">
|
|
||||||
<h5>Community</h5>
|
|
||||||
<ul class="list-unstyled">
|
|
||||||
<li class="mb-2"><a href="{{ .Site.Params.github_org }}/bootstrap/issues" target="_blank" rel="noopener">Issues</a></li>
|
|
||||||
<li class="mb-2"><a href="{{ .Site.Params.github_org }}/bootstrap/discussions" target="_blank" rel="noopener">Discussions</a></li>
|
|
||||||
<li class="mb-2"><a href="https://github.com/sponsors/twbs" target="_blank" rel="noopener">Corporate sponsors</a></li>
|
|
||||||
<li class="mb-2"><a href="{{ .Site.Params.opencollective }}" target="_blank" rel="noopener">Open Collective</a></li>
|
|
||||||
<li class="mb-2"><a href="https://stackoverflow.com/questions/tagged/bootstrap-5" target="_blank" rel="noopener">Stack Overflow</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
|
@ -1,3 +0,0 @@
|
||||||
<hr class="my-5">
|
|
||||||
|
|
||||||
_See something wrong or out of date here? Please [open an issue on GitHub]({{ .Site.Params.repo }}/issues/new/choose). Need help troubleshooting? [Search or start a discussion]({{ .Site.Params.repo }}/discussions) on GitHub._
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue