Switch to Hugo

This commit includes all the needed workarounds and most changes from the main branch for everything to work, like:

* removing empty lines in raw HTML that break output
* read .browserslistrc, CSS variables from disk instead of duplicating it
* using Hugo mounts
* using Hugo for the docs CSS/JS
* move ToC Sass code to a separate file while adapting it for Hugo

Thus, this patch makes our npm scripts faster since lint runs on one step and there's no separate docs assets processing.
This commit is contained in:
XhmikosR 2020-11-04 16:39:29 +02:00
parent ae87f8f7ce
commit b46f05a948
325 changed files with 4463 additions and 3596 deletions

View File

@ -3,4 +3,4 @@
**/vendor/
/_gh_pages/
/js/coverage/
/site/sw.js
/site/static/sw.js

View File

@ -142,7 +142,7 @@ and/or [`/bootstrap/js/src/`](https://github.com/twbs/bootstrap/tree/v4-dev/js/s
Similarly, when contributing to Bootstrap's documentation, you should edit the
documentation source files in
[the `/bootstrap/site/docs/` directory of the `v4-dev` branch](https://github.com/twbs/bootstrap/tree/v4-dev/site/docs).
[the `/bootstrap/site/content/docs/` directory of the `v4-dev` branch](https://github.com/twbs/bootstrap/tree/v4-dev/site/content/docs).
**Do not edit the `gh-pages` branch.** That branch is generated from the
documentation source files and is managed separately by the Bootstrap Core Team.

View File

@ -9,7 +9,6 @@ on:
env:
CI: true
NODE: 14.x
RUBY: 2.7.x
jobs:
docs:
@ -24,25 +23,7 @@ jobs:
with:
node-version: "${{ env.NODE }}"
- name: Set up Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY }}
- name: Set up Ruby env
run: |
echo "gem: --no-document" > ~/.gemrc # Disable gem docs
bundle config set clean 'true'
bundle config set deployment 'true'
- name: Set up Ruby cache
uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-ruby-v${{ env.RUBY }}-${{ hashFiles('Gemfile') }}-${{ hashFiles('Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-ruby-v${{ env.RUBY }}-${{ hashFiles('Gemfile') }}-${{ hashFiles('Gemfile.lock') }}
${{ runner.os }}-ruby-v${{ env.RUBY }}-
- run: java -version
- name: Set up npm cache
uses: actions/cache@v2
@ -53,19 +34,8 @@ jobs:
${{ runner.OS }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
${{ runner.OS }}-node-v${{ env.NODE }}-
- run: ruby --version
- run: gem --version
- run: bundle --version
- run: java -version
- name: Install npm dependencies
run: npm ci
- name: Install bundler dependencies
run: bundle install --deployment --jobs=4 --retry=3 --clean
- name: Copy CSS and JS
run: npm run css-copy && npm run js-copy
- name: Test docs
run: npm run docs

8
.gitignore vendored
View File

@ -1,16 +1,8 @@
# Ignore docs files
/_gh_pages/
/site/.jekyll-cache
/site/.jekyll-metadata
/site/docs/**/dist/
# Hugo folders
/resources/
# Ignore ruby/bundler files
/.bundle/
/vendor/
/.ruby-version
# Numerous always-ignore extensions
*.diff
*.err

View File

@ -2,3 +2,4 @@
**/dist/
**/vendor/
/_gh_pages/
/js/coverage/

View File

@ -1,9 +0,0 @@
source 'https://rubygems.org'
group :development, :test do
gem 'jekyll', '~> 4.1.1'
gem 'jekyll-redirect-from', '~> 0.16.0'
gem 'jekyll-sitemap', '~> 1.4.0'
gem 'jekyll-toc', '~> 0.15.0'
gem 'wdm', '~> 0.1.1', :install_if => Gem.win_platform?
end

View File

@ -1,89 +0,0 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
colorator (1.1.0)
concurrent-ruby (1.1.7)
em-websocket (0.5.2)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
eventmachine (1.2.7)
eventmachine (1.2.7-x64-mingw32)
ffi (1.13.1)
ffi (1.13.1-x64-mingw32)
forwardable-extended (2.6.0)
http_parser.rb (0.6.0)
i18n (1.8.5)
concurrent-ruby (~> 1.0)
jekyll (4.1.1)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
i18n (~> 1.0)
jekyll-sass-converter (~> 2.0)
jekyll-watch (~> 2.0)
kramdown (~> 2.1)
kramdown-parser-gfm (~> 1.0)
liquid (~> 4.0)
mercenary (~> 0.4.0)
pathutil (~> 0.9)
rouge (~> 3.0)
safe_yaml (~> 1.0)
terminal-table (~> 1.8)
jekyll-redirect-from (0.16.0)
jekyll (>= 3.3, < 5.0)
jekyll-sass-converter (2.1.0)
sassc (> 2.0.1, < 3.0)
jekyll-sitemap (1.4.0)
jekyll (>= 3.7, < 5.0)
jekyll-toc (0.15.0)
jekyll (>= 3.8)
nokogiri (~> 1.10)
jekyll-watch (2.2.1)
listen (~> 3.0)
kramdown (2.3.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
liquid (4.0.3)
listen (3.3.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.4.0)
mini_portile2 (2.4.0)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
nokogiri (1.10.10-x64-mingw32)
mini_portile2 (~> 2.4.0)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (4.0.6)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.4)
rouge (3.25.0)
safe_yaml (1.0.5)
sassc (2.4.0)
ffi (~> 1.9)
sassc (2.4.0-x64-mingw32)
ffi (~> 1.9)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
unicode-display_width (1.7.0)
wdm (0.1.1)
PLATFORMS
ruby
x64-mingw32
DEPENDENCIES
jekyll (~> 4.1.1)
jekyll-redirect-from (~> 0.16.0)
jekyll-sitemap (~> 1.4.0)
jekyll-toc (~> 0.15.0)
wdm (~> 0.1.1)
BUNDLED WITH
2.1.4

View File

@ -111,18 +111,18 @@ Have a bug or a feature request? Please first read the [issue guidelines](https:
## Documentation
Bootstrap's documentation, included in this repo in the root directory, is built with [Jekyll](https://jekyllrb.com/) 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 [Hugo](https://gohugo.io/) 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://community.algolia.com/docsearch/). Working on our search? Be sure to set `debug: true` in `site/docs/4.5/assets/js/src/search.js` file.
Documentation search is powered by [Algolia's DocSearch](https://community.algolia.com/docsearch/). Working on our search? Be sure to set `debug: true` in `site/assets/js/src/search.js` file.
### Running documentation locally
1. Run through the [tooling setup](https://getbootstrap.com/docs/4.5/getting-started/build-tools/#tooling-setup) to install Jekyll (the site builder) and other Ruby dependencies with `bundle install`.
2. Run `npm install` to install Node.js dependencies.
1. Run `npm install` to install the Node.js dependencies, including Hugo (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.
3. Run `npm start` to compile CSS and JavaScript files, generate our docs, and watch for changes.
4. Open `http://localhost:9001` in your browser, and voilà.
4. Open `http://localhost:9001/` in your browser, and voilà.
Learn more about using Jekyll by reading its [documentation](https://jekyllrb.com/docs/).
Learn more about using Hugo by reading its [documentation](https://gohugo.io/documentation/).
### Documentation for previous releases

View File

@ -1,77 +0,0 @@
# Dependencies
markdown: kramdown
highlighter: rouge
kramdown:
auto_ids: true
# Permalinks
permalink: pretty
# Server
source: "site"
destination: ./_gh_pages
host: "localhost"
port: 9001
baseurl: ""
url: "https://getbootstrap.com"
encoding: UTF-8
exclude:
- docs/4.5/assets/scss/
liquid:
error_mode: strict
plugins:
- jekyll-redirect-from
- jekyll-sitemap
- jekyll-toc
redirect_from:
json: false
# Social
title: Bootstrap
description: "The most popular HTML, CSS, and JS library in the world."
twitter: getbootstrap
authors: "Mark Otto, Jacob Thornton, and Bootstrap contributors"
social_image_path: /docs/4.5/assets/brand/bootstrap-social.png
social_logo_path: /docs/4.5/assets/brand/bootstrap-social-logo.png
# Custom variables
current_version: 4.5.3
current_ruby_version: 4.5.3
docs_version: 4.5
github_org: "https://github.com/twbs"
repo: "https://github.com/twbs/bootstrap"
slack: "https://bootstrap-slack.herokuapp.com"
opencollective: "https://opencollective.com/bootstrap"
blog: "https://blog.getbootstrap.com"
expo: "https://expo.getbootstrap.com"
themes: "https://themes.getbootstrap.com"
icons: "https://icons.getbootstrap.com"
download:
source: "https://github.com/twbs/bootstrap/archive/v4.5.3.zip"
dist: "https://github.com/twbs/bootstrap/releases/download/v4.5.3/bootstrap-4.5.3-dist.zip"
dist_examples: "https://github.com/twbs/bootstrap/releases/download/v4.5.3/bootstrap-4.5.3-examples.zip"
cdn:
# See https://www.srihash.org for info on how to generate the hashes
css: "https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css"
css_hash: "sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2"
js: "https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js"
js_hash: "sha384-w1Q4orYjBQndcko6MimVbzY0tgp4pWB4lZ7lr30WKz0vr/aWKhXdBNmNb5D92v7s"
js_bundle: "https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js"
js_bundle_hash: "sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx"
jquery: "https://code.jquery.com/jquery-3.5.1.slim.min.js"
jquery_hash: "sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
popper: "https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"
popper_hash: "sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN"
toc:
min_level: 2
max_level: 4
no_toc_section_class:
- "bd-callout"
- "bd-example"

View File

@ -21,11 +21,11 @@ const pkg = require('../package.json')
sh.config.fatal = true
const configFile = path.join(__dirname, '../_config.yml')
const configFile = path.join(__dirname, '../config.yml')
// Array of objects which holds the files to generate SRI hashes for.
// `file` is the path from the root folder
// `configPropertyName` is the _config.yml variable's name of the file
// `configPropertyName` is the config.yml variable's name of the file
const files = [
{
file: 'dist/css/bootstrap.min.css',
@ -40,7 +40,7 @@ const files = [
configPropertyName: 'js_bundle_hash'
},
{
file: `site/docs/${pkg.version_short}/assets/js/vendor/jquery.slim.min.js`,
file: `site/static/docs/${pkg.version_short}/assets/js/vendor/jquery.slim.min.js`,
configPropertyName: 'jquery_hash'
},
{

79
config.yml Normal file
View File

@ -0,0 +1,79 @@
languageCode: "en"
title: "Bootstrap"
baseURL: "https://getbootstrap.com"
enableInlineShortcodes: true
markup:
goldmark:
renderer:
unsafe: true
highlight:
noClasses: false
tableOfContents:
startLevel: 2
endLevel: 6
buildDrafts: true
buildFuture: true
enableRobotsTXT: true
metaDataFormat: "yaml"
disableKinds: ["404", "taxonomy", "taxonomyTerm", "RSS"]
publishDir: "_gh_pages"
module:
mounts:
- source: dist
target: static/docs/4.5/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: site/static/docs/4.5/assets/img/favicons/apple-touch-icon.png
target: static/apple-touch-icon.png
- source: site/static/docs/4.5/assets/img/favicons/favicon.ico
target: static/favicon.ico
params:
description: "The most popular HTML, CSS, and JS library in the world."
authors: "Mark Otto, Jacob Thornton, and Bootstrap contributors"
social_image_path: /docs/4.5/assets/brand/bootstrap-social.png
social_logo_path: /docs/4.5/assets/brand/bootstrap-social-logo.png
current_version: "4.5.3"
current_ruby_version: "4.5.3"
docs_version: "4.5"
github_org: "https://github.com/twbs"
repo: "https://github.com/twbs/bootstrap"
twitter: "getbootstrap"
slack: "https://bootstrap-slack.herokuapp.com/"
opencollective: "https://opencollective.com/bootstrap"
blog: "https://blog.getbootstrap.com/"
expo: "https://expo.getbootstrap.com/"
themes: "https://themes.getbootstrap.com/"
icons: "https://icons.getbootstrap.com/"
download:
source: "https://github.com/twbs/bootstrap/archive/v4.5.3.zip"
dist: "https://github.com/twbs/bootstrap/releases/download/v4.5.3/bootstrap-4.5.3-dist.zip"
dist_examples: "https://github.com/twbs/bootstrap/releases/download/v4.5.3/bootstrap-4.5.3-examples.zip"
cdn:
# See https://www.srihash.org for info on how to generate the hashes
css: "https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css"
css_hash: "sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2"
js: "https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js"
js_hash: "sha384-w1Q4orYjBQndcko6MimVbzY0tgp4pWB4lZ7lr30WKz0vr/aWKhXdBNmNb5D92v7s"
js_bundle: "https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js"
js_bundle_hash: "sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx"
jquery: "https://code.jquery.com/jquery-3.5.1.slim.min.js"
jquery_hash: "sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
popper: "https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"
popper_hash: "sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN"

1234
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -20,40 +20,25 @@
"scripts": {
"start": "npm-run-all --parallel watch docs-serve",
"bundlewatch": "bundlewatch --config .bundlewatch.config.json",
"css": "npm-run-all css-compile css-prefix css-minify css-copy",
"css-copy": "cross-env-shell shx mkdir -p site/docs/$npm_package_version_short/dist/ && cross-env-shell shx cp -r dist/css/ site/docs/$npm_package_version_short/dist/",
"css-main": "npm-run-all css-lint css-compile-main css-prefix-main css-minify-main css-copy",
"css-docs": "npm-run-all css-compile-docs css-prefix-docs css-minify-docs",
"css-compile": "npm-run-all --parallel css-compile-*",
"css-compile-main": "node-sass --output-style expanded --source-map true --source-map-contents true --precision 6 scss/ -o dist/css/ && npm run css-copy",
"css-compile-docs": "cross-env-shell node-sass --output-style expanded --source-map true --source-map-contents true --precision 6 site/docs/$npm_package_version_short/assets/scss/docs.scss site/docs/$npm_package_version_short/assets/css/docs.min.css",
"css": "npm-run-all css-compile css-prefix css-minify",
"css-compile": "node-sass --output-style expanded --source-map true --source-map-contents true --precision 6 scss/ -o dist/css/",
"css-lint": "npm-run-all --continue-on-error --parallel css-lint-*",
"css-lint-main": "stylelint \"scss/**/*.scss\" --cache --cache-location .cache/.stylelintcache --rd",
"css-lint-docs": "stylelint \"site/docs/**/assets/scss/*.scss\" \"site/docs/**/*.css\" --cache --cache-location .cache/.stylelintcache",
"css-lint-vars": "fusv scss/ site/docs/",
"css-minify": "npm-run-all --parallel css-minify-*",
"css-minify-main": "cleancss -O1 --format breakWith=lf --source-map --source-map-inline-sources --output dist/css/bootstrap.min.css dist/css/bootstrap.css && cleancss -O1 --format breakWith=lf --source-map --source-map-inline-sources --output dist/css/bootstrap-grid.min.css dist/css/bootstrap-grid.css && cleancss -O1 --format breakWith=lf --source-map --source-map-inline-sources --output dist/css/bootstrap-reboot.min.css dist/css/bootstrap-reboot.css",
"css-minify-docs": "cross-env-shell cleancss -O1 --format breakWith=lf --source-map --source-map-inline-sources --output site/docs/$npm_package_version_short/assets/css/docs.min.css site/docs/$npm_package_version_short/assets/css/docs.min.css",
"css-lint-stylelint": "stylelint \"**/*.{css,scss}\" --cache --cache-location .cache/.stylelintcache --rd",
"css-lint-vars": "fusv scss/ site/assets/scss/",
"css-minify": "cleancss -O1 --format breakWith=lf --source-map --source-map-inline-sources --output dist/css/bootstrap.min.css dist/css/bootstrap.css && cleancss -O1 --format breakWith=lf --source-map --source-map-inline-sources --output dist/css/bootstrap-grid.min.css dist/css/bootstrap-grid.css && cleancss -O1 --format breakWith=lf --source-map --source-map-inline-sources --output dist/css/bootstrap-reboot.min.css dist/css/bootstrap-reboot.css",
"css-prefix": "npm-run-all --parallel css-prefix-*",
"css-prefix-main": "postcss --config build/postcss.config.js --replace \"dist/css/*.css\" \"!dist/css/*.min.css\"",
"css-prefix-docs": "postcss --config build/postcss.config.js --replace \"site/docs/**/*.css\"",
"js": "npm-run-all js-compile js-minify js-copy",
"js-copy": "cross-env-shell shx mkdir -p site/docs/$npm_package_version_short/dist/ && cross-env-shell shx cp -r dist/js/ site/docs/$npm_package_version_short/dist/",
"js-main": "npm-run-all js-lint js-compile js-minify-main",
"js-docs": "npm-run-all js-lint-docs js-minify-docs",
"js-compile": "npm-run-all --parallel js-compile-* --sequential js-copy",
"css-prefix-examples": "postcss --config build/postcss.config.js --replace \"site/content/**/*.css\"",
"js": "npm-run-all js-compile js-minify",
"js-compile": "npm-run-all --parallel js-compile-*",
"js-compile-standalone": "rollup --environment BUNDLE:false --config build/rollup.config.js --sourcemap",
"js-compile-bundle": "rollup --environment BUNDLE:true --config build/rollup.config.js --sourcemap",
"js-compile-plugins": "node build/build-plugins.js",
"js-compile-plugins-coverage": "cross-env NODE_ENV=test node build/build-plugins.js",
"js-lint": "npm-run-all --continue-on-error --parallel js-lint-*",
"js-lint-main": "eslint --report-unused-disable-directives --cache --cache-location .cache/.eslintcache js/src js/tests build/",
"js-lint-docs": "eslint --report-unused-disable-directives --cache --cache-location .cache/.eslintcache site/",
"js-minify": "npm-run-all --parallel js-minify-main js-minify-docs",
"js-minify-main": "npm-run-all js-minify-standalone js-minify-bundle",
"js-lint": "eslint --cache --cache-location .cache/.eslintcache --report-unused-disable-directives .",
"js-minify": "npm-run-all --parallel js-minify-*",
"js-minify-standalone": "terser --compress typeofs=false --mangle --comments \"/^!/\" --source-map \"content=dist/js/bootstrap.js.map,includeSources,url=bootstrap.min.js.map\" --output dist/js/bootstrap.min.js dist/js/bootstrap.js",
"js-minify-bundle": "terser --compress typeofs=false --mangle --comments \"/^!/\" --source-map \"content=dist/js/bootstrap.bundle.js.map,includeSources,url=bootstrap.bundle.min.js.map\" --output dist/js/bootstrap.bundle.min.js dist/js/bootstrap.bundle.js",
"js-minify-docs": "cross-env-shell terser --mangle --comments \\\"/^!/\\\" --output site/docs/$npm_package_version_short/assets/js/docs.min.js site/docs/$npm_package_version_short/assets/js/vendor/anchor.min.js site/docs/$npm_package_version_short/assets/js/vendor/clipboard.min.js site/docs/$npm_package_version_short/assets/js/vendor/bs-custom-file-input.min.js \"site/docs/$npm_package_version_short/assets/js/src/*.js\"",
"js-test": "npm-run-all js-test-karma* js-test-integration",
"js-test-karma": "karma start js/tests/karma.conf.js",
"js-test-karma-old": "cross-env USE_OLD_JQUERY=true npm run js-test-karma",
@ -62,31 +47,29 @@
"js-test-integration": "rollup --config js/tests/integration/rollup.bundle.js",
"js-test-cloud": "cross-env BROWSER=true npm run js-test-karma",
"lint": "npm-run-all --parallel js-lint css-lint lockfile-lint",
"docs": "npm-run-all css-docs js-docs docs-build docs-lint",
"docs-build": "bundle exec jekyll build",
"docs": "npm-run-all docs-build docs-lint",
"docs-build": "hugo --cleanDestinationDir",
"docs-compile": "npm run docs-build",
"docs-production": "cross-env JEKYLL_ENV=production npm run docs-build",
"docs-netlify": "cross-env JEKYLL_ENV=netlify npm run docs-build",
"docs-linkinator": "linkinator _gh_pages --recurse --silent --skip \"^(?!http://localhost)\"",
"docs-vnu": "node build/vnu-jar.js",
"docs-lint": "npm-run-all --parallel docs-vnu docs-linkinator",
"docs-serve": "bundle exec jekyll serve",
"docs-serve-only": "npm run docs-serve -- --skip-initial-build --no-watch",
"docs-serve": "hugo server --port 9001 --disableFastRender",
"docs-serve-only": "npx sirv-cli _gh_pages --port 9001",
"lockfile-lint": "lockfile-lint --allowed-hosts npm --allowed-schemes https: --empty-hostname false --type npm --path package-lock.json",
"update-deps": "ncu -u -x \"jquery,karma-browserstack-launcher,sinon,terser\" && npm update && bundle update && cross-env-shell echo Manually update \\\"site/docs/$npm_package_version_short/assets/js/vendor/\\\"",
"release": "npm-run-all dist release-sri docs-production release-zip*",
"update-deps": "ncu -u -x \"jquery,karma-browserstack-launcher,sinon,terser\" && npm update && echo Manually update site/assets/js/vendor",
"release": "npm-run-all dist release-sri docs-build release-zip*",
"release-sri": "node build/generate-sri.js",
"release-version": "node build/change-version.js",
"release-zip": "cross-env-shell \"shx rm -rf bootstrap-$npm_package_version-dist && shx cp -r dist/ bootstrap-$npm_package_version-dist && zip -r9 bootstrap-$npm_package_version-dist.zip bootstrap-$npm_package_version-dist && shx rm -rf bootstrap-$npm_package_version-dist\"",
"release-zip": "cross-env-shell \"rm -rf bootstrap-$npm_package_version-dist && cp -r dist/ bootstrap-$npm_package_version-dist && zip -r9 bootstrap-$npm_package_version-dist.zip bootstrap-$npm_package_version-dist && rm -rf bootstrap-$npm_package_version-dist\"",
"release-zip-examples": "node build/zip-examples.js",
"dist": "npm-run-all --parallel css js",
"test": "npm-run-all lint dist js-test docs-build docs-lint",
"netlify": "npm-run-all dist release-sri docs-netlify",
"netlify": "cross-env-shell HUGO_BASEURL=$DEPLOY_PRIME_URL npm-run-all dist release-sri docs-build",
"watch": "npm-run-all --parallel watch-*",
"watch-css-main": "nodemon --watch scss/ --ext scss --exec \"npm run css-main\"",
"watch-css-docs": "nodemon --watch \"site/docs/**/assets/scss/\" --ext scss --exec \"npm run css-docs\"",
"watch-js-main": "nodemon --watch js/src/ --ext js --exec \"npm run js-compile\"",
"watch-js-docs": "nodemon --watch \"site/docs/**/assets/js/src/\" --ext js --exec \"npm run js-docs\""
"watch-css-main": "nodemon --watch scss/ --ext scss --exec \"npm-run-all css-lint css-compile css-prefix\"",
"watch-css-docs": "nodemon --watch site/assets/scss/ --ext scss --exec \"npm run css-lint\"",
"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\""
},
"style": "dist/css/bootstrap.css",
"sass": "scss/bootstrap.scss",
@ -127,6 +110,7 @@
"find-unused-sass-variables": "^3.0.0",
"glob": "^7.1.6",
"hammer-simulator": "0.0.1",
"hugo-bin": "^0.66.2",
"ip": "^1.1.5",
"jquery": "^3.5.1",
"karma": "^5.2.3",
@ -148,7 +132,6 @@
"qunit": "^2.12.0",
"rollup": "^2.33.1",
"shelljs": "^0.8.4",
"shx": "^0.3.3",
"sinon": "^7.5.0",
"stylelint": "^13.7.2",
"stylelint-config-twbs-bootstrap": "^2.1.0",
@ -160,6 +143,9 @@
"js/{src,dist}/**/*.{js,map}",
"scss/**/*.scss"
],
"hugo-bin": {
"buildTags": "extended"
},
"jspm": {
"registry": "npm",
"main": "js/bootstrap",

View File

@ -1,4 +1,3 @@
// Do not forget to update getting-started/theming.md!
:root {
// Custom variable values only support SassScript inside `#{}`.
@each $color, $value in $colors {

View File

@ -1,46 +0,0 @@
- group: v1.x
baseurl: https://getbootstrap.com
description: Every minor and patch release from v1 is listed below.
versions:
- v: 1.0.0
- v: 1.1.0
- v: 1.1.1
- v: 1.2.0
- v: 1.3.0
- v: 1.4.0
- group: v2.x
baseurl: https://getbootstrap.com
description: Every minor and patch release from v2 is listed below.
versions:
- v: 2.0.0
- v: 2.0.1
- v: 2.0.2
- v: 2.0.3
- v: 2.0.4
- v: 2.1.0
- v: 2.1.1
- v: 2.2.0
- v: 2.2.1
- v: 2.2.2
- v: 2.3.0
- v: 2.3.1
- v: 2.3.2
- group: v3.x
baseurl: https://getbootstrap.com/docs
description: Our previous major release and its minor versions. Last update was v3.4.1.
versions:
- v: 3.3
- v: 3.4
- group: v4.x
baseurl: https://getbootstrap.com/docs
description: Current major release and its minor versions. Last update was v4.5.3.
versions:
- v: 4.0
- v: 4.1
- v: 4.2
- v: 4.3
- v: 4.4
- v: 4.5

View File

@ -1,42 +0,0 @@
{%- comment -%}
Usage: include bugify.html content=text,
where content is a string that contains a bug reference name and id.
e.g. Bootstrap#19984
{%- endcomment -%}
{%- assign words = include.content | split: " " -%}
{%- for word in words -%}
{% if word contains "#" %}
{% if word contains "," %}{% assign separator = true %}{% else %}{% assign separator = false %}{% endif %}
{%- assign data = word | split: "#" -%}
{%- assign bug_cat = data[0] | strip_newlines -%}
{%- assign bug_id = data[1] | strip_newlines | remove: "," -%}
{%- case bug_cat -%}
{%- when "Bootstrap" -%}
<a href="https://github.com/twbs/bootstrap/issues/{{ bug_id }}">#{{ bug_id }}</a>
{%- when "Edge" -%}
<a href="https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/{{ bug_id }}/">Edge issue #{{ bug_id }}</a>
{%- when "A11yUserVoice" -%}
<a href="https://microsoftaccessibility.uservoice.com/forums/307429-microsoft-accessibility-feedback/suggestions/{{ bug_id }}">Microsoft A11y UserVoice idea #{{ bug_id }}</a>
{%- when "UserVoice" -%}
<a href="https://wpdev.uservoice.com/forums/257854-microsoft-edge-developer/suggestions/{{ bug_id }}">Edge UserVoice idea #{{ bug_id }}</a>
{%- when "Mozilla" -%}
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id={{ bug_id }}">Mozilla bug #{{ bug_id }}</a>
{%- when "Chromium" -%}
<a href="https://bugs.chromium.org/p/chromium/issues/detail?id={{ bug_id }}">Chromium issue #{{ bug_id }}</a>
{%- when "WebKit" -%}
<a href="https://bugs.webkit.org/show_bug.cgi?id={{ bug_id }}">WebKit bug #{{ bug_id }}</a>
{%- when "Safari" -%}
<a href="https://openradar.appspot.com/{{ bug_id }}">Apple Safari Radar #{{ bug_id }}</a>
{%- when "Normalize" -%}
<a href="https://github.com/necolas/normalize.css/issues/{{ bug_id }}">Normalize #{{ bug_id }}</a>
{%- else -%}
<strong>parse error</strong>
{%- endcase -%}{% if separator %}, {% endif %}
{% else %}
{{ word }}
{%- endif -%}
{%- endfor -%}

View File

@ -1,4 +0,0 @@
{% capture callout %}
The animation effect of this component is dependent on the `prefers-reduced-motion` media query. See the [reduced motion section of our accessibility documentation]({{ site.baseurl }}/docs/{{ site.docs_version }}/getting-started/accessibility/#reduced-motion).
{% endcapture %}
{% include callout.html content=callout type="info" %}

View File

@ -1,9 +0,0 @@
{%- comment -%}
Usage: include callout.html content=callout type="type",
where content is a capture with the content
and type is one of: info (default), danger, warning
{%- endcomment -%}
{%- assign css_class = include.type | default: "info" -%}
<div class="bd-callout bd-callout-{{ css_class }}">
{{- include.content | markdownify -}}
</div>

View File

@ -1,70 +0,0 @@
<header class="navbar navbar-expand navbar-dark flex-column flex-md-row bd-navbar">
<a class="navbar-brand mr-0 mr-md-2" href="{{ site.baseurl }}/" aria-label="Bootstrap">
{%- include icons/bootstrap.svg width="36" height="36" class="d-block" -%}
</a>
<div class="navbar-nav-scroll">
<ul class="navbar-nav bd-navbar-nav flex-row">
<li class="nav-item">
<a class="nav-link {% if page.layout == "home" %}active{% endif %}" href="{{ site.baseurl }}/" onclick="ga('send', 'event', 'Navbar', 'Community links', 'Bootstrap');">Home</a>
</li>
<li class="nav-item">
<a class="nav-link {% if page.layout == "docs" %}active{% endif %}" href="{{ site.baseurl }}/docs/{{ site.docs_version }}/getting-started/introduction/" onclick="ga('send', 'event', 'Navbar', 'Community links', 'Docs');">Documentation</a>
</li>
<li class="nav-item">
<a class="nav-link {% if page.title == "Examples" %}active{% endif %}" href="{{ site.baseurl }}/docs/{{ site.docs_version }}/examples/" onclick="ga('send', 'event', 'Navbar', 'Community links', 'Examples');">Examples</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ site.icons }}/" onclick="ga('send', 'event', 'Navbar', 'Community links', 'Icons');" target="_blank" rel="noopener">Icons</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ site.themes }}/" onclick="ga('send', 'event', 'Navbar', 'Community links', 'Themes');" target="_blank" rel="noopener">Themes</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ site.expo }}/" onclick="ga('send', 'event', 'Navbar', 'Community links', 'Expo');" target="_blank" rel="noopener">Expo</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ site.blog }}/" onclick="ga('send', 'event', 'Navbar', 'Community links', 'Blog');" target="_blank" rel="noopener">Blog</a>
</li>
</ul>
</div>
<ul class="navbar-nav ml-md-auto">
<li class="nav-item dropdown">
<a class="nav-item nav-link dropdown-toggle mr-md-2" href="#" id="bd-versions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
v{{ site.docs_version }}
</a>
<div class="dropdown-menu dropdown-menu-md-right" aria-labelledby="bd-versions">
<a class="dropdown-item active" href="{{ site.baseurl }}/docs/{{ site.docs_version }}/">Latest (4.5.x)</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="https://getbootstrap.com/docs/3.4/">v3.4.1</a>
<a class="dropdown-item" href="https://getbootstrap.com/2.3.2/">v2.3.2</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{{ site.baseurl }}/docs/versions/">All versions</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link pl-2 pr-1 mx-1 py-3 my-n2" href="{{ site.github_org }}" target="_blank" rel="noopener" aria-label="GitHub">
{%- include icons/github.svg class="navbar-nav-svg" -%}
</a>
</li>
<li class="nav-item">
<a class="nav-link px-1 mx-1 py-3 my-n2" href="https://twitter.com/{{ site.twitter }}" target="_blank" rel="noopener" aria-label="Twitter">
{%- include icons/twitter.svg class="navbar-nav-svg" -%}
</a>
</li>
<li class="nav-item">
<a class="nav-link px-1 mx-1 py-3 my-n2" href="{{ site.slack }}/" target="_blank" rel="noopener" aria-label="Slack">
{%- include icons/slack.svg class="navbar-nav-svg" -%}
</a>
</li>
<li class="nav-item">
<a class="nav-link px-1 mx-1 py-3 my-n2" href="{{ site.opencollective }}/" target="_blank" rel="noopener" aria-label="Open Collective">
{%- include icons/opencollective.svg class="navbar-nav-svg" -%}
</a>
</li>
</ul>
<a class="btn btn-bd-download d-none d-lg-inline-block mb-3 mb-md-0 ml-md-3" href="{{ site.baseurl }}/docs/{{ site.docs_version }}/getting-started/download/">Download</a>
</header>

View File

@ -1,45 +0,0 @@
<form role="search" class="bd-search d-flex align-items-center">
<input type="search" class="form-control" id="search-input" placeholder="Search..." aria-label="Search for..." autocomplete="off" data-docs-version="{{ site.docs_version }}">
<button class="btn bd-search-docs-toggle d-md-none p-0 ml-3" type="button" data-toggle="collapse" data-target="#bd-docs-nav" aria-controls="bd-docs-nav" aria-expanded="false" aria-label="Toggle docs navigation">
{%- include icons/menu.svg width="30" height="30" -%}
</button>
</form>
<div class="collapse d-md-block row" id="bd-docs-nav">
<nav class="bd-links" aria-label="Main navigation">
{%- assign page_slug = page.url | split: '/' | last -%}
{%- for group in site.data.nav -%}
{%- assign link = group.pages | first -%}
{%- assign link_slug = link.title | slugify -%}
{%- assign group_slug = group.title | slugify -%}
{%- assign active = nil -%}
{%- if page.group == group_slug -%}
{%- assign active = 'active' -%}
{%- endif -%}
<div class="bd-toc-item{% unless active == nil %} {{ active }}{% endunless %}">
<a class="bd-toc-link" href="{{ site.baseurl }}/docs/{{ site.docs_version }}/{{ group_slug }}/{{ link_slug }}{% if link_slug %}/{% endif %}">
{{ group.title }}
</a>
<ul class="nav bd-sidenav">
{%- for doc in group.pages -%}
{%- assign doc_slug = doc.title | slugify -%}
{%- assign active = nil -%}
{%- if page.group == group_slug and page_slug == doc_slug -%}
{%- assign active = 'active bd-sidenav-active' -%}
{%- endif -%}
<li{% unless active == nil %} class="{{ active }}"{% endunless %}>
<a href="{{ site.baseurl }}/docs/{{ site.docs_version }}/{{ group_slug }}/{{ doc_slug }}/">
{{ doc.title }}
</a>
</li>
{%- endfor -%}
</ul>
</div>
{%- endfor -%}
</nav>
</div>

View File

@ -1,51 +0,0 @@
{%- comment -%}
Usage: include example.html content=markup [args],
where content is a capture with the HTML content
args can be one of the following:
id - null (default)
class - "bd-example" (default)
optional: hide_preview - disabled (default)
optional: hide_markup - disabled (default)
{%- endcomment -%}
{%- assign id = include.id -%}
{%- assign class = include.class -%}
{%- if include.hide_preview == null -%}
<div{% if id %} id="{{ id }}"{% endif %} class="bd-example{% if class %} {{ class }}{% endif %}">
{{- include.content -}}
</div>
{%- endif -%}
{%- if include.hide_markup == null -%}
{%- highlight html -%}
{%- if include.content contains '<svg class="bd-placeholder-img' -%}
{%- assign modified_content = include.content
| replace: '<svg class="bd-placeholder-img', '✂️<svg class="bd-placeholder-img'
| replace: '</svg>', '</svg>✂️'
| split: '✂️' -%}
{%- if include.content contains 'bd-placeholder-img ' -%}
{%- assign image_class = include.content
| replace_first: 'bd-placeholder-img', 'bd-placeholder-img ✂️'
| replace: '" width="', '✂️" width="'
| split: '✂️' -%}
{%- assign image_class = image_class[1] | replace: 'bd-placeholder-img-lg', '' | strip -%}
{%- endif -%}
{%- for content_chunk in modified_content -%}
{%- if content_chunk contains '<svg class="bd-placeholder-img' -%}
{%- capture img_placeholder -%}
<img src="..." {% if image_class %}class="{{ image_class }}" {% endif %}alt="...">
{%- endcapture -%}
{{- img_placeholder -}}
{%- else -%}
{{- content_chunk -}}
{%- endif -%}
{%- endfor -%}
{%- else -%}
{{- include.content -}}
{%- endif -%}
{%- endhighlight -%}
{%- endif -%}

View File

@ -1,9 +0,0 @@
<!-- Favicons -->
<link rel="apple-touch-icon" href="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/img/favicons/apple-touch-icon.png" sizes="180x180">
<link rel="icon" href="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/img/favicons/favicon-32x32.png" sizes="32x32" type="image/png">
<link rel="icon" href="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/img/favicons/favicon-16x16.png" sizes="16x16" type="image/png">
<link rel="manifest" href="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/img/favicons/manifest.json">
<link rel="mask-icon" href="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/img/favicons/safari-pinned-tab.svg" color="#563d7c">
<link rel="icon" href="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/img/favicons/favicon.ico">
<meta name="msapplication-config" content="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/img/favicons/browserconfig.xml">
<meta name="theme-color" content="#563d7c">

View File

@ -1,12 +0,0 @@
<footer class="bd-footer text-muted">
<div class="container-fluid p-3 p-md-5">
<ul class="bd-footer-links">
<li><a href="{{ site.github_org }}">GitHub</a></li>
<li><a href="https://twitter.com/{{ site.twitter }}">Twitter</a></li>
<li><a href="{{ site.baseurl }}/docs/{{ site.docs_version }}/examples/">Examples</a></li>
<li><a href="{{ site.baseurl }}/docs/{{ site.docs_version }}/about/overview/">About</a></li>
</ul>
<p>Designed and built with all the love in the world by the <a href="{{ site.baseurl }}/docs/{{ site.docs_version }}/about/team/">Bootstrap team</a> with the help of <a href="{{ site.repo }}/graphs/contributors">our contributors</a>.</p>
<p>Currently v{{ site.current_version }}. Code licensed <a href="{{ site.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>.</p>
</div>
</footer>

View File

@ -1,23 +0,0 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="{{ page.description | default: site.description | smartify }}">
<meta name="author" content="{{ site.authors }}">
<meta name="generator" content="Jekyll v{{ jekyll.version }}">
<meta name="docsearch:language" content="en">
<meta name="docsearch:version" content="{{ site.docs_version }}">
<title>
{%- if page.title -%}
{{ page.title | smartify }} · {{ site.title | smartify }} v{{ site.docs_version }}
{%- else -%}
{{ site.title | smartify }} · {{ site.description | smartify }}
{%- endif -%}
</title>
<link rel="canonical" href="{{ site.url | append: page.url }}">
{% include stylesheet.html %}
{% include favicons.html %}
{% include social.html %}
{% include analytics.html %}

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"{% if include.width %} width="{{ include.width }}"{% endif %}{% if include.height %} height="{{ include.height }}"{% endif %}{% if include.class %} class="{{ include.class }}"{% endif %} viewBox="0 0 1024 860" focusable="false" role="img"><title>Bootstrap</title><defs><linearGradient id="c" x1="50%" x2="50%" y1="0%" y2="100%"><stop offset="0%" stop-color="#5c24ae"/><stop offset="100%" stop-color="#30135a"/></linearGradient><path id="b" d="M355.967 242.807l-322 216.395c-44.275 29.754-44.275 78.443 0 108.197l322 216.395c44.275 29.754 116.725 29.754 161 0l322-216.395c44.275-29.754 44.275-78.443 0-108.197l-322-216.395c-44.275-29.754-116.725-29.754-161 0z"/><filter id="a" width="108%" height="112%" x="-4%" y="-4.3%" filterUnits="objectBoundingBox"><feOffset dy="10" in="SourceAlpha" result="shadowOffsetOuter1"/><feGaussianBlur in="shadowOffsetOuter1" result="shadowBlurOuter1" stdDeviation="10"/><feColorMatrix in="shadowBlurOuter1" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/></filter><linearGradient id="f" x1="50%" x2="50%" y1="-17.303%" y2="100%"><stop offset="0%" stop-color="#7331d4"/><stop offset="100%" stop-color="#461b84"/></linearGradient><path id="e" d="M355.967 132.807l-322 216.395c-44.275 29.754-44.275 78.443 0 108.197l322 216.395c44.275 29.754 116.725 29.754 161 0l322-216.395c44.275-29.754 44.275-78.443 0-108.197l-322-216.395c-44.275-29.754-116.725-29.754-161 0z"/><filter id="d" width="108%" height="112%" x="-4%" y="-4.3%" filterUnits="objectBoundingBox"><feOffset dy="10" in="SourceAlpha" result="shadowOffsetOuter1"/><feGaussianBlur in="shadowOffsetOuter1" result="shadowBlurOuter1" stdDeviation="10"/><feColorMatrix in="shadowBlurOuter1" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/></filter><linearGradient id="i" x1="50%" x2="50%" y1="0%" y2="100%"><stop offset="0%" stop-color="#905bdd"/><stop offset="100%" stop-color="#5521a0"/></linearGradient><path id="h" d="M355.967 22.807l-322 216.395c-44.275 29.754-44.275 78.443 0 108.197l322 216.395c44.275 29.754 116.725 29.754 161 0l322-216.395c44.275-29.754 44.275-78.443 0-108.197l-322-216.395c-44.275-29.754-116.725-29.754-161 0z"/><filter id="g" width="108%" height="112%" x="-4%" y="-4.3%" filterUnits="objectBoundingBox"><feOffset dy="10" in="SourceAlpha" result="shadowOffsetOuter1"/><feGaussianBlur in="shadowOffsetOuter1" result="shadowBlurOuter1" stdDeviation="10"/><feColorMatrix in="shadowBlurOuter1" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/></filter></defs><g fill="none"><g transform="translate(75 23)"><use fill="#000" filter="url(#a)" xlink:href="#b"/><use fill="url(#c)" xlink:href="#b"/></g><g transform="translate(75 23)"><use fill="#000" filter="url(#d)" xlink:href="#e"/><use fill="url(#f)" xlink:href="#e"/></g><g transform="translate(75 23)"><use fill="#000" filter="url(#g)" xlink:href="#h"/><use fill="url(#i)" xlink:href="#h"/></g><path fill="#fff" d="M558.273 447.667L308.036 279.5l97.982-65.847c42.83-28.784 96.789-31.483 134.245-6.311 26.044 17.502 31.214 46.615 11.444 65.724l1.389.934c38.324-19.932 84.107-18.527 117.396 3.845 44.046 29.6 38.671 68.419-14.561 104.193l-97.658 65.629zM447.112 331.01l49.942-33.562c36.935-24.822 42.31-48.249 15.224-66.451-24.798-16.665-55.49-14.453-85.851 5.95l-59.641 40.081 80.326 53.982zm176.532 35.663c37.63-25.289 42.136-48.832 13.203-68.276-28.932-19.444-64.163-15.614-104.042 11.186l-58.789 39.508 87.92 59.084 61.708-41.502z"/></g></svg>

Before

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg"{% if include.width %} width="{{ include.width }}"{% endif %}{% if include.height %} height="{{ include.height }}"{% endif %}{% if include.class %} class="{{ include.class }}"{% endif %} viewBox="0 0 612 612" role="img" focusable="false"><title>Bootstrap</title><path fill="currentColor" d="M510 8a94.3 94.3 0 0 1 94 94v408a94.3 94.3 0 0 1-94 94H102a94.3 94.3 0 0 1-94-94V102a94.3 94.3 0 0 1 94-94h408m0-8H102C45.9 0 0 45.9 0 102v408c0 56.1 45.9 102 102 102h408c56.1 0 102-45.9 102-102V102C612 45.9 566.1 0 510 0z"/><path fill="currentColor" d="M196.77 471.5V154.43h124.15c54.27 0 91 31.64 91 79.1 0 33-24.17 63.72-54.71 69.21v1.76c43.07 5.49 70.75 35.82 70.75 78 0 55.81-40 89-107.45 89zm39.55-180.4h63.28c46.8 0 72.29-18.68 72.29-53 0-31.42-21.53-48.78-60-48.78h-75.57zm78.22 145.46c47.68 0 72.73-19.34 72.73-56s-25.93-55.37-76.46-55.37h-74.49v111.4z"/></svg>

Before

Width:  |  Height:  |  Size: 900 B

View File

@ -1,4 +0,0 @@
<svg{% if include.width %} width="{{ include.width }}"{% endif %}{% if include.height %} height="{{ include.height }}"{% endif %}{% if include.class %} class="{{ include.class }}"{% endif %} focusable="false" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path d="M0 6a6 6 0 1112 0A6 6 0 010 6z"/>
<path d="M12.93 5h1.57a.5.5 0 01.5.5v9a.5.5 0 01-.5.5h-9a.5.5 0 01-.5-.5v-1.57a6.953 6.953 0 01-1-.22v1.79A1.5 1.5 0 005.5 16h9a1.5 1.5 0 001.5-1.5v-9A1.5 1.5 0 0014.5 4h-1.79c.097.324.17.658.22 1z"/>
</svg>

Before

Width:  |  Height:  |  Size: 540 B

View File

@ -1,3 +0,0 @@
<svg{% if include.width %} width="{{ include.width }}"{% endif %}{% if include.height %} height="{{ include.height }}"{% endif %}{% if include.class %} class="{{ include.class }}"{% endif %} focusable="false" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M3.5 13a3.5 3.5 0 11.59-6.95 5.002 5.002 0 119.804 1.98A2.5 2.5 0 0113.5 13h-10z" clip-rule="evenodd"/>
</svg>

Before

Width:  |  Height:  |  Size: 427 B

View File

@ -1,3 +0,0 @@
<svg{% if include.width %} width="{{ include.width }}"{% endif %}{% if include.height %} height="{{ include.height }}"{% endif %}{% if include.class %} class="{{ include.class }}"{% endif %} focusable="false" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M8 16a6 6 0 006-6c0-1.655-1.122-2.904-2.432-4.362C10.254 4.176 8.75 2.503 8 0c0 0-6 5.686-6 10a6 6 0 006 6zM6.646 4.646c-.376.377-1.272 1.489-2.093 3.13l.894.448c.78-1.559 1.616-2.58 1.907-2.87l-.708-.708z" clip-rule="evenodd"/>
</svg>

Before

Width:  |  Height:  |  Size: 552 B

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg"{% if include.width %} width="{{ include.width }}"{% endif %}{% if include.height %} height="{{ include.height }}"{% endif %}{% if include.class %} class="{{ include.class }}"{% endif %} viewBox="0 0 512 499.36" role="img" focusable="false"><title>GitHub</title><path fill="currentColor" fill-rule="evenodd" d="M256 0C114.64 0 0 114.61 0 256c0 113.09 73.34 209 175.08 242.9 12.8 2.35 17.47-5.56 17.47-12.34 0-6.08-.22-22.18-.35-43.54-71.2 15.49-86.2-34.34-86.2-34.34-11.64-29.57-28.42-37.45-28.42-37.45-23.27-15.84 1.73-15.55 1.73-15.55 25.69 1.81 39.21 26.38 39.21 26.38 22.84 39.12 59.92 27.82 74.5 21.27 2.33-16.54 8.94-27.82 16.25-34.22-56.84-6.43-116.6-28.43-116.6-126.49 0-27.95 10-50.8 26.35-68.69-2.63-6.48-11.42-32.5 2.51-67.75 0 0 21.49-6.88 70.4 26.24a242.65 242.65 0 0 1 128.18 0c48.87-33.13 70.33-26.24 70.33-26.24 14 35.25 5.18 61.27 2.55 67.75 16.41 17.9 26.31 40.75 26.31 68.69 0 98.35-59.85 120-116.88 126.32 9.19 7.9 17.38 23.53 17.38 47.41 0 34.22-.31 61.83-.31 70.23 0 6.85 4.61 14.81 17.6 12.31C438.72 464.97 512 369.08 512 256.02 512 114.62 397.37 0 256 0z"/></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg"{% if include.width %} width="{{ include.width }}"{% endif %}{% if include.height %} height="{{ include.height }}"{% endif %}{% if include.class %} class="{{ include.class }}"{% endif %} viewBox="0 0 30 30" role="img" focusable="false"><title>Menu</title><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"/></svg>

Before

Width:  |  Height:  |  Size: 420 B

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg"{% if include.width %} width="{{ include.width }}"{% endif %}{% if include.height %} height="{{ include.height }}"{% endif %} fill="currentColor" fill-rule="evenodd"{% if include.class %} class="{{ include.class }}"{% endif %} viewBox="0 0 40 41" role="img" focusable="false"><title>Open Collective</title><path fill-opacity=".4" d="M32.8 21c0 2.4-.8 4.9-2 6.9l5.1 5.1c2.5-3.4 4.1-7.6 4.1-12 0-4.6-1.6-8.8-4-12.2L30.7 14c1.2 2 2 4.3 2 7z"/><path d="M20 33.7a12.8 12.8 0 0 1 0-25.6c2.6 0 5 .7 7 2.1L32 5a20 20 0 1 0 .1 31.9l-5-5.2a13 13 0 0 1-7 2z"/></svg>

Before

Width:  |  Height:  |  Size: 594 B

View File

@ -1,35 +0,0 @@
{%- comment -%}
Usage: include icons/placeholder.svg args
args can be one of the following:
title: Used in the SVG `title` tag
text: The text to show in the image - default: 'width x height'
class: default: 'bd-placeholder-img'
color: The text color (foreground) - default: '#dee2e6'
background: The background color - default: '#868e96'
width: default: 100%
height: default: 180px
{%- endcomment -%}
{%- assign title = include.title | default: 'Placeholder' -%}
{%- assign class = include.class | default: '' -%}
{%- assign color = include.color | default: site.data.grays[2].hex -%}
{%- assign background = include.background | default: site.data.grays[5].hex -%}
{%- assign width = include.width | default: '100%' -%}
{%- assign height = include.height | default: '180' -%}
{%- if include.text -%}
{%- assign text = include.text -%}
{%- else -%}
{%- assign text = width | append: 'x' | append: height -%}
{%- endif -%}
{%- capture svg -%}
<svg class="bd-placeholder-img{% if class != '' %} {{ class }}{% endif %}" width="{{ width }}" height="{{ height }}" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img"{% if title != ' ' or text != ' ' %} aria-label="{% if title != ' ' %}{{ title }}{% if text != ' ' %}: {% endif %}{% endif %}{% if text != ' ' %}{{ text }}{% endif %}"{% endif %}>
{% if title != ' ' %}<title>{{ title }}</title>{% endif %}
<rect width="100%" height="100%" fill="{{ background }}"/>
{% if text != ' ' %}<text x="50%" y="50%" fill="{{ color }}" dy=".3em">{{ text }}</text>{% endif %}
</svg>
{%- endcapture -%}
{{- svg | replace: ' ', '' | strip_newlines -}}

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg"{% if include.width %} width="{{ include.width }}"{% endif %}{% if include.height %} height="{{ include.height }}"{% endif %}{% if include.class %} class="{{ include.class }}"{% endif %} viewBox="0 0 512 512" role="img" focusable="false"><title>Slack</title><path fill="currentColor" d="M210.787 234.832l68.31-22.883 22.1 65.977-68.309 22.882z"/><path fill="currentColor" d="M490.54 185.6C437.7 9.59 361.6-31.34 185.6 21.46S-31.3 150.4 21.46 326.4 150.4 543.3 326.4 490.54 543.34 361.6 490.54 185.6zM401.7 299.8l-33.15 11.05 11.46 34.38c4.5 13.92-2.87 29.06-16.78 33.56-2.87.82-6.14 1.64-9 1.23a27.32 27.32 0 0 1-24.56-18l-11.46-34.38-68.36 22.92 11.46 34.38c4.5 13.92-2.87 29.06-16.78 33.56-2.87.82-6.14 1.64-9 1.23a27.32 27.32 0 0 1-24.56-18l-11.46-34.43-33.15 11.05c-2.87.82-6.14 1.64-9 1.23a27.32 27.32 0 0 1-24.56-18c-4.5-13.92 2.87-29.06 16.78-33.56l33.12-11.03-22.1-65.9-33.15 11.05c-2.87.82-6.14 1.64-9 1.23a27.32 27.32 0 0 1-24.56-18c-4.48-13.93 2.89-29.07 16.81-33.58l33.15-11.05-11.46-34.38c-4.5-13.92 2.87-29.06 16.78-33.56s29.06 2.87 33.56 16.78l11.46 34.38 68.36-22.92-11.46-34.38c-4.5-13.92 2.87-29.06 16.78-33.56s29.06 2.87 33.56 16.78l11.47 34.42 33.15-11.05c13.92-4.5 29.06 2.87 33.56 16.78s-2.87 29.06-16.78 33.56L329.7 194.6l22.1 65.9 33.15-11.05c13.92-4.5 29.06 2.87 33.56 16.78s-2.88 29.07-16.81 33.57z"/></svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg"{% if include.width %} width="{{ include.width }}"{% endif %}{% if include.height %} height="{{ include.height }}"{% endif %}{% if include.class %} class="{{ include.class }}"{% endif %} viewBox="0 0 512 416.32" role="img" focusable="false"><title>Twitter</title><path fill="currentColor" d="M160.83 416.32c193.2 0 298.92-160.22 298.92-298.92 0-4.51 0-9-.2-13.52A214 214 0 0 0 512 49.38a212.93 212.93 0 0 1-60.44 16.6 105.7 105.7 0 0 0 46.3-58.19 209 209 0 0 1-66.79 25.37 105.09 105.09 0 0 0-181.73 71.91 116.12 116.12 0 0 0 2.66 24c-87.28-4.3-164.73-46.3-216.56-109.82A105.48 105.48 0 0 0 68 159.6a106.27 106.27 0 0 1-47.53-13.11v1.43a105.28 105.28 0 0 0 84.21 103.06 105.67 105.67 0 0 1-47.33 1.84 105.06 105.06 0 0 0 98.14 72.94A210.72 210.72 0 0 1 25 370.84a202.17 202.17 0 0 1-25-1.43 298.85 298.85 0 0 0 160.83 46.92"/></svg>

Before

Width:  |  Height:  |  Size: 871 B

View File

@ -1,23 +0,0 @@
<script src="{{ site.cdn.jquery }}" integrity="{{ site.cdn.jquery_hash }}" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/js/vendor/jquery.slim.min.js"><\/script>')</script>
{%- if jekyll.environment == "production" or jekyll.environment == "netlify" -%}
<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/dist/js/bootstrap.bundle.min.js" integrity="{{ site.cdn.js_bundle_hash }}" crossorigin="anonymous"></script>
{%- else -%}
<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/dist/js/bootstrap.bundle.js"></script>
{%- endif -%}
{%- if page.layout == "docs" -%}
<script src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
{%- endif -%}
{%- if jekyll.environment == "production" or jekyll.environment == "netlify" -%}
<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/js/docs.min.js"></script>
{%- else -%}
<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/js/vendor/anchor.min.js"></script>
<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/js/vendor/clipboard.min.js"></script>
<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/js/vendor/bs-custom-file-input.min.js"></script>
<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/js/src/application.js"></script>
<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/js/src/search.js"></script>
<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/js/src/ie-emulation-modes-warning.js"></script>
{%- endif -%}

View File

@ -1,17 +0,0 @@
<!-- Twitter -->
<meta name="twitter:card" content="{% if page.title %}summary{% else %}summary_large_image{% endif %}">
<meta name="twitter:site" content="@{{ site.twitter }}">
<meta name="twitter:creator" content="@{{ site.twitter }}">
<meta name="twitter:title" content="{{ page.title | default: site.title | smartify }}">
<meta name="twitter:description" content="{{ page.description | default: site.description | smartify }}">
<meta name="twitter:image" content="{% if page.title %}{{ site.url | append: site.social_logo_path }}{% else %}{{ site.url | append: site.social_image_path }}{% endif %}">
<!-- Facebook -->
<meta property="og:url" content="{{ site.url | append: page.url }}">
<meta property="og:title" content="{{ page.title | default: site.title | smartify }}">
<meta property="og:description" content="{{ page.description | default: site.description | smartify }}">
<meta property="og:type" content="website">
<meta property="og:image" content="{{ site.url | append: site.social_image_path }}">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">

View File

@ -1,16 +0,0 @@
<!-- Bootstrap core CSS -->
{%- if jekyll.environment == "production" or jekyll.environment == "netlify" %}
<link href="{{ site.baseurl }}/docs/{{ site.docs_version }}/dist/css/bootstrap.min.css" rel="stylesheet" integrity="{{ site.cdn.css_hash }}" crossorigin="anonymous">
{% else %}
<link href="{{ site.baseurl }}/docs/{{ site.docs_version }}/dist/css/bootstrap.css" rel="stylesheet">
{% endif -%}
{%- if page.layout == "docs" or page.layout != "examples" -%}
<!-- Documentation extras -->
{% if page.layout == "docs" %}
<link href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" rel="stylesheet">
{% endif %}
{% if page.layout != "examples" %}
<link href="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/css/docs.min.css" rel="stylesheet">
{% endif %}
{%- endif -%}

View File

@ -1,22 +0,0 @@
<!doctype html>
<html lang="en">
<head>
{% include header.html %}
</head>
<body>
{% include skippy.html %}
{% include docs-navbar.html %}
{% if page.layout == "simple" %}
{{ content }}
{% else %}
<main id="content" role="main">
{{ content }}
</main>
{% endif %}
{% include footer.html %}
{% include scripts.html %}
</body>
</html>

View File

@ -1,37 +0,0 @@
<!doctype html>
<html lang="en">
<head>
{% include header.html %}
</head>
<body>
{% include skippy.html %}
{% include docs-navbar.html %}
<div class="container-fluid">
<div class="row flex-xl-nowrap">
<div class="col-md-3 col-xl-2 bd-sidebar">
{% include docs-sidebar.html %}
</div>
{% if page.toc %}
<nav class="d-none d-xl-block col-xl-2 bd-toc" aria-label="Secondary navigation">
{{ content | toc_only }}
</nav>
{% endif %}
<main class="col-md-9 col-xl-8 py-md-3 pl-md-5 bd-content" role="main">
<div class="d-md-flex flex-md-row-reverse align-items-center justify-content-between">
<a class="btn btn-sm btn-bd-light my-2 my-md-0" href="{{ site.repo }}/blob/v4-dev/site/{{ page.path }}" title="View and edit this file on GitHub" target="_blank" rel="noopener">View on GitHub</a>
<h1 class="bd-title" id="content">{{ page.title | smartify }}</h1>
</div>
<p class="bd-lead">{{ page.description | smartify }}</p>
{% include ads.html %}
{{ content }}
</main>
</div>
</div>
{% include scripts.html %}
</body>
</html>

View File

@ -1,56 +0,0 @@
<!doctype html>
<html lang="en"{% if page.html_class %} class="{{ page.html_class }}"{% endif %}>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="{{ site.authors }}">
<meta name="generator" content="Jekyll v{{ jekyll.version }}">
<title>{{ page.title | smartify }} · {{ site.title | smartify }}</title>
<link rel="canonical" href="{{ site.url | append: page.url }}">
{% include stylesheet.html %}
{% include favicons.html %}
<style>
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
@media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
</style>
{%- for css in page.extra_css %}
<!-- Custom styles for this template -->
<link href="{{ css }}" rel="stylesheet">
{%- endfor %}
</head>
<body{% if page.body_class %} class="{{ page.body_class }}"{% endif %}>
{{ content }}
{%- if page.include_js != false -%}
<script src="{{ site.cdn.jquery }}" integrity="{{ site.cdn.jquery_hash }}" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/js/vendor/jquery.slim.min.js"><\/script>')</script>
{%- if jekyll.environment == "production" or jekyll.environment == "netlify" -%}
<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/dist/js/bootstrap.bundle.min.js" integrity="{{ site.cdn.js_bundle_hash }}" crossorigin="anonymous"></script>
{%- else -%}
<script src="{{ site.baseurl }}/docs/{{ site.docs_version }}/dist/js/bootstrap.bundle.js"></script>
{%- endif -%}
{%- for js in page.extra_js %}
<script src="{{ js }}"></script>
{%- endfor %}
{%- endif -%}
</body>
</html>

View File

@ -1,16 +0,0 @@
<!doctype html>
<html lang="en">
<head>
{% include header.html %}
</head>
<body>
{% include skippy.html %}
{% include docs-navbar.html %}
{{ content }}
{% include footer.html %}
{% include scripts.html %}
</body>
</html>

View File

@ -1,21 +0,0 @@
---
layout: default
---
<header class="d-flex flex-column flex-md-row align-items-md-center p-5 bg-light">
<div class="pt-md-3 pb-md-4">
<h1 class="bd-title mt-0">{{ page.title | smartify }}</h1>
<p class="bd-lead">{{ page.description | smartify }}</p>
{%- if page.title == "Examples" -%}
<div class="d-flex flex-column flex-sm-row">
<a href="{{ site.download.dist_examples }}" class="btn btn-bd-primary py-2 px-3" onclick="ga('send', 'event', 'Examples', 'Hero', 'Download Examples');">Download examples</a>
<a href="{{ site.download.source }}" class="btn btn-outline-secondary py-2 px-3 mt-3 mt-sm-0 ml-sm-3" onclick="ga('send', 'event', 'Examples', 'Hero', 'Download');">Download source code</a>
</div>
{%- endif -%}
</div>
{% include ads.html %}
</header>
<main class="bd-content p-5" id="content" role="main">
{{ content }}
</main>

View File

@ -59,7 +59,7 @@
})
// Insert copy to clipboard button before .highlight
$('figure.highlight, div.highlight').each(function () {
$('div.highlight').each(function () {
var btnHtml = '<div class="bd-clipboard"><button type="button" class="btn-clipboard" title="Copy to clipboard">Copy</button></div>'
$(this).before(btnHtml)
$('.btn-clipboard')

View File

@ -1,46 +1,3 @@
// stylelint-disable declaration-no-important
//
// Right side table of contents
//
.bd-toc {
@supports (position: sticky) {
position: sticky;
top: 4rem;
height: subtract(100vh, 4rem);
overflow-y: auto;
}
order: 2;
padding-top: 1.5rem;
padding-bottom: 1.5rem;
@include font-size(.875rem);
}
.section-nav {
padding-left: 0;
border-left: 1px solid #eee;
ul {
padding-left: 1rem;
}
}
.toc-entry {
display: block;
a {
display: block;
padding: .125rem 1.5rem;
color: #77757a;
&:hover {
color: $blue;
text-decoration: none;
}
}
}
//
// Left side navigation
//

View File

@ -0,0 +1,94 @@
// stylelint-disable comment-empty-line-before, declaration-block-single-line-max-declarations, selector-class-pattern
/* NEW Background .chroma { background-color: #f0f0f0; } */
/* NEW Error .chroma .err { } */
/* NEW LineTableTD .chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; } */
/* NEW LineTable .chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; width: auto; overflow: auto; display: block; } */
/* NEW LineHighlight .chroma .hl { display: block; width: 100%; background-color: #ffffcc; } */
/* NEW LineNumbersTable .chroma .lnt { margin-right: .4em; padding: 0 .4em; } */
/* NEW LineNumbers .chroma .ln { margin-right: .4em; padding: 0 .4em; } */
/* LiteralStringDelimiter */ .chroma .dl { color: #4070a0; } /* NEW */
/* Comment */ .chroma .c { color: #727272; }
/* CommentMultiline */ .chroma .c1 { color: #727272; }
/* CommentHashbang */ .chroma .ch { font-style: italic; color: #60a0b0; } /* NEW */
/* CommentMultiline */ .chroma .cm { color: #727272; }
/* CommentPreproc */ .chroma .cp { color: #008085; }
/* CommentPreprocFile */ .chroma .cpf { color: #007020; } /* NEW */
/* CommentSpecial */ .chroma .cs { color: #727272; }
/* GenericDeleted */ .chroma .gd { background-color: #fcc; border: 1px solid #c00; }
/* GenericEmph */ .chroma .ge { font-style: italic; }
/* GenericHeading */ .chroma .gh { color: #030; }
/* GenericInserted */ .chroma .gi { background-color: #cfc; border: 1px solid #0c0; }
/* GenericUnderline */ .chroma .gl { text-decoration: underline; } /* NEW */
/* GenericOutput */ .chroma .go { color: #aaa; }
/* GenericPrompt */ .chroma .gp { color: #009; }
/* GenericError */ .chroma .gr { color: #f00; }
/* GenericStrong */ .chroma .gs { font-weight: 700; } /* NEW */
/* GenericTraceback */ .chroma .gt { color: #9c6; }
/* GenericSubheading */ .chroma .gu { color: #030; }
/* LiteralNumberIntegerLong */ .chroma .il { color: #c24f19; }
/* Keyword */ .chroma .k { color: #069; }
/* KeywordConstant */ .chroma .kc { color: #069; }
/* KeywordDeclaration */ .chroma .kd { color: #069; }
/* KeywordNamespace */ .chroma .kn { color: #069; }
/* KeywordPseudo */ .chroma .kp { color: #069; }
/* KeywordReserved */ .chroma .kr { color: #069; }
/* KeywordType */ .chroma .kt { color: #078; }
/* LiteralNumber */ .chroma .m { color: #c24f19; }
/* LiteralNumberFloat */ .chroma .mf { color: #c24f19; }
/* LiteralNumberBin */ .chroma .mb { color: #40a070; } /* NEW */
/* LiteralNumberHex */ .chroma .mh { color: #c24f19; }
/* LiteralNumberInteger */ .chroma .mi { color: #c24f19; }
/* LiteralNumberOct */ .chroma .mo { color: #c24f19; }
/* NameAttribute */ .chroma .na { color: #006ee0; }
/* NameBuiltin */ .chroma .nb { color: #366; }
/* NameClass */ .chroma .nc { color: #168174; }
/* NameDecorator */ .chroma .nd { color: #6b62de; }
/* NameException */ .chroma .ne { color: #c00; }
/* NameFunction */ .chroma .nf { color: #b715f4; }
/* NameEntity */ .chroma .ni { color: #727272; }
/* NameLabel */ .chroma .nl { color: #6b62de; }
/* NameNamespace */ .chroma .nn { color: #007ca5; }
/* NameConstant */ .chroma .no { color: #360; }
/* NameTag */ .chroma .nt { color: #2f6f9f; }
/* NameVariable */ .chroma .nv { color: #033; }
/* Operator */ .chroma .o { color: #555; }
/* OperatorWord */ .chroma .ow { color: #000; }
/* LiteralString */ .chroma .s { color: #d73038; }
/* LiteralStringSingle */ .chroma .s1 { color: #c30; }
/* LiteralStringDouble */ .chroma .s2 { color: #c30; }
/* LiteralStringAffix */ .chroma .sa { color: #4070a0; } /* NEW */
/* LiteralStringBacktick */ .chroma .sb { color: #c30; }
/* LiteralStringChar */ .chroma .sc { color: #c30; }
/* LiteralStringDoc */ .chroma .sd { font-style: italic; color: #c30; }
/* LiteralStringEscape */ .chroma .se { color: #c30; }
/* LiteralStringHeredoc */ .chroma .sh { color: #c30; }
/* LiteralStringInterpol */ .chroma .si { color: #a00; }
/* LiteralStringRegex */ .chroma .sr { color: #337e7e; }
/* LiteralStringSymbol */ .chroma .ss { color: #fc3; }
/* LiteralStringOther */ .chroma .sx { color: #c30; }
/* TextWhitespace */ .chroma .w { color: #bbb; }
.chroma {
.language-bash,
.language-sh {
&::before {
color: #009;
content: "$ ";
user-select: none;
}
// This is just to work around a Chroma bug;
// should be removed when fixed upstream
.m {
color: inherit;
}
}
.language-powershell::before {
color: #009;
content: "PM> ";
user-select: none;
}
}

View File

@ -0,0 +1,54 @@
// stylelint-disable selector-max-combinators, selector-max-type, selector-max-compound-selectors
//
// Right side table of contents
//
.bd-toc {
@supports (position: sticky) {
position: sticky;
top: 4rem;
height: subtract(100vh, 4rem);
overflow-y: auto;
}
order: 2;
padding-top: 1.5rem;
padding-bottom: 1.5rem;
@include font-size(.875rem);
nav {
padding-left: 0;
border-left: 1px solid #eee;
ul {
padding-left: 0;
ul {
padding-left: 1rem;
}
}
a code {
font: inherit;
}
li {
display: block;
ul li ul {
padding-left: 1rem;
}
a {
display: block;
padding: .125rem 1.5rem;
color: #77757a;
&:hover {
color: $blue;
text-decoration: none;
}
}
}
}
}

View File

@ -24,9 +24,9 @@
// Happy Bootstrapping!
// Load Bootstrap variables and mixins
@import "../../../../../scss/functions";
@import "../../../../../scss/variables";
@import "../../../../../scss/mixins";
@import "../../../scss/functions";
@import "../../../scss/variables";
@import "../../../scss/mixins";
// Load docs components
@import "variables";
@ -36,6 +36,7 @@
@import "content";
@import "skippy";
@import "sidebar";
@import "toc";
@import "footer";
@import "component-examples";
@import "buttons";

View File

@ -0,0 +1,5 @@
---
layout: redirect
sitemap_exclude: true
redirect: "/docs/4.5/getting-started/introduction/"
---

View File

@ -14,10 +14,10 @@ Use either the Bootstrap mark (a capital **B**) or the standard logo (just **Boo
<div class="bd-brand-logos">
<div class="bd-brand-item">
<img class="svg" src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/brand/bootstrap-solid.svg" alt="Bootstrap" width="144" height="144" loading="lazy">
<img class="svg" src="/docs/{{< param docs_version >}}/assets/brand/bootstrap-solid.svg" alt="Bootstrap" width="144" height="144" loading="lazy">
</div>
<div class="bd-brand-item inverse">
<img class="svg" src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/brand/bootstrap-outline.svg" alt="Bootstrap" width="144" height="144" loading="lazy">
<img class="svg" src="/docs/{{< param docs_version >}}/assets/brand/bootstrap-outline.svg" alt="Bootstrap" width="144" height="144" loading="lazy">
</div>
</div>
<div class="bd-brand-logos">
@ -35,13 +35,13 @@ Download the Bootstrap mark in one of three styles, each available as an SVG fil
<div class="bd-brand-logos">
<div class="bd-brand-item">
<img class="svg" src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/brand/bootstrap-solid.svg" alt="Bootstrap" width="144" height="144" loading="lazy">
<img class="svg" src="/docs/{{< param docs_version >}}/assets/brand/bootstrap-solid.svg" alt="Bootstrap" width="144" height="144" loading="lazy">
</div>
<div class="bd-brand-item inverse">
<img class="svg" src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/brand/bootstrap-outline.svg" alt="Bootstrap" width="144" height="144" loading="lazy">
<img class="svg" src="/docs/{{< param docs_version >}}/assets/brand/bootstrap-outline.svg" alt="Bootstrap" width="144" height="144" loading="lazy">
</div>
<div class="bd-brand-item inverse">
<img class="svg" src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/brand/bootstrap-punchout.svg" alt="Bootstrap" width="144" height="144" loading="lazy">
<img class="svg" src="/docs/{{< param docs_version >}}/assets/brand/bootstrap-punchout.svg" alt="Bootstrap" width="144" height="144" loading="lazy">
</div>
</div>

View File

@ -5,7 +5,7 @@ description: Commonly asked questions about Bootstrap's open source license.
group: about
---
Bootstrap is released under the MIT license and is copyright {{ site.time | date: "%Y" }} Twitter. Boiled down to smaller chunks, it can be described with the following conditions.
Bootstrap is released under the MIT license and is copyright {{< year >}} Twitter. Boiled down to smaller chunks, it can be described with the following conditions.
#### It requires you to:
@ -31,4 +31,4 @@ Bootstrap is released under the MIT license and is copyright {{ site.time | date
- Include the source of Bootstrap itself, or of any modifications you may have made to it, in any redistribution you may assemble that includes it
- Submit changes that you make to Bootstrap back to the Bootstrap project (though such feedback is encouraged)
The full Bootstrap license is located [in the project repository]({{ site.repo }}/blob/v{{ site.current_version }}/LICENSE) for more information.
The full Bootstrap license is located [in the project repository]({{< param repo >}}/blob/v{{< param current_version >}}/LICENSE) for more information.

View File

@ -3,7 +3,7 @@ layout: docs
title: About
description: Learn more about the team maintaining Bootstrap, how and why the project started, and how to get involved.
group: about
redirect_from:
aliases:
- "/about/"
- "/docs/4.5/about/"
---
@ -18,10 +18,10 @@ Originally created by a designer and a developer at Twitter, Bootstrap has becom
Bootstrap was created at Twitter in mid-2010 by [@mdo](https://twitter.com/mdo) and [@fat](https://twitter.com/fat). Prior to being an open-sourced framework, Bootstrap was known as _Twitter Blueprint_. A few months into development, Twitter held its [first Hack Week](https://blog.twitter.com/engineering/en_us/a/2010/hack-week.html) and the project exploded as developers of all skill levels jumped in without any external guidance. It served as the style guide for internal tools development at the company for over a year before its public release, and continues to do so today.
Originally [released](https://blog.twitter.com/developer/en_us/a/2011/bootstrap-twitter.html) on <time datetime="2011-08-19 11:25">Friday, August 19, 2011</time>, we've since had over [twenty releases]({{ site.repo }}/releases), including two major rewrites with v2 and v3. With Bootstrap 2, we added responsive functionality to the entire framework as an optional stylesheet. Building on that with Bootstrap 3, we rewrote the library once more to make it responsive by default with a mobile first approach.
Originally [released](https://blog.twitter.com/developer/en_us/a/2011/bootstrap-twitter.html) on <time datetime="2011-08-19 11:25">Friday, August 19, 2011</time>, we've since had over [twenty releases]({{< param repo >}}/releases), including two major rewrites with v2 and v3. With Bootstrap 2, we added responsive functionality to the entire framework as an optional stylesheet. Building on that with Bootstrap 3, we rewrote the library once more to make it responsive by default with a mobile first approach.
With Bootstrap 4, we once again rewrote the project to account for two key architectural changes: a migration to Sass and the move to CSS's flexbox. Our intention is to help in a small way to move the web development community forward by pushing for newer CSS properties, fewer dependencies, and new technologies across more modern browsers.
## Get involved
Get involved with Bootstrap development by [opening an issue]({{ site.repo }}/issues/new) or submitting a pull request. Read our [contributing guidelines]({{ site.repo }}/blob/v{{ site.current_version }}/.github/CONTRIBUTING.md) for information on how we develop.
Get involved with Bootstrap development by [opening an issue]({{< param repo >}}/issues/new) 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.

View File

@ -0,0 +1,23 @@
---
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 mr-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) 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.

View File

@ -7,11 +7,13 @@ 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>
{% for language in site.data.translations %}
<li><a href="{{ language.url }}" hreflang="{{ language.code }}">{{ language.description }} ({{ language.name }})</a></li>
{% endfor %}
{{ range .Site.Data.translations -}}
<li><a href="{{ .url }}" hreflang="{{ .code }}">{{ .description }} ({{ .name }})</a></li>
{{ end -}}
</ul>
{{< /translations.inline >}}
**We don't help organize or host translations, we just link to them.**

View File

@ -2,19 +2,18 @@
layout: docs
title: Wall of browser bugs
group: browser-bugs
redirect_from: "/browser-bugs/"
aliases: "/browser-bugs/"
---
{% capture callout %}
{{< callout danger >}}
##### Outdated content
This page is outdated and is no longer applicable to the latest versions of Bootstrap. It's here purely for historical purposes now and will be removed in our next major release.
{% endcapture %}
{% include callout.html content=callout type="danger" %}
{{< /callout >}}
Bootstrap currently works around several outstanding browser bugs in major browsers to deliver the best cross-browser experience possible. Some bugs, like those listed below, cannot be solved by us.
We publicly list browser bugs that are impacting us here, in the hopes of expediting the process of fixing them. For information on Bootstrap's browser compatibility, [see our browser compatibility docs]({{ site.baseurl }}/docs/{{ site.docs_version }}/getting-started/browsers-devices/#supported-browsers).
We publicly list browser bugs that are impacting us here, in the hopes of expediting the process of fixing them. For information on Bootstrap's browser compatibility, [see our browser compatibility docs]({{< docsref "/getting-started/browsers-devices#supported-browsers" >}}).
See also:
@ -23,26 +22,31 @@ See also:
* [WebKit bug 159753: [meta] Issues affecting Bootstrap](https://bugs.webkit.org/show_bug.cgi?id=159753)
* [jQuery's browser bug workarounds](https://docs.google.com/document/d/1LPaPA30bLUB_publLIMF0RlhdnPx_ePXm7oW02iiT6o)
{{< bug.inline >}}
{{- $type := .Get "type" | default "bug" -}}
{{- $data := .Get "data" | default "browser-bugs" -}}
<table class="bd-browser-bugs table table-bordered table-hover">
<thead>
<tr>
<th>Browser(s)</th>
<th>Summary of bug</th>
<th>Upstream bug(s)</th>
<th>Summary of {{ $type }}</th>
<th>Upstream issue(s)</th>
<th>Bootstrap issue(s)</th>
</tr>
</thead>
<tbody>
{% for bug in site.data.browser-bugs %}
{{- range (index $.Site.Data $data) }}
<tr>
<td>{{ bug.browser }}</td>
<td>{{ bug.summary | markdownify }}</td>
<td>{% include bugify.html content=bug.upstream_bug %}</td>
<td>{% include bugify.html content=bug.origin %}</td>
<td>{{ .browser | chomp }}</td>
<td>{{ .summary | markdownify }}</td>
<td>{{ partial "bugify" .upstream_bug }}</td>
<td>{{ partial "bugify" .origin }}</td>
</tr>
{% endfor %}
{{- end }}
</tbody>
</table>
{{< /bug.inline >}}
# Most wanted features
@ -50,23 +54,4 @@ There are several features specified in Web standards which would allow us to ma
We publicly list these "most wanted" feature requests here, in the hopes of expediting the process of getting them implemented.
<table class="bd-browser-bugs table table-bordered table-hover">
<thead>
<tr>
<th>Browser(s)</th>
<th>Summary of feature</th>
<th>Upstream issue(s)</th>
<th>Bootstrap issue(s)</th>
</tr>
</thead>
<tbody>
{% for feat in site.data.browser-features %}
<tr>
<td>{{ feat.browser }}</td>
<td>{{ feat.summary | markdownify }}</td>
<td>{% include bugify.html content=feat.upstream_bug %}</td>
<td>{% include bugify.html content=feat.origin %}</td>
</tr>
{% endfor %}
</tbody>
</table>
{{< bug.inline data="browser-features" type="feature" />}}

View File

@ -3,7 +3,7 @@ layout: docs
title: Alerts
description: Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages.
group: components
redirect_from:
aliases:
- "/components/"
- "/docs/4.5/components/"
toc: true
@ -13,41 +13,44 @@ toc: true
Alerts are available for any length of text, as well as an optional dismiss button. For proper styling, use one of the eight **required** contextual classes (e.g., `.alert-success`). For inline dismissal, use the [alerts jQuery plugin](#dismissing).
{% capture example %}
{% for color in site.data.theme-colors %}
<div class="alert alert-{{ color.name }}" role="alert">
A simple {{ color.name }} alert—check it out!
</div>{% endfor %}
{% endcapture %}
{% include example.html content=example %}
{{< 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 >}}
{% include callout-warning-color-assistive-technologies.md %}
{{< callout warning >}}
{{< partial "callout-warning-color-assistive-technologies.md" >}}
{{< /callout >}}
### Link color
Use the `.alert-link` utility class to quickly provide matching colored links within any alert.
{% capture example %}
{% for color in site.data.theme-colors %}
<div class="alert alert-{{ color.name }}" role="alert">
A simple {{ color.name }} alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
</div>{% endfor %}
{% endcapture %}
{% include example.html content=example %}
{{< 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.
{% capture example %}
{{< 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>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Dismissing
@ -55,22 +58,21 @@ Alerts can also contain additional HTML elements like headings, paragraphs and d
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.
- If you're building our JavaScript from source, it [requires `util.js`]({{ site.baseurl }}/docs/{{ site.docs_version }}/getting-started/javascript/#util). The compiled version includes this.
- If you're building our JavaScript from source, it [requires `util.js`]({{< docsref "/getting-started/javascript#util" >}}). The compiled version includes this.
- Add a dismiss button and the `.alert-dismissible` class, which adds extra padding to the right of the alert and positions the `.close` button.
- On the dismiss button, add the `data-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:
{% capture example %}
{{< 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="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## JavaScript behavior
@ -78,17 +80,17 @@ You can see this in action with a live demo:
Enable dismissal of an alert via JavaScript:
{% highlight js %}
```js
$('.alert').alert()
{% endhighlight %}
```
Or with `data` attributes on a button **within the alert**, as demonstrated above:
{% highlight html %}
```html
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
{% endhighlight %}
```
Note that closing an alert will remove it from the DOM.
@ -100,7 +102,9 @@ Note that closing an alert will remove it from the DOM.
| `$().alert('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. |
| `$().alert('dispose')` | Destroys an element's alert. |
{% highlight js %}$('.alert').alert('close'){% endhighlight %}
```js
$('.alert').alert('close')
```
### Events
@ -111,8 +115,8 @@ Bootstrap's alert plugin exposes a few events for hooking into alert functionali
| `close.bs.alert` | This event fires immediately when the `close` instance method is called. |
| `closed.bs.alert` | This event is fired when the alert has been closed (will wait for CSS transitions to complete). |
{% highlight js %}
```js
$('#myAlert').on('closed.bs.alert', function () {
// do something...
})
{% endhighlight %}
```

View File

@ -10,65 +10,67 @@ toc: true
Badges scale to match the size of the immediate parent element by using relative font sizing and `em` units.
{% capture example %}
{{< example >}}
<h1>Example heading <span class="badge badge-secondary">New</span></h1>
<h2>Example heading <span class="badge badge-secondary">New</span></h2>
<h3>Example heading <span class="badge badge-secondary">New</span></h3>
<h4>Example heading <span class="badge badge-secondary">New</span></h4>
<h5>Example heading <span class="badge badge-secondary">New</span></h5>
<h6>Example heading <span class="badge badge-secondary">New</span></h6>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Badges can be used as part of links or buttons to provide a counter.
{% capture example %}
{{< example >}}
<button type="button" class="btn btn-primary">
Notifications <span class="badge badge-light">4</span>
</button>
{% endcapture %}
{% include example.html content=example %}
{{< /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.
{% capture example %}
{{< example >}}
<button type="button" class="btn btn-primary">
Profile <span class="badge badge-light">9</span>
<span class="sr-only">unread messages</span>
</button>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Contextual variations
Add any of the below mentioned modifier classes to change the appearance of a badge.
{% capture example %}
{% for color in site.data.theme-colors %}
<span class="badge badge-{{ color.name }}">{{ color.name | capitalize }}</span>{% endfor %}
{% endcapture %}
{% include example.html content=example %}
{{< example >}}
{{< badge.inline >}}
{{- range (index $.Site.Data "theme-colors") }}
<span class="badge badge-{{ .name }}">{{ .name | title }}</span>{{- end -}}
{{< /badge.inline >}}
{{< /example >}}
{% include callout-warning-color-assistive-technologies.md %}
{{< callout warning >}}
{{< partial "callout-warning-color-assistive-technologies.md" >}}
{{< /callout >}}
## Pill badges
Use the `.badge-pill` modifier class to make badges more rounded (with a larger `border-radius` and additional horizontal `padding`). Useful if you miss the badges from v3.
{% capture example %}
{% for color in site.data.theme-colors %}
<span class="badge badge-pill badge-{{ color.name }}">{{ color.name | capitalize }}</span>{% endfor %}
{% endcapture %}
{% include example.html content=example %}
{{< example >}}
{{< badge.inline >}}
{{- range (index $.Site.Data "theme-colors") }}
<span class="badge badge-pill badge-{{ .name }}">{{ .name | title }}</span>{{- end -}}
{{< /badge.inline >}}
{{< /example >}}
## Links
Using the contextual `.badge-*` classes on an `<a>` element quickly provide _actionable_ badges with hover and focus states.
{% capture example %}
{% for color in site.data.theme-colors %}
<a href="#" class="badge badge-{{ color.name }}">{{ color.name | capitalize }}</a>{% endfor %}
{% endcapture %}
{% include example.html content=example %}
{{< example >}}
{{< badge.inline >}}
{{- range (index $.Site.Data "theme-colors") }}
<a href="#" class="badge badge-{{ .name }}">{{ .name | title }}</a>{{- end -}}
{{< /badge.inline >}}
{{< /example >}}

View File

@ -7,7 +7,7 @@ group: components
## Example
{% capture example %}
{{< example >}}
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item active" aria-current="page">Home</li>
@ -28,8 +28,7 @@ group: components
<li class="breadcrumb-item active" aria-current="page">Data</li>
</ol>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Changing the separator

View File

@ -8,31 +8,29 @@ toc: true
## Basic example
Wrap a series of buttons with `.btn` in `.btn-group`. Add on optional JavaScript radio and checkbox style behavior with [our buttons plugin]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/buttons/#button-plugin).
Wrap a series of buttons with `.btn` in `.btn-group`. Add on optional JavaScript radio and checkbox style behavior with [our buttons plugin]({{< docsref "/components/buttons#button-plugin" >}}).
{% capture example %}
{{< example >}}
<div class="btn-group" role="group" aria-label="Basic example">
<button type="button" class="btn btn-secondary">Left</button>
<button type="button" class="btn btn-secondary">Middle</button>
<button type="button" class="btn btn-secondary">Right</button>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture callout %}
{{< callout warning >}}
##### Ensure correct `role` and provide a label
In order for assistive technologies (such as screen readers) to convey that a series of buttons is grouped, an appropriate `role` attribute needs to be provided. For button groups, this would be `role="group"`, while toolbars should have a `role="toolbar"`.
In addition, groups and toolbars should be given an explicit label, as most assistive technologies will otherwise not announce them, despite the presence of the correct role attribute. In the examples provided here, we use `aria-label`, but alternatives such as `aria-labelledby` can also be used.
{% endcapture %}
{% include callout.html content=callout type="warning" %}
{{< /callout >}}
## 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.
{% capture example %}
{{< example >}}
<div class="btn-toolbar" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group mr-2" role="group" aria-label="First group">
<button type="button" class="btn btn-secondary">1</button>
@ -49,12 +47,11 @@ Combine sets of button groups into button toolbars for more complex components.
<button type="button" class="btn btn-secondary">8</button>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /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.
{% capture example %}
{{< example >}}
<div class="btn-toolbar mb-3" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group mr-2" role="group" aria-label="First group">
<button type="button" class="btn btn-secondary">1</button>
@ -84,8 +81,7 @@ Feel free to mix input groups with button groups in your toolbars. Similar to th
<input type="text" class="form-control" placeholder="Input group example" aria-label="Input group example" aria-describedby="btnGroupAddon2">
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Sizing
@ -111,17 +107,17 @@ Instead of applying button sizing classes to every button in a group, just add `
</div>
</div>
{% highlight html %}
```html
<div class="btn-group btn-group-lg" role="group" aria-label="...">...</div>
<div class="btn-group" role="group" aria-label="...">...</div>
<div class="btn-group btn-group-sm" role="group" aria-label="...">...</div>
{% endhighlight %}
```
## Nesting
Place a `.btn-group` within another `.btn-group` when you want dropdown menus mixed with a series of buttons.
{% capture example %}
{{< example >}}
<div class="btn-group" role="group" aria-label="Button group with nested dropdown">
<button type="button" class="btn btn-secondary">1</button>
<button type="button" class="btn btn-secondary">2</button>
@ -136,8 +132,7 @@ Place a `.btn-group` within another `.btn-group` when you want dropdown menus mi
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Vertical variation
@ -200,8 +195,8 @@ Make a set of buttons appear vertically stacked rather than horizontally. **Spli
</div>
</div>
{% highlight html %}
```html
<div class="btn-group-vertical">
...
</div>
{% endhighlight %}
```

View File

@ -10,15 +10,19 @@ toc: true
Bootstrap includes several predefined button styles, each serving its own semantic purpose, with a few extras thrown in for more control.
{% capture example %}
{% for color in site.data.theme-colors %}
<button type="button" class="btn btn-{{ color.name }}">{{ color.name | capitalize }}</button>{% endfor %}
{{< 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>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% include callout-warning-color-assistive-technologies.md %}
{{< callout warning >}}
{{< partial "callout-warning-color-assistive-technologies.md" >}}
{{< /callout >}}
## Disable text wrapping
@ -30,73 +34,68 @@ The `.btn` classes are designed to be used with the `<button>` element. However,
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.
{% capture example %}
{{< 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">
{% endcapture %}
{% include example.html content=example %}
{{< /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.
{% capture example %}
{% for color in site.data.theme-colors %}
<button type="button" class="btn btn-outline-{{ color.name }}">{{ color.name | capitalize }}</button>{% endfor %}
{% endcapture %}
{% include example.html content=example %}
{{< example >}}
{{< buttons.inline >}}
{{- range (index $.Site.Data "theme-colors") }}
<button type="button" class="btn btn-outline-{{ .name }}">{{ .name | title }}</button>
{{- end -}}
{{< /buttons.inline >}}
{{< /example >}}
{% capture callout %}
{{< 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.
{% endcapture %}
{% include callout.html content=callout type="info" %}
{{< /callout >}}
## Sizes
Fancy larger or smaller buttons? Add `.btn-lg` or `.btn-sm` for additional sizes.
{% capture example %}
{{< 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>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture 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>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Create block level buttons—those that span the full width of a parent—by adding `.btn-block`.
{% capture example %}
{{< example >}}
<button type="button" class="btn btn-primary btn-lg btn-block">Block level button</button>
<button type="button" class="btn btn-secondary btn-lg btn-block">Block level button</button>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Active state
Buttons will appear pressed (with a darker background, darker border, and inset shadow) when active. **There's no need to add a class to `<button>`s as they use a pseudo-class**. However, you can still force the same active appearance with `.active` (and include the <code>aria-pressed="true"</code> attribute) should you need to replicate the state programmatically.
{% capture example %}
{{< example >}}
<a href="#" class="btn btn-primary btn-lg active" role="button" aria-pressed="true">Primary link</a>
<a href="#" class="btn btn-secondary btn-lg active" role="button" aria-pressed="true">Link</a>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Disabled state
Make buttons look inactive by adding the `disabled` boolean attribute to any `<button>` element.
{% capture example %}
{{< example >}}
<button type="button" class="btn btn-lg btn-primary" disabled>Primary button</button>
<button type="button" class="btn btn-secondary btn-lg" disabled>Button</button>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Disabled buttons using the `<a>` element behave a bit different:
@ -104,18 +103,16 @@ Disabled buttons using the `<a>` element behave a bit different:
- Some future-friendly styles are included to disable all `pointer-events` on anchor buttons. In browsers which support that property, you won't see the disabled cursor at all.
- Disabled buttons should include the `aria-disabled="true"` attribute to indicate the state of the element to assistive technologies.
{% capture example %}
{{< example >}}
<a href="#" class="btn btn-primary btn-lg disabled" tabindex="-1" role="button" aria-disabled="true">Primary link</a>
<a href="#" class="btn btn-secondary btn-lg disabled" tabindex="-1" role="button" aria-disabled="true">Link</a>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture callout %}
{{< callout warning >}}
##### Link functionality caveat
The `.disabled` class uses `pointer-events: none` to try to disable the link functionality of `<a>`s, but that CSS property is not yet standardized. 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, add a `tabindex="-1"` attribute on these links (to prevent them from receiving keyboard focus) and use custom JavaScript to disable their functionality.
{% endcapture %}
{% include callout.html content=callout type="warning" %}
{{< /callout >}}
## Button plugin
@ -125,12 +122,11 @@ Do more with buttons. Control button states or create groups of buttons for more
Add `data-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 the `<button>`.
{% capture example %}
{{< example >}}
<button type="button" class="btn btn-primary" data-toggle="button" aria-pressed="false">
Single toggle
</button>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Checkbox and radio buttons
@ -140,16 +136,15 @@ The checked state for these buttons is **only updated via `click` event** on the
Note that pre-checked buttons require you to manually add the `.active` class to the input's `<label>`.
{% capture example %}
{{< example >}}
<div class="btn-group-toggle" data-toggle="buttons">
<label class="btn btn-secondary active">
<input type="checkbox" checked> Checked
</label>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture example %}
{{< example >}}
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-secondary active">
<input type="radio" name="options" id="option1" checked> Active
@ -161,8 +156,7 @@ Note that pre-checked buttons require you to manually add the `.active` class to
<input type="radio" name="options" id="option3"> Radio
</label>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Methods

View File

@ -12,21 +12,20 @@ A **card** is a flexible and extensible content container. It includes options f
## 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]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/spacing/) as needed.
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).
{% capture example %}
{{< example >}}
<div class="card" style="width: 18rem;">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Content types
@ -36,14 +35,13 @@ Cards support a wide variety of content, including images, text, list groups, li
The building block of a card is the `.card-body`. Use it whenever you need a padded section within a card.
{% capture example %}
{{< example >}}
<div class="card">
<div class="card-body">
This is some text within a card body.
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Titles, text, and links
@ -51,7 +49,7 @@ Card titles are used by adding `.card-title` to a `<h*>` tag. In the same way, l
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.
{% capture example %}
{{< example >}}
<div class="card" style="width: 18rem;">
<div class="card-body">
<h5 class="card-title">Card title</h5>
@ -61,28 +59,26 @@ Subtitles are used by adding a `.card-subtitle` to a `<h*>` tag. If the `.card-t
<a href="#" class="card-link">Another link</a>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Images
`.card-img-top` places an image to the top of the card. With `.card-text`, text can be added to the card. Text within `.card-text` can also be styled with the standard HTML tags.
{% capture example %}
{{< example >}}
<div class="card" style="width: 18rem;">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### List groups
Create lists of content in a card with a flush list group.
{% capture example %}
{{< example >}}
<div class="card" style="width: 18rem;">
<ul class="list-group list-group-flush">
<li class="list-group-item">Cras justo odio</li>
@ -90,10 +86,9 @@ Create lists of content in a card with a flush list group.
<li class="list-group-item">Vestibulum at eros</li>
</ul>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture example %}
{{< example >}}
<div class="card" style="width: 18rem;">
<div class="card-header">
Featured
@ -104,10 +99,9 @@ Create lists of content in a card with a flush list group.
<li class="list-group-item">Vestibulum at eros</li>
</ul>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture example %}
{{< example >}}
<div class="card" style="width: 18rem;">
<ul class="list-group list-group-flush">
<li class="list-group-item">Cras justo odio</li>
@ -118,16 +112,15 @@ Create lists of content in a card with a flush list group.
Card footer
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /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.
{% capture example %}
{{< example >}}
<div class="card" style="width: 18rem;">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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>
@ -142,14 +135,13 @@ Mix and match multiple content types to create the card you need, or throw every
<a href="#" class="card-link">Another link</a>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Header and footer
Add an optional header and/or footer within a card.
{% capture example %}
{{< example >}}
<div class="card">
<div class="card-header">
Featured
@ -160,12 +152,11 @@ Add an optional header and/or footer within a card.
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Card headers can be styled by adding `.card-header` to `<h*>` elements.
{% capture example %}
{{< example >}}
<div class="card">
<h5 class="card-header">Featured</h5>
<div class="card-body">
@ -174,10 +165,9 @@ Card headers can be styled by adding `.card-header` to `<h*>` elements.
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture example %}
{{< example >}}
<div class="card">
<div class="card-header">
Quote
@ -189,10 +179,9 @@ Card headers can be styled by adding `.card-header` to `<h*>` elements.
</blockquote>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture example %}
{{< example >}}
<div class="card text-center">
<div class="card-header">
Featured
@ -206,8 +195,7 @@ Card headers can be styled by adding `.card-header` to `<h*>` elements.
2 days ago
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Sizing
@ -217,7 +205,7 @@ Cards assume no specific `width` to start, so they'll be 100% wide unless otherw
Using the grid, wrap cards in columns and rows as needed.
{% capture example %}
{{< example >}}
<div class="row">
<div class="col-sm-6">
<div class="card">
@ -238,14 +226,13 @@ Using the grid, wrap cards in columns and rows as needed.
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Using utilities
Use our handful of [available sizing utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/sizing/) to quickly set a card's width.
Use our handful of [available sizing utilities]({{< docsref "/utilities/sizing" >}}) to quickly set a card's width.
{% capture example %}
{{< example >}}
<div class="card w-75">
<div class="card-body">
<h5 class="card-title">Card title</h5>
@ -261,14 +248,13 @@ Use our handful of [available sizing utilities]({{ site.baseurl }}/docs/{{ site.
<a href="#" class="btn btn-primary">Button</a>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Using custom CSS
Use custom CSS in your stylesheets or as inline styles to set a width.
{% capture example %}
{{< example >}}
<div class="card" style="width: 18rem;">
<div class="card-body">
<h5 class="card-title">Special title treatment</h5>
@ -276,14 +262,13 @@ Use custom CSS in your stylesheets or as inline styles to set a width.
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Text alignment
You can quickly change the text alignment of any card—in its entirety or specific parts—with our [text align classes]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/text/#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" >}}).
{% capture example %}
{{< example >}}
<div class="card" style="width: 18rem;">
<div class="card-body">
<h5 class="card-title">Special title treatment</h5>
@ -307,14 +292,13 @@ You can quickly change the text alignment of any card—in its entirety or speci
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Navigation
Add some navigation to a card's header (or block) with Bootstrap's [nav components]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/navs/).
Add some navigation to a card's header (or block) with Bootstrap's [nav components]({{< docsref "/components/navs" >}}).
{% capture example %}
{{< example >}}
<div class="card text-center">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs">
@ -335,10 +319,9 @@ Add some navigation to a card's header (or block) with Bootstrap's [nav componen
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture example %}
{{< example >}}
<div class="card text-center">
<div class="card-header">
<ul class="nav nav-pills card-header-pills">
@ -359,8 +342,7 @@ Add some navigation to a card's header (or block) with Bootstrap's [nav componen
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Images
@ -372,7 +354,7 @@ Similar to headers and footers, cards can include top and bottom "image caps"—
<div class="bd-example">
<div class="card mb-3">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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>
@ -385,11 +367,11 @@ Similar to headers and footers, cards can include top and bottom "image caps"—
<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-muted">Last updated 3 mins ago</small></p>
</div>
{% include icons/placeholder.svg width="100%" height="180" class="card-img-bottom" text="Image cap" %}
{{< placeholder width="100%" height="180" class="card-img-bottom" text="Image cap" >}}
</div>
</div>
{% highlight html %}
```html
<div class="card mb-3">
<img src="..." class="card-img-top" alt="...">
<div class="card-body">
@ -406,38 +388,36 @@ Similar to headers and footers, cards can include top and bottom "image caps"—
</div>
<img src="..." class="card-img-bottom" alt="...">
</div>
{% endhighlight %}
```
### 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.
{% capture example %}
{{< example >}}
<div class="card bg-dark text-white">
{% include icons/placeholder.svg width="100%" height="270" class="bd-placeholder-img-lg card-img" text="Card image" %}
{{< 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">Last updated 3 mins ago</p>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture callout %}
{{< 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.
{% endcapture %}
{% include callout.html content=callout type="info" %}
{{< /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 `.no-gutters` and use `.col-md-*` classes to make the card horizontal at the `md` breakpoint. Further adjustments may be needed depending on your card content.
{% capture example %}
{{< example >}}
<div class="card mb-3" style="max-width: 540px;">
<div class="row no-gutters">
<div class="col-md-4">
{% include icons/placeholder.svg width="100%" height="250" class="" text="Image" %}
{{< placeholder width="100%" height="250" class="" text="Image" >}}
</div>
<div class="col-md-8">
<div class="card-body">
@ -448,8 +428,7 @@ Using a combination of grid and utility classes, cards can be made horizontal in
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Card styles
@ -457,43 +436,49 @@ Cards include various options for customizing their backgrounds, borders, and co
### Background and color
Use [text and background utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/colors/) to change the appearance of a card.
Use [text and background utilities]({{< docsref "/utilities/colors" >}}) to change the appearance of a card.
{% capture example %}
{% for color in site.data.theme-colors %}
<div class="card{% unless color.name == "light" %} text-white{% endunless %} bg-{{ color.name }} mb-3" style="max-width: 18rem;">
{{< example >}}
{{< card.inline >}}
{{- range (index $.Site.Data "theme-colors") }}
<div class="card{{ if not (eq .name "light") }} text-white{{ end }} bg-{{ .name }} mb-3" style="max-width: 18rem;">
<div class="card-header">Header</div>
<div class="card-body">
<h5 class="card-title">{{ color.name | capitalize }} card title</h5>
<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>{% endfor %}
{% endcapture %}
{% include example.html content=example %}
</div>
{{- end -}}
{{< /card.inline >}}
{{< /example >}}
{% include callout-warning-color-assistive-technologies.md %}
{{< callout warning >}}
{{< partial "callout-warning-color-assistive-technologies.md" >}}
{{< /callout >}}
### Border
Use [border utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/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.
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.
{% capture example %}
{% for color in site.data.theme-colors %}
<div class="card border-{{ color.name }} mb-3" style="max-width: 18rem;">
{{< 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{% unless color.name == "light" %} text-{{ color.name }}{% endunless %}">
<h5 class="card-title">{{ color.name | capitalize }} card title</h5>
<div class="card-body{{ if not (eq .name "light") }} 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>{% endfor %}
{% endcapture %}
{% include example.html content=example %}
</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`.
{% capture example %}
{{< 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">
@ -502,8 +487,7 @@ You can also change the borders on the card header and footer as needed, and eve
</div>
<div class="card-footer bg-transparent border-success">Footer</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Card layout
@ -513,10 +497,10 @@ In addition to styling the content within cards, Bootstrap includes a few option
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.
{% capture example %}
{{< example >}}
<div class="card-group">
<div class="card">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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>
@ -524,7 +508,7 @@ Use card groups to render cards as a single, attached element with equal width a
</div>
</div>
<div class="card">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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>
@ -532,7 +516,7 @@ Use card groups to render cards as a single, attached element with equal width a
</div>
</div>
<div class="card">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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>
@ -540,15 +524,14 @@ Use card groups to render cards as a single, attached element with equal width a
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
When using card groups with footers, their content will automatically line up.
{% capture example %}
{{< example >}}
<div class="card-group">
<div class="card">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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>
@ -558,7 +541,7 @@ When using card groups with footers, their content will automatically line up.
</div>
</div>
<div class="card">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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>
@ -568,7 +551,7 @@ When using card groups with footers, their content will automatically line up.
</div>
</div>
<div class="card">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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>
@ -578,17 +561,16 @@ When using card groups with footers, their content will automatically line up.
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Card decks
Need a set of equal width and height cards that aren't attached to one another? Use card decks.
{% capture example %}
{{< example >}}
<div class="card-deck">
<div class="card">
{% include icons/placeholder.svg width="100%" height="200" class="card-img-top" text="Image cap" %}
{{< placeholder width="100%" height="200" 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>
@ -596,7 +578,7 @@ Need a set of equal width and height cards that aren't attached to one another?
</div>
</div>
<div class="card">
{% include icons/placeholder.svg width="100%" height="200" class="card-img-top" text="Image cap" %}
{{< placeholder width="100%" height="200" 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>
@ -604,7 +586,7 @@ Need a set of equal width and height cards that aren't attached to one another?
</div>
</div>
<div class="card">
{% include icons/placeholder.svg width="100%" height="200" class="card-img-top" text="Image cap" %}
{{< placeholder width="100%" height="200" 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>
@ -612,15 +594,14 @@ Need a set of equal width and height cards that aren't attached to one another?
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Just like with card groups, card footers in decks will automatically line up.
{% capture example %}
{{< example >}}
<div class="card-deck">
<div class="card">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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>
@ -630,7 +611,7 @@ Just like with card groups, card footers in decks will automatically line up.
</div>
</div>
<div class="card">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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>
@ -640,7 +621,7 @@ Just like with card groups, card footers in decks will automatically line up.
</div>
</div>
<div class="card">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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>
@ -650,18 +631,17 @@ Just like with card groups, card footers in decks will automatically line up.
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Grid cards
Use the Bootstrap grid system and its [`.row-cols` classes]({{ site.baseurl }}/docs/{{ site.docs_version }}/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.
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.
{% capture example %}
{{< example >}}
<div class="row row-cols-1 row-cols-md-2">
<div class="col mb-4">
<div class="card">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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 longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
@ -670,7 +650,7 @@ Use the Bootstrap grid system and its [`.row-cols` classes]({{ site.baseurl }}/d
</div>
<div class="col mb-4">
<div class="card">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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 longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
@ -679,7 +659,7 @@ Use the Bootstrap grid system and its [`.row-cols` classes]({{ site.baseurl }}/d
</div>
<div class="col mb-4">
<div class="card">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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 longer card with supporting text below as a natural lead-in to additional content.</p>
@ -688,7 +668,7 @@ Use the Bootstrap grid system and its [`.row-cols` classes]({{ site.baseurl }}/d
</div>
<div class="col mb-4">
<div class="card">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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 longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
@ -696,16 +676,15 @@ Use the Bootstrap grid system and its [`.row-cols` classes]({{ site.baseurl }}/d
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Change it to `.row-cols-3` and you'll see the fourth card wrap.
{% capture example %}
{{< example >}}
<div class="row row-cols-1 row-cols-md-3">
<div class="col mb-4">
<div class="card">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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 longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
@ -714,7 +693,7 @@ Change it to `.row-cols-3` and you'll see the fourth card wrap.
</div>
<div class="col mb-4">
<div class="card">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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 longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
@ -723,7 +702,7 @@ Change it to `.row-cols-3` and you'll see the fourth card wrap.
</div>
<div class="col mb-4">
<div class="card">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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 longer card with supporting text below as a natural lead-in to additional content.</p>
@ -732,7 +711,7 @@ Change it to `.row-cols-3` and you'll see the fourth card wrap.
</div>
<div class="col mb-4">
<div class="card">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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 longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
@ -740,16 +719,15 @@ Change it to `.row-cols-3` and you'll see the fourth card wrap.
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /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.
{% capture example %}
{{< example >}}
<div class="row row-cols-1 row-cols-md-3">
<div class="col mb-4">
<div class="card h-100">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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 longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
@ -758,7 +736,7 @@ When you need equal height, add `.h-100` to the cards. If you want equal heights
</div>
<div class="col mb-4">
<div class="card h-100">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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 short card.</p>
@ -767,7 +745,7 @@ When you need equal height, add `.h-100` to the cards. If you want equal heights
</div>
<div class="col mb-4">
<div class="card h-100">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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 longer card with supporting text below as a natural lead-in to additional content.</p>
@ -776,7 +754,7 @@ When you need equal height, add `.h-100` to the cards. If you want equal heights
</div>
<div class="col mb-4">
<div class="card h-100">
{% include icons/placeholder.svg width="100%" height="180" class="card-img-top" text="Image cap" %}
{{< 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 longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
@ -784,8 +762,7 @@ When you need equal height, add `.h-100` to the cards. If you want equal heights
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Card columns
@ -793,10 +770,10 @@ Cards can be organized into [Masonry](https://masonry.desandro.com/)-like column
**Heads up!** Your mileage with card columns may vary. To prevent cards breaking across columns, we must set them to `display: inline-block` as `column-break-inside: avoid` isn't a bulletproof solution yet.
{% capture example %}
{{< example >}}
<div class="card-columns">
<div class="card">
{% include icons/placeholder.svg width="100%" height="160" class="card-img-top" text="Image cap" %}
{{< placeholder width="100%" height="160" class="card-img-top" text="Image cap" >}}
<div class="card-body">
<h5 class="card-title">Card title that wraps to a new line</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>
@ -813,7 +790,7 @@ Cards can be organized into [Masonry](https://masonry.desandro.com/)-like column
</blockquote>
</div>
<div class="card">
{% include icons/placeholder.svg width="100%" height="160" class="card-img-top" text="Image cap" %}
{{< placeholder width="100%" height="160" 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>
@ -838,7 +815,7 @@ Cards can be organized into [Masonry](https://masonry.desandro.com/)-like column
</div>
</div>
<div class="card">
{% include icons/placeholder.svg width="100%" height="260" class="card-img" text="Card image" %}
{{< placeholder width="100%" height="260" class="card-img" text="Card image" >}}
</div>
<div class="card p-3 text-right">
<blockquote class="blockquote mb-0">
@ -858,12 +835,11 @@ Cards can be organized into [Masonry](https://masonry.desandro.com/)-like column
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Card columns can also be extended and customized with some additional code. Shown below is an extension of the `.card-columns` class using the same CSS we use—CSS columns— to generate a set of responsive tiers for changing the number of columns.
{% highlight scss %}
```scss
.card-columns {
@include media-breakpoint-only(lg) {
column-count: 4;
@ -872,4 +848,4 @@ Card columns can also be extended and customized with some additional code. Show
column-count: 5;
}
}
{% endhighlight %}
```

View File

@ -12,11 +12,13 @@ The carousel is a slideshow for cycling through a series of content, built with
In browsers where the [Page Visibility API](https://www.w3.org/TR/page-visibility/) is supported, the carousel will avoid sliding when the webpage is not visible to the user (such as when the browser tab is inactive, the browser window is minimized, etc.).
{% include callout-info-prefersreducedmotion.md %}
{{< callout info >}}
{{< partial "callout-info-prefersreducedmotion.md" >}}
{{< /callout >}}
Please be aware that nested carousels are not supported, and carousels are generally not compliant with accessibility standards.
Lastly, if you're building our JavaScript from source, it [requires `util.js`]({{ site.baseurl }}/docs/{{ site.docs_version }}/getting-started/javascript/#util).
Lastly, if you're building our JavaScript from source, it [requires `util.js`]({{< docsref "/getting-started/javascript#util" >}}).
## Example
@ -28,38 +30,37 @@ Carousels don't automatically normalize slide dimensions. As such, you may need
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.
{% capture example %}
{{< example >}}
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
{% include icons/placeholder.svg width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" %}
{{< 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">
{% include icons/placeholder.svg width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" %}
{{< 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">
{% include icons/placeholder.svg width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" %}
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### With controls
Adding in the previous and next controls:
{% capture example %}
{{< example >}}
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
{% include icons/placeholder.svg width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" %}
{{< 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">
{% include icons/placeholder.svg width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" %}
{{< 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">
{% include icons/placeholder.svg width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" %}
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
@ -71,14 +72,13 @@ Adding in the previous and next controls:
<span class="sr-only">Next</span>
</a>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### With indicators
You can also add the indicators to the carousel, alongside the controls, too.
{% capture example %}
{{< example >}}
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
@ -87,13 +87,13 @@ You can also add the indicators to the carousel, alongside the controls, too.
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
{% include icons/placeholder.svg width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" %}
{{< 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">
{% include icons/placeholder.svg width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" %}
{{< 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">
{% include icons/placeholder.svg width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" %}
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
@ -105,14 +105,13 @@ You can also add the indicators to the carousel, alongside the controls, too.
<span class="sr-only">Next</span>
</a>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### With captions
Add captions to your slides easily with the `.carousel-caption` element within any `.carousel-item`. They can be easily hidden on smaller viewports, as shown below, with optional [display utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/display/). We hide them initially with `.d-none` and bring them back on medium-sized devices with `.d-md-block`.
Add captions to your slides easily 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`.
{% capture example %}
{{< example >}}
<div id="carouselExampleCaptions" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleCaptions" data-slide-to="0" class="active"></li>
@ -121,21 +120,21 @@ Add captions to your slides easily with the `.carousel-caption` element within a
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
{% include icons/placeholder.svg width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" %}
{{< 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>Nulla vitae elit libero, a pharetra augue mollis interdum.</p>
</div>
</div>
<div class="carousel-item">
{% include icons/placeholder.svg width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" %}
{{< 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>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</div>
<div class="carousel-item">
{% include icons/placeholder.svg width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" %}
{{< 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>Praesent commodo cursus magna, vel scelerisque nisl consectetur.</p>
@ -151,24 +150,23 @@ Add captions to your slides easily with the `.carousel-caption` element within a
<span class="sr-only">Next</span>
</a>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Crossfade
Add `.carousel-fade` to your carousel to animate slides with a fade transition instead of a slide.
{% capture example %}
{{< example >}}
<div id="carouselExampleFade" class="carousel slide carousel-fade" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
{% include icons/placeholder.svg width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" %}
{{< 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">
{% include icons/placeholder.svg width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" %}
{{< 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">
{% include icons/placeholder.svg width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" %}
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleFade" role="button" data-slide="prev">
@ -180,24 +178,23 @@ Add `.carousel-fade` to your carousel to animate slides with a fade transition i
<span class="sr-only">Next</span>
</a>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Individual `.carousel-item` interval
Add `data-interval=""` to a `.carousel-item` to change the amount of time to delay between automatically cycling to the next item.
{% capture example %}
{{< example >}}
<div id="carouselExampleInterval" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active" data-interval="10000">
{% include icons/placeholder.svg width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" %}
{{< 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-interval="2000">
{% include icons/placeholder.svg width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" %}
{{< 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">
{% include icons/placeholder.svg width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" %}
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleInterval" role="button" data-slide="prev">
@ -209,8 +206,7 @@ Add `data-interval=""` to a `.carousel-item` to change the amount of time to del
<span class="sr-only">Next</span>
</a>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Usage
@ -225,9 +221,9 @@ The `data-ride="carousel"` attribute is used to mark a carousel as animating sta
Call carousel manually with:
{% highlight js %}
```js
$('.carousel').carousel()
{% endhighlight %}
```
### Options
@ -285,17 +281,19 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap
### Methods
{% include callout-danger-async-methods.md %}
{{< callout danger >}}
{{< partial "callout-danger-async-methods.md" >}}
{{< /callout >}}
#### `.carousel(options)`
Initializes the carousel with an optional options `object` and starts cycling through items.
{% highlight js %}
```js
$('.carousel').carousel({
interval: 2000
})
{% endhighlight %}
```
#### `.carousel('cycle')`
@ -359,11 +357,11 @@ All carousel events are fired at the carousel itself (i.e. at the `<div class="c
</tbody>
</table>
{% highlight js %}
```js
$('#myCarousel').on('slide.bs.carousel', function () {
// do something...
})
{% endhighlight %}
```
### Change transition duration

View File

@ -10,7 +10,9 @@ toc: true
The collapse JavaScript plugin is used to show and hide content. Buttons or anchors are used as triggers that are mapped to specific elements you toggle. Collapsing an element will animate the `height` from its current value to `0`. Given how CSS handles animations, you cannot use `padding` on a `.collapse` element. Instead, use the class as an independent wrapping element.
{% include callout-info-prefersreducedmotion.md %}
{{< callout info >}}
{{< partial "callout-info-prefersreducedmotion.md" >}}
{{< /callout >}}
## Example
@ -22,7 +24,7 @@ Click the buttons below to show and hide another element via class changes:
You can use a link with the `href` attribute, or a button with the `data-target` attribute. In both cases, the `data-toggle="collapse"` is required.
{% capture example %}
{{< example >}}
<p>
<a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
Link with href
@ -36,15 +38,14 @@ You can use a link with the `href` attribute, or a button with the `data-target`
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Multiple targets
A `<button>` or `<a>` can show and hide multiple elements by referencing them with a JQuery selector in its `href` or `data-target` attribute.
Multiple `<button>` or `<a>` can show and hide an element if they each reference it with their `href` or `data-target` attribute
{% capture example %}
{{< example >}}
<p>
<a class="btn btn-primary" data-toggle="collapse" href="#multiCollapseExample1" role="button" aria-expanded="false" aria-controls="multiCollapseExample1">Toggle first element</a>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#multiCollapseExample2" aria-expanded="false" aria-controls="multiCollapseExample2">Toggle second element</button>
@ -66,14 +67,13 @@ Multiple `<button>` or `<a>` can show and hide an element if they each reference
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Accordion example
Using the [card]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/card/) component, you can extend the default collapse behavior to create an accordion. To properly achieve the accordion style, be sure to use `.accordion` as a wrapper.
Using the [card]({{< docsref "/components/card" >}}) component, you can extend the default collapse behavior to create an accordion. To properly achieve the accordion style, be sure to use `.accordion` as a wrapper.
{% capture example %}
{{< example >}}
<div class="accordion" id="accordionExample">
<div class="card">
<div class="card-header" id="headingOne">
@ -119,8 +119,7 @@ Using the [card]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/card
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Accessibility
@ -150,9 +149,9 @@ To add accordion-like group management to a collapsible area, add the data attri
Enable manually with:
{% highlight js %}
```js
$('.collapse').collapse()
{% endhighlight %}
```
### Options
@ -185,17 +184,19 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap
### Methods
{% include callout-danger-async-methods.md %}
{{< callout danger >}}
{{< partial "callout-danger-async-methods.md" >}}
{{< /callout >}}
#### `.collapse(options)`
Activates your content as a collapsible element. Accepts an optional options `object`.
{% highlight js %}
```js
$('#myCollapsible').collapse({
toggle: false
})
{% endhighlight %}
```
#### `.collapse('toggle')`
@ -244,8 +245,8 @@ Bootstrap's collapse class exposes a few events for hooking into collapse functi
</tbody>
</table>
{% highlight js %}
```js
$('#myCollapsible').on('hidden.bs.collapse', function () {
// do something...
})
{% endhighlight %}
```

View File

@ -10,9 +10,9 @@ toc: true
Dropdowns are toggleable, contextual overlays for displaying lists of links and more. They're made interactive with the included Bootstrap dropdown JavaScript plugin. They're toggled by clicking, not by hovering; this is [an intentional design decision](https://markdotto.com/2012/02/27/bootstrap-explained-dropdowns/).
Dropdowns are built on a third party library, [Popper.js](https://popper.js.org/), which provides dynamic positioning and viewport detection. Be sure to include [popper.min.js]({{ site.cdn.popper }}) before Bootstrap's JavaScript or use `bootstrap.bundle.min.js` / `bootstrap.bundle.js` which contains Popper.js. Popper.js isn't used to position dropdowns in navbars though as dynamic positioning isn't required.
Dropdowns are built on a third party library, [Popper.js](https://popper.js.org/), which provides dynamic positioning and viewport detection. Be sure to include [popper.min.js]({{< param "cdn.popper" >}}) before Bootstrap's JavaScript or use `bootstrap.bundle.min.js` / `bootstrap.bundle.js` which contains Popper.js. Popper.js isn't used to position dropdowns in navbars though as dynamic positioning isn't required.
If you're building our JavaScript from source, it [requires `util.js`]({{ site.baseurl }}/docs/{{ site.docs_version }}/getting-started/javascript/#util).
If you're building our JavaScript from source, it [requires `util.js`]({{< docsref "/getting-started/javascript#util" >}}).
## Accessibility
@ -30,7 +30,7 @@ Wrap the dropdown's toggle (your button or link) and the dropdown menu within `.
Any single `.btn` can be turned into a dropdown toggle with some markup changes. Here's how you can put them to work with either `<button>` elements:
{% capture example %}
{{< example >}}
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown button
@ -41,12 +41,11 @@ Any single `.btn` can be turned into a dropdown toggle with some markup changes.
<a class="dropdown-item" href="#">Something else here</a>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
And with `<a>` elements:
{% capture example %}
{{< example >}}
<div class="dropdown">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown link
@ -58,8 +57,7 @@ And with `<a>` elements:
<a class="dropdown-item" href="#">Something else here</a>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
The best part is you can do this with any button variant, too:
@ -126,7 +124,7 @@ The best part is you can do this with any button variant, too:
</div><!-- /btn-group -->
</div>
{% highlight html %}
```html
<!-- Example single danger button -->
<div class="btn-group">
<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@ -140,7 +138,7 @@ The best part is you can do this with any button variant, too:
<a class="dropdown-item" href="#">Separated link</a>
</div>
</div>
{% endhighlight %}
```
### Split button
@ -229,7 +227,7 @@ We use this extra class to reduce the horizontal `padding` on either side of the
</div><!-- /btn-group -->
</div>
{% highlight html %}
```html
<!-- Example split danger button -->
<div class="btn-group">
<button type="button" class="btn btn-danger">Action</button>
@ -244,7 +242,7 @@ We use this extra class to reduce the horizontal `padding` on either side of the
<a class="dropdown-item" href="#">Separated link</a>
</div>
</div>
{% endhighlight %}
```
## Sizing
@ -278,7 +276,7 @@ Button dropdowns work with buttons of all sizes, including default and split dro
</div>
</div>
{% highlight html %}
```html
<!-- Large button groups (default and split) -->
<div class="btn-group">
<button class="btn btn-secondary btn-lg dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@ -299,7 +297,7 @@ Button dropdowns work with buttons of all sizes, including default and split dro
...
</div>
</div>
{% endhighlight %}
```
<div class="bd-example">
<div class="btn-group">
@ -329,7 +327,7 @@ Button dropdowns work with buttons of all sizes, including default and split dro
</div>
</div>
{% highlight html %}
```html
<!-- Small button groups (default and split) -->
<div class="btn-group">
<button class="btn btn-secondary btn-sm dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@ -350,7 +348,7 @@ Button dropdowns work with buttons of all sizes, including default and split dro
...
</div>
</div>
{% endhighlight %}
```
## Directions
@ -371,7 +369,6 @@ Trigger dropdown menus above elements by adding `.dropup` to the parent element.
<a class="dropdown-item" href="#">Separated link</a>
</div>
</div>
<div class="btn-group dropup">
<button type="button" class="btn btn-secondary">
Split dropup
@ -389,7 +386,7 @@ Trigger dropdown menus above elements by adding `.dropup` to the parent element.
</div>
</div>
{% highlight html %}
```html
<!-- Default dropup button -->
<div class="btn-group dropup">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@ -412,7 +409,7 @@ Trigger dropdown menus above elements by adding `.dropup` to the parent element.
<!-- Dropdown menu links -->
</div>
</div>
{% endhighlight %}
```
### Dropright
@ -431,7 +428,6 @@ Trigger dropdown menus at the right of the elements by adding `.dropright` to th
<a class="dropdown-item" href="#">Separated link</a>
</div>
</div>
<div class="btn-group dropright">
<button type="button" class="btn btn-secondary">
Split dropright
@ -449,7 +445,7 @@ Trigger dropdown menus at the right of the elements by adding `.dropright` to th
</div>
</div>
{% highlight html %}
```html
<!-- Default dropright button -->
<div class="btn-group dropright">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@ -472,7 +468,7 @@ Trigger dropdown menus at the right of the elements by adding `.dropright` to th
<!-- Dropdown menu links -->
</div>
</div>
{% endhighlight %}
```
### Dropleft
@ -491,7 +487,6 @@ Trigger dropdown menus at the left of the elements by adding `.dropleft` to the
<a class="dropdown-item" href="#">Separated link</a>
</div>
</div>
<div class="btn-group">
<div class="btn-group dropleft" role="group">
<button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@ -511,7 +506,7 @@ Trigger dropdown menus at the left of the elements by adding `.dropleft` to the
</div>
</div>
{% highlight html %}
```html
<!-- Default dropleft button -->
<div class="btn-group dropleft">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@ -536,13 +531,13 @@ Trigger dropdown menus at the left of the elements by adding `.dropleft` to the
Split dropleft
</button>
</div>
{% endhighlight %}
```
## Menu items
Historically dropdown menu contents *had* to be links, but that's no longer the case with v4. Now you can optionally use `<button>` elements in your dropdowns instead of just `<a>`s.
{% capture example %}
{{< example >}}
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
@ -553,57 +548,52 @@ Historically dropdown menu contents *had* to be links, but that's no longer the
<button class="dropdown-item" type="button">Something else here</button>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
You can also create non-interactive dropdown items with `.dropdown-item-text`. Feel free to style further with custom CSS or text utilities.
{% capture example %}
{{< example >}}
<div class="dropdown-menu">
<span class="dropdown-item-text">Dropdown item text</span>
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Active
Add `.active` to items in the dropdown to **style them as active**.
{% capture example %}
{{< example >}}
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Regular link</a>
<a class="dropdown-item active" href="#">Active link</a>
<a class="dropdown-item" href="#">Another link</a>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Disabled
Add `.disabled` to items in the dropdown to **style them as disabled**.
{% capture example %}
{{< example >}}
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Regular link</a>
<a class="dropdown-item disabled" href="#" tabindex="-1" aria-disabled="true">Disabled link</a>
<a class="dropdown-item" href="#">Another link</a>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Menu alignment
By default, a dropdown menu is automatically positioned 100% from the top and along the left side of its parent. Add `.dropdown-menu-right` to a `.dropdown-menu` to right align the dropdown menu.
{% capture callout %}
{{< callout info >}}
**Heads up!** Dropdowns are positioned thanks to Popper.js (except when they are contained in a navbar).
{% endcapture %}
{% include callout.html content=callout type="info" %}
{{< /callout >}}
{% capture example %}
{{< example >}}
<div class="btn-group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Right-aligned menu
@ -614,8 +604,7 @@ By default, a dropdown menu is automatically positioned 100% from the top and al
<button class="dropdown-item" type="button">Something else here</button>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Responsive alignment
@ -623,7 +612,7 @@ If you want to use responsive alignment, disable dynamic positioning by adding t
To align **right** the dropdown menu with the given breakpoint or larger, add `.dropdown-menu{-sm|-md|-lg|-xl}-right`.
{% capture example %}
{{< example >}}
<div class="btn-group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" data-display="static" aria-haspopup="true" aria-expanded="false">
Left-aligned but right aligned when large screen
@ -634,12 +623,11 @@ To align **right** the dropdown menu with the given breakpoint or larger, add `.
<button class="dropdown-item" type="button">Something else here</button>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
To align **left** the dropdown menu with the given breakpoint or larger, add `.dropdown-menu-right` and `.dropdown-menu{-sm|-md|-lg|-xl}-left`.
{% capture example %}
{{< example >}}
<div class="btn-group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" data-display="static" aria-haspopup="true" aria-expanded="false">
Right-aligned but left aligned when large screen
@ -650,8 +638,7 @@ To align **left** the dropdown menu with the given breakpoint or larger, add `.d
<button class="dropdown-item" type="button">Something else here</button>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Note that you don't need to add a `data-display="static"` attribute to dropdown buttons in navbars, since Popper.js isn't used in navbars.
@ -661,20 +648,19 @@ Note that you don't need to add a `data-display="static"` attribute to dropdown
Add a header to label sections of actions in any dropdown menu.
{% capture example %}
{{< example >}}
<div class="dropdown-menu">
<h6 class="dropdown-header">Dropdown header</h6>
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Dividers
Separate groups of related menu items with a divider.
{% capture example %}
{{< example >}}
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
@ -682,14 +668,13 @@ Separate groups of related menu items with a divider.
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Separated link</a>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Text
Place any freeform text within a dropdown menu with text and use [spacing utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/spacing/). Note that you'll likely need additional sizing styles to constrain the menu width.
Place any freeform text within a dropdown menu with text and use [spacing utilities]({{< docsref "/utilities/spacing" >}}). Note that you'll likely need additional sizing styles to constrain the menu width.
{% capture example %}
{{< example >}}
<div class="dropdown-menu p-4 text-muted" style="max-width: 200px;">
<p>
Some example text that's free-flowing within the dropdown menu.
@ -698,14 +683,13 @@ Place any freeform text within a dropdown menu with text and use [spacing utilit
And this is more example text.
</p>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Forms
Put a form within a dropdown menu, or make it into a dropdown menu, and use [margin or padding utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/spacing/) to give it the negative space you require.
Put a form within a dropdown menu, or make it into a dropdown menu, and use [margin or padding utilities]({{< docsref "/utilities/spacing" >}}) to give it the negative space you require.
{% capture example %}
{{< example >}}
<div class="dropdown-menu">
<form class="px-4 py-3">
<div class="form-group">
@ -730,10 +714,9 @@ Put a form within a dropdown menu, or make it into a dropdown menu, and use [mar
<a class="dropdown-item" href="#">New around here? Sign up</a>
<a class="dropdown-item" href="#">Forgot password?</a>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture example %}
{{< example >}}
<form class="dropdown-menu p-4">
<div class="form-group">
<label for="exampleDropdownFormEmail2">Email address</label>
@ -753,14 +736,13 @@ Put a form within a dropdown menu, or make it into a dropdown menu, and use [mar
</div>
<button type="submit" class="btn btn-primary">Sign in</button>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Dropdown options
Use `data-offset` or `data-reference` to change the location of the dropdown.
{% capture example %}
{{< example >}}
<div class="d-flex">
<div class="dropdown mr-1">
<button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuOffset" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" data-offset="10,20">
@ -786,23 +768,21 @@ Use `data-offset` or `data-reference` to change the location of the dropdown.
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Usage
Via data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) by toggling the `.show` class on the parent list item. The `data-toggle="dropdown"` attribute is relied on for closing dropdown menus at an application level, so it's a good idea to always use it.
{% capture callout %}
{{< callout info >}}
On touch-enabled devices, opening a dropdown adds empty (`$.noop`) `mouseover` handlers to the immediate children of the `<body>` element. This admittedly ugly hack is necessary to work around a [quirk in iOS' event delegation](https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html), which would otherwise prevent a tap anywhere outside of the dropdown from triggering the code that closes the dropdown. Once the dropdown is closed, these additional empty `mouseover` handlers are removed.
{% endcapture %}
{% include callout.html content=callout type="info" %}
{{< /callout >}}
### Via data attributes
Add `data-toggle="dropdown"` to a link or button to toggle a dropdown.
{% highlight html %}
```html
<div class="dropdown">
<button id="dLabel" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown trigger
@ -811,22 +791,21 @@ Add `data-toggle="dropdown"` to a link or button to toggle a dropdown.
...
</div>
</div>
{% endhighlight %}
```
### Via JavaScript
Call the dropdowns via JavaScript:
{% highlight js %}
```js
$('.dropdown-toggle').dropdown()
{% endhighlight %}
```
{% capture callout %}
{{< callout info >}}
##### `data-toggle="dropdown"` still required
Regardless of whether you call your dropdown via JavaScript or instead use the data-api, `data-toggle="dropdown"` is always required to be present on the dropdown's trigger element.
{% endcapture %}
{% include callout.html content=callout type="info" %}
{{< /callout >}}
### Options
@ -909,8 +888,8 @@ All dropdown events are fired at the `.dropdown-menu`'s parent element and have
| `hide.bs.dropdown` | This event is fired immediately when the hide instance method has been called. |
| `hidden.bs.dropdown`| This event is fired when the dropdown has finished being hidden from the user (will wait for CSS transitions, to complete). |
{% highlight js %}
```js
$('#myDropdown').on('show.bs.dropdown', function () {
// do something...
})
{% endhighlight %}
```

View File

@ -8,13 +8,13 @@ toc: true
## Overview
Bootstrap's form controls expand on [our Rebooted form styles]({{ site.baseurl }}/docs/{{ site.docs_version }}/content/reboot/#forms) with classes. Use these classes to opt into their customized displays for a more consistent rendering across browsers and devices.
Bootstrap's form controls expand on [our Rebooted form styles]({{< docsref "/content/reboot#forms" >}}) with classes. Use these classes to opt into their customized displays for a more consistent rendering across browsers and devices.
Be sure to use an appropriate `type` attribute on all inputs (e.g., `email` for email address or `number` for numerical information) to take advantage of newer input controls like email verification, number selection, and more.
Here's a quick example to demonstrate Bootstrap's form styles. Keep reading for documentation on required classes, form layout, and more.
{% capture example %}
{{< example >}}
<form>
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
@ -31,8 +31,7 @@ Here's a quick example to demonstrate Bootstrap's form styles. Keep reading for
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Form controls
@ -40,7 +39,7 @@ Textual form controls—like `<input>`s, `<select>`s, and `<textarea>`s—are st
Be sure to explore our [custom forms](#custom-forms) to further style `<select>`s.
{% capture example %}
{{< example >}}
<form>
<div class="form-group">
<label for="exampleFormControlInput1">Email address</label>
@ -71,33 +70,30 @@ Be sure to explore our [custom forms](#custom-forms) to further style `<select>`
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea>
</div>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
For file inputs, swap the `.form-control` for `.form-control-file`.
{% capture example %}
{{< example >}}
<form>
<div class="form-group">
<label for="exampleFormControlFile1">Example file input</label>
<input type="file" class="form-control-file" id="exampleFormControlFile1">
</div>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Sizing
Set heights using classes like `.form-control-lg` and `.form-control-sm`.
{% capture example %}
{{< example >}}
<input class="form-control form-control-lg" type="text" placeholder=".form-control-lg">
<input class="form-control" type="text" placeholder="Default input">
<input class="form-control form-control-sm" type="text" placeholder=".form-control-sm">
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture example %}
{{< example >}}
<select class="form-control form-control-lg">
<option>Large select</option>
</select>
@ -107,23 +103,21 @@ Set heights using classes like `.form-control-lg` and `.form-control-sm`.
<select class="form-control form-control-sm">
<option>Small select</option>
</select>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Readonly
Add the `readonly` boolean attribute on an input to prevent modification of the input's value. Read-only inputs appear lighter (just like disabled inputs), but retain the standard cursor.
{% capture example %}
{{< example >}}
<input class="form-control" type="text" placeholder="Readonly input here..." readonly>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Readonly plain text
If you want to have `<input readonly>` elements in your form styled as plain text, use the `.form-control-plaintext` class to remove the default form field styling and preserve the correct margin and padding.
{% capture example %}
{{< example >}}
<form>
<div class="form-group row">
<label for="staticEmail" class="col-sm-2 col-form-label">Email</label>
@ -138,10 +132,9 @@ If you want to have `<input readonly>` elements in your form styled as plain tex
</div>
</div>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture example %}
{{< example >}}
<form class="form-inline">
<div class="form-group mb-2">
<label for="staticEmail2" class="sr-only">Email</label>
@ -153,22 +146,20 @@ If you want to have `<input readonly>` elements in your form styled as plain tex
</div>
<button type="submit" class="btn btn-primary mb-2">Confirm identity</button>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Range Inputs
Set horizontally scrollable range inputs using `.form-control-range`.
{% capture example %}
{{< example >}}
<form>
<div class="form-group">
<label for="formControlRange">Example Range input</label>
<input type="range" class="form-control-range" id="formControlRange">
</div>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Checkboxes and radios
@ -182,7 +173,7 @@ Checkboxes and radio buttons support HTML-based form validation and provide conc
By default, any number of checkboxes and radios that are immediate sibling will be vertically stacked and appropriately spaced with `.form-check`.
{% capture example %}
{{< example >}}
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="defaultCheck1">
<label class="form-check-label" for="defaultCheck1">
@ -195,10 +186,9 @@ By default, any number of checkboxes and radios that are immediate sibling will
Disabled checkbox
</label>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture 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">
@ -217,14 +207,13 @@ By default, any number of checkboxes and radios that are immediate sibling will
Disabled radio
</label>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Inline
Group checkboxes or radios on the same horizontal row by adding `.form-check-inline` to any `.form-check`.
{% capture example %}
{{< 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>
@ -237,10 +226,9 @@ Group checkboxes or radios on the same horizontal row by adding `.form-check-inl
<input class="form-check-input" type="checkbox" id="inlineCheckbox3" value="option3" disabled>
<label class="form-check-label" for="inlineCheckbox3">3 (disabled)</label>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture 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>
@ -253,22 +241,20 @@ Group checkboxes or radios on the same horizontal row by adding `.form-check-inl
<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>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Without labels
Add `.position-static` to inputs within `.form-check` that don't have any label text. Remember to still provide some form of accessible name for assistive technologies (for instance, using `aria-label`).
{% capture example %}
{{< example >}}
<div class="form-check">
<input class="form-check-input position-static" type="checkbox" id="blankCheckbox" value="option1" aria-label="...">
</div>
<div class="form-check">
<input class="form-check-input position-static" type="radio" name="blankRadio" id="blankRadio1" value="option1" aria-label="...">
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Layout
@ -278,7 +264,7 @@ Since Bootstrap applies `display: block` and `width: 100%` to almost all our for
The `.form-group` class is the easiest way to add some structure to forms. It provides a flexible class that encourages proper grouping of labels, controls, optional help text, and form validation messaging. By default it only applies `margin-bottom`, but it picks up additional styles in `.form-inline` as needed. Use it with `<fieldset>`s, `<div>`s, or nearly any other element.
{% capture example %}
{{< example >}}
<form>
<div class="form-group">
<label for="formGroupExampleInput">Example label</label>
@ -289,14 +275,13 @@ The `.form-group` class is the easiest way to add some structure to forms. It pr
<input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Another input placeholder">
</div>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /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.
{% capture example %}
{{< example >}}
<form>
<div class="row">
<div class="col">
@ -307,14 +292,13 @@ More complex forms can be built using our grid classes. Use these for form layou
</div>
</div>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
#### Form row
You may also swap `.row` for `.form-row`, a variation of our standard grid row that overrides the default column gutters for tighter and more compact layouts.
{% capture example %}
{{< example >}}
<form>
<div class="form-row">
<div class="col">
@ -325,12 +309,11 @@ You may also swap `.row` for `.form-row`, a variation of our standard grid row t
</div>
</div>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
More complex layouts can also be created with the grid system.
{% capture example %}
{{< example >}}
<form>
<div class="form-row">
<div class="form-group col-md-6">
@ -377,8 +360,7 @@ More complex layouts can also be created with the grid system.
</div>
<button type="submit" class="btn btn-primary">Sign in</button>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
#### Horizontal form
@ -386,7 +368,7 @@ Create horizontal forms with the grid by adding the `.row` class to form groups
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.
{% capture example %}
{{< example >}}
<form>
<div class="form-group row">
<label for="inputEmail3" class="col-sm-2 col-form-label">Email</label>
@ -439,14 +421,13 @@ At times, you maybe need to use margin or padding utilities to create that perfe
</div>
</div>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /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`.
{% capture example %}
{{< example >}}
<form>
<div class="form-group row">
<label for="colFormLabelSm" class="col-sm-2 col-form-label col-form-label-sm">Email</label>
@ -467,14 +448,13 @@ Be sure to use `.col-form-label-sm` or `.col-form-label-lg` to your `<label>`s o
</div>
</div>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
#### Column sizing
As shown in the previous examples, our grid system allows you to place any number of `.col`s within a `.row` or `.form-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-7`.
{% capture example %}
{{< example >}}
<form>
<div class="form-row">
<div class="col-7">
@ -488,14 +468,13 @@ As shown in the previous examples, our grid system allows you to place any numbe
</div>
</div>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /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.
{% capture example %}
{{< example >}}
<form>
<div class="form-row align-items-center">
<div class="col-auto">
@ -524,12 +503,11 @@ The example below uses a flexbox utility to vertically center the contents and c
</div>
</div>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
You can then remix that once again with size-specific column classes.
{% capture example %}
{{< example >}}
<form>
<div class="form-row align-items-center">
<div class="col-sm-3 my-1">
@ -558,12 +536,11 @@ You can then remix that once again with size-specific column classes.
</div>
</div>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
And of course [custom form controls](#custom-forms) are supported.
{% capture example %}
{{< example >}}
<form>
<div class="form-row align-items-center">
<div class="col-auto my-1">
@ -586,20 +563,19 @@ And of course [custom form controls](#custom-forms) are supported.
</div>
</div>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Inline forms
Use the `.form-inline` class to display a series of labels, form controls, and buttons on a single horizontal row. Form controls within inline forms vary slightly from their default states.
- Controls are `display: flex`, collapsing any HTML white space and allowing you to provide alignment control with [spacing]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/spacing/) and [flexbox]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/flex/) utilities.
- Controls are `display: flex`, collapsing any HTML white space and allowing you to provide alignment control with [spacing]({{< docsref "/utilities/spacing" >}}) and [flexbox]({{< docsref "/utilities/flex" >}}) utilities.
- Controls and input groups receive `width: auto` to override the Bootstrap default `width: 100%`.
- Controls **only appear inline in viewports that are at least 576px wide** to account for narrow viewports on mobile devices.
You may need to manually address the width and alignment of individual form controls with [spacing utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/spacing/) (as shown below). Lastly, be sure to always include a `<label>` with each form control, even if you need to hide it from non-screenreader visitors with `.sr-only`.
You may need to manually address the width and alignment of individual form controls with [spacing utilities]({{< docsref "/utilities/spacing" >}}) (as shown below). Lastly, be sure to always include a `<label>` with each form control, even if you need to hide it from non-screenreader visitors with `.sr-only`.
{% capture example %}
{{< example >}}
<form class="form-inline">
<label class="sr-only" for="inlineFormInputName2">Name</label>
<input type="text" class="form-control mb-2 mr-sm-2" id="inlineFormInputName2" placeholder="Jane Doe">
@ -621,12 +597,11 @@ You may need to manually address the width and alignment of individual form cont
<button type="submit" class="btn btn-primary mb-2">Submit</button>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Custom form controls and selects are also supported.
{% capture example %}
{{< example >}}
<form class="form-inline">
<label class="my-1 mr-2" for="inlineFormCustomSelectPref">Preference</label>
<select class="custom-select my-1 mr-sm-2" id="inlineFormCustomSelectPref">
@ -643,40 +618,36 @@ Custom form controls and selects are also supported.
<button type="submit" class="btn btn-primary my-1">Submit</button>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture callout %}
{{< callout warning >}}
##### Alternatives to hidden labels
Assistive technologies such as screen readers will have trouble with your forms if you don't include a label for every input. For these inline forms, you can hide the labels using the `.sr-only` class. There are further alternative methods of providing a label for assistive technologies, such as the `aria-label`, `aria-labelledby` or `title` attribute. If none of these are present, assistive technologies may resort to using the `placeholder` attribute, if present, but note that use of `placeholder` as a replacement for other labelling methods is not advised.
{% endcapture %}
{% include callout.html content=callout type="warning" %}
{{< /callout >}}
## Help text
Block-level help text in forms can be created using `.form-text` (previously known as `.help-block` in v3). Inline help text can be flexibly implemented using any inline HTML element and utility classes like `.text-muted`.
{% capture callout %}
{{< callout warning >}}
##### Associating help text with form controls
Help 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 help text when the user focuses or enters the control.
{% endcapture %}
{% include callout.html content=callout type="warning" %}
{{< /callout >}}
Help text below inputs can be styled with `.form-text`. This class includes `display: block` and adds some top margin for easy spacing from the inputs above.
{% capture example %}
{{< example >}}
<label for="inputPassword5">Password</label>
<input type="password" id="inputPassword5" class="form-control" aria-describedby="passwordHelpBlock">
<small id="passwordHelpBlock" class="form-text text-muted">
Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji.
</small>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Inline text can use any typical inline HTML element (be it a `<small>`, `<span>`, or something else) with nothing more than a utility class.
{% capture example %}
{{< example >}}
<form class="form-inline">
<div class="form-group">
<label for="inputPassword6">Password</label>
@ -686,20 +657,19 @@ Inline text can use any typical inline HTML element (be it a `<small>`, `<span>`
</small>
</div>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Disabled forms
Add the `disabled` boolean attribute on an input to prevent user interactions and make it appear lighter.
{% highlight html %}
```html
<input class="form-control" id="disabledInput" type="text" placeholder="Disabled input here..." disabled>
{% endhighlight %}
```
Add the `disabled` attribute to a `<fieldset>` to disable all the controls within.
{% capture example %}
{{< example >}}
<form>
<fieldset disabled>
<legend>Disabled fieldset example</legend>
@ -724,33 +694,29 @@ Add the `disabled` attribute to a `<fieldset>` to disable all the controls withi
<button type="submit" class="btn btn-primary">Submit</button>
</fieldset>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture callout %}
{{< callout warning >}}
##### Caveat with anchors
Browsers treat all native form controls (`<input>`, `<select>`, and `<button>` elements) inside a `<fieldset disabled>` as disabled, preventing both keyboard and mouse interactions on them.
However, if your form also includes custom button-like elements such as `<a ... class="btn btn-*">`, these will only be given a style of `pointer-events: none`. As noted in the section about [disabled state for buttons]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/buttons/#disabled-state) (and specifically in the sub-section for anchor elements), this CSS property is not yet standardized and isn't fully supported in Internet Explorer 10. The anchor-based controls will also still be focusable and operable using the keyboard. You must manually modify these controls by adding `tabindex="-1"` to prevent them from receiving focus and `aria-disabled="disabled"` to signal their state to assistive technologies.
{% endcapture %}
{% include callout.html content=callout type="warning" %}
However, if your form also includes custom button-like elements such as `<a ... class="btn btn-*">`, these will only be given a style of `pointer-events: none`. As noted in the section about [disabled state for buttons]({{< docsref "/components/buttons#disabled-state" >}}) (and specifically in the sub-section for anchor elements), this CSS property is not yet standardized and isn't fully supported in Internet Explorer 10. The anchor-based controls will also still be focusable and operable using the keyboard. You must manually modify these controls by adding `tabindex="-1"` to prevent them from receiving focus and `aria-disabled="disabled"` to signal their state to assistive technologies.
{{< /callout >}}
{% capture callout %}
{{< callout danger >}}
#### Cross-browser compatibility
While Bootstrap will apply these styles in all browsers, Internet Explorer 11 and below don't fully support the `disabled` attribute on a `<fieldset>`. Use custom JavaScript to disable the fieldset in these browsers.
{% endcapture %}
{% include callout.html content=callout type="danger" %}
{{< /callout >}}
## Validation
Provide valuable, actionable feedback to your users with HTML5 form validation[available in all our supported browsers](https://caniuse.com/form-validation). Choose from the browser default validation feedback, or implement custom messages with our built-in classes and starter JavaScript.
{% capture callout %}
{{< 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.
{% endcapture %}
{% include callout.html content=callout type="warning" %}
{{< /callout >}}
### How it works
@ -773,7 +739,7 @@ For custom Bootstrap form validation messages, you'll need to add the `novalidat
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 `.custom-select`, and not `.form-control`.
{% capture example %}
{{< example >}}
<form class="needs-validation" novalidate>
<div class="form-row">
<div class="col-md-6 mb-3">
@ -851,8 +817,7 @@ Custom feedback styles apply custom colors, borders, focus styles, and backgroun
}, false);
})();
</script>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Browser defaults
@ -860,7 +825,7 @@ Not interested in custom validation feedback messages or writing JavaScript to c
While these feedback styles cannot be styled with CSS, you can still customize the feedback text through JavaScript.
{% capture example %}
{{< example >}}
<form>
<div class="form-row">
<div class="col-md-6 mb-3">
@ -899,8 +864,7 @@ While these feedback styles cannot be styled with CSS, you can still customize t
</div>
<button class="btn btn-primary" type="submit">Submit form</button>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Server side
@ -908,7 +872,7 @@ We recommend using client-side validation, but in case you require server-side v
For invalid fields, ensure that the invalid feedback/error message is associated with the relevant form field using `aria-describedby`. This attribute allows more than one `id` to be referenced, in case the field already points to additional form text.
{% capture example %}
{{< example >}}
<form>
<div class="form-row">
<div class="col-md-6 mb-3">
@ -965,8 +929,7 @@ For invalid fields, ensure that the invalid feedback/error message is associated
</div>
<button class="btn btn-primary" type="submit">Submit form</button>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Supported elements
@ -978,7 +941,7 @@ Validation styles are available for the following form controls and components:
- `.custom-checkbox`s and `.custom-radio`s
- `.custom-file`
{% capture example %}
{{< example >}}
<form class="was-validated">
<div class="mb-3">
<label for="validationTextarea">Textarea</label>
@ -1062,14 +1025,13 @@ Validation styles are available for the following form controls and components:
Example invalid input group feedback
</div>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /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.
{% capture example %}
{{< example >}}
<form class="needs-validation" novalidate>
<div class="form-row">
<div class="col-md-6 mb-3">
@ -1115,8 +1077,7 @@ If your form layout allows it, you can swap the `.{valid|invalid}-feedback` clas
</div>
<button class="btn btn-primary" type="submit">Submit form</button>
</form>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Customizing
@ -1124,7 +1085,7 @@ Validation states can be customized via Sass with the `$form-validation-states`
Please note that we do not recommend customizing these values without also modifying the `form-validation-state` mixin.
{% highlight scss %}
```scss
// Sass map from `_variables.scss`
// Override this and recompile your Sass to generate different states
$form-validation-states: map-merge(
@ -1147,13 +1108,13 @@ $form-validation-states: map-merge(
@each $state, $data in $form-validation-states {
@include form-validation-state($state, map-get($data, color), map-get($data, icon));
}
{% endhighlight %}
```
### Input group validation
To detect what elements need rounded corners inside an input group with validation, an input group requires an additional `.has-validation` class.
{% highlight html %}
```html
<div class="input-group has-validation">
<div class="input-group-prepend">
<span class="input-group-text">@</span>
@ -1163,7 +1124,7 @@ To detect what elements need rounded corners inside an input group with validati
Please choose a username.
</div>
</div>
{% endhighlight %}
```
<div class="bd-example bd-example-forms-input-group-workaround">
<div class="input-group has-validation">
@ -1193,13 +1154,12 @@ In the checked states, we use **base64 embedded SVG icons** from [Open Iconic](h
#### Checkboxes
{% capture example %}
{{< example >}}
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="customCheck1">
<label class="custom-control-label" for="customCheck1">Check this custom checkbox</label>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Custom checkboxes can also utilize the `:indeterminate` pseudo class when manually set via JavaScript (there is no available HTML attribute for specifying it).
@ -1212,13 +1172,13 @@ Custom checkboxes can also utilize the `:indeterminate` pseudo class when manual
If you're using jQuery, something like this should suffice:
{% highlight js %}
```js
$('.your-checkbox').prop('indeterminate', true)
{% endhighlight %}
```
#### Radios
{% capture example %}
{{< example >}}
<div class="custom-control custom-radio">
<input type="radio" id="customRadio1" name="customRadio" class="custom-control-input">
<label class="custom-control-label" for="customRadio1">Toggle this custom radio</label>
@ -1227,12 +1187,11 @@ $('.your-checkbox').prop('indeterminate', true)
<input type="radio" id="customRadio2" name="customRadio" class="custom-control-input">
<label class="custom-control-label" for="customRadio2">Or toggle this other custom radio</label>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
#### Inline
{% capture example %}
{{< example >}}
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="customRadioInline1" name="customRadioInline" class="custom-control-input">
<label class="custom-control-label" for="customRadioInline1">Toggle this custom radio</label>
@ -1241,14 +1200,13 @@ $('.your-checkbox').prop('indeterminate', true)
<input type="radio" id="customRadioInline2" name="customRadioInline" class="custom-control-input">
<label class="custom-control-label" for="customRadioInline2">Or toggle this other custom radio</label>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
#### Disabled
Custom checkboxes and radios can also be disabled. Add the `disabled` boolean attribute to the `<input>` and the custom indicator and label description will be automatically styled.
{% capture example %}
{{< example >}}
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="customCheckDisabled1" disabled>
<label class="custom-control-label" for="customCheckDisabled1">Check this custom checkbox</label>
@ -1258,14 +1216,13 @@ Custom checkboxes and radios can also be disabled. Add the `disabled` boolean at
<input type="radio" name="radioDisabled" id="customRadioDisabled2" class="custom-control-input" disabled>
<label class="custom-control-label" for="customRadioDisabled2">Toggle this custom radio</label>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Switches
A switch has the markup of a custom checkbox but uses the `.custom-switch` class to render a toggle switch. Switches also support the `disabled` attribute.
{% capture example %}
{{< example >}}
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="customSwitch1">
<label class="custom-control-label" for="customSwitch1">Toggle this switch element</label>
@ -1274,26 +1231,24 @@ A switch has the markup of a custom checkbox but uses the `.custom-switch` class
<input type="checkbox" class="custom-control-input" disabled id="customSwitch2">
<label class="custom-control-label" for="customSwitch2">Disabled switch element</label>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Select menu
Custom `<select>` menus need only a custom class, `.custom-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.
{% capture example %}
{{< example >}}
<select class="custom-select">
<option selected>Open this select menu</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
You may also choose from small and large custom selects to match our similarly sized text inputs.
{% capture example %}
{{< example >}}
<select class="custom-select custom-select-lg mb-3">
<option selected>Open this select menu</option>
<option value="1">One</option>
@ -1307,75 +1262,67 @@ You may also choose from small and large custom selects to match our similarly s
<option value="2">Two</option>
<option value="3">Three</option>
</select>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
The `multiple` attribute is also supported:
{% capture example %}
{{< example >}}
<select class="custom-select" multiple>
<option selected>Open this select menu</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
As is the `size` attribute:
{% capture example %}
{{< example >}}
<select class="custom-select" size="3">
<option selected>Open this select menu</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Range
Create custom `<input type="range">` controls with `.custom-range`. The track (the background) and thumb (the value) are both styled to appear the same across browsers. As only IE and Firefox support "filling" their track from the left or right of the thumb as a means to visually indicate progress, we do not currently support it.
{% capture example %}
{{< example >}}
<label for="customRange1">Example range</label>
<input type="range" class="custom-range" id="customRange1">
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Range inputs have implicit values for `min` and `max`—`0` and `100`, respectively. You may specify new values for those using the `min` and `max` attributes.
{% capture example %}
{{< example >}}
<label for="customRange2">Example range</label>
<input type="range" class="custom-range" min="0" max="5" id="customRange2">
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
By default, range inputs "snap" to integer values. To change this, you can specify a `step` value. In the example below, we double the number of steps by using `step="0.5"`.
{% capture example %}
{{< example >}}
<label for="customRange3">Example range</label>
<input type="range" class="custom-range" min="0" max="5" step="0.5" id="customRange3">
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### File browser
{% capture callout %}
{{< callout info >}}
The recommended plugin to animate custom file input: [bs-custom-file-input](https://www.npmjs.com/package/bs-custom-file-input), that's what we are using currently here in our docs.
{% endcapture %}
{% include callout.html content=callout type="info" %}
{{< /callout >}}
The file input is the most gnarly of the bunch and requires additional JavaScript if you'd like to hook them up with functional *Choose file...* and selected file name text.
{% capture example %}
{{< example >}}
<div class="custom-file">
<input type="file" class="custom-file-input" id="customFile">
<label class="custom-file-label" for="customFile">Choose file</label>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
We hide the default file `<input>` via `opacity` and instead style the `<label>`. The button is generated and positioned with `::after`. Lastly, we declare a `width` and `height` on the `<input>` for proper spacing for surrounding content.
@ -1383,22 +1330,21 @@ We hide the default file `<input>` via `opacity` and instead style the `<label>`
The [`:lang()` pseudo-class](https://developer.mozilla.org/en-US/docs/Web/CSS/:lang) is used to allow for translation of the "Browse" text into other languages. Override or add entries to the `$custom-file-text` Sass variable with the relevant [language tag](https://en.wikipedia.org/wiki/IETF_language_tag) and localized strings. The English strings can be customized the same way. For example, here's how one might add a Spanish translation (Spanish's language code is `es`):
{% highlight scss %}
```scss
$custom-file-text: (
en: "Browse",
es: "Elegir"
);
{% endhighlight %}
```
Here's `lang(es)` in action on the custom file input for a Spanish translation:
{% capture example %}
{{< example >}}
<div class="custom-file">
<input type="file" class="custom-file-input" id="customFileLang" lang="es">
<label class="custom-file-label" for="customFileLang">Seleccionar Archivo</label>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
You'll need to set the language of your document (or subtree thereof) correctly in order for the correct text to be shown. This can be done using [the `lang` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang) on the `<html>` element or the [`Content-Language` HTTP header](https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.12), among other methods.
@ -1406,10 +1352,9 @@ You'll need to set the language of your document (or subtree thereof) correctly
Bootstrap also provides a way to translate the "Browse" text in HTML with the `data-browse` attribute which can be added to the custom input label (example in Dutch):
{% capture example %}
{{< example >}}
<div class="custom-file">
<input type="file" class="custom-file-input" id="customFileLangHTML">
<label class="custom-file-label" for="customFileLangHTML" data-browse="Bestand kiezen">Voeg je document toe</label>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}

View File

@ -10,7 +10,7 @@ toc: true
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.
{% capture example %}
{{< example >}}
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">@</span>
@ -49,22 +49,20 @@ Place one add-on or button on either side of an input. You may also place one on
</div>
<textarea class="form-control" aria-label="With textarea"></textarea>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /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`.
{% capture example %}
{{< example >}}
<div class="input-group flex-nowrap">
<div class="input-group-prepend">
<span class="input-group-text" id="addon-wrapping">@</span>
</div>
<input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="addon-wrapping">
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Sizing
@ -72,7 +70,7 @@ Add the relative form sizing classes to the `.input-group` itself and contents w
**Sizing on the individual input group elements isn't supported.**
{% capture example %}
{{< example >}}
<div class="input-group input-group-sm mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="inputGroup-sizing-sm">Small</span>
@ -93,14 +91,13 @@ Add the relative form sizing classes to the `.input-group` itself and contents w
</div>
<input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-lg">
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Checkboxes and radios
Place any checkbox or radio option within an input group's addon instead of text.
{% capture example %}
{{< example >}}
<div class="input-group mb-3">
<div class="input-group-prepend">
<div class="input-group-text">
@ -118,14 +115,13 @@ Place any checkbox or radio option within an input group's addon instead of text
</div>
<input type="text" class="form-control" aria-label="Text input with radio button">
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Multiple inputs
While multiple `<input>`s are supported visually, validation styles are only available for input groups with a single `<input>`.
{% capture example %}
{{< example >}}
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">First and last name</span>
@ -133,14 +129,13 @@ While multiple `<input>`s are supported visually, validation styles are only ava
<input type="text" aria-label="First name" class="form-control">
<input type="text" aria-label="Last name" class="form-control">
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Multiple addons
Multiple add-ons are supported and can be mixed with checkbox and radio input versions.
{% capture example %}
{{< example >}}
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">$</span>
@ -156,12 +151,11 @@ Multiple add-ons are supported and can be mixed with checkbox and radio input ve
<span class="input-group-text">0.00</span>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Button addons
{% capture example %}
{{< example >}}
<div class="input-group mb-3">
<div class="input-group-prepend">
<button class="btn btn-outline-secondary" type="button" id="button-addon1">Button</button>
@ -191,12 +185,11 @@ Multiple add-ons are supported and can be mixed with checkbox and radio input ve
<button class="btn btn-outline-secondary" type="button">Button</button>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Buttons with dropdowns
{% capture example %}
{{< example >}}
<div class="input-group mb-3">
<div class="input-group-prepend">
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</button>
@ -224,12 +217,11 @@ Multiple add-ons are supported and can be mixed with checkbox and radio input ve
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Segmented buttons
{% capture example %}
{{< example >}}
<div class="input-group mb-3">
<div class="input-group-prepend">
<button type="button" class="btn btn-outline-secondary">Action</button>
@ -263,8 +255,7 @@ Multiple add-ons are supported and can be mixed with checkbox and radio input ve
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Custom forms
@ -272,7 +263,7 @@ Input groups include support for custom selects and custom file inputs. Browser
### Custom select
{% capture example %}
{{< example >}}
<div class="input-group mb-3">
<div class="input-group-prepend">
<label class="input-group-text" for="inputGroupSelect01">Options</label>
@ -320,12 +311,11 @@ Input groups include support for custom selects and custom file inputs. Browser
<button class="btn btn-outline-secondary" type="button">Button</button>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Custom file input
{% capture example %}
{{< example >}}
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="inputGroupFileAddon01">Upload</span>
@ -365,8 +355,7 @@ Input groups include support for custom selects and custom file inputs. Browser
<button class="btn btn-outline-secondary" type="button" id="inputGroupFileAddon04">Button</button>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Accessibility

View File

@ -7,7 +7,7 @@ group: components
A lightweight, flexible component that can optionally extend the entire viewport to showcase key marketing messages on your site.
{% capture example %}
{{< example >}}
<div class="jumbotron">
<h1 class="display-4">Hello, world!</h1>
<p class="lead">This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p>
@ -15,17 +15,15 @@ A lightweight, flexible component that can optionally extend the entire viewport
<p>It uses utility classes for typography and spacing to space content out within the larger container.</p>
<a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
To make the jumbotron full width, and without rounded corners, add the `.jumbotron-fluid` modifier class and add a `.container` or `.container-fluid` within.
{% capture example %}
{{< example >}}
<div class="jumbotron jumbotron-fluid">
<div class="container">
<h1 class="display-4">Fluid jumbotron</h1>
<p class="lead">This is a modified jumbotron that occupies the entire horizontal space of its parent.</p>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}

View File

@ -10,7 +10,7 @@ toc: true
The most basic list group is an unordered list with list items and the proper classes. Build upon it with the options that follow, or with your own CSS as needed.
{% capture example %}
{{< example >}}
<ul class="list-group">
<li class="list-group-item">Cras justo odio</li>
<li class="list-group-item">Dapibus ac facilisis in</li>
@ -18,14 +18,13 @@ The most basic list group is an unordered list with list items and the proper cl
<li class="list-group-item">Porta ac consectetur ac</li>
<li class="list-group-item">Vestibulum at eros</li>
</ul>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Active items
Add `.active` to a `.list-group-item` to indicate the current active selection.
{% capture example %}
{{< example >}}
<ul class="list-group">
<li class="list-group-item active">Cras justo odio</li>
<li class="list-group-item">Dapibus ac facilisis in</li>
@ -33,14 +32,13 @@ Add `.active` to a `.list-group-item` to indicate the current active selection.
<li class="list-group-item">Porta ac consectetur ac</li>
<li class="list-group-item">Vestibulum at eros</li>
</ul>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Disabled items
Add `.disabled` to a `.list-group-item` to make it _appear_ disabled. Note that some elements with `.disabled` will also require custom JavaScript to fully disable their click events (e.g., links).
{% capture example %}
{{< example >}}
<ul class="list-group">
<li class="list-group-item disabled" aria-disabled="true">Cras justo odio</li>
<li class="list-group-item">Dapibus ac facilisis in</li>
@ -48,8 +46,7 @@ Add `.disabled` to a `.list-group-item` to make it _appear_ disabled. Note that
<li class="list-group-item">Porta ac consectetur ac</li>
<li class="list-group-item">Vestibulum at eros</li>
</ul>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Links and buttons
@ -57,7 +54,7 @@ Use `<a>`s or `<button>`s to create _actionable_ list group items with hover, di
Be sure to **not use the standard `.btn` classes here**.
{% capture example %}
{{< example >}}
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action active">
Cras justo odio
@ -67,12 +64,11 @@ Be sure to **not use the standard `.btn` classes here**.
<a href="#" class="list-group-item list-group-item-action">Porta ac consectetur ac</a>
<a href="#" class="list-group-item list-group-item-action disabled" tabindex="-1" aria-disabled="true">Vestibulum at eros</a>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
With `<button>`s, you can also make use of the `disabled` attribute instead of the `.disabled` class. Sadly, `<a>`s don't support the disabled attribute.
{% capture example %}
{{< example >}}
<div class="list-group">
<button type="button" class="list-group-item list-group-item-action active">
Cras justo odio
@ -82,14 +78,13 @@ With `<button>`s, you can also make use of the `disabled` attribute instead of t
<button type="button" class="list-group-item list-group-item-action">Porta ac consectetur ac</button>
<button type="button" class="list-group-item list-group-item-action" disabled>Vestibulum at eros</button>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Flush
Add `.list-group-flush` to remove some borders and rounded corners to render list group items edge-to-edge in a parent container (e.g., cards).
{% capture example %}
{{< example >}}
<ul class="list-group list-group-flush">
<li class="list-group-item">Cras justo odio</li>
<li class="list-group-item">Dapibus ac facilisis in</li>
@ -97,8 +92,7 @@ Add `.list-group-flush` to remove some borders and rounded corners to render lis
<li class="list-group-item">Porta ac consectetur ac</li>
<li class="list-group-item">Vestibulum at eros</li>
</ul>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Horizontal
@ -106,49 +100,55 @@ Add `.list-group-horizontal` to change the layout of list group items from verti
**ProTip:** Want equal-width list group items when horizontal? Add `.flex-fill` to each list group item.
{% for bp in site.data.breakpoints %}
{% capture example %}
<ul class="list-group list-group-horizontal{{ bp.abbr }}">
{{< example >}}
{{< list-group.inline >}}
{{- range $.Site.Data.breakpoints }}
<ul class="list-group list-group-horizontal{{ .abbr }}">
<li class="list-group-item">Cras justo odio</li>
<li class="list-group-item">Dapibus ac facilisis in</li>
<li class="list-group-item">Morbi leo risus</li>
</ul>
{% endcapture %}
{% include example.html content=example %}{% endfor %}
{{- end -}}
{{< /list-group.inline >}}
{{< /example >}}
## Contextual classes
Use contextual classes to style list items with a stateful background and color.
{% capture example %}
{{< example >}}
<ul class="list-group">
<li class="list-group-item">Dapibus ac facilisis in</li>
{% for color in site.data.theme-colors %}
<li class="list-group-item list-group-item-{{ color.name }}">A simple {{ color.name }} list group item</li>{% endfor %}
{{< list.inline >}}
{{- range (index $.Site.Data "theme-colors") }}
<li class="list-group-item list-group-item-{{ .name }}">A simple {{ .name }} list group item</li>
{{- end -}}
{{< /list.inline >}}
</ul>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Contextual classes also work with `.list-group-item-action`. Note the addition of the hover styles here not present in the previous example. Also supported is the `.active` state; apply it to indicate an active selection on a contextual list group item.
{% capture example %}
{{< example >}}
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action">Dapibus ac facilisis in</a>
{% for color in site.data.theme-colors %}
<a href="#" class="list-group-item list-group-item-action list-group-item-{{ color.name }}">A simple {{ color.name }} list group item</a>{% endfor %}
{{< list.inline >}}
{{- range (index $.Site.Data "theme-colors") }}
<a href="#" class="list-group-item list-group-item-action list-group-item-{{ .name }}">A simple {{ .name }} list group item</a>
{{- end -}}
{{< /list.inline >}}
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% include callout-warning-color-assistive-technologies.md %}
{{< callout warning >}}
{{< partial "callout-warning-color-assistive-technologies.md" >}}
{{< /callout >}}
## With badges
Add badges to any list group item to show unread counts, activity, and more with the help of some [utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/flex/).
Add badges to any list group item to show unread counts, activity, and more with the help of some [utilities]({{< docsref "/utilities/flex" >}}).
{% capture example %}
{{< example >}}
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between align-items-center">
Cras justo odio
@ -163,14 +163,13 @@ Add badges to any list group item to show unread counts, activity, and more with
<span class="badge badge-primary badge-pill">1</span>
</li>
</ul>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Custom content
Add nearly any HTML within, even for linked list groups like the one below, with the help of [flexbox utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/flex/).
Add nearly any HTML within, even for linked list groups like the one below, with the help of [flexbox utilities]({{< docsref "/utilities/flex" >}}).
{% capture example %}
{{< example >}}
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action active">
<div class="d-flex w-100 justify-content-between">
@ -197,8 +196,7 @@ Add nearly any HTML within, even for linked list groups like the one below, with
<small class="text-muted">Donec id elit non mi porta.</small>
</a>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## JavaScript behavior
@ -233,7 +231,7 @@ Use the tab JavaScript plugin—include it individually or through the compiled
</div>
</div>
{% highlight html %}
```html
<div class="row">
<div class="col-4">
<div class="list-group" id="list-tab" role="tablist">
@ -252,13 +250,13 @@ Use the tab JavaScript plugin—include it individually or through the compiled
</div>
</div>
</div>
{% endhighlight %}
```
### Using data attributes
You can activate a list group navigation without writing any JavaScript by simply specifying `data-toggle="list"` or on an element. Use these data attributes on `.list-group-item`.
{% highlight html %}
```html
<div role="tabpanel">
<!-- List group -->
<div class="list-group" id="myList" role="tablist">
@ -276,40 +274,40 @@ You can activate a list group navigation without writing any JavaScript by simpl
<div class="tab-pane" id="settings" role="tabpanel">...</div>
</div>
</div>
{% endhighlight %}
```
### Via JavaScript
Enable tabbable list item via JavaScript (each list item needs to be activated individually):
{% highlight js %}
```js
$('#myList a').on('click', function (e) {
e.preventDefault()
$(this).tab('show')
})
{% endhighlight %}
```
You can activate individual list item in several ways:
{% highlight js %}
```js
$('#myList a[href="#profile"]').tab('show') // Select tab by name
$('#myList a:first-child').tab('show') // Select first tab
$('#myList a:last-child').tab('show') // Select last tab
$('#myList a:nth-child(3)').tab('show') // Select third tab
{% endhighlight %}
```
### Fade effect
To make tabs panel fade in, add `.fade` to each `.tab-pane`. The first tab pane must also have `.show` to make the initial content visible.
{% highlight html %}
```html
<div class="tab-content">
<div class="tab-pane fade show active" id="home" role="tabpanel">...</div>
<div class="tab-pane fade" id="profile" role="tabpanel">...</div>
<div class="tab-pane fade" id="messages" role="tabpanel">...</div>
<div class="tab-pane fade" id="settings" role="tabpanel">...</div>
</div>
{% endhighlight %}
```
### Methods
@ -317,7 +315,7 @@ To make tabs panel fade in, add `.fade` to each `.tab-pane`. The first tab pane
Activates a list item element and content container. Tab should have either a `data-target` or an `href` targeting a container node in the DOM.
{% highlight html %}
```html
<div class="list-group" id="myList" role="tablist">
<a class="list-group-item list-group-item-action active" data-toggle="list" href="#home" role="tab">Home</a>
<a class="list-group-item list-group-item-action" data-toggle="list" href="#profile" role="tab">Profile</a>
@ -337,15 +335,15 @@ Activates a list item element and content container. Tab should have either a `d
$('#myList a:last-child').tab('show')
})
</script>
{% endhighlight %}
```
#### .tab('show')
Selects the given list item and shows its associated pane. Any other list item that was previously selected becomes unselected and its associated pane is hidden. **Returns to the caller before the tab pane has actually been shown** (for example, before the `shown.bs.tab` event occurs).
{% highlight js %}
```js
$('#someListItem').tab('show')
{% endhighlight %}
```
### Events
@ -385,9 +383,9 @@ If no tab was already active, the `hide.bs.tab` and `hidden.bs.tab` events will
</tbody>
</table>
{% highlight js %}
```js
$('a[data-toggle="list"]').on('shown.bs.tab', function (e) {
e.target // newly activated tab
e.relatedTarget // previous active tab
})
{% endhighlight %}
```

View File

@ -10,42 +10,40 @@ toc: true
The [media object](http://www.stubbornella.org/content/2010/06/25/the-media-object-saves-hundreds-of-lines-of-code/) helps build complex and repetitive components where some media is positioned alongside content that doesn't wrap around said media. Plus, it does this with only two required classes thanks to flexbox.
Below is an example of a single media object. Only two classes are required—the wrapping `.media` and the `.media-body` around your content. Optional padding and margin can be controlled through [spacing utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/spacing/).
Below is an example of a single media object. Only two classes are required—the wrapping `.media` and the `.media-body` around your content. Optional padding and margin can be controlled through [spacing utilities]({{< docsref "/utilities/spacing" >}}).
{% capture example %}
{{< example >}}
<div class="media">
{% include icons/placeholder.svg width="64" height="64" class="mr-3" %}
{{< placeholder width="64" height="64" class="mr-3" >}}
<div class="media-body">
<h5 class="mt-0">Media heading</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture callout %}
{{< callout warning >}}
##### Flexbug #12: Inline elements aren't treated as flex items
Internet Explorer 10-11 do not render inline elements like links or images (or `::before` and `::after` pseudo-elements) as flex items. The only workaround is to set a non-inline `display` value (e.g., `block`, `inline-block`, or `flex`). We suggest using `.d-flex`, one of our [display utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/display/), as an easy fix.
Internet Explorer 10-11 do not render inline elements like links or images (or `::before` and `::after` pseudo-elements) as flex items. The only workaround is to set a non-inline `display` value (e.g., `block`, `inline-block`, or `flex`). We suggest using `.d-flex`, one of our [display utilities]({{< docsref "/utilities/display" >}}), as an easy fix.
**Source:** [Flexbugs on GitHub](https://github.com/philipwalton/flexbugs#flexbug-12)
{% endcapture %}
{% include callout.html content=callout type="warning" %}
{{< /callout >}}
## Nesting
Media objects can be infinitely nested, though we suggest you stop at some point. Place nested `.media` within the `.media-body` of a parent media object.
{% capture example %}
{{< example >}}
<div class="media">
{% include icons/placeholder.svg width="64" height="64" class="mr-3" %}
{{< placeholder width="64" height="64" class="mr-3" >}}
<div class="media-body">
<h5 class="mt-0">Media heading</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
<div class="media mt-3">
<a class="mr-3" href="#">
{% include icons/placeholder.svg width="64" height="64" %}
{{< placeholder width="64" height="64" >}}
</a>
<div class="media-body">
<h5 class="mt-0">Media heading</h5>
@ -54,91 +52,85 @@ Media objects can be infinitely nested, though we suggest you stop at some point
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Alignment
Media in a media object can be aligned with flexbox utilities to the top (default), middle, or end of your `.media-body` content.
{% capture example %}
{{< example >}}
<div class="media">
{% include icons/placeholder.svg width="64" height="64" class="align-self-start mr-3" %}
{{< placeholder width="64" height="64" class="align-self-start mr-3" >}}
<div class="media-body">
<h5 class="mt-0">Top-aligned media</h5>
<p>Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.</p>
<p>Donec sed odio dui. Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture example %}
{{< example >}}
<div class="media">
{% include icons/placeholder.svg width="64" height="64" class="align-self-center mr-3" %}
{{< placeholder width="64" height="64" class="align-self-center mr-3" >}}
<div class="media-body">
<h5 class="mt-0">Center-aligned media</h5>
<p>Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.</p>
<p class="mb-0">Donec sed odio dui. Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture example %}
{{< example >}}
<div class="media">
{% include icons/placeholder.svg width="64" height="64" class="align-self-end mr-3" %}
{{< placeholder width="64" height="64" class="align-self-end mr-3" >}}
<div class="media-body">
<h5 class="mt-0">Bottom-aligned media</h5>
<p>Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.</p>
<p class="mb-0">Donec sed odio dui. Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Order
Change the order of content in media objects by modifying the HTML itself, or by adding some custom flexbox CSS to set the `order` property (to an integer of your choosing).
{% capture example %}
{{< example >}}
<div class="media">
<div class="media-body">
<h5 class="mt-0 mb-1">Media object</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
</div>
{% include icons/placeholder.svg width="64" height="64" class="ml-3" %}
{{< placeholder width="64" height="64" class="ml-3" >}}
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Media list
Because the media object has so few structural requirements, you can also use these classes on list HTML elements. On your `<ul>` or `<ol>`, add the `.list-unstyled` to remove any browser default list styles, and then apply `.media` to your `<li>`s. As always, use spacing utilities wherever needed to fine tune.
{% capture example %}
{{< example >}}
<ul class="list-unstyled">
<li class="media">
{% include icons/placeholder.svg width="64" height="64" class="mr-3" %}
{{< placeholder width="64" height="64" class="mr-3" >}}
<div class="media-body">
<h5 class="mt-0 mb-1">List-based media object</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
</div>
</li>
<li class="media my-4">
{% include icons/placeholder.svg width="64" height="64" class="mr-3" %}
{{< placeholder width="64" height="64" class="mr-3" >}}
<div class="media-body">
<h5 class="mt-0 mb-1">List-based media object</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
</div>
</li>
<li class="media">
{% include icons/placeholder.svg width="64" height="64" class="mr-3" %}
{{< placeholder width="64" height="64" class="mr-3" >}}
<div class="media-body">
<h5 class="mt-0 mb-1">List-based media object</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
</div>
</li>
</ul>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}

View File

@ -14,16 +14,18 @@ Before getting started with Bootstrap's modal component, be sure to read the fol
- Clicking on the modal "backdrop" will automatically close the modal.
- Bootstrap only supports one modal window at a time. Nested modals aren't supported as we believe them to be poor user experiences.
- Modals use `position: fixed`, which can sometimes be a bit particular about its rendering. Whenever possible, place your modal HTML in a top-level position to avoid potential interference from other elements. You'll likely run into issues when nesting a `.modal` within another fixed element.
- Once again, due to `position: fixed`, there are some caveats with using modals on mobile devices. [See our browser support docs]({{ site.baseurl }}/docs/{{ site.docs_version }}/getting-started/browsers-devices/#modals-and-dropdowns-on-mobile) for details.
- Once again, due to `position: fixed`, there are some caveats with using modals on mobile devices. [See our browser support docs]({{< docsref "/getting-started/browsers-devices#modals-and-dropdowns-on-mobile" >}}) for details.
- Due to how HTML5 defines its semantics, [the `autofocus` HTML attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-autofocus) has no effect in Bootstrap modals. To achieve the same effect, use some custom JavaScript:
{% highlight js %}
```js
$('#myModal').on('shown.bs.modal', function () {
$('#myInput').trigger('focus')
})
{% endhighlight %}
```
{% include callout-info-prefersreducedmotion.md %}
{{< callout info >}}
{{< partial "callout-info-prefersreducedmotion.md" >}}
{{< /callout >}}
Keep reading for demos and usage guidelines.
@ -55,7 +57,7 @@ Below is a _static_ modal example (meaning its `position` and `display` have bee
</div>
</div>
{% highlight html %}
```html
<div class="modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
@ -75,7 +77,7 @@ Below is a _static_ modal example (meaning its `position` and `display` have bee
</div>
</div>
</div>
{% endhighlight %}
```
### Live demo
@ -107,7 +109,7 @@ Toggle a working modal demo by clicking the button below. It will slide down and
</button>
</div>
{% highlight html %}
```html
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Launch demo modal
@ -133,7 +135,7 @@ Toggle a working modal demo by clicking the button below. It will slide down and
</div>
</div>
</div>
{% endhighlight %}
```
### Static backdrop
@ -165,7 +167,7 @@ When backdrop is set to static, the modal will not close when clicking outside i
</button>
</div>
{% highlight html %}
```html
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#staticBackdrop">
Launch static backdrop modal
@ -191,7 +193,7 @@ When backdrop is set to static, the modal will not close when clicking outside i
</div>
</div>
</div>
{% endhighlight %}
```
### Scrolling long content
@ -286,12 +288,12 @@ You can also create a scrollable modal that allows scroll the modal body by addi
</button>
</div>
{% highlight html %}
```html
<!-- Scrollable modal -->
<div class="modal-dialog modal-dialog-scrollable">
...
</div>
{% endhighlight %}
```
### Vertically centered
@ -350,7 +352,7 @@ Add `.modal-dialog-centered` to `.modal-dialog` to vertically center the modal.
</button>
</div>
{% highlight html %}
```html
<!-- Vertically centered modal -->
<div class="modal-dialog modal-dialog-centered">
...
@ -360,11 +362,11 @@ Add `.modal-dialog-centered` to `.modal-dialog` to vertically center the modal.
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
...
</div>
{% endhighlight %}
```
### Tooltips and popovers
[Tooltips]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/tooltips/) and [popovers]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/popovers/) can be placed within modals as needed. When modals are closed, any tooltips and popovers within are also automatically dismissed.
[Tooltips]({{< docsref "/components/tooltips" >}}) and [popovers]({{< docsref "/components/popovers" >}}) can be placed within modals as needed. When modals are closed, any tooltips and popovers within are also automatically dismissed.
<div class="modal fade" id="exampleModalPopovers" tabindex="-1" aria-labelledby="exampleModalPopoversLabel" aria-hidden="true">
<div class="modal-dialog">
@ -396,7 +398,7 @@ Add `.modal-dialog-centered` to `.modal-dialog` to vertically center the modal.
</button>
</div>
{% highlight html %}
```html
<div class="modal-body">
<h5>Popover in a modal</h5>
<p>This <a href="#" role="button" class="btn btn-secondary popover-test" title="Popover title" data-content="Popover body content is set in this attribute.">button</a> triggers a popover on click.</p>
@ -404,7 +406,7 @@ Add `.modal-dialog-centered` to `.modal-dialog` to vertically center the modal.
<h5>Tooltips in a modal</h5>
<p><a href="#" class="tooltip-test" title="Tooltip">This link</a> and <a href="#" class="tooltip-test" title="Tooltip">that link</a> have tooltips on hover.</p>
</div>
{% endhighlight %}
```
### Using the grid
@ -459,7 +461,7 @@ Utilize the Bootstrap grid system within a modal by nesting `.container-fluid` w
</button>
</div>
{% highlight html %}
```html
<div class="modal-body">
<div class="container-fluid">
<div class="row">
@ -488,7 +490,7 @@ Utilize the Bootstrap grid system within a modal by nesting `.container-fluid` w
</div>
</div>
</div>
{% endhighlight %}
```
### Varying modal content
@ -496,7 +498,7 @@ Have a bunch of buttons that all trigger the same modal with slightly different
Below is a live demo followed by example HTML and JavaScript. For more information, [read the modal events docs](#events) for details on `relatedTarget`.
{% capture example %}
{{< example >}}
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@mdo">Open modal for @mdo</button>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@fat">Open modal for @fat</button>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@getbootstrap">Open modal for @getbootstrap</button>
@ -529,10 +531,9 @@ Below is a live demo followed by example HTML and JavaScript. For more informati
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% highlight js %}
```js
$('#exampleModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget) // Button that triggered the modal
var recipient = button.data('whatever') // Extract info from data-* attributes
@ -542,7 +543,7 @@ $('#exampleModal').on('show.bs.modal', function (event) {
modal.find('.modal-title').text('New message to ' + recipient)
modal.find('.modal-body input').val(recipient)
})
{% endhighlight %}
```
### Change animation
@ -554,11 +555,11 @@ If you want for example a zoom-in animation, you can set `$modal-fade-transform:
For modals that simply appear rather than fade in to view, remove the `.fade` class from your modal markup.
{% highlight html %}
```html
<div class="modal" tabindex="-1" aria-labelledby="..." aria-hidden="true">
...
</div>
{% endhighlight %}
```
### Dynamic heights
@ -616,16 +617,15 @@ Our default modal without modifier class constitutes the "medium" size modal.
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalSm">Small modal</button>
</div>
{% highlight html %}
```html
<div class="modal-dialog modal-xl">...</div>
<div class="modal-dialog modal-lg">...</div>
<div class="modal-dialog modal-sm">...</div>
{% endhighlight %}
```
<div class="modal fade" id="exampleModalXl" tabindex="-1" aria-labelledby="exampleModalXlLabel" aria-hidden="true">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title h4" id="exampleModalXlLabel">Extra large modal</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
@ -642,7 +642,6 @@ Our default modal without modifier class constitutes the "medium" size modal.
<div class="modal fade" id="exampleModalLg" tabindex="-1" aria-labelledby="exampleModalLgLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title h4" id="exampleModalLgLabel">Large modal</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
@ -680,15 +679,17 @@ The modal plugin toggles your hidden content on demand, via data attributes or J
Activate a modal without writing JavaScript. Set `data-toggle="modal"` on a controller element, like a button, along with a `data-target="#foo"` or `href="#foo"` to target a specific modal to toggle.
{% highlight html %}
```html
<button type="button" data-toggle="modal" data-target="#myModal">Launch modal</button>
{% endhighlight %}
```
### Via JavaScript
Call a modal with id `myModal` with a single line of JavaScript:
{% highlight js %}$('#myModal').modal(options){% endhighlight %}
```js
$('#myModal').modal(options)
```
### Options
@ -733,41 +734,51 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap
### Methods
{% include callout-danger-async-methods.md %}
{{< callout danger >}}
{{< partial "callout-danger-async-methods.md" >}}
{{< /callout >}}
#### `.modal(options)`
Activates your content as a modal. Accepts an optional options `object`.
{% highlight js %}
```js
$('#myModal').modal({
keyboard: false
})
{% endhighlight %}
```
#### `.modal('toggle')`
Manually toggles a modal. **Returns to the caller before the modal has actually been shown or hidden** (i.e. before the `shown.bs.modal` or `hidden.bs.modal` event occurs).
{% highlight js %}$('#myModal').modal('toggle'){% endhighlight %}
```js
$('#myModal').modal('toggle')
```
#### `.modal('show')`
Manually opens a modal. **Returns to the caller before the modal has actually been shown** (i.e. before the `shown.bs.modal` event occurs).
{% highlight js %}$('#myModal').modal('show'){% endhighlight %}
```js
$('#myModal').modal('show')
```
#### `.modal('hide')`
Manually hides a modal. **Returns to the caller before the modal has actually been hidden** (i.e. before the `hidden.bs.modal` event occurs).
{% highlight js %}$('#myModal').modal('hide'){% endhighlight %}
```js
$('#myModal').modal('hide')
```
#### `.modal('handleUpdate')`
Manually readjust the modal's position if the height of a modal changes while it is open (i.e. in case a scrollbar appears).
{% highlight js %}$('#myModal').modal('handleUpdate'){% endhighlight %}
```js
$('#myModal').modal('handleUpdate')
```
#### `.modal('dispose')`
@ -808,8 +819,8 @@ Bootstrap's modal class exposes a few events for hooking into modal functionalit
</tbody>
</table>
{% highlight js %}
```js
$('#myModal').on('hidden.bs.modal', function (e) {
// do something...
})
{% endhighlight %}
```

View File

@ -12,12 +12,14 @@ 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}` for responsive collapsing and [color scheme](#color-schemes) classes.
- Navbars and their contents are fluid by default. Use [optional containers](#containers) to limit their horizontal width.
- Use our [spacing]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/spacing/) and [flex]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/flex/) utility classes for controlling spacing and alignment within navbars.
- 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.
- Navbars are hidden by default when printing. Force them to be printed by adding `.d-print` to the `.navbar`. See the [display]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/display/) utility class.
- Navbars are hidden by default when printing. Force them to be printed by adding `.d-print` to the `.navbar`. See the [display]({{< docsref "/utilities/display" >}}) utility class.
- 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.
{% include callout-info-prefersreducedmotion.md %}
{{< callout info >}}
{{< partial "callout-info-prefersreducedmotion.md" >}}
{{< /callout >}}
## Supported content
@ -32,7 +34,7 @@ Navbars come with built-in support for a handful of sub-components. Choose from
Here's an example of all the sub-components included in a responsive light-themed navbar that automatically collapses at the `lg` (large) breakpoint.
{% capture example %}
{{< example >}}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
@ -68,16 +70,15 @@ Here's an example of all the sub-components included in a responsive light-theme
</form>
</div>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
This example uses [color]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/colors/) (`bg-light`) and [spacing]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/spacing/) (`my-2`, `my-lg-0`, `mr-sm-0`, `my-sm-0`) utility classes.
This example uses [color]({{< docsref "/utilities/colors" >}}) (`bg-light`) and [spacing]({{< docsref "/utilities/spacing" >}}) (`my-2`, `my-lg-0`, `mr-sm-0`, `my-sm-0`) 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.
{% capture example %}
{{< example >}}
<!-- As a link -->
<nav class="navbar navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
@ -87,31 +88,28 @@ The `.navbar-brand` can be applied to most elements, but an anchor works best, a
<nav class="navbar navbar-light bg-light">
<span class="navbar-brand mb-0 h1">Navbar</span>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Adding images to the `.navbar-brand` will likely always require custom styles or utilities to properly size. Here are some examples to demonstrate.
{% capture example %}
{{< example >}}
<!-- Just an image -->
<nav class="navbar navbar-light bg-light">
<a class="navbar-brand" href="#">
<img src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/brand/bootstrap-solid.svg" width="30" height="30" alt="">
<img src="/docs/{{< param docs_version >}}/assets/brand/bootstrap-solid.svg" width="30" height="30" alt="">
</a>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture example %}
{{< example >}}
<!-- Image and text -->
<nav class="navbar navbar-light bg-light">
<a class="navbar-brand" href="#">
<img src="{{ site.baseurl }}/docs/{{ site.docs_version }}/assets/brand/bootstrap-solid.svg" width="30" height="30" class="d-inline-block align-top" alt="">
<img src="/docs/{{< param docs_version >}}/assets/brand/bootstrap-solid.svg" width="30" height="30" class="d-inline-block align-top" alt="">
Bootstrap
</a>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Nav
@ -119,7 +117,7 @@ Navbar navigation links build on our `.nav` options with their own modifier clas
Active states—with `.active`—to indicate the current page can be applied directly to `.nav-link`s or their immediate parent `.nav-item`s.
{% capture example %}
{{< example >}}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
@ -142,12 +140,11 @@ Active states—with `.active`—to indicate the current page can be applied dir
</ul>
</div>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
And because we use classes for our navs, you can avoid the list-based approach entirely if you like.
{% capture example %}
{{< example >}}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
@ -162,12 +159,11 @@ And because we use classes for our navs, you can avoid the list-based approach e
</div>
</div>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /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.
{% capture example %}
{{< example >}}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
@ -197,26 +193,24 @@ You can also use dropdowns in your navbar. Dropdown menus require a wrapping ele
</ul>
</div>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Forms
Place various form controls and components within a navbar with `.form-inline`.
{% capture example %}
{{< example >}}
<nav class="navbar navbar-light bg-light">
<form class="form-inline">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Immediate child elements of `.navbar` use flex layout and will default to `justify-content: space-between`. Use additional [flex utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/flex/) as needed to adjust this behavior.
Immediate child elements of `.navbar` use flex layout and will default to `justify-content: space-between`. Use additional [flex utilities]({{< docsref "/utilities/flex" >}}) as needed to adjust this behavior.
{% capture example %}
{{< example >}}
<nav class="navbar navbar-light bg-light">
<a class="navbar-brand">Navbar</a>
<form class="form-inline">
@ -224,12 +218,11 @@ Immediate child elements of `.navbar` use flex layout and will default to `justi
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Input groups work, too:
{% capture example %}
{{< example >}}
<nav class="navbar navbar-light bg-light">
<form class="form-inline">
<div class="input-group">
@ -240,37 +233,34 @@ Input groups work, too:
</div>
</form>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /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.
{% capture example %}
{{< example >}}
<nav class="navbar navbar-light bg-light">
<form class="form-inline">
<button class="btn btn-outline-success" type="button">Main button</button>
<button class="btn btn-sm btn-outline-secondary" type="button">Smaller button</button>
</form>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /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.
{% capture example %}
{{< example >}}
<nav class="navbar navbar-light bg-light">
<span class="navbar-text">
Navbar text with an inline element
</span>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Mix and match with other components and utilities as needed.
{% capture example %}
{{< example >}}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar w/ text</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
@ -293,8 +283,7 @@ Mix and match with other components and utilities as needed.
</span>
</div>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Color schemes
@ -306,7 +295,6 @@ Theming the navbar has never been easier thanks to the combination of theming cl
<button class="navbar-toggler" type="button" data-toggle="collapse" data-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 mr-auto">
<li class="nav-item active">
@ -334,7 +322,6 @@ Theming the navbar has never been easier thanks to the combination of theming cl
<button class="navbar-toggler" type="button" data-toggle="collapse" data-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 mr-auto">
<li class="nav-item active">
@ -362,7 +349,6 @@ Theming the navbar has never been easier thanks to the combination of theming cl
<button class="navbar-toggler" type="button" data-toggle="collapse" data-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 mr-auto">
<li class="nav-item active">
@ -386,7 +372,7 @@ Theming the navbar has never been easier thanks to the combination of theming cl
</nav>
</div>
{% highlight html %}
```html
<nav class="navbar navbar-dark bg-dark">
<!-- Navbar content -->
</nav>
@ -398,65 +384,59 @@ Theming the navbar has never been easier thanks to the combination of theming cl
<nav class="navbar navbar-light" style="background-color: #e3f2fd;">
<!-- Navbar content -->
</nav>
{% endhighlight %}
```
## Containers
Although it's not required, you can wrap a navbar in a `.container` to center it on a page. Or you can add a container inside the `.navbar` to only center the contents of a [fixed or static top navbar](#placement).
{% capture example %}
{{< example >}}
<div class="container">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
</nav>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
When the container is within your navbar, its horizontal padding is removed at breakpoints lower than your specified `.navbar-expand{-sm|-md|-lg|-xl}` class. This ensures we're not doubling up on padding unnecessarily on lower viewports when your navbar is collapsed.
{% capture example %}
{{< example >}}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<a class="navbar-brand" href="#">Navbar</a>
</div>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Placement
Use our [position utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/position/) to place navbars in non-static positions. Choose from fixed to the top, fixed to the bottom, or stickied to the top (scrolls with the page until it reaches the top, then stays there). Fixed navbars use `position: fixed`, meaning they're pulled from the normal flow of the DOM and may require custom CSS (e.g., `padding-top` on the `<body>`) to prevent overlap with other elements.
Use our [position utilities]({{< docsref "/utilities/position" >}}) to place navbars in non-static positions. Choose from fixed to the top, fixed to the bottom, or stickied to the top (scrolls with the page until it reaches the top, 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.
Also note that **`.sticky-top` uses `position: sticky`, which [isn't fully supported in every browser](https://caniuse.com/css-sticky)**.
{% capture example %}
{{< example >}}
<nav class="navbar navbar-light bg-light">
<a class="navbar-brand" href="#">Default</a>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture example %}
{{< example >}}
<nav class="navbar fixed-top navbar-light bg-light">
<a class="navbar-brand" href="#">Fixed top</a>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture example %}
{{< example >}}
<nav class="navbar fixed-bottom navbar-light bg-light">
<a class="navbar-brand" href="#">Fixed bottom</a>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture example %}
{{< example >}}
<nav class="navbar sticky-top navbar-light bg-light">
<a class="navbar-brand" href="#">Sticky top</a>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Responsive behaviors
@ -470,7 +450,7 @@ Navbar togglers are left-aligned by default, but should they follow a sibling el
With no `.navbar-brand` shown at the smallest breakpoint:
{% capture example %}
{{< example >}}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
@ -494,12 +474,11 @@ With no `.navbar-brand` shown at the smallest breakpoint:
</form>
</div>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
With a brand name shown on the left and toggler on the right:
{% capture example %}
{{< example >}}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
@ -524,12 +503,11 @@ With a brand name shown on the left and toggler on the right:
</form>
</div>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
With a toggler on the left and brand name on the right:
{% capture example %}
{{< example >}}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
@ -554,14 +532,13 @@ With a toggler on the left and brand name on the right:
</form>
</div>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /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-target` matching, that's easily done!
{% capture example %}
{{< example >}}
<div class="fixed-top">
<div class="collapse" id="navbarToggleExternalContent">
<div class="bg-dark p-4">
@ -575,7 +552,6 @@ Sometimes you want to use the collapse plugin to trigger a container element for
</button>
</nav>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /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 controlsbut support for this is currently quite patchy.

View File

@ -12,12 +12,11 @@ Navigation available in Bootstrap share general markup and styles, from the base
The base `.nav` component is built with flexbox and provide a strong foundation for building all types of navigation components. It includes some style overrides (for working with lists), some link padding for larger hit areas, and basic disabled styling.
{% capture callout %}
{{< callout info >}}
The base `.nav` component does not include any `.active` state. The following examples include the class, mainly to demonstrate that this particular class does not trigger any special styling.
{% endcapture %}
{% include callout.html content=callout type="info" %}
{{< /callout >}}
{% capture example %}
{{< example >}}
<ul class="nav">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
@ -32,20 +31,18 @@ The base `.nav` component does not include any `.active` state. The following ex
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Classes are used throughout, so your markup can be super flexible. Use `<ul>`s like above, `<ol>` if the order of your items is important, or roll your own with a `<nav>` element. Because the `.nav` uses `display: flex`, the nav links behave the same as nav items would, but without the extra markup.
{% capture example %}
{{< example >}}
<nav class="nav">
<a class="nav-link active" href="#">Active</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Available styles
@ -53,11 +50,11 @@ Change the style of `.nav`s component with modifiers and utilities. Mix and matc
### Horizontal alignment
Change the horizontal alignment of your nav with [flexbox utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/layout/grid/#horizontal-alignment). By default, navs are left-aligned, but you can easily change them to center or right aligned.
Change the horizontal alignment of your nav with [flexbox utilities]({{< docsref "/layout/grid#horizontal-alignment" >}}). By default, navs are left-aligned, but you can easily change them to center or right aligned.
Centered with `.justify-content-center`:
{% capture example %}
{{< example >}}
<ul class="nav justify-content-center">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
@ -72,12 +69,11 @@ Centered with `.justify-content-center`:
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Right-aligned with `.justify-content-end`:
{% capture example %}
{{< example >}}
<ul class="nav justify-content-end">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
@ -92,14 +88,13 @@ Right-aligned with `.justify-content-end`:
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Vertical
Stack your navigation by changing the flex item direction with the `.flex-column` utility. Need to stack them on some viewports but not others? Use the responsive versions (e.g., `.flex-sm-column`).
{% capture example %}
{{< example >}}
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
@ -114,26 +109,24 @@ Stack your navigation by changing the flex item direction with the `.flex-column
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
As always, vertical navigation is possible without `<ul>`s, too.
{% capture example %}
{{< example >}}
<nav class="nav flex-column">
<a class="nav-link active" href="#">Active</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Tabs
Takes the basic nav from above and adds the `.nav-tabs` class to generate a tabbed interface. Use them to create tabbable regions with our [tab JavaScript plugin](#javascript-behavior).
{% capture example %}
{{< example >}}
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
@ -148,14 +141,13 @@ Takes the basic nav from above and adds the `.nav-tabs` class to generate a tabb
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Pills
Take that same HTML, but use `.nav-pills` instead:
{% capture example %}
{{< example >}}
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
@ -170,14 +162,13 @@ Take that same HTML, but use `.nav-pills` instead:
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Fill and justify
Force your `.nav`'s contents to extend the full available width one of two modifier classes. To proportionately fill all available space with your `.nav-item`s, use `.nav-fill`. Notice that all horizontal space is occupied, but not every nav item has the same width.
{% capture example %}
{{< example >}}
<ul class="nav nav-pills nav-fill">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
@ -192,24 +183,22 @@ Force your `.nav`'s contents to extend the full available width one of two modif
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
When using a `<nav>`-based navigation, you can safely omit `.nav-item` as only `.nav-link` is required for styling `<a>` elements.
{% capture example %}
{{< example >}}
<nav class="nav nav-pills nav-fill">
<a class="nav-link active" href="#">Active</a>
<a class="nav-link" href="#">Much longer nav link</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
For equal-width elements, use `.nav-justified`. All horizontal space will be occupied by nav links, but unlike the `.nav-fill` above, every nav item will be the same width.
{% capture example %}
{{< example >}}
<ul class="nav nav-pills nav-justified">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
@ -224,12 +213,11 @@ For equal-width elements, use `.nav-justified`. All horizontal space will be occ
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Similar to the `.nav-fill` example using a `<nav>`-based navigation.
{% capture example %}
{{< example >}}
<nav class="nav nav-pills nav-justified">
<a class="nav-link active" href="#">Active</a>
<a class="nav-link" href="#">Much longer nav link</a>
@ -237,21 +225,19 @@ Similar to the `.nav-fill` example using a `<nav>`-based navigation.
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Working with flex utilities
If you need responsive nav variations, consider using a series of [flexbox utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/flex/). While more verbose, these utilities offer greater customization across responsive breakpoints. In the example below, our nav will be stacked on the lowest breakpoint, then adapt to a horizontal layout that fills the available width starting from the small breakpoint.
If you need responsive nav variations, consider using a series of [flexbox utilities]({{< docsref "/utilities/flex" >}}). While more verbose, these utilities offer greater customization across responsive breakpoints. In the example below, our nav will be stacked on the lowest breakpoint, then adapt to a horizontal layout that fills the available width starting from the small breakpoint.
{% capture example %}
{{< example >}}
<nav class="nav nav-pills flex-column flex-sm-row">
<a class="flex-sm-fill text-sm-center nav-link active" href="#">Active</a>
<a class="flex-sm-fill text-sm-center nav-link" href="#">Longer nav link</a>
<a class="flex-sm-fill text-sm-center nav-link" href="#">Link</a>
<a class="flex-sm-fill text-sm-center nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Regarding accessibility
@ -261,11 +247,11 @@ Note that navigation bars, even if visually styled as tabs with the `.nav-tabs`
## Using dropdowns
Add dropdown menus with a little extra HTML and the [dropdowns JavaScript plugin]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/dropdowns/#usage).
Add dropdown menus with a little extra HTML and the [dropdowns JavaScript plugin]({{< docsref "/components/dropdowns#usage" >}}).
### Tabs with dropdowns
{% capture example %}
{{< example >}}
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
@ -287,12 +273,11 @@ Add dropdown menus with a little extra HTML and the [dropdowns JavaScript plugin
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Pills with dropdowns
{% capture example %}
{{< example >}}
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
@ -314,14 +299,13 @@ Add dropdown menus with a little extra HTML and the [dropdowns JavaScript plugin
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## JavaScript behavior
Use the tab JavaScript plugin—include it individually or through the compiled `bootstrap.js` file—to extend our navigational tabs and pills to create tabbable panes of local content, even via dropdown menus.
If you're building our JavaScript from source, it [requires `util.js`]({{ site.baseurl }}/docs/{{ site.docs_version }}/getting-started/javascript/#util).
If you're building our JavaScript from source, it [requires `util.js`]({{< docsref "/getting-started/javascript#util" >}}).
Dynamic tabbed interfaces, as described in the [<abbr title="Web Accessibility Initiative">WAI</abbr> <abbr title="Accessible Rich Internet Applications">ARIA</abbr> Authoring Practices](https://www.w3.org/TR/wai-aria-practices/#tabpanel), require `role="tablist"`, `role="tab"`, `role="tabpanel"`, and additional `aria-` attributes in order to convey their structure, functionality and current state to users of assistive technologies (such as screen readers).
@ -352,7 +336,7 @@ Note that dynamic tabbed interfaces should <em>not</em> contain dropdown menus,
</div>
</div>
{% highlight html %}
```html
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Home</a>
@ -369,7 +353,7 @@ Note that dynamic tabbed interfaces should <em>not</em> contain dropdown menus,
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
<div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">...</div>
</div>
{% endhighlight %}
```
To help fit your needs, this works with `<ul>`-based markup, as shown above, or with any arbitrary "roll your own" markup. Note that if you're using `<nav>`, you shouldn't add `role="tablist"` directly to it, as this would override the element's native role as a navigation landmark. Instead, switch to an alternative element (in the example below, a simple `<div>`) and wrap the `<nav>` around it.
@ -394,7 +378,7 @@ To help fit your needs, this works with `<ul>`-based markup, as shown above, or
</div>
</div>
{% highlight html %}
```html
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<a class="nav-link active" id="nav-home-tab" data-toggle="tab" href="#nav-home" role="tab" aria-controls="nav-home" aria-selected="true">Home</a>
@ -407,7 +391,7 @@ To help fit your needs, this works with `<ul>`-based markup, as shown above, or
<div class="tab-pane fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">...</div>
<div class="tab-pane fade" id="nav-contact" role="tabpanel" aria-labelledby="nav-contact-tab">...</div>
</div>
{% endhighlight %}
```
The tabs plugin also works with pills.
@ -436,7 +420,7 @@ The tabs plugin also works with pills.
</div>
</div>
{% highlight html %}
```html
<ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
<li class="nav-item" role="presentation">
<a class="nav-link active" id="pills-home-tab" data-toggle="pill" href="#pills-home" role="tab" aria-controls="pills-home" aria-selected="true">Home</a>
@ -453,7 +437,7 @@ The tabs plugin also works with pills.
<div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab">...</div>
<div class="tab-pane fade" id="pills-contact" role="tabpanel" aria-labelledby="pills-contact-tab">...</div>
</div>
{% endhighlight %}
```
And with vertical pills.
@ -486,7 +470,7 @@ And with vertical pills.
</div>
</div>
{% highlight html %}
```html
<div class="row">
<div class="col-3">
<div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
@ -505,13 +489,13 @@ And with vertical pills.
</div>
</div>
</div>
{% endhighlight %}
```
### Using data attributes
You can activate a tab or pill navigation without writing any JavaScript by simply specifying `data-toggle="tab"` or `data-toggle="pill"` on an element. Use these data attributes on `.nav-tabs` or `.nav-pills`.
{% highlight html %}
```html
<!-- Nav tabs -->
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
@ -535,50 +519,52 @@ You can activate a tab or pill navigation without writing any JavaScript by simp
<div class="tab-pane" id="messages" role="tabpanel" aria-labelledby="messages-tab">...</div>
<div class="tab-pane" id="settings" role="tabpanel" aria-labelledby="settings-tab">...</div>
</div>
{% endhighlight %}
```
### Via JavaScript
Enable tabbable tabs via JavaScript (each tab needs to be activated individually):
{% highlight js %}
```js
$('#myTab a').on('click', function (e) {
e.preventDefault()
$(this).tab('show')
})
{% endhighlight %}
```
You can activate individual tabs in several ways:
{% highlight js %}
```js
$('#myTab a[href="#profile"]').tab('show') // Select tab by name
$('#myTab li:first-child a').tab('show') // Select first tab
$('#myTab li:last-child a').tab('show') // Select last tab
$('#myTab li:nth-child(3) a').tab('show') // Select third tab
{% endhighlight %}
```
### Fade effect
To make tabs fade in, add `.fade` to each `.tab-pane`. The first tab pane must also have `.show` to make the initial content visible.
{% highlight html %}
```html
<div class="tab-content">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">...</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
<div class="tab-pane fade" id="messages" role="tabpanel" aria-labelledby="messages-tab">...</div>
<div class="tab-pane fade" id="settings" role="tabpanel" aria-labelledby="settings-tab">...</div>
</div>
{% endhighlight %}
```
### Methods
{% include callout-danger-async-methods.md %}
{{< callout danger >}}
{{< partial "callout-danger-async-methods.md" >}}
{{< /callout >}}
#### $().tab
Activates a tab element and content container. Tab should have either a `data-target` or an `href` targeting a container node in the DOM.
{% highlight html %}
```html
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Home</a>
@ -606,15 +592,15 @@ Activates a tab element and content container. Tab should have either a `data-ta
$('#myTab li:last-child a').tab('show')
})
</script>
{% endhighlight %}
```
#### .tab('show')
Selects the given tab and shows its associated pane. Any other tab that was previously selected becomes unselected and its associated pane is hidden. **Returns to the caller before the tab pane has actually been shown** (i.e. before the `shown.bs.tab` event occurs).
{% highlight js %}
```js
$('#someTab').tab('show')
{% endhighlight %}
```
#### .tab('dispose')
@ -658,9 +644,9 @@ If no tab was already active, then the `hide.bs.tab` and `hidden.bs.tab` events
</tbody>
</table>
{% highlight js %}
```js
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
e.target // newly activated tab
e.relatedTarget // previous active tab
})
{% endhighlight %}
```

View File

@ -12,7 +12,7 @@ We use a large block of connected links for our pagination, making links hard to
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"`.
{% capture example %}
{{< example >}}
<nav aria-label="Page navigation example">
<ul class="pagination">
<li class="page-item"><a class="page-link" href="#">Previous</a></li>
@ -22,14 +22,13 @@ In addition, as pages likely have more than one such navigation section, it's ad
<li class="page-item"><a class="page-link" href="#">Next</a></li>
</ul>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /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.
{% capture example %}
{{< example >}}
<nav aria-label="Page navigation example">
<ul class="pagination">
<li class="page-item">
@ -47,8 +46,7 @@ Looking to use an icon or symbol in place of text for some pagination links? Be
</li>
</ul>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Disabled and active states
@ -56,7 +54,7 @@ Pagination links are customizable for different circumstances. Use `.disabled` f
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.
{% capture example %}
{{< example >}}
<nav aria-label="...">
<ul class="pagination">
<li class="page-item disabled">
@ -72,12 +70,11 @@ While the `.disabled` class uses `pointer-events: none` to _try_ to disable the
</li>
</ul>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /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.
{% capture example %}
{{< example >}}
<nav aria-label="...">
<ul class="pagination">
<li class="page-item disabled">
@ -93,14 +90,13 @@ You can optionally swap out active or disabled anchors for `<span>`, or omit the
</li>
</ul>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Sizing
Fancy larger or smaller pagination? Add `.pagination-lg` or `.pagination-sm` for additional sizes.
{% capture example %}
{{< example >}}
<nav aria-label="...">
<ul class="pagination pagination-lg">
<li class="page-item active" aria-current="page">
@ -110,10 +106,9 @@ Fancy larger or smaller pagination? Add `.pagination-lg` or `.pagination-sm` for
<li class="page-item"><a class="page-link" href="#">3</a></li>
</ul>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture example %}
{{< example >}}
<nav aria-label="...">
<ul class="pagination pagination-sm">
<li class="page-item active" aria-current="page">
@ -123,14 +118,13 @@ Fancy larger or smaller pagination? Add `.pagination-lg` or `.pagination-sm` for
<li class="page-item"><a class="page-link" href="#">3</a></li>
</ul>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Alignment
Change the alignment of pagination components with [flexbox utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/flex/).
Change the alignment of pagination components with [flexbox utilities]({{< docsref "/utilities/flex" >}}).
{% capture example %}
{{< example >}}
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center">
<li class="page-item disabled">
@ -144,10 +138,9 @@ Change the alignment of pagination components with [flexbox utilities]({{ site.b
</li>
</ul>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture example %}
{{< example >}}
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-end">
<li class="page-item disabled">
@ -161,5 +154,4 @@ Change the alignment of pagination components with [flexbox utilities]({{ site.b
</li>
</ul>
</nav>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}

View File

@ -10,9 +10,9 @@ toc: true
Things to know when using the popover plugin:
- Popovers rely on the 3rd party library [Popper.js](https://popper.js.org/) for positioning. You must include [popper.min.js]({{ site.cdn.popper }}) before bootstrap.js or use `bootstrap.bundle.min.js` / `bootstrap.bundle.js` which contains Popper.js in order for popovers to work!
- Popovers require the [tooltip plugin]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/tooltips/) as a dependency.
- If you're building our JavaScript from source, it [requires `util.js`]({{ site.baseurl }}/docs/{{ site.docs_version }}/getting-started/javascript/#util).
- Popovers rely on the 3rd party library [Popper.js](https://popper.js.org/) for positioning. You must include [popper.min.js]({{< param "cdn.popper" >}}) before bootstrap.js or use `bootstrap.bundle.min.js` / `bootstrap.bundle.js` which contains Popper.js in order for popovers to work!
- Popovers require the [tooltip plugin]({{< docsref "/components/tooltips" >}}) as a dependency.
- If you're building our JavaScript from source, it [requires `util.js`]({{< docsref "/getting-started/javascript#util" >}}).
- Popovers are opt-in for performance reasons, so **you must initialize them yourself**.
- Zero-length `title` and `content` values will never show a popover.
- Specify `container: 'body'` to avoid rendering problems in more complex components (like our input groups, button groups, etc).
@ -22,7 +22,9 @@ Things to know when using the popover plugin:
- Popovers must be hidden before their corresponding elements have been removed from the DOM.
- Popovers can be triggered thanks to an element inside a shadow DOM.
{% include callout-info-prefersreducedmotion.md %}
{{< callout info >}}
{{< partial "callout-info-prefersreducedmotion.md" >}}
{{< /callout >}}
Keep reading to see how popovers work with some examples.
@ -30,30 +32,29 @@ Keep reading to see how popovers work with some examples.
One way to initialize all popovers on a page would be to select them by their `data-toggle` attribute:
{% highlight js %}
```js
$(function () {
$('[data-toggle="popover"]').popover()
})
{% endhighlight %}
```
## Example: Using the `container` option
When you have some styles on a parent element that interfere with a popover, you'll want to specify a custom `container` so that the popover's HTML appears within that element instead.
{% highlight js %}
```js
$(function () {
$('.example-popover').popover({
container: 'body'
})
})
{% endhighlight %}
```
## Example
{% capture example %}
{{< example >}}
<button type="button" class="btn btn-lg btn-danger" data-toggle="popover" title="Popover title" data-content="And here's some amazing content. It's very engaging. Right?">Click to toggle popover</button>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Four directions
@ -76,7 +77,7 @@ Four options are available: top, right, bottom, and left aligned.
</div>
</div>
{% highlight html %}
```html
<button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="top" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
Popover on top
</button>
@ -85,37 +86,34 @@ Four options are available: top, right, bottom, and left aligned.
Popover on right
</button>
<button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="bottom" data-content="Vivamus
sagittis lacus vel augue laoreet rutrum faucibus.">
<button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="bottom" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
Popover on bottom
</button>
<button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="left" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
Popover on left
</button>
{% endhighlight %}
```
### Dismiss on next click
Use the `focus` trigger to dismiss popovers on the user's next click of a different element than the toggle element.
{% capture callout %}
{{< callout danger >}}
#### Specific markup required for dismiss-on-next-click
For proper cross-browser and cross-platform behavior, you must use the `<a>` tag, _not_ the `<button>` tag, and you also must include a [`tabindex`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex) attribute.
{% endcapture %}
{% include callout.html content=callout type="danger" %}
{{< /callout >}}
{% capture example %}
{{< example >}}
<a tabindex="0" class="btn btn-lg btn-danger" role="button" data-toggle="popover" data-trigger="focus" title="Dismissible popover" data-content="And here's some amazing content. It's very engaging. Right?">Dismissible popover</a>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% highlight js %}
```js
$('.popover-dismiss').popover({
trigger: 'focus'
})
{% endhighlight %}
```
### Disabled elements
@ -123,33 +121,33 @@ Elements with the `disabled` attribute aren't interactive, meaning users cannot
For disabled popover triggers, you may also prefer `data-trigger="hover"` so that the popover appears as immediate visual feedback to your users as they may not expect to _click_ on a disabled element.
{% capture example %}
{{< example >}}
<span class="d-inline-block" data-toggle="popover" data-content="Disabled popover">
<button class="btn btn-primary" style="pointer-events: none;" type="button" disabled>Disabled button</button>
</span>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Usage
Enable popovers via JavaScript:
{% highlight js %}$('#example').popover(options){% endhighlight %}
```js
$('#example').popover(options)
```
{% capture callout %}
{{< callout warning >}}
##### GPU acceleration
Popovers sometimes appear blurry on Windows 10 devices due to GPU acceleration and a modified system DPI. The workaround for this in v4 is to disable GPU acceleration as needed on your popovers.
Suggested fix:
{% highlight js %}
```js
Popper.Defaults.modifiers.computeStyle.gpuAcceleration = !(window.devicePixelRatio < 1.5 && /Win/.test(navigator.platform))
{% endhighlight %}
{% endcapture %}
{% include callout.html content=callout type="warning" %}
```
{{< /callout >}}
{% capture callout %}
{{< callout warning >}}
### Making popovers work for keyboard and assistive technology users
To allow keyboard users to activate your popovers, you should only add them to HTML elements that are traditionally keyboard-focusable and interactive (such as links or form controls). Although arbitrary HTML elements (such as `<span>`s) can be made focusable by adding the `tabindex="0"` attribute, this will add potentially annoying and confusing tab stops on non-interactive elements for keyboard users, and most assistive technologies currently do not announce the popover's content in this situation. Additionally, do not rely solely on `hover` as the trigger for your popovers, as this will make them impossible to trigger for keyboard users.
@ -157,17 +155,15 @@ To allow keyboard users to activate your popovers, you should only add them to H
While you can insert rich, structured HTML in popovers with the `html` option, we strongly recommend that you avoid adding an excessive amount of content. The way popovers currently work is that, once displayed, their content is tied to the trigger element with the `aria-describedby` attribute. As a result, the entirety of the popover's content will be announced to assistive technology users as one long, uninterrupted stream.
Additionally, while it is possible to also include interactive controls (such as form elements or links) in your popover (by adding these elements to the `whiteList` or allowed attributes and tags), be aware that currently the popover does not manage keyboard focus order. When a keyboard user opens a popover, focus remains on the triggering element, and as the popover usually does not immediately follow the trigger in the document's structure, there is no guarantee that moving forward/pressing <kbd>TAB</kbd> will move a keyboard user into the popover itself. In short, simply adding interactive controls to a popover is likely to make these controls unreachable/unusable for keyboard users and users of assistive technologies, or at the very least make for an illogical overall focus order. In these cases, consider using a modal dialog instead.
{% endcapture %}
{% include callout.html content=callout type="warning" %}
{{< /callout >}}
### Options
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to `data-`, as in `data-animation=""`.
{% capture callout %}
{{< callout warning >}}
Note that for security reasons the `sanitize`, `sanitizeFn` and `whiteList` options cannot be supplied using data attributes.
{% endcapture %}
{% include callout.html content=callout type="warning" %}
{{< /callout >}}
<table class="table table-bordered table-striped">
<thead>
@ -231,7 +227,7 @@ Note that for security reasons the `sanitize`, `sanitizeFn` and `whiteList` opti
<td>selector</td>
<td>string | false</td>
<td>false</td>
<td>If a selector is provided, popover objects will be delegated to the specified targets. In practice, this is used to enable dynamic HTML content to have popovers added. See <a href="{{ site.repo }}/issues/4215">this</a> and <a href="https://codepen.io/Johann-S/pen/djJYPb">an informative example</a>.</td>
<td>If a selector is provided, popover objects will be delegated to the specified targets. In practice, this is used to enable dynamic HTML content to have popovers added. See <a href="{{< param repo >}}/issues/4215">this</a> and <a href="https://codepen.io/Johann-S/pen/djJYPb">an informative example</a>.</td>
</tr>
<tr>
<td>template</td>
@ -288,7 +284,7 @@ Note that for security reasons the `sanitize`, `sanitizeFn` and `whiteList` opti
<tr>
<td>whiteList</td>
<td>object</td>
<td><a href="{{ site.baseurl }}/docs/{{ site.docs_version }}/getting-started/javascript/#sanitizer">Default value</a></td>
<td><a href="{{< docsref "/getting-started/javascript#sanitizer" >}}">Default value</a></td>
<td>Object which contains allowed attributes and tags</td>
</tr>
<tr>
@ -306,16 +302,17 @@ Note that for security reasons the `sanitize`, `sanitizeFn` and `whiteList` opti
</tbody>
</table>
{% capture callout %}
{{< callout info >}}
#### Data attributes for individual popovers
Options for individual popovers can alternatively be specified through the use of data attributes, as explained above.
{% endcapture %}
{% include callout.html content=callout type="info" %}
{{< /callout >}}
### Methods
{% include callout-danger-async-methods.md %}
{{< callout danger >}}
{{< partial "callout-danger-async-methods.md" >}}
{{< /callout >}}
#### `$().popover(options)`
@ -325,49 +322,65 @@ Initializes popovers for an element collection.
Reveals an element's popover. **Returns to the caller before the popover has actually been shown** (i.e. before the `shown.bs.popover` event occurs). This is considered a "manual" triggering of the popover. Popovers whose title and content are both zero-length are never displayed.
{% highlight js %}$('#element').popover('show'){% endhighlight %}
```js
$('#element').popover('show')
```
#### `.popover('hide')`
Hides an element's popover. **Returns to the caller before the popover has actually been hidden** (i.e. before the `hidden.bs.popover` event occurs). This is considered a "manual" triggering of the popover.
{% highlight js %}$('#element').popover('hide'){% endhighlight %}
```js
$('#element').popover('hide')
```
#### `.popover('toggle')`
Toggles an element's popover. **Returns to the caller before the popover has actually been shown or hidden** (i.e. before the `shown.bs.popover` or `hidden.bs.popover` event occurs). This is considered a "manual" triggering of the popover.
{% highlight js %}$('#element').popover('toggle'){% endhighlight %}
```js
$('#element').popover('toggle')
```
#### `.popover('dispose')`
Hides and destroys an element's popover. Popovers that use delegation (which are created using [the `selector` option](#options)) cannot be individually destroyed on descendant trigger elements.
{% highlight js %}$('#element').popover('dispose'){% endhighlight %}
```js
$('#element').popover('dispose')
```
#### `.popover('enable')`
Gives an element's popover the ability to be shown. **Popovers are enabled by default.**
{% highlight js %}$('#element').popover('enable'){% endhighlight %}
```js
$('#element').popover('enable')
```
#### `.popover('disable')`
Removes the ability for an element's popover to be shown. The popover will only be able to be shown if it is re-enabled.
{% highlight js %}$('#element').popover('disable'){% endhighlight %}
```js
$('#element').popover('disable')
```
#### `.popover('toggleEnabled')`
Toggles the ability for an element's popover to be shown or hidden.
{% highlight js %}$('#element').popover('toggleEnabled'){% endhighlight %}
```js
$('#element').popover('toggleEnabled')
```
#### `.popover('update')`
Updates the position of an element's popover.
{% highlight js %}$('#element').popover('update'){% endhighlight %}
```js
$('#element').popover('update')
```
### Events
@ -402,8 +415,8 @@ Updates the position of an element's popover.
</tbody>
</table>
{% highlight js %}
```js
$('#myPopover').on('hidden.bs.popover', function () {
// do something...
})
{% endhighlight %}
```

View File

@ -17,7 +17,7 @@ Progress components are built with two HTML elements, some CSS to set the width,
Put that all together, and you have the following examples.
{% capture example %}
{{< example >}}
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
</div>
@ -33,48 +33,44 @@ Put that all together, and you have the following examples.
<div class="progress">
<div class="progress-bar" role="progressbar" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Bootstrap provides a handful of [utilities for setting width]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/sizing/). Depending on your needs, these may help with quickly configuring progress.
Bootstrap provides a handful of [utilities for setting width]({{< docsref "/utilities/sizing" >}}). Depending on your needs, these may help with quickly configuring progress.
{% capture example %}
{{< example >}}
<div class="progress">
<div class="progress-bar w-75" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"></div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Labels
Add labels to your progress bars by placing text within the `.progress-bar`.
{% capture example %}
{{< example >}}
<div class="progress">
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">25%</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Height
We only set a `height` value on the `.progress`, so if you change that value the inner `.progress-bar` will automatically resize accordingly.
{% capture example %}
{{< example >}}
<div class="progress" style="height: 1px;">
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div class="progress" style="height: 20px;">
<div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Backgrounds
Use background utility classes to change the appearance of individual progress bars.
{% capture example %}
{{< example >}}
<div class="progress">
<div class="progress-bar bg-success" role="progressbar" style="width: 25%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div>
@ -87,27 +83,25 @@ Use background utility classes to change the appearance of individual progress b
<div class="progress">
<div class="progress-bar bg-danger" role="progressbar" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Multiple bars
Include multiple progress bars in a progress component if you need.
{% capture example %}
{{< example >}}
<div class="progress">
<div class="progress-bar" role="progressbar" style="width: 15%" aria-valuenow="15" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress-bar bg-success" role="progressbar" style="width: 30%" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress-bar bg-info" role="progressbar" style="width: 20%" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"></div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Striped
Add `.progress-bar-striped` to any `.progress-bar` to apply a stripe via CSS gradient over the progress bar's background color.
{% capture example %}
{{< example >}}
<div class="progress">
<div class="progress-bar progress-bar-striped" role="progressbar" style="width: 10%" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100"></div>
</div>
@ -123,8 +117,7 @@ Add `.progress-bar-striped` to any `.progress-bar` to apply a stripe via CSS gra
<div class="progress">
<div class="progress-bar progress-bar-striped bg-danger" role="progressbar" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Animated stripes
@ -139,8 +132,8 @@ The striped gradient can also be animated. Add `.progress-bar-animated` to `.pro
</button>
</div>
{% highlight html %}
```html
<div class="progress">
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 75%"></div>
</div>
{% endhighlight %}
```

View File

@ -10,8 +10,8 @@ toc: true
Scrollspy has a few requirements to function properly:
- If you're building our JavaScript from source, it [requires `util.js`]({{ site.baseurl }}/docs/{{ site.docs_version }}/getting-started/javascript/#util).
- It must be used on a Bootstrap [nav component]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/navs/) or [list group]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/list-group/).
- If you're building our JavaScript from source, it [requires `util.js`]({{< docsref "/getting-started/javascript#util" >}}).
- It must be used on a Bootstrap [nav component]({{< docsref "/components/navs" >}}) or [list group]({{< docsref "/components/list-group" >}}).
- Scrollspy requires `position: relative;` on the element you're spying on, usually the `<body>`.
- When spying on elements other than the `<body>`, be sure to have a `height` set and `overflow-y: scroll;` applied.
- Anchors (`<a>`) are required and must point to an element with that `id`.
@ -59,7 +59,7 @@ Scroll the area below the navbar and watch the active class change. The dropdown
</div>
</div>
{% highlight html %}
```html
<nav id="navbar-example2" class="navbar navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<ul class="nav nav-pills">
@ -92,7 +92,7 @@ Scroll the area below the navbar and watch the active class change. The dropdown
<h4 id="three">three</h4>
<p>...</p>
</div>
{% endhighlight %}
```
## Example with nested nav
@ -139,7 +139,7 @@ Scrollspy also works with nested `.nav`s. If a nested `.nav` is `.active`, its p
</div>
</div>
{% highlight html %}
```html
<nav id="navbar-example3" class="navbar navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<nav class="nav nav-pills flex-column">
@ -173,7 +173,7 @@ Scrollspy also works with nested `.nav`s. If a nested `.nav` is `.active`, its p
<h5 id="item-3-2">Item 3-2</h5>
<p>...</p>
</div>
{% endhighlight %}
```
## Example with list-group
@ -204,7 +204,7 @@ Scrollspy also works with `.list-group`s. Scroll the area next to the list group
</div>
</div>
{% highlight html %}
```html
<div id="list-example" class="list-group">
<a class="list-group-item list-group-item-action" href="#list-item-1">Item 1</a>
<a class="list-group-item list-group-item-action" href="#list-item-2">Item 2</a>
@ -221,7 +221,7 @@ Scrollspy also works with `.list-group`s. Scroll the area next to the list group
<h4 id="list-item-4">Item 4</h4>
<p>...</p>
</div>
{% endhighlight %}
```
## Usage
@ -230,13 +230,13 @@ Scrollspy also works with `.list-group`s. Scroll the area next to the list group
To easily add scrollspy behavior to your topbar navigation, add `data-spy="scroll"` to the element you want to spy on (most typically this would be the `<body>`). Then add the `data-target` attribute with the ID or class of the parent element of any Bootstrap `.nav` component.
{% highlight css %}
```css
body {
position: relative;
}
{% endhighlight %}
```
{% highlight html %}
```html
<body data-spy="scroll" data-target="#navbar-example">
...
<div id="navbar-example">
@ -246,29 +246,27 @@ body {
</div>
...
</body>
{% endhighlight %}
```
### Via JavaScript
After adding `position: relative;` in your CSS, call the scrollspy via JavaScript:
{% highlight js %}
```js
$('body').scrollspy({ target: '#navbar-example' })
{% endhighlight %}
```
{% capture callout %}
{{< callout danger >}}
#### Resolvable ID targets required
Navbar links must have resolvable id targets. For example, a `<a href="#home">home</a>` must correspond to something in the DOM like `<div id="home"></div>`.
{% endcapture %}
{% include callout.html content=callout type="danger" %}
{{< /callout >}}
{% capture callout %}
{{< callout info >}}
#### Non-`:visible` target elements ignored
Target elements that are not [`:visible` according to jQuery](https://api.jquery.com/visible-selector/) will be ignored and their corresponding nav items will never be highlighted.
{% endcapture %}
{% include callout.html content=callout type="info" %}
{{< /callout >}}
### Methods
@ -276,11 +274,11 @@ Target elements that are not [`:visible` according to jQuery](https://api.jquery
When using scrollspy in conjunction with adding or removing of elements from the DOM, you'll need to call the refresh method like so:
{% highlight js %}
```js
$('[data-spy="scroll"]').each(function () {
var $spy = $(this).scrollspy('refresh')
})
{% endhighlight %}
```
#### `.scrollspy('dispose')`
@ -338,8 +336,8 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap
</tbody>
</table>
{% highlight js %}
```js
$('[data-spy="scroll"]').on('activate.bs.scrollspy', function () {
// do something...
})
{% endhighlight %}
```

View File

@ -12,56 +12,59 @@ Bootstrap "spinners" can be used to show the loading state in your projects. The
For accessibility purposes, each loader here includes `role="status"` and a nested `<span class="sr-only">Loading...</span>`.
{% include callout-info-prefersreducedmotion.md %}
{{< callout info >}}
{{< partial "callout-info-prefersreducedmotion.md" >}}
{{< /callout >}}
## Border spinner
Use the border spinners for a lightweight loading indicator.
{% capture example %}
{{< example >}}
<div class="spinner-border" role="status">
<span class="sr-only">Loading...</span>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /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.
{% capture example %}
{% for color in site.data.theme-colors %}
<div class="spinner-border text-{{ color.name }}" role="status">
{{< example >}}
{{< spinner.inline >}}
{{- range (index $.Site.Data "theme-colors") }}
<div class="spinner-border text-{{ .name }}" role="status">
<span class="sr-only">Loading...</span>
</div>{% endfor %}
{% endcapture %}
{% include example.html content=example %}
</div>
{{- end -}}
{{< /spinner.inline >}}
{{< /example >}}
{% capture callout %}
{{< 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.
{% endcapture %}
{% include callout.html content=callout type="info" %}
{{< /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!
{% capture example %}
{{< example >}}
<div class="spinner-grow" role="status">
<span class="sr-only">Loading...</span>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /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.
{% capture example %}
{% for color in site.data.theme-colors %}
<div class="spinner-grow text-{{ color.name }}" role="status">
{{< example >}}
{{< spinner.inline >}}
{{- range (index $.Site.Data "theme-colors") }}
<div class="spinner-grow text-{{ .name }}" role="status">
<span class="sr-only">Loading...</span>
</div>{% endfor %}
{% endcapture %}
{% include example.html content=example %}
</div>
{{- end -}}
{{< /spinner.inline >}}
{{< /example >}}
## Alignment
@ -71,12 +74,11 @@ Spinners in Bootstrap are built with `rem`s, `currentColor`, and `display: inlin
Use [margin utilities][margin] like `.m-5` for easy spacing.
{% capture example %}
{{< example >}}
<div class="spinner-border m-5" role="status">
<span class="sr-only">Loading...</span>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
### Placement
@ -84,76 +86,70 @@ Use [flexbox utilities][flex], [float utilities][float], or [text alignment][tex
#### Flex
{% capture example %}
{{< example >}}
<div class="d-flex justify-content-center">
<div class="spinner-border" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture example %}
{{< example >}}
<div class="d-flex align-items-center">
<strong>Loading...</strong>
<div class="spinner-border ml-auto" role="status" aria-hidden="true"></div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
#### Floats
{% capture example %}
{{< example >}}
<div class="clearfix">
<div class="spinner-border float-right" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
#### Text align
{% capture example %}
{{< example >}}
<div class="text-center">
<div class="spinner-border" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
## Size
Add `.spinner-border-sm` and `.spinner-grow-sm` to make a smaller spinner that can quickly be used within other components.
{% capture example %}
{{< example >}}
<div class="spinner-border spinner-border-sm" role="status">
<span class="sr-only">Loading...</span>
</div>
<div class="spinner-grow spinner-grow-sm" role="status">
<span class="sr-only">Loading...</span>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
Or, use custom CSS or inline styles to change the dimensions as needed.
{% capture example %}
{{< example >}}
<div class="spinner-border" style="width: 3rem; height: 3rem;" role="status">
<span class="sr-only">Loading...</span>
</div>
<div class="spinner-grow" style="width: 3rem; height: 3rem;" role="status">
<span class="sr-only">Loading...</span>
</div>
{% endcapture %}
{% include example.html content=example %}
{{< /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.
{% capture example %}
{{< example >}}
<button class="btn btn-primary" type="button" disabled>
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
<span class="sr-only">Loading...</span>
@ -162,10 +158,9 @@ Use spinners within buttons to indicate an action is currently processing or tak
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
Loading...
</button>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
{% capture example %}
{{< example >}}
<button class="btn btn-primary" type="button" disabled>
<span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
<span class="sr-only">Loading...</span>
@ -174,14 +169,13 @@ Use spinners within buttons to indicate an action is currently processing or tak
<span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
Loading...
</button>
{% endcapture %}
{% include example.html content=example %}
{{< /example >}}
[color]: {{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/colors/
[display]: {{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/display/
[flex]: {{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/flex/
[float]: {{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/float/
[margin]: {{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/spacing/
[sizing]: {{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/sizing/
[text]: {{ site.baseurl }}/docs/{{ site.docs_version }}/content/typography/
[color]: {{< docsref "/utilities/colors" >}}
[display]: {{< docsref "/utilities/display" >}}
[flex]: {{< docsref "/utilities/flex" >}}
[float]: {{< docsref "/utilities/float" >}}
[margin]: {{< docsref "/utilities/spacing" >}}
[sizing]: {{< docsref "/utilities/sizing" >}}
[text]: {{< docsref "/content/typography" >}}

View File

@ -12,12 +12,14 @@ Toasts are lightweight notifications designed to mimic the push notifications th
Things to know when using the toast plugin:
- If you're building our JavaScript from source, it [requires `util.js`]({{ site.baseurl }}/docs/{{ site.docs_version }}/getting-started/javascript/#util).
- If you're building our JavaScript from source, it [requires `util.js`]({{< docsref "/getting-started/javascript#util" >}}).
- Toasts are opt-in for performance reasons, so **you must initialize them yourself**.
- **Please note that you are responsible for positioning toasts.**
- Toasts will automatically hide if you do not specify `autohide: false`.
{% include callout-info-prefersreducedmotion.md %}
{{< callout info >}}
{{< partial "callout-info-prefersreducedmotion.md" >}}
{{< /callout >}}
## Examples
@ -27,10 +29,10 @@ To encourage extensible and predictable toasts, we recommend a header and body.
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.
{% capture example %}
{{< example class="bg-light" >}}
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
{% include icons/placeholder.svg width="20" height="20" background="#007aff" class="rounded mr-2" text=" " title=" " %}
{{< placeholder width="20" height="20" background="#007aff" class="rounded mr-2" text=" " title=" " >}}
<strong class="mr-auto">Bootstrap</strong>
<small>11 mins ago</small>
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
@ -41,17 +43,16 @@ Toasts are as flexible as you need and have very little required markup. At a mi
Hello, world! This is a toast message.
</div>
</div>
{% endcapture %}
{% include example.html content=example class="bg-light" %}
{{< /example >}}
### Translucent
Toasts are slightly translucent, too, so they blend over whatever they might appear over. For browsers that support the `backdrop-filter` CSS property, we'll also attempt to blur the elements under a toast.
{% capture example %}
{{< example class="bg-dark" >}}
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
{% include icons/placeholder.svg width="20" height="20" background="#007aff" class="rounded mr-2" text=" " title=" " %}
{{< placeholder width="20" height="20" background="#007aff" class="rounded mr-2" text=" " title=" " >}}
<strong class="mr-auto">Bootstrap</strong>
<small class="text-muted">11 mins ago</small>
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
@ -62,17 +63,16 @@ Toasts are slightly translucent, too, so they blend over whatever they might app
Hello, world! This is a toast message.
</div>
</div>
{% endcapture %}
{% include example.html content=example class="bg-dark" %}
{{< /example >}}
### Stacking
When you have multiple toasts, we default to vertically stacking them in a readable manner.
{% capture example %}
{{< example class="bg-light" >}}
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
{% include icons/placeholder.svg width="20" height="20" background="#007aff" class="rounded mr-2" text=" " title=" " %}
{{< placeholder width="20" height="20" background="#007aff" class="rounded mr-2" text=" " title=" " >}}
<strong class="mr-auto">Bootstrap</strong>
<small class="text-muted">just now</small>
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
@ -86,7 +86,7 @@ When you have multiple toasts, we default to vertically stacking them in a reada
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
{% include icons/placeholder.svg width="20" height="20" background="#007aff" class="rounded mr-2" text=" " title=" " %}
{{< placeholder width="20" height="20" background="#007aff" class="rounded mr-2" text=" " title=" " >}}
<strong class="mr-auto">Bootstrap</strong>
<small class="text-muted">2 seconds ago</small>
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
@ -97,18 +97,17 @@ When you have multiple toasts, we default to vertically stacking them in a reada
Heads up, toasts will stack automatically
</div>
</div>
{% endcapture %}
{% include example.html content=example class="bg-light" %}
{{< /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`.
{% capture example %}
{{< example class="bg-dark" >}}
<div aria-live="polite" aria-atomic="true" style="position: relative; min-height: 200px;">
<div class="toast" style="position: absolute; top: 0; right: 0;">
<div class="toast-header">
{% include icons/placeholder.svg width="20" height="20" background="#007aff" class="rounded mr-2" text=" " title=" " %}
{{< placeholder width="20" height="20" background="#007aff" class="rounded mr-2" text=" " title=" " >}}
<strong class="mr-auto">Bootstrap</strong>
<small>11 mins ago</small>
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
@ -120,12 +119,11 @@ Place toasts with custom CSS as you need them. The top right is often used for n
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example class="bg-dark" %}
{{< /example >}}
For systems that generate more notifications, consider using a wrapping element so they can easily stack.
{% capture example %}
{{< example class="bg-dark" >}}
<div aria-live="polite" aria-atomic="true" style="position: relative; min-height: 200px;">
<!-- Position it -->
<div style="position: absolute; top: 0; right: 0;">
@ -133,7 +131,7 @@ For systems that generate more notifications, consider using a wrapping element
<!-- Then put toasts within -->
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
{% include icons/placeholder.svg width="20" height="20" background="#007aff" class="rounded mr-2" text=" " title=" " %}
{{< placeholder width="20" height="20" background="#007aff" class="rounded mr-2" text=" " title=" " >}}
<strong class="mr-auto">Bootstrap</strong>
<small class="text-muted">just now</small>
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
@ -147,7 +145,7 @@ For systems that generate more notifications, consider using a wrapping element
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
{% include icons/placeholder.svg width="20" height="20" background="#007aff" class="rounded mr-2" text=" " title=" " %}
{{< placeholder width="20" height="20" background="#007aff" class="rounded mr-2" text=" " title=" " >}}
<strong class="mr-auto">Bootstrap</strong>
<small class="text-muted">2 seconds ago</small>
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
@ -160,19 +158,18 @@ For systems that generate more notifications, consider using a wrapping element
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example class="bg-dark" %}
{{< /example >}}
You can also get fancy with flexbox utilities to align toasts horizontally and/or vertically.
{% capture example %}
{{< example class="bg-dark" >}}
<!-- Flexbox container for aligning the toasts -->
<div aria-live="polite" aria-atomic="true" class="d-flex justify-content-center align-items-center" style="height: 200px;">
<!-- Then put toasts within -->
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
{% include icons/placeholder.svg width="20" height="20" background="#007aff" class="rounded mr-2" text=" " title=" " %}
{{< placeholder width="20" height="20" background="#007aff" class="rounded mr-2" text=" " title=" " >}}
<strong class="mr-auto">Bootstrap</strong>
<small>11 mins ago</small>
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
@ -184,12 +181,11 @@ You can also get fancy with flexbox utilities to align toasts horizontally and/o
</div>
</div>
</div>
{% endcapture %}
{% include example.html content=example class="bg-dark" %}
{{< /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 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]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/alerts/) instead of toast.
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 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.
@ -197,18 +193,18 @@ You also need to adapt the `role` and `aria-live` level depending on the content
As the content you're displaying changes, be sure to update the [`delay` timeout](#options) to ensure people have enough time to read the toast.
{% highlight html %}
```html
<div class="toast" role="alert" aria-live="polite" aria-atomic="true" data-delay="10000">
<div role="alert" aria-live="assertive" aria-atomic="true">...</div>
</div>
{% endhighlight %}
```
When using `autohide: false`, you must add a close button to allow users to dismiss the toast.
{% capture example %}
{{< example class="bg-light" >}}
<div role="alert" aria-live="assertive" aria-atomic="true" class="toast" data-autohide="false">
<div class="toast-header">
{% include icons/placeholder.svg width="20" height="20" background="#007aff" class="rounded mr-2" text=" " title=" " %}
{{< placeholder width="20" height="20" background="#007aff" class="rounded mr-2" text=" " title=" " >}}
<strong class="mr-auto">Bootstrap</strong>
<small>11 mins ago</small>
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
@ -219,8 +215,7 @@ When using `autohide: false`, you must add a close button to allow users to dism
Hello, world! This is a toast message.
</div>
</div>
{% endcapture %}
{% include example.html content=example class="bg-light" %}
{{< /example >}}
## JavaScript behavior
@ -228,9 +223,9 @@ When using `autohide: false`, you must add a close button to allow users to dism
Initialize toasts via JavaScript:
{% highlight js %}
```js
$('.toast').toast(option)
{% endhighlight %}
```
### Options
@ -271,7 +266,9 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap
### Methods
{% include callout-danger-async-methods.md %}
{{< callout danger >}}
{{< partial "callout-danger-async-methods.md" >}}
{{< /callout >}}
#### `$().toast(options)`
@ -282,19 +279,25 @@ Attaches a toast handler to an element collection.
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.
{% highlight js %}$('#element').toast('show'){% endhighlight %}
```js
$('#element').toast('show')
```
#### `.toast('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`.
{% highlight js %}$('#element').toast('hide'){% endhighlight %}
```js
$('#element').toast('hide')
```
#### `.toast('dispose')`
Hides an element's toast. Your toast will remain on the DOM but won't show anymore.
{% highlight js %}$('#element').toast('dispose'){% endhighlight %}
```js
$('#element').toast('dispose')
```
### Events
@ -325,8 +328,8 @@ Hides an element's toast. Your toast will remain on the DOM but won't show anymo
</tbody>
</table>
{% highlight js %}
```js
$('#myToast').on('hidden.bs.toast', function () {
// do something...
})
{% endhighlight %}
```

Some files were not shown because too many files have changed in this diff Show More