Apply theme to 5.3.8
This commit is contained in:
parent
f203f0c103
commit
be164cfe0a
930 changed files with 53160 additions and 42297 deletions
|
|
@ -1,54 +0,0 @@
|
|||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"node": false
|
||||
},
|
||||
"plugins": [
|
||||
"markdown"
|
||||
],
|
||||
"overrides": [
|
||||
{
|
||||
// 2. Enable the Markdown processor for all .md files.
|
||||
"files": ["./**/*.md"],
|
||||
"processor": "markdown/markdown"
|
||||
},
|
||||
{
|
||||
// In v2, configuration for fenced code blocks is separate from the
|
||||
// containing Markdown file. Each code block has a virtual filename
|
||||
// appended to the Markdown file's path.
|
||||
"files": [
|
||||
"./**/*.md/*.js"
|
||||
],
|
||||
// Configuration for fenced code blocks goes with the override for
|
||||
// the code block's virtual filename, for example:
|
||||
"parserOptions": {
|
||||
"ecmaFeatures": {
|
||||
"impliedStrict": true
|
||||
}
|
||||
},
|
||||
"rules": {
|
||||
"no-array-for-each": "off",
|
||||
"no-undef": "off",
|
||||
"no-unused-vars": "off",
|
||||
"unicorn/no-array-for-each": "off",
|
||||
"unicorn/numeric-separators-style": "off",
|
||||
"no-unused-expressions": "off",
|
||||
"no-unused-labels": "off",
|
||||
"no-labels": "off",
|
||||
"no-redeclare": "off"
|
||||
}
|
||||
}
|
||||
],
|
||||
"parserOptions": {
|
||||
"sourceType": "script"
|
||||
},
|
||||
"extends": "../.eslintrc.json",
|
||||
"rules": {
|
||||
"no-new": "off",
|
||||
"prefer-template": "error",
|
||||
"strict": "error",
|
||||
"unicorn/no-array-for-each": "off",
|
||||
"unicorn/numeric-separators-style": "off",
|
||||
"unicorn/prefer-node-protocol": "off"
|
||||
}
|
||||
}
|
||||
8
site/.prettierrc.json
Normal file
8
site/.prettierrc.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"$schema": "http://json.schemastore.org/prettierrc",
|
||||
"arrowParens": "always",
|
||||
"printWidth": 120,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none"
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
|
||||
// IT'S ALL JUST JUNK FOR OUR DOCS!
|
||||
// ++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
/*!
|
||||
* JavaScript for Bootstrap's docs (https://getbootstrap.com/)
|
||||
* Copyright 2011-2022 The Bootstrap Authors
|
||||
* Copyright 2011-2022 Twitter, Inc.
|
||||
* Licensed under the Creative Commons Attribution 3.0 Unported License.
|
||||
* For details, see https://creativecommons.org/licenses/by/3.0/.
|
||||
*/
|
||||
|
||||
(() => {
|
||||
'use strict'
|
||||
|
||||
// Scroll the active sidebar link into view
|
||||
const sidenav = document.querySelector('.bd-sidebar')
|
||||
if (sidenav) {
|
||||
const sidenavHeight = sidenav.clientHeight
|
||||
const sidenavActiveLink = document.querySelector('.bd-links-nav .active')
|
||||
const sidenavActiveLinkTop = sidenavActiveLink.offsetTop
|
||||
const sidenavActiveLinkHeight = sidenavActiveLink.clientHeight
|
||||
const viewportTop = sidenavActiveLinkTop
|
||||
const viewportBottom = viewportTop - sidenavHeight + sidenavActiveLinkHeight
|
||||
|
||||
if (sidenav.scrollTop > viewportTop || sidenav.scrollTop < viewportBottom) {
|
||||
sidenav.scrollTop = viewportTop - (sidenavHeight / 2) + (sidenavActiveLinkHeight / 2)
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
|
||||
// IT'S ALL JUST JUNK FOR OUR DOCS!
|
||||
// ++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
/*!
|
||||
* JavaScript for Bootstrap's docs (https://getbootstrap.com/)
|
||||
* Copyright 2011-2022 The Bootstrap Authors
|
||||
* Copyright 2011-2022 Twitter, Inc.
|
||||
* Licensed under the Creative Commons Attribution 3.0 Unported License.
|
||||
* For details, see https://creativecommons.org/licenses/by/3.0/.
|
||||
*/
|
||||
|
||||
/* global ClipboardJS: false, bootstrap: false */
|
||||
|
||||
(() => {
|
||||
'use strict'
|
||||
// Insert copy to clipboard button before .highlight
|
||||
const btnTitle = 'Copy to clipboard'
|
||||
const btnEdit = 'Edit on StackBlitz'
|
||||
|
||||
const btnHtml = [
|
||||
'<div class="bd-code-snippet">',
|
||||
' <div class="bd-clipboard">',
|
||||
' <button type="button" class="btn-clipboard">',
|
||||
' <svg class="bi" role="img" aria-label="Copy"><use xlink:href="#clipboard"/></svg>',
|
||||
' </button>',
|
||||
' </div>',
|
||||
'</div>'
|
||||
].join('')
|
||||
|
||||
// wrap programmatically code blocks and add copy btn.
|
||||
document.querySelectorAll('.highlight')
|
||||
.forEach(element => {
|
||||
if (!element.closest('.bd-example-snippet')) { // Ignore examples made be shortcode
|
||||
element.insertAdjacentHTML('beforebegin', btnHtml)
|
||||
element.previousElementSibling.append(element)
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} selector
|
||||
* @param {string} title
|
||||
*/
|
||||
function snippetButtonTooltip(selector, title) {
|
||||
document.querySelectorAll(selector).forEach(btn => {
|
||||
bootstrap.Tooltip.getOrCreateInstance(btn, { title })
|
||||
})
|
||||
}
|
||||
|
||||
snippetButtonTooltip('.btn-clipboard', btnTitle)
|
||||
snippetButtonTooltip('.btn-edit', btnEdit)
|
||||
|
||||
const clipboard = new ClipboardJS('.btn-clipboard', {
|
||||
target: trigger => trigger.closest('.bd-code-snippet').querySelector('.highlight')
|
||||
})
|
||||
|
||||
clipboard.on('success', event => {
|
||||
const iconFirstChild = event.trigger.querySelector('.bi').firstChild
|
||||
const tooltipBtn = bootstrap.Tooltip.getInstance(event.trigger)
|
||||
const namespace = 'http://www.w3.org/1999/xlink'
|
||||
const originalXhref = iconFirstChild.getAttributeNS(namespace, 'href')
|
||||
const originalTitle = event.trigger.title
|
||||
|
||||
tooltipBtn.setContent({ '.tooltip-inner': 'Copied!' })
|
||||
event.trigger.addEventListener('hidden.bs.tooltip', () => {
|
||||
tooltipBtn.setContent({ '.tooltip-inner': btnTitle })
|
||||
}, { once: true })
|
||||
event.clearSelection()
|
||||
iconFirstChild.setAttributeNS(namespace, 'href', originalXhref.replace('clipboard', 'check2'))
|
||||
|
||||
setTimeout(() => {
|
||||
iconFirstChild.setAttributeNS(namespace, 'href', originalXhref)
|
||||
event.trigger.title = originalTitle
|
||||
}, 2000)
|
||||
})
|
||||
|
||||
clipboard.on('error', event => {
|
||||
const modifierKey = /mac/i.test(navigator.userAgent) ? '\u2318' : 'Ctrl-'
|
||||
const fallbackMsg = `Press ${modifierKey}C to copy`
|
||||
const tooltipBtn = bootstrap.Tooltip.getInstance(event.trigger)
|
||||
|
||||
tooltipBtn.setContent({ '.tooltip-inner': fallbackMsg })
|
||||
event.trigger.addEventListener('hidden.bs.tooltip', () => {
|
||||
tooltipBtn.setContent({ '.tooltip-inner': btnTitle })
|
||||
}, { once: true })
|
||||
})
|
||||
})()
|
||||
7
site/assets/js/vendor/clipboard.min.js
vendored
7
site/assets/js/vendor/clipboard.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -1,38 +0,0 @@
|
|||
// stylelint-disable declaration-no-important, selector-max-id
|
||||
|
||||
//
|
||||
// Carbon ads
|
||||
//
|
||||
|
||||
#carbonads {
|
||||
position: static;
|
||||
display: block;
|
||||
max-width: 400px;
|
||||
padding: 15px 15px 15px 160px;
|
||||
margin: 2rem 0;
|
||||
overflow: hidden;
|
||||
@include font-size(.8125rem);
|
||||
line-height: 1.4;
|
||||
text-align: left;
|
||||
background-color: $gray-100;
|
||||
|
||||
a {
|
||||
color: $gray-800;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
@include media-breakpoint-up(sm) {
|
||||
@include border-radius(.5rem);
|
||||
}
|
||||
}
|
||||
|
||||
.carbon-img {
|
||||
float: left;
|
||||
margin-left: -145px;
|
||||
}
|
||||
|
||||
.carbon-poweredby {
|
||||
display: block;
|
||||
margin-top: .75rem;
|
||||
color: $gray-700 !important;
|
||||
}
|
||||
|
|
@ -1,126 +0,0 @@
|
|||
//
|
||||
// Bootstrap docs content theming
|
||||
//
|
||||
|
||||
.bd-content {
|
||||
// Offset content from fixed navbar when jumping to headings
|
||||
> :target {
|
||||
padding-top: 5rem;
|
||||
margin-top: -5rem;
|
||||
}
|
||||
|
||||
> h2:not(:first-child) {
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
> h3 {
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
> ul li,
|
||||
> ol li {
|
||||
margin-bottom: .25rem;
|
||||
|
||||
// stylelint-disable selector-max-type, selector-max-compound-selectors
|
||||
> p ~ ul {
|
||||
margin-top: -.5rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
// stylelint-enable selector-max-type, selector-max-compound-selectors
|
||||
}
|
||||
|
||||
// Override Bootstrap defaults
|
||||
> .table,
|
||||
> .table-responsive .table {
|
||||
margin-bottom: 1.5rem;
|
||||
@include font-size(.875rem);
|
||||
|
||||
@include media-breakpoint-down(lg) {
|
||||
&.table-bordered {
|
||||
border: 0;
|
||||
}
|
||||
}
|
||||
|
||||
thead {
|
||||
border-bottom: 2px solid currentcolor;
|
||||
}
|
||||
|
||||
tbody:not(:first-child) {
|
||||
border-top: 2px solid currentcolor;
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
&:first-child {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
&:not(:last-child) {
|
||||
padding-right: 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent breaking of code
|
||||
// stylelint-disable-next-line selector-max-compound-selectors
|
||||
th,
|
||||
td:first-child > code {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.table-options {
|
||||
td:nth-child(2) {
|
||||
min-width: 160px;
|
||||
}
|
||||
}
|
||||
|
||||
.table-options td:last-child,
|
||||
.table-utilities td:last-child {
|
||||
min-width: 280px;
|
||||
}
|
||||
|
||||
.bd-title {
|
||||
@include font-size(3rem);
|
||||
}
|
||||
|
||||
.bd-lead {
|
||||
@include font-size(1.5rem);
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.bd-bg-violet {
|
||||
background-color: $bd-violet;
|
||||
}
|
||||
|
||||
.bi {
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
fill: currentcolor;
|
||||
}
|
||||
|
||||
.icon-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
text-decoration-color: rgba($primary, .5);
|
||||
text-underline-offset: .5rem;
|
||||
backface-visibility: hidden;
|
||||
|
||||
.bi {
|
||||
width: 1.5em;
|
||||
height: 1.5em;
|
||||
transition: .2s ease-in-out transform; // stylelint-disable-line property-disallowed-list
|
||||
}
|
||||
|
||||
&:hover {
|
||||
.bi {
|
||||
transform: translate3d(5px, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.border-lg-start {
|
||||
@include media-breakpoint-up(lg) {
|
||||
border-left: $border-width solid $border-color;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
.bd-navbar {
|
||||
padding: .75rem 0;
|
||||
background-color: transparent;
|
||||
background-image: linear-gradient(to bottom, rgba(var(--bd-violet-rgb), 1), rgba(var(--bd-violet-rgb), .95));
|
||||
box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15), inset 0 -1px 0 rgba(0, 0, 0, .15);
|
||||
|
||||
.bd-navbar-toggle {
|
||||
@include media-breakpoint-down(lg) {
|
||||
width: 4.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
.navbar-toggler {
|
||||
padding: 0;
|
||||
margin-right: -.5rem;
|
||||
border: 0;
|
||||
|
||||
&:first-child {
|
||||
margin-left: -.5rem;
|
||||
}
|
||||
|
||||
.bi {
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
}
|
||||
|
||||
&:focus {
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
transition: .2s ease-in-out transform; // stylelint-disable-line property-disallowed-list
|
||||
|
||||
&:hover {
|
||||
transform: rotate(-5deg) scale(1.1);
|
||||
}
|
||||
}
|
||||
|
||||
.navbar-toggler,
|
||||
.nav-link {
|
||||
padding-right: $spacer * .25;
|
||||
padding-left: $spacer * .25;
|
||||
color: rgba($white, .85);
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
color: $white;
|
||||
}
|
||||
|
||||
&.active {
|
||||
font-weight: 600;
|
||||
color: $white;
|
||||
}
|
||||
}
|
||||
|
||||
.navbar-nav-svg {
|
||||
display: inline-block;
|
||||
vertical-align: -.125rem;
|
||||
}
|
||||
|
||||
.offcanvas-lg {
|
||||
background-color: var(--bd-violet);
|
||||
border-left: 0;
|
||||
|
||||
@include media-breakpoint-down(lg) {
|
||||
box-shadow: $box-shadow-lg;
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-toggle {
|
||||
&:focus:not(:focus-visible) {
|
||||
outline: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-menu {
|
||||
--#{$prefix}dropdown-min-width: 12rem;
|
||||
--#{$prefix}dropdown-link-hover-bg: rgba(var(--bd-violet-rgb), .1);
|
||||
@include rfs(.875rem, --#{$prefix}dropdown-font-size);
|
||||
box-shadow: $dropdown-box-shadow;
|
||||
}
|
||||
|
||||
.dropdown-item.current {
|
||||
font-weight: 600;
|
||||
background-image: escape-svg($dropdown-active-icon);
|
||||
background-repeat: no-repeat;
|
||||
background-position: right $dropdown-item-padding-x top .6rem;
|
||||
background-size: .75rem .75rem;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
:root {
|
||||
--base00: #fff;
|
||||
--base01: #f5f5f5;
|
||||
--base02: #c8c8fa;
|
||||
--base03: #565c64;
|
||||
--base04: #030303;
|
||||
--base05: #333;
|
||||
--base06: #fff;
|
||||
--base07: #9a6700;
|
||||
--base08: #bc4c00;
|
||||
--base09: #087990;
|
||||
--base0A: #795da3;
|
||||
--base0B: #183691;
|
||||
--base0C: #183691;
|
||||
--base0D: #795da3;
|
||||
--base0E: #a71d5d;
|
||||
--base0F: #333;
|
||||
}
|
||||
|
||||
.hl { background-color: var(--base02); }
|
||||
.c { color: var(--base03); }
|
||||
.err { color: var(--base08); }
|
||||
.k { color: var(--base0E); }
|
||||
.l { color: var(----base09); }
|
||||
.n { color: var(--base08); }
|
||||
.o { color: var(--base05); }
|
||||
.p { color: var(--base05); }
|
||||
.cm { color: var(--base04); }
|
||||
.cp { color: var(--base08); }
|
||||
.c1 { color: var(--base03); }
|
||||
.cs { color: var(--base04); }
|
||||
.gd { color: var(--base08); }
|
||||
.ge { font-style: italic; }
|
||||
.gh {
|
||||
font-weight: 600;
|
||||
color: #fff;
|
||||
}
|
||||
.gi { color: var(--bs-success); }
|
||||
.gp {
|
||||
font-weight: 600;
|
||||
color: var(--base04);
|
||||
}
|
||||
.gs { font-weight: 600; }
|
||||
.gu {
|
||||
font-weight: 600;
|
||||
color: var(--base0C);
|
||||
}
|
||||
.kc { color: var(--base0E); }
|
||||
.kd { color: var(--base0E); }
|
||||
.kn { color: var(--base0C); }
|
||||
.kp { color: var(--base0E); }
|
||||
.kr { color: var(--base0E); }
|
||||
.kt { color: var(--base0A); }
|
||||
.ld { color: var(--base0C); }
|
||||
.m { color: var(--base09); }
|
||||
.s { color: var(--base0C); }
|
||||
.na { color: var(--base0A); }
|
||||
.nb { color: var(--base05); }
|
||||
.nc { color: var(--base07); }
|
||||
.no { color: var(--base08); }
|
||||
.nd { color: var(--base07); }
|
||||
.ni { color: var(--base08); }
|
||||
.ne { color: var(--base08); }
|
||||
.nf { color: var(--base0B); }
|
||||
.nl { color: var(--base05); }
|
||||
.nn { color: var(--base0A); }
|
||||
.nx { color: var(--base0A); }
|
||||
.py { color: var(--base08); }
|
||||
.nt { color: var(--base08); }
|
||||
.nv { color: var(--base08); }
|
||||
.ow { color: var(--base0C); }
|
||||
.w { color: #fff; }
|
||||
.mf { color: var(--base09); }
|
||||
.mh { color: var(--base09); }
|
||||
.mi { color: var(--base09); }
|
||||
.mo { color: var(--base09); }
|
||||
.sb { color: var(--base0C); }
|
||||
.sc { color: #fff; }
|
||||
.sd { color: var(--base04); }
|
||||
.s2 { color: var(--base0C); }
|
||||
.se { color: var(--base09); }
|
||||
.sh { color: var(--base0C); }
|
||||
.si { color: var(--base09); }
|
||||
.sx { color: var(--base0C); }
|
||||
.sr { color: var(--base0C); }
|
||||
.s1 { color: var(--base0C); }
|
||||
.ss { color: var(--base0C); }
|
||||
.bp { color: var(--base05); }
|
||||
.vc { color: var(--base08); }
|
||||
.vg { color: var(--base08); }
|
||||
.vi { color: var(--base08); }
|
||||
.il { color: var(--base09); }
|
||||
|
||||
// Color commas in rgba() values
|
||||
.m + .o { color: var(--base03); }
|
||||
|
||||
// Fix bash
|
||||
.language-sh .c { color: var(--base03); }
|
||||
|
||||
.chroma {
|
||||
.language-bash,
|
||||
.language-sh {
|
||||
.line::before {
|
||||
color: #777;
|
||||
content: "$ ";
|
||||
user-select: none;
|
||||
}
|
||||
}
|
||||
|
||||
.language-powershell::before {
|
||||
color: #009;
|
||||
content: "PM> ";
|
||||
user-select: none;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
// stylelint-disable scss/dollar-variable-default
|
||||
|
||||
// Local docs variables
|
||||
$bd-purple: #4c0bce;
|
||||
$bd-violet: lighten(saturate($bd-purple, 5%), 15%); // stylelint-disable-line function-disallowed-list
|
||||
$bd-purple-light: lighten(saturate($bd-purple, 5%), 45%); // stylelint-disable-line function-disallowed-list
|
||||
$bd-accent: #ffe484;
|
||||
$dropdown-active-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'><path fill='#292b2c' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/></svg>");
|
||||
|
||||
$bd-gutter-x: 3rem;
|
||||
$bd-callout-variants: info, warning, danger !default;
|
||||
|
||||
:root {
|
||||
--bd-purple: #{$bd-purple};
|
||||
--bd-violet: #{$bd-violet};
|
||||
--bd-accent: #{$bd-accent};
|
||||
--bd-violet-rgb: #{to-rgb($bd-violet)};
|
||||
--bd-accent-rgb: #{to-rgb($bd-accent)};
|
||||
--bd-pink-rgb: #{to-rgb($pink-500)};
|
||||
--bd-teal-rgb: #{to-rgb($teal-500)};
|
||||
--docsearch-primary-color: var(--bd-violet);
|
||||
--docsearch-logo-color: var(--bd-violet);
|
||||
}
|
||||
33
site/astro.config.ts
Normal file
33
site/astro.config.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { defineConfig } from 'astro/config'
|
||||
|
||||
import { bootstrap } from './src/libs/astro'
|
||||
import { getConfig } from './src/libs/config'
|
||||
import { algoliaPlugin } from './src/plugins/algolia-plugin'
|
||||
import { stackblitzPlugin } from './src/plugins/stackblitz-plugin'
|
||||
|
||||
const isDev = process.env.NODE_ENV === 'development'
|
||||
|
||||
const site = isDev
|
||||
? // In development mode, use the local dev server.
|
||||
'http://localhost:9001'
|
||||
: process.env.DEPLOY_PRIME_URL !== undefined
|
||||
? // If deploying on Netlify, use the `DEPLOY_PRIME_URL` environment variable.
|
||||
process.env.DEPLOY_PRIME_URL
|
||||
: // Otherwise, use the `baseURL` value defined in the `config.yml` file.
|
||||
getConfig().baseURL
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
build: {
|
||||
assets: `docs/${getConfig().docs_version}/assets`
|
||||
},
|
||||
integrations: [bootstrap()],
|
||||
markdown: {
|
||||
smartypants: false,
|
||||
syntaxHighlight: 'prism'
|
||||
},
|
||||
site,
|
||||
vite: {
|
||||
plugins: [algoliaPlugin(), stackblitzPlugin()]
|
||||
}
|
||||
})
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
---
|
||||
title: "404 - File not found"
|
||||
layout: 404
|
||||
description: ""
|
||||
url: /404.html
|
||||
robots: noindex,follow
|
||||
sitemap_exclude: true
|
||||
---
|
||||
|
||||
<div class="text-center py-5">
|
||||
<h1 class="display-1">404</h1>
|
||||
<h2>File not found</h2>
|
||||
</div>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
layout: redirect
|
||||
sitemap_exclude: true
|
||||
redirect: "/docs/5.2/getting-started/introduction/"
|
||||
---
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Brand guidelines
|
||||
description: Documentation and examples for Bootstrap's logo and brand usage guidelines.
|
||||
group: about
|
||||
toc: true
|
||||
---
|
||||
|
||||
Have a need for Bootstrap's brand resources? Great! We have only a few guidelines we follow, and in turn ask you to follow as well.
|
||||
|
||||
## Logo
|
||||
|
||||
When referencing Bootstrap, use our logo mark. Do not modify our logos in any way. Do not use Bootstrap's branding for your own open or closed source projects. **Do not use the Twitter name or logo** in association with Bootstrap.
|
||||
|
||||
<div class="bd-brand-item px-2 py-5 mb-3 bg-light rounded-lg">
|
||||
<img class="d-block img-fluid mx-auto" src="/docs/{{< param docs_version >}}/assets/brand/bootstrap-logo.svg" alt="Bootstrap" width="256" height="204">
|
||||
</div>
|
||||
|
||||
Our logo mark is also available in black and white. All rules for our primary logo apply to these as well.
|
||||
|
||||
<div class="bd-brand-logos d-sm-flex text-center bg-light rounded-lg overflow-hidden w-100 mb-3">
|
||||
<div class="bd-brand-item w-100 px-2 py-5">
|
||||
<img src="/docs/{{< param docs_version >}}/assets/brand/bootstrap-logo-black.svg" alt="Bootstrap" width="128" height="102" loading="lazy">
|
||||
</div>
|
||||
<div class="bd-brand-item w-100 px-2 py-5 inverse">
|
||||
<img src="/docs/{{< param docs_version >}}/assets/brand/bootstrap-logo-white.svg" alt="Bootstrap" width="128" height="102" loading="lazy">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
## Name
|
||||
|
||||
Bootstrap should always be referred to as just **Bootstrap**. No Twitter before it and no capital _s_.
|
||||
|
||||
<div class="bd-brand-logos d-sm-flex text-center bg-light rounded-lg overflow-hidden w-100 mb-3">
|
||||
<div class="bd-brand-item w-100 p-3">
|
||||
<div class="h3">Bootstrap</div>
|
||||
<strong class="text-success">Correct</strong>
|
||||
</div>
|
||||
<div class="bd-brand-item w-100 p-3">
|
||||
<div class="h3 text-muted">BootStrap</div>
|
||||
<strong class="text-danger">Incorrect</strong>
|
||||
</div>
|
||||
<div class="bd-brand-item w-100 p-3">
|
||||
<div class="h3 text-muted">Twitter Bootstrap</div>
|
||||
<strong class="text-danger">Incorrect</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
---
|
||||
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
|
||||
aliases:
|
||||
- "/about/"
|
||||
- "/docs/5.2/about/"
|
||||
---
|
||||
|
||||
## Team
|
||||
|
||||
Bootstrap is maintained by a [small team of developers](https://github.com/orgs/twbs/people) on GitHub. We're actively looking to grow this team and would love to hear from you if you're excited about CSS at scale, writing and maintaining vanilla JavaScript plugins, and improving build tooling processes for frontend code.
|
||||
|
||||
## History
|
||||
|
||||
Originally created by a designer and a developer at Twitter, Bootstrap has become one of the most popular front-end frameworks and open source projects in the world.
|
||||
|
||||
Bootstrap was created at Twitter in mid-2010 by [@mdo](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]({{< 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.
|
||||
|
||||
Our latest release, Bootstrap 5, focuses on improving v4's codebase with as few major breaking changes as possible. We improved existing features and components, removed support for older browsers, dropped jQuery for regular JavaScript, and embraced more future-friendly technologies like CSS custom properties as part of our tooling.
|
||||
|
||||
## Get involved
|
||||
|
||||
Get involved with Bootstrap development by [opening an issue]({{< param repo >}}/issues/new/choose) or submitting a pull request. Read our [contributing guidelines]({{< param repo >}}/blob/v{{< param current_version >}}/.github/CONTRIBUTING.md) for information on how we develop.
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Team
|
||||
description: An overview of the founding team and core contributors to Bootstrap.
|
||||
group: about
|
||||
---
|
||||
|
||||
Bootstrap is maintained by the founding team and a small group of invaluable core contributors, with the massive support and involvement of our community.
|
||||
|
||||
{{< team.inline >}}
|
||||
<div class="list-group mb-3">
|
||||
{{- range (index $.Site.Data "core-team") }}
|
||||
<a class="list-group-item list-group-item-action d-flex align-items-center" href="https://github.com/{{ .user }}">
|
||||
<img src="https://github.com/{{ .user }}.png" alt="@{{ .user }}" width="32" height="32" class="rounded me-2" loading="lazy">
|
||||
<span>
|
||||
<strong>{{ .name }}</strong> @{{ .user }}
|
||||
</span>
|
||||
</a>
|
||||
{{ end -}}
|
||||
</div>
|
||||
{{< /team.inline >}}
|
||||
|
||||
Get involved with Bootstrap development by [opening an issue]({{< param repo >}}/issues/new/choose) or submitting a pull request. Read our [contributing guidelines]({{< param repo >}}/blob/v{{< param current_version >}}/.github/CONTRIBUTING.md) for information on how we develop.
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Translations
|
||||
description: Links to community-translated Bootstrap documentation sites.
|
||||
group: about
|
||||
---
|
||||
|
||||
Community members have translated Bootstrap's documentation into various languages. None are officially supported and they may not always be up-to-date.
|
||||
|
||||
{{< translations.inline >}}
|
||||
<ul>
|
||||
{{ range .Site.Data.translations -}}
|
||||
<li><a href="{{ .url }}" hreflang="{{ .code }}">{{ .description }} ({{ .name }})</a></li>
|
||||
{{ end -}}
|
||||
</ul>
|
||||
{{< /translations.inline >}}
|
||||
|
||||
**We don't help organize or host translations, we just link to them.**
|
||||
|
||||
Finished a new or better translation? Open a pull request to add it to our list.
|
||||
|
|
@ -1,165 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Accordion
|
||||
description: Build vertically collapsing accordions in combination with our Collapse JavaScript plugin.
|
||||
group: components
|
||||
aliases:
|
||||
- "/components/"
|
||||
- "/docs/5.2/components/"
|
||||
toc: true
|
||||
---
|
||||
|
||||
## How it works
|
||||
|
||||
The accordion uses [collapse]({{< docsref "/components/collapse" >}}) internally to make it collapsible. To render an accordion that's expanded, add the `.open` class on the `.accordion`.
|
||||
|
||||
{{< callout info >}}
|
||||
{{< partial "callout-info-prefersreducedmotion.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
## Example
|
||||
|
||||
Click the accordions below to expand/collapse the accordion content.
|
||||
|
||||
{{< example >}}
|
||||
<div class="accordion" id="accordionExample">
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="headingOne">
|
||||
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
|
||||
Accordion Item #1
|
||||
</button>
|
||||
</h2>
|
||||
<div id="collapseOne" class="accordion-collapse collapse show" aria-labelledby="headingOne" data-bs-parent="#accordionExample">
|
||||
<div class="accordion-body">
|
||||
<strong>This is the first item's accordion body.</strong> It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="headingTwo">
|
||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
|
||||
Accordion Item #2
|
||||
</button>
|
||||
</h2>
|
||||
<div id="collapseTwo" class="accordion-collapse collapse" aria-labelledby="headingTwo" data-bs-parent="#accordionExample">
|
||||
<div class="accordion-body">
|
||||
<strong>This is the second item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="headingThree">
|
||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
|
||||
Accordion Item #3
|
||||
</button>
|
||||
</h2>
|
||||
<div id="collapseThree" class="accordion-collapse collapse" aria-labelledby="headingThree" data-bs-parent="#accordionExample">
|
||||
<div class="accordion-body">
|
||||
<strong>This is the third item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Flush
|
||||
|
||||
Add `.accordion-flush` to remove the default `background-color`, some borders, and some rounded corners to render accordions edge-to-edge with their parent container.
|
||||
|
||||
{{< example class="bg-light" >}}
|
||||
<div class="accordion accordion-flush" id="accordionFlushExample">
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="flush-headingOne">
|
||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseOne" aria-expanded="false" aria-controls="flush-collapseOne">
|
||||
Accordion Item #1
|
||||
</button>
|
||||
</h2>
|
||||
<div id="flush-collapseOne" class="accordion-collapse collapse" aria-labelledby="flush-headingOne" data-bs-parent="#accordionFlushExample">
|
||||
<div class="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the first item's accordion body.</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="flush-headingTwo">
|
||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseTwo" aria-expanded="false" aria-controls="flush-collapseTwo">
|
||||
Accordion Item #2
|
||||
</button>
|
||||
</h2>
|
||||
<div id="flush-collapseTwo" class="accordion-collapse collapse" aria-labelledby="flush-headingTwo" data-bs-parent="#accordionFlushExample">
|
||||
<div class="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the second item's accordion body. Let's imagine this being filled with some actual content.</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="flush-headingThree">
|
||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseThree" aria-expanded="false" aria-controls="flush-collapseThree">
|
||||
Accordion Item #3
|
||||
</button>
|
||||
</h2>
|
||||
<div id="flush-collapseThree" class="accordion-collapse collapse" aria-labelledby="flush-headingThree" data-bs-parent="#accordionFlushExample">
|
||||
<div class="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the third item's accordion body. Nothing more exciting happening here in terms of content, but just filling up the space to make it look, at least at first glance, a bit more representative of how this would look in a real-world application.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Always open
|
||||
|
||||
Omit the `data-bs-parent` attribute on each `.accordion-collapse` to make accordion items stay open when another item is opened.
|
||||
|
||||
{{< example >}}
|
||||
<div class="accordion" id="accordionPanelsStayOpenExample">
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="panelsStayOpen-headingOne">
|
||||
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseOne" aria-expanded="true" aria-controls="panelsStayOpen-collapseOne">
|
||||
Accordion Item #1
|
||||
</button>
|
||||
</h2>
|
||||
<div id="panelsStayOpen-collapseOne" class="accordion-collapse collapse show" aria-labelledby="panelsStayOpen-headingOne">
|
||||
<div class="accordion-body">
|
||||
<strong>This is the first item's accordion body.</strong> It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="panelsStayOpen-headingTwo">
|
||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseTwo" aria-expanded="false" aria-controls="panelsStayOpen-collapseTwo">
|
||||
Accordion Item #2
|
||||
</button>
|
||||
</h2>
|
||||
<div id="panelsStayOpen-collapseTwo" class="accordion-collapse collapse" aria-labelledby="panelsStayOpen-headingTwo">
|
||||
<div class="accordion-body">
|
||||
<strong>This is the second item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="panelsStayOpen-headingThree">
|
||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseThree" aria-expanded="false" aria-controls="panelsStayOpen-collapseThree">
|
||||
Accordion Item #3
|
||||
</button>
|
||||
</h2>
|
||||
<div id="panelsStayOpen-collapseThree" class="accordion-collapse collapse" aria-labelledby="panelsStayOpen-headingThree">
|
||||
<div class="accordion-body">
|
||||
<strong>This is the third item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Accessibility
|
||||
|
||||
Please read the [collapse accessibility section]({{< docsref "/components/collapse#accessibility" >}}) for more information.
|
||||
|
||||
## CSS
|
||||
|
||||
### Variables
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
As part of Bootstrap's evolving CSS variables approach, accordions now use local CSS variables on `.accordion` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
|
||||
|
||||
{{< scss-docs name="accordion-css-vars" file="scss/_accordion.scss" >}}
|
||||
|
||||
### Sass variables
|
||||
|
||||
{{< scss-docs name="accordion-variables" file="scss/_variables.scss" >}}
|
||||
|
|
@ -1,257 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Alerts
|
||||
description: Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages.
|
||||
group: components
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Examples
|
||||
|
||||
Alerts are available for any length of text, as well as an optional close button. For proper styling, use one of the eight **required** contextual classes (e.g., `.alert-success`). For inline dismissal, use the [alerts JavaScript plugin](#dismissing).
|
||||
|
||||
{{< example >}}
|
||||
{{< alerts.inline >}}
|
||||
{{- range (index $.Site.Data "theme-colors") }}
|
||||
<div class="alert alert-{{ .name }}" role="alert">
|
||||
A simple {{ .name }} alert—check it out!
|
||||
</div>{{- end -}}
|
||||
{{< /alerts.inline >}}
|
||||
{{< /example >}}
|
||||
|
||||
{{< callout info >}}
|
||||
{{< partial "callout-warning-color-assistive-technologies.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
### Live example
|
||||
|
||||
Click the button below to show an alert (hidden with inline styles to start), then dismiss (and destroy) it with the built-in close button.
|
||||
|
||||
{{< example stackblitz_add_js="true" >}}
|
||||
<div id="liveAlertPlaceholder"></div>
|
||||
<button type="button" class="btn btn-primary" id="liveAlertBtn">Show live alert</button>
|
||||
{{< /example >}}
|
||||
|
||||
We use the following JavaScript to trigger our live alert demo:
|
||||
|
||||
```js
|
||||
const alertPlaceholder = document.getElementById('liveAlertPlaceholder')
|
||||
|
||||
const alert = (message, type) => {
|
||||
const wrapper = document.createElement('div')
|
||||
wrapper.innerHTML = [
|
||||
`<div class="alert alert-${type} alert-dismissible" role="alert">`,
|
||||
` <div>${message}</div>`,
|
||||
' <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>',
|
||||
'</div>'
|
||||
].join('')
|
||||
|
||||
alertPlaceholder.append(wrapper)
|
||||
}
|
||||
|
||||
const alertTrigger = document.getElementById('liveAlertBtn')
|
||||
if (alertTrigger) {
|
||||
alertTrigger.addEventListener('click', () => {
|
||||
alert('Nice, you triggered this alert message!', 'success')
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
### Link color
|
||||
|
||||
Use the `.alert-link` utility class to quickly provide matching colored links within any alert.
|
||||
|
||||
{{< example >}}
|
||||
{{< alerts.inline >}}
|
||||
{{- range (index $.Site.Data "theme-colors") }}
|
||||
<div class="alert alert-{{ .name }}" role="alert">
|
||||
A simple {{ .name }} alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
|
||||
</div>{{ end -}}
|
||||
{{< /alerts.inline >}}
|
||||
{{< /example >}}
|
||||
|
||||
### Additional content
|
||||
|
||||
Alerts can also contain additional HTML elements like headings, paragraphs and dividers.
|
||||
|
||||
{{< example >}}
|
||||
<div class="alert alert-success" role="alert">
|
||||
<h4 class="alert-heading">Well done!</h4>
|
||||
<p>Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.</p>
|
||||
<hr>
|
||||
<p class="mb-0">Whenever you need to, be sure to use margin utilities to keep things nice and tidy.</p>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Icons
|
||||
|
||||
Similarly, you can use [flexbox utilities]({{< docsref "/utilities/flex" >}}) and [Bootstrap Icons]({{< param icons >}}) to create alerts with icons. Depending on your icons and content, you may want to add more utilities or custom styles.
|
||||
|
||||
{{< example >}}
|
||||
<div class="alert alert-primary d-flex align-items-center" role="alert">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="bi bi-exclamation-triangle-fill flex-shrink-0 me-2" viewBox="0 0 16 16" role="img" aria-label="Warning:">
|
||||
<path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
|
||||
</svg>
|
||||
<div>
|
||||
An example alert with an icon
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Need more than one icon for your alerts? Consider using more Bootstrap Icons and making a local SVG sprite like so to easily reference the same icons repeatedly.
|
||||
|
||||
{{< example >}}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
|
||||
<symbol id="check-circle-fill" viewBox="0 0 16 16">
|
||||
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
|
||||
</symbol>
|
||||
<symbol id="info-fill" viewBox="0 0 16 16">
|
||||
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
|
||||
</symbol>
|
||||
<symbol id="exclamation-triangle-fill" viewBox="0 0 16 16">
|
||||
<path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
|
||||
</symbol>
|
||||
</svg>
|
||||
|
||||
<div class="alert alert-primary d-flex align-items-center" role="alert">
|
||||
<svg class="bi flex-shrink-0 me-2" role="img" aria-label="Info:"><use xlink:href="#info-fill"/></svg>
|
||||
<div>
|
||||
An example alert with an icon
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-success d-flex align-items-center" role="alert">
|
||||
<svg class="bi flex-shrink-0 me-2" role="img" aria-label="Success:"><use xlink:href="#check-circle-fill"/></svg>
|
||||
<div>
|
||||
An example success alert with an icon
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-warning d-flex align-items-center" role="alert">
|
||||
<svg class="bi flex-shrink-0 me-2" role="img" aria-label="Warning:"><use xlink:href="#exclamation-triangle-fill"/></svg>
|
||||
<div>
|
||||
An example warning alert with an icon
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-danger d-flex align-items-center" role="alert">
|
||||
<svg class="bi flex-shrink-0 me-2" role="img" aria-label="Danger:"><use xlink:href="#exclamation-triangle-fill"/></svg>
|
||||
<div>
|
||||
An example danger alert with an icon
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Dismissing
|
||||
|
||||
Using the alert JavaScript plugin, it's possible to dismiss any alert inline. Here's how:
|
||||
|
||||
- Be sure you've loaded the alert plugin, or the compiled Bootstrap JavaScript.
|
||||
- Add a [close button]({{< docsref "/components/close-button" >}}) and the `.alert-dismissible` class, which adds extra padding to the right of the alert and positions the close button.
|
||||
- On the close button, add the `data-bs-dismiss="alert"` attribute, which triggers the JavaScript functionality. Be sure to use the `<button>` element with it for proper behavior across all devices.
|
||||
- To animate alerts when dismissing them, be sure to add the `.fade` and `.show` classes.
|
||||
|
||||
You can see this in action with a live demo:
|
||||
|
||||
{{< example >}}
|
||||
<div class="alert alert-warning alert-dismissible fade show" role="alert">
|
||||
<strong>Holy guacamole!</strong> You should check in on some of those fields below.
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< callout warning >}}
|
||||
When an alert is dismissed, the element is completely removed from the page structure. If a keyboard user dismisses the alert using the close button, their focus will suddenly be lost and, depending on the browser, reset to the start of the page/document. For this reason, we recommend including additional JavaScript that listens for the `closed.bs.alert` event and programmatically sets `focus()` to the most appropriate location in the page. If you're planning to move focus to a non-interactive element that normally does not receive focus, make sure to add `tabindex="-1"` to the element.
|
||||
{{< /callout >}}
|
||||
|
||||
## CSS
|
||||
|
||||
### Variables
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
As part of Bootstrap's evolving CSS variables approach, alerts now use local CSS variables on `.alert` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
|
||||
|
||||
{{< scss-docs name="alert-css-vars" file="scss/_alert.scss" >}}
|
||||
|
||||
### Sass variables
|
||||
|
||||
{{< scss-docs name="alert-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
### Sass mixin
|
||||
|
||||
Used in combination with `$theme-colors` to create contextual modifier classes for our alerts.
|
||||
|
||||
{{< scss-docs name="alert-variant-mixin" file="scss/mixins/_alert.scss" >}}
|
||||
|
||||
### Sass loop
|
||||
|
||||
Loop that generates the modifier classes with the `alert-variant()` mixin.
|
||||
|
||||
{{< scss-docs name="alert-modifiers" file="scss/_alert.scss" >}}
|
||||
|
||||
## JavaScript behavior
|
||||
|
||||
### Initialize
|
||||
|
||||
Initialize elements as alerts
|
||||
|
||||
```js
|
||||
const alertList = document.querySelectorAll('.alert')
|
||||
const alerts = [...alertList].map(element => new bootstrap.Alert(element))
|
||||
```
|
||||
|
||||
{{< callout info >}}
|
||||
For the sole purpose of dismissing an alert, it isn't necessary to initialize the component manually via the JS API. By making use of `data-bs-dismiss="alert"`, the component will be initialized automatically and properly dismissed.
|
||||
|
||||
See the [triggers](#triggers) section for more details.
|
||||
{{< /callout >}}
|
||||
|
||||
### Triggers
|
||||
|
||||
{{% js-dismiss "alert" %}}
|
||||
|
||||
**Note that closing an alert will remove it from the DOM.**
|
||||
|
||||
### Methods
|
||||
|
||||
You can create an alert instance with the alert constructor, for example:
|
||||
|
||||
```js
|
||||
const bsAlert = new bootstrap.Alert('#myAlert')
|
||||
```
|
||||
|
||||
This makes an alert listen for click events on descendant elements which have the `data-bs-dismiss="alert"` attribute. (Not necessary when using the data-api’s auto-initialization.)
|
||||
|
||||
{{< bs-table >}}
|
||||
| Method | Description |
|
||||
| --- | --- |
|
||||
| `close` | Closes an alert by removing it from the DOM. If the `.fade` and `.show` classes are present on the element, the alert will fade out before it is removed. |
|
||||
| `dispose` | Destroys an element's alert. (Removes stored data on the DOM element) |
|
||||
| `getInstance` | Static method which allows you to get the alert instance associated to a DOM element. For example: `bootstrap.Alert.getInstance(alert)`. |
|
||||
| `getOrCreateInstance` | Static method which returns an alert instance associated to a DOM element or create a new one in case it wasn't initialized. You can use it like this: `bootstrap.Alert.getOrCreateInstance(element)`. |
|
||||
{{< /bs-table >}}
|
||||
|
||||
Basic usage:
|
||||
|
||||
```js
|
||||
const alert = bootstrap.Alert.getOrCreateInstance('#myAlert')
|
||||
alert.close()
|
||||
```
|
||||
|
||||
### Events
|
||||
|
||||
Bootstrap's alert plugin exposes a few events for hooking into alert functionality.
|
||||
|
||||
{{< bs-table >}}
|
||||
| Event | Description |
|
||||
| --- | --- |
|
||||
| `close.bs.alert` | Fires immediately when the `close` instance method is called. |
|
||||
| `closed.bs.alert` | Fired when the alert has been closed and CSS transitions have completed. |
|
||||
{{< /bs-table >}}
|
||||
|
||||
```js
|
||||
const myAlert = document.getElementById('myAlert')
|
||||
myAlert.addEventListener('closed.bs.alert', event => {
|
||||
// do something, for instance, explicitly move focus to the most appropriate element,
|
||||
// so it doesn't get lost/reset to the start of the page
|
||||
// document.getElementById('...').focus()
|
||||
})
|
||||
```
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Badges
|
||||
description: Documentation and examples for badges, our small count and labeling component.
|
||||
group: components
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Examples
|
||||
|
||||
Badges scale to match the size of the immediate parent element by using relative font sizing and `em` units. As of v5, badges no longer have focus or hover styles for links.
|
||||
|
||||
### Headings
|
||||
|
||||
{{< example >}}
|
||||
<h1>Example heading <span class="badge bg-secondary">New</span></h1>
|
||||
<h2>Example heading <span class="badge bg-secondary">New</span></h2>
|
||||
<h3>Example heading <span class="badge bg-secondary">New</span></h3>
|
||||
<h4>Example heading <span class="badge bg-secondary">New</span></h4>
|
||||
<h5>Example heading <span class="badge bg-secondary">New</span></h5>
|
||||
<h6>Example heading <span class="badge bg-secondary">New</span></h6>
|
||||
{{< /example >}}
|
||||
|
||||
### Buttons
|
||||
|
||||
Badges can be used as part of links or buttons to provide a counter.
|
||||
|
||||
{{< example >}}
|
||||
<button type="button" class="btn btn-primary">
|
||||
Notifications <span class="badge text-bg-secondary">4</span>
|
||||
</button>
|
||||
{{< /example >}}
|
||||
|
||||
Note that depending on how they are used, badges may be confusing for users of screen readers and similar assistive technologies. While the styling of badges provides a visual cue as to their purpose, these users will simply be presented with the content of the badge. Depending on the specific situation, these badges may seem like random additional words or numbers at the end of a sentence, link, or button.
|
||||
|
||||
Unless the context is clear (as with the "Notifications" example, where it is understood that the "4" is the number of notifications), consider including additional context with a visually hidden piece of additional text.
|
||||
|
||||
### Positioned
|
||||
|
||||
Use utilities to modify a `.badge` and position it in the corner of a link or button.
|
||||
|
||||
{{< example >}}
|
||||
<button type="button" class="btn btn-primary position-relative">
|
||||
Inbox
|
||||
<span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger">
|
||||
99+
|
||||
<span class="visually-hidden">unread messages</span>
|
||||
</span>
|
||||
</button>
|
||||
{{< /example >}}
|
||||
|
||||
You can also replace the `.badge` class with a few more utilities without a count for a more generic indicator.
|
||||
|
||||
{{< example >}}
|
||||
<button type="button" class="btn btn-primary position-relative">
|
||||
Profile
|
||||
<span class="position-absolute top-0 start-100 translate-middle p-2 bg-danger border border-light rounded-circle">
|
||||
<span class="visually-hidden">New alerts</span>
|
||||
</span>
|
||||
</button>
|
||||
{{< /example >}}
|
||||
|
||||
## Background colors
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
Set a `background-color` with contrasting foreground `color` with [our `.text-bg-{color}` helpers]({{< docsref "helpers/color-background" >}}). Previously it was required to manually pair your choice of [`.text-{color}`]({{< docsref "/utilities/colors" >}}) and [`.bg-{color}`]({{< docsref "/utilities/background" >}}) utilities for styling, which you still may use if you prefer.
|
||||
|
||||
{{< example >}}
|
||||
{{< badge.inline >}}
|
||||
{{- range (index $.Site.Data "theme-colors") }}
|
||||
<span class="badge text-bg-{{ .name }}">{{ .name | title }}</span>{{- end -}}
|
||||
{{< /badge.inline >}}
|
||||
{{< /example >}}
|
||||
|
||||
{{< callout info >}}
|
||||
{{< partial "callout-warning-color-assistive-technologies.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
## Pill badges
|
||||
|
||||
Use the `.rounded-pill` utility class to make badges more rounded with a larger `border-radius`.
|
||||
|
||||
{{< example >}}
|
||||
{{< badge.inline >}}
|
||||
{{- range (index $.Site.Data "theme-colors") }}
|
||||
<span class="badge rounded-pill text-bg-{{ .name }}">{{ .name | title }}</span>{{- end -}}
|
||||
{{< /badge.inline >}}
|
||||
{{< /example >}}
|
||||
|
||||
## CSS
|
||||
|
||||
### Variables
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
As part of Bootstrap's evolving CSS variables approach, badges now use local CSS variables on `.badge` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
|
||||
|
||||
{{< scss-docs name="badge-css-vars" file="scss/_badge.scss" >}}
|
||||
|
||||
### Sass variables
|
||||
|
||||
{{< scss-docs name="badge-variables" file="scss/_variables.scss" >}}
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Breadcrumb
|
||||
description: Indicate the current page's location within a navigational hierarchy that automatically adds separators via CSS.
|
||||
group: components
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Example
|
||||
|
||||
Use an ordered or unordered list with linked list items to create a minimally styled breadcrumb. Use our utilities to add additional styles as desired.
|
||||
|
||||
{{< example >}}
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item active" aria-current="page">Home</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Library</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
||||
<li class="breadcrumb-item"><a href="#">Library</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Data</li>
|
||||
</ol>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
## Dividers
|
||||
|
||||
Dividers are automatically added in CSS through [`::before`](https://developer.mozilla.org/en-US/docs/Web/CSS/::before) and [`content`](https://developer.mozilla.org/en-US/docs/Web/CSS/content). They can be changed by modifying a local CSS custom property `--bs-breadcrumb-divider`, or through the `$breadcrumb-divider` Sass variable — and `$breadcrumb-divider-flipped` for its RTL counterpart, if needed. We default to our Sass variable, which is set as a fallback to the custom property. This way, you get a global divider that you can override without recompiling CSS at any time.
|
||||
|
||||
{{< example >}}
|
||||
<nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Library</li>
|
||||
</ol>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
When modifying via Sass, the [quote](https://sass-lang.com/documentation/modules/string#quote) function is required to generate the quotes around a string. For example, using `>` as the divider, you can use this:
|
||||
|
||||
```scss
|
||||
$breadcrumb-divider: quote(">");
|
||||
```
|
||||
|
||||
It's also possible to use an **embedded SVG icon**. Apply it via our CSS custom property, or use the Sass variable.
|
||||
|
||||
|
||||
{{< callout info >}}
|
||||
### Using embedded SVG
|
||||
|
||||
Inlining SVG as data URI requires to URL escape a few characters, most notably `<`, `>` and `#`. That's why the `$breadcrumb-divider` variable is passed through our [`escape-svg()` Sass function]({{< docsref "/customize/sass#escape-svg" >}}). When using the CSS custom property, you need to URL escape your SVG on your own. Read [Kevin Weber's explanations on CodePen](https://codepen.io/kevinweber/pen/dXWoRw ) for detailed information on what to escape.
|
||||
{{< /callout >}}
|
||||
|
||||
{{< example >}}
|
||||
<nav style="--bs-breadcrumb-divider: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M2.5 0L1 1.5 3.5 4 1 6.5 2.5 8l4-4-4-4z' fill='%236c757d'/%3E%3C/svg%3E");" aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Library</li>
|
||||
</ol>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
```scss
|
||||
$breadcrumb-divider: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8'><path d='M2.5 0L1 1.5 3.5 4 1 6.5 2.5 8l4-4-4-4z' fill='#{$breadcrumb-divider-color}'/></svg>");
|
||||
```
|
||||
|
||||
You can also remove the divider setting `--bs-breadcrumb-divider: '';` (empty strings in CSS custom properties counts as a value), or setting the Sass variable to `$breadcrumb-divider: none;`.
|
||||
|
||||
{{< example >}}
|
||||
<nav style="--bs-breadcrumb-divider: '';" aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Library</li>
|
||||
</ol>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
|
||||
```scss
|
||||
$breadcrumb-divider: none;
|
||||
```
|
||||
|
||||
## Accessibility
|
||||
|
||||
Since breadcrumbs provide a navigation, it's a good idea to add a meaningful label such as `aria-label="breadcrumb"` to describe the type of navigation provided in the `<nav>` element, as well as applying an `aria-current="page"` to the last item of the set to indicate that it represents the current page.
|
||||
|
||||
For more information, see the [ARIA Authoring Practices Guide breadcrumb pattern](https://www.w3.org/WAI/ARIA/apg/patterns/breadcrumb/).
|
||||
|
||||
## CSS
|
||||
|
||||
### Variables
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
As part of Bootstrap's evolving CSS variables approach, breadcrumbs now use local CSS variables on `.breadcrumb` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
|
||||
|
||||
{{< scss-docs name="breadcrumb-css-vars" file="scss/_breadcrumb.scss" >}}
|
||||
|
||||
### Sass variables
|
||||
|
||||
{{< scss-docs name="breadcrumb-variables" file="scss/_variables.scss" >}}
|
||||
|
|
@ -1,256 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Button group
|
||||
description: Group a series of buttons together on a single line or stack them in a vertical column.
|
||||
group: components
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Basic example
|
||||
|
||||
Wrap a series of buttons with `.btn` in `.btn-group`.
|
||||
|
||||
{{< example >}}
|
||||
<div class="btn-group" role="group" aria-label="Basic example">
|
||||
<button type="button" class="btn btn-primary">Left</button>
|
||||
<button type="button" class="btn btn-primary">Middle</button>
|
||||
<button type="button" class="btn btn-primary">Right</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< callout 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.
|
||||
{{< /callout >}}
|
||||
|
||||
These classes can also be added to groups of links, as an alternative to the [`.nav` navigation components]({{< docsref "/components/navs-tabs" >}}).
|
||||
|
||||
{{< example >}}
|
||||
<div class="btn-group">
|
||||
<a href="#" class="btn btn-primary active" aria-current="page">Active link</a>
|
||||
<a href="#" class="btn btn-primary">Link</a>
|
||||
<a href="#" class="btn btn-primary">Link</a>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Mixed styles
|
||||
|
||||
{{< example >}}
|
||||
<div class="btn-group" role="group" aria-label="Basic mixed styles example">
|
||||
<button type="button" class="btn btn-danger">Left</button>
|
||||
<button type="button" class="btn btn-warning">Middle</button>
|
||||
<button type="button" class="btn btn-success">Right</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Outlined styles
|
||||
|
||||
{{< example >}}
|
||||
<div class="btn-group" role="group" aria-label="Basic outlined example">
|
||||
<button type="button" class="btn btn-outline-primary">Left</button>
|
||||
<button type="button" class="btn btn-outline-primary">Middle</button>
|
||||
<button type="button" class="btn btn-outline-primary">Right</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Checkbox and radio button groups
|
||||
|
||||
Combine button-like checkbox and radio [toggle buttons]({{< docsref "/forms/checks-radios" >}}) into a seamless looking button group.
|
||||
|
||||
{{< example >}}
|
||||
<div class="btn-group" role="group" aria-label="Basic checkbox toggle button group">
|
||||
<input type="checkbox" class="btn-check" id="btncheck1" autocomplete="off">
|
||||
<label class="btn btn-outline-primary" for="btncheck1">Checkbox 1</label>
|
||||
|
||||
<input type="checkbox" class="btn-check" id="btncheck2" autocomplete="off">
|
||||
<label class="btn btn-outline-primary" for="btncheck2">Checkbox 2</label>
|
||||
|
||||
<input type="checkbox" class="btn-check" id="btncheck3" autocomplete="off">
|
||||
<label class="btn btn-outline-primary" for="btncheck3">Checkbox 3</label>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<div class="btn-group" role="group" aria-label="Basic radio toggle button group">
|
||||
<input type="radio" class="btn-check" name="btnradio" id="btnradio1" autocomplete="off" checked>
|
||||
<label class="btn btn-outline-primary" for="btnradio1">Radio 1</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="btnradio" id="btnradio2" autocomplete="off">
|
||||
<label class="btn btn-outline-primary" for="btnradio2">Radio 2</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="btnradio" id="btnradio3" autocomplete="off">
|
||||
<label class="btn btn-outline-primary" for="btnradio3">Radio 3</label>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Button toolbar
|
||||
|
||||
Combine sets of button groups into button toolbars for more complex components. Use utility classes as needed to space out groups, buttons, and more.
|
||||
|
||||
{{< example >}}
|
||||
<div class="btn-toolbar" role="toolbar" aria-label="Toolbar with button groups">
|
||||
<div class="btn-group me-2" role="group" aria-label="First group">
|
||||
<button type="button" class="btn btn-primary">1</button>
|
||||
<button type="button" class="btn btn-primary">2</button>
|
||||
<button type="button" class="btn btn-primary">3</button>
|
||||
<button type="button" class="btn btn-primary">4</button>
|
||||
</div>
|
||||
<div class="btn-group me-2" role="group" aria-label="Second group">
|
||||
<button type="button" class="btn btn-secondary">5</button>
|
||||
<button type="button" class="btn btn-secondary">6</button>
|
||||
<button type="button" class="btn btn-secondary">7</button>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="Third group">
|
||||
<button type="button" class="btn btn-info">8</button>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Feel free to mix input groups with button groups in your toolbars. Similar to the example above, you'll likely need some utilities though to space things properly.
|
||||
|
||||
{{< example >}}
|
||||
<div class="btn-toolbar mb-3" role="toolbar" aria-label="Toolbar with button groups">
|
||||
<div class="btn-group me-2" role="group" aria-label="First group">
|
||||
<button type="button" class="btn btn-outline-secondary">1</button>
|
||||
<button type="button" class="btn btn-outline-secondary">2</button>
|
||||
<button type="button" class="btn btn-outline-secondary">3</button>
|
||||
<button type="button" class="btn btn-outline-secondary">4</button>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<div class="input-group-text" id="btnGroupAddon">@</div>
|
||||
<input type="text" class="form-control" placeholder="Input group example" aria-label="Input group example" aria-describedby="btnGroupAddon">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="btn-toolbar justify-content-between" role="toolbar" aria-label="Toolbar with button groups">
|
||||
<div class="btn-group" role="group" aria-label="First group">
|
||||
<button type="button" class="btn btn-outline-secondary">1</button>
|
||||
<button type="button" class="btn btn-outline-secondary">2</button>
|
||||
<button type="button" class="btn btn-outline-secondary">3</button>
|
||||
<button type="button" class="btn btn-outline-secondary">4</button>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<div class="input-group-text" id="btnGroupAddon2">@</div>
|
||||
<input type="text" class="form-control" placeholder="Input group example" aria-label="Input group example" aria-describedby="btnGroupAddon2">
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Sizing
|
||||
|
||||
Instead of applying button sizing classes to every button in a group, just add `.btn-group-*` to each `.btn-group`, including each one when nesting multiple groups.
|
||||
|
||||
{{< example >}}
|
||||
<div class="btn-group btn-group-lg" role="group" aria-label="Large button group">
|
||||
<button type="button" class="btn btn-outline-dark">Left</button>
|
||||
<button type="button" class="btn btn-outline-dark">Middle</button>
|
||||
<button type="button" class="btn btn-outline-dark">Right</button>
|
||||
</div>
|
||||
<br>
|
||||
<div class="btn-group" role="group" aria-label="Default button group">
|
||||
<button type="button" class="btn btn-outline-dark">Left</button>
|
||||
<button type="button" class="btn btn-outline-dark">Middle</button>
|
||||
<button type="button" class="btn btn-outline-dark">Right</button>
|
||||
</div>
|
||||
<br>
|
||||
<div class="btn-group btn-group-sm" role="group" aria-label="Small button group">
|
||||
<button type="button" class="btn btn-outline-dark">Left</button>
|
||||
<button type="button" class="btn btn-outline-dark">Middle</button>
|
||||
<button type="button" class="btn btn-outline-dark">Right</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Nesting
|
||||
|
||||
Place a `.btn-group` within another `.btn-group` when you want dropdown menus mixed with a series of buttons.
|
||||
|
||||
{{< example >}}
|
||||
<div class="btn-group" role="group" aria-label="Button group with nested dropdown">
|
||||
<button type="button" class="btn btn-primary">1</button>
|
||||
<button type="button" class="btn btn-primary">2</button>
|
||||
|
||||
<div class="btn-group" role="group">
|
||||
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Dropdown
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Vertical variation
|
||||
|
||||
Make a set of buttons appear vertically stacked rather than horizontally. **Split button dropdowns are not supported here.**
|
||||
|
||||
{{< example >}}
|
||||
<div class="btn-group-vertical" role="group" aria-label="Vertical button group">
|
||||
<button type="button" class="btn btn-dark">Button</button>
|
||||
<button type="button" class="btn btn-dark">Button</button>
|
||||
<button type="button" class="btn btn-dark">Button</button>
|
||||
<button type="button" class="btn btn-dark">Button</button>
|
||||
<button type="button" class="btn btn-dark">Button</button>
|
||||
<button type="button" class="btn btn-dark">Button</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<div class="btn-group-vertical" role="group" aria-label="Vertical button group">
|
||||
<button type="button" class="btn btn-primary">Button</button>
|
||||
<button type="button" class="btn btn-primary">Button</button>
|
||||
<div class="btn-group" role="group">
|
||||
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Dropdown
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary">Button</button>
|
||||
<button type="button" class="btn btn-primary">Button</button>
|
||||
<div class="btn-group" role="group">
|
||||
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Dropdown
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="btn-group" role="group">
|
||||
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Dropdown
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="btn-group" role="group">
|
||||
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Dropdown
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
||||
<li><a class="dropdown-item" href="#">Dropdown link</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<div class="btn-group-vertical" role="group" aria-label="Vertical radio toggle button group">
|
||||
<input type="radio" class="btn-check" name="vbtn-radio" id="vbtn-radio1" autocomplete="off" checked>
|
||||
<label class="btn btn-outline-danger" for="vbtn-radio1">Radio 1</label>
|
||||
<input type="radio" class="btn-check" name="vbtn-radio" id="vbtn-radio2" autocomplete="off">
|
||||
<label class="btn btn-outline-danger" for="vbtn-radio2">Radio 2</label>
|
||||
<input type="radio" class="btn-check" name="vbtn-radio" id="vbtn-radio3" autocomplete="off">
|
||||
<label class="btn btn-outline-danger" for="vbtn-radio3">Radio 3</label>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
|
@ -1,242 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Buttons
|
||||
description: Use Bootstrap's custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more.
|
||||
group: components
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Examples
|
||||
|
||||
Bootstrap includes several predefined button styles, each serving its own semantic purpose, with a few extras thrown in for more control.
|
||||
|
||||
{{< example >}}
|
||||
{{< buttons.inline >}}
|
||||
{{- range (index $.Site.Data "theme-colors") }}
|
||||
<button type="button" class="btn btn-{{ .name }}">{{ .name | title }}</button>
|
||||
{{- end -}}
|
||||
{{< /buttons.inline >}}
|
||||
|
||||
<button type="button" class="btn btn-link">Link</button>
|
||||
{{< /example >}}
|
||||
|
||||
{{< callout info >}}
|
||||
{{< partial "callout-warning-color-assistive-technologies.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
## Disable text wrapping
|
||||
|
||||
If you don't want the button text to wrap, you can add the `.text-nowrap` class to the button. In Sass, you can set `$btn-white-space: nowrap` to disable text wrapping for each button.
|
||||
|
||||
## Button tags
|
||||
|
||||
The `.btn` classes are designed to be used with the `<button>` element. However, you can also use these classes on `<a>` or `<input>` elements (though some browsers may apply a slightly different rendering).
|
||||
|
||||
When using button classes on `<a>` elements that are used to trigger in-page functionality (like collapsing content), rather than linking to new pages or sections within the current page, these links should be given a `role="button"` to appropriately convey their purpose to assistive technologies such as screen readers.
|
||||
|
||||
{{< example >}}
|
||||
<a class="btn btn-primary" href="#" role="button">Link</a>
|
||||
<button class="btn btn-primary" type="submit">Button</button>
|
||||
<input class="btn btn-primary" type="button" value="Input">
|
||||
<input class="btn btn-primary" type="submit" value="Submit">
|
||||
<input class="btn btn-primary" type="reset" value="Reset">
|
||||
{{< /example >}}
|
||||
|
||||
## Outline buttons
|
||||
|
||||
In need of a button, but not the hefty background colors they bring? Replace the default modifier classes with the `.btn-outline-*` ones to remove all background images and colors on any button.
|
||||
|
||||
{{< example >}}
|
||||
{{< buttons.inline >}}
|
||||
{{- range (index $.Site.Data "theme-colors") }}
|
||||
<button type="button" class="btn btn-outline-{{ .name }}">{{ .name | title }}</button>
|
||||
{{- end -}}
|
||||
{{< /buttons.inline >}}
|
||||
{{< /example >}}
|
||||
|
||||
{{< callout info >}}
|
||||
Some of the button styles use a relatively light foreground color, and should only be used on a dark background in order to have sufficient contrast.
|
||||
{{< /callout >}}
|
||||
|
||||
## Sizes
|
||||
|
||||
Fancy larger or smaller buttons? Add `.btn-lg` or `.btn-sm` for additional sizes.
|
||||
|
||||
{{< example >}}
|
||||
<button type="button" class="btn btn-primary btn-lg">Large button</button>
|
||||
<button type="button" class="btn btn-secondary btn-lg">Large button</button>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<button type="button" class="btn btn-primary btn-sm">Small button</button>
|
||||
<button type="button" class="btn btn-secondary btn-sm">Small button</button>
|
||||
{{< /example >}}
|
||||
|
||||
You can even roll your own custom sizing with CSS variables:
|
||||
|
||||
{{< example >}}
|
||||
<button type="button" class="btn btn-primary"
|
||||
style="--bs-btn-padding-y: .25rem; --bs-btn-padding-x: .5rem; --bs-btn-font-size: .75rem;">
|
||||
Custom button
|
||||
</button>
|
||||
{{< /example >}}
|
||||
|
||||
## Disabled state
|
||||
|
||||
Make buttons look inactive by adding the `disabled` boolean attribute to any `<button>` element. Disabled buttons have `pointer-events: none` applied to, preventing hover and active states from triggering.
|
||||
|
||||
{{< example >}}
|
||||
<button type="button" class="btn btn-primary" disabled>Primary button</button>
|
||||
<button type="button" class="btn btn-secondary" disabled>Button</button>
|
||||
<button type="button" class="btn btn-outline-primary" disabled>Primary button</button>
|
||||
<button type="button" class="btn btn-outline-secondary" disabled>Button</button>
|
||||
{{< /example >}}
|
||||
|
||||
Disabled buttons using the `<a>` element behave a bit different:
|
||||
|
||||
- `<a>`s don't support the `disabled` attribute, so you must add the `.disabled` class to make it visually appear disabled.
|
||||
- Some future-friendly styles are included to disable all `pointer-events` on anchor buttons.
|
||||
- Disabled buttons using `<a>` should include the `aria-disabled="true"` attribute to indicate the state of the element to assistive technologies.
|
||||
- Disabled buttons using `<a>` *should not* include the `href` attribute.
|
||||
|
||||
{{< example >}}
|
||||
<a class="btn btn-primary disabled" role="button" aria-disabled="true">Primary link</a>
|
||||
<a class="btn btn-secondary disabled" role="button" aria-disabled="true">Link</a>
|
||||
{{< /example >}}
|
||||
|
||||
### Link functionality caveat
|
||||
|
||||
To cover cases where you have to keep the `href` attribute on a disabled link, the `.disabled` class uses `pointer-events: none` to try to disable the link functionality of `<a>`s. Note that this CSS property is not yet standardized for HTML, but all modern browsers support it. In addition, even in browsers that do support `pointer-events: none`, keyboard navigation remains unaffected, meaning that sighted keyboard users and users of assistive technologies will still be able to activate these links. So to be safe, in addition to `aria-disabled="true"`, also include a `tabindex="-1"` attribute on these links to prevent them from receiving keyboard focus, and use custom JavaScript to disable their functionality altogether.
|
||||
|
||||
{{< example >}}
|
||||
<a href="#" class="btn btn-primary disabled" tabindex="-1" role="button" aria-disabled="true">Primary link</a>
|
||||
<a href="#" class="btn btn-secondary disabled" tabindex="-1" role="button" aria-disabled="true">Link</a>
|
||||
{{< /example >}}
|
||||
|
||||
## Block buttons
|
||||
|
||||
Create responsive stacks of full-width, "block buttons" like those in Bootstrap 4 with a mix of our display and gap utilities. By using utilities instead of button specific classes, we have much greater control over spacing, alignment, and responsive behaviors.
|
||||
|
||||
{{< example >}}
|
||||
<div class="d-grid gap-2">
|
||||
<button class="btn btn-primary" type="button">Button</button>
|
||||
<button class="btn btn-primary" type="button">Button</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Here we create a responsive variation, starting with vertically stacked buttons until the `md` breakpoint, where `.d-md-block` replaces the `.d-grid` class, thus nullifying the `gap-2` utility. Resize your browser to see them change.
|
||||
|
||||
{{< example >}}
|
||||
<div class="d-grid gap-2 d-md-block">
|
||||
<button class="btn btn-primary" type="button">Button</button>
|
||||
<button class="btn btn-primary" type="button">Button</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
You can adjust the width of your block buttons with grid column width classes. For example, for a half-width "block button", use `.col-6`. Center it horizontally with `.mx-auto`, too.
|
||||
|
||||
{{< example >}}
|
||||
<div class="d-grid gap-2 col-6 mx-auto">
|
||||
<button class="btn btn-primary" type="button">Button</button>
|
||||
<button class="btn btn-primary" type="button">Button</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Additional utilities can be used to adjust the alignment of buttons when horizontal. Here we've taken our previous responsive example and added some flex utilities and a margin utility on the button to right align the buttons when they're no longer stacked.
|
||||
|
||||
{{< example >}}
|
||||
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
|
||||
<button class="btn btn-primary me-md-2" type="button">Button</button>
|
||||
<button class="btn btn-primary" type="button">Button</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Button plugin
|
||||
|
||||
The button plugin allows you to create simple on/off toggle buttons.
|
||||
|
||||
{{< callout info >}}
|
||||
Visually, these toggle buttons are identical to the [checkbox toggle buttons]({{< docsref "/forms/checks-radios#checkbox-toggle-buttons" >}}). However, they are conveyed differently by assistive technologies: the checkbox toggles will be announced by screen readers as "checked"/"not checked" (since, despite their appearance, they are fundamentally still checkboxes), whereas these toggle buttons will be announced as "button"/"button pressed". The choice between these two approaches will depend on the type of toggle you are creating, and whether or not the toggle will make sense to users when announced as a checkbox or as an actual button.
|
||||
{{< /callout >}}
|
||||
|
||||
### Toggle states
|
||||
|
||||
Add `data-bs-toggle="button"` to toggle a button's `active` state. If you're pre-toggling a button, you must manually add the `.active` class **and** `aria-pressed="true"` to ensure that it is conveyed appropriately to assistive technologies.
|
||||
|
||||
{{< example >}}
|
||||
<button type="button" class="btn btn-primary" data-bs-toggle="button">Toggle button</button>
|
||||
<button type="button" class="btn btn-primary active" data-bs-toggle="button" aria-pressed="true">Active toggle button</button>
|
||||
<button type="button" class="btn btn-primary" disabled data-bs-toggle="button">Disabled toggle button</button>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<a href="#" class="btn btn-primary" role="button" data-bs-toggle="button">Toggle link</a>
|
||||
<a href="#" class="btn btn-primary active" role="button" data-bs-toggle="button" aria-pressed="true">Active toggle link</a>
|
||||
<a class="btn btn-primary disabled" aria-disabled="true" role="button" data-bs-toggle="button">Disabled toggle link</a>
|
||||
{{< /example >}}
|
||||
|
||||
### Methods
|
||||
|
||||
You can create a button instance with the button constructor, for example:
|
||||
|
||||
```js
|
||||
const bsButton = new bootstrap.Button('#myButton')
|
||||
```
|
||||
|
||||
{{< bs-table "table" >}}
|
||||
| Method | Description |
|
||||
| --- | --- |
|
||||
| `dispose` | Destroys an element's button. (Removes stored data on the DOM element) |
|
||||
| `getInstance` | Static method which allows you to get the button instance associated to a DOM element, you can use it like this: `bootstrap.Button.getInstance(element)`. |
|
||||
| `getOrCreateInstance` | Static method which returns a button instance associated to a DOM element or create a new one in case it wasn't initialized. You can use it like this: `bootstrap.Button.getOrCreateInstance(element)`. |
|
||||
| `toggle` | Toggles push state. Gives the button the appearance that it has been activated. |
|
||||
{{< /bs-table >}}
|
||||
|
||||
For example, to toggle all buttons
|
||||
|
||||
```js
|
||||
document.querySelectorAll('.btn').forEach(buttonElement => {
|
||||
const button = bootstrap.Button.getOrCreateInstance(buttonElement)
|
||||
button.toggle()
|
||||
})
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
### Variables
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
As part of Bootstrap's evolving CSS variables approach, buttons now use local CSS variables on `.btn` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
|
||||
|
||||
{{< scss-docs name="btn-css-vars" file="scss/_buttons.scss" >}}
|
||||
|
||||
Each `.btn-*` modifier class updates the appropriate CSS variables to minimize additional CSS rules with our `button-variant()`, `button-outline-variant()`, and `button-size()` mixins.
|
||||
|
||||
Here's an example of building a custom `.btn-*` modifier class like we do for the buttons unique to our docs by reassigning Bootstrap's CSS variables with a mixture of our own CSS and Sass variables.
|
||||
|
||||
<div class="bd-example">
|
||||
<button type="button" class="btn btn-bd-primary">Custom button</button>
|
||||
</div>
|
||||
|
||||
{{< scss-docs name="btn-css-vars-example" file="site/assets/scss/_buttons.scss" >}}
|
||||
|
||||
### Sass variables
|
||||
|
||||
{{< scss-docs name="btn-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
### Sass mixins
|
||||
|
||||
There are three mixins for buttons: button and button outline variant mixins (both based on `$theme-colors`), plus a button size mixin.
|
||||
|
||||
{{< scss-docs name="btn-variant-mixin" file="scss/mixins/_buttons.scss" >}}
|
||||
|
||||
{{< scss-docs name="btn-outline-variant-mixin" file="scss/mixins/_buttons.scss" >}}
|
||||
|
||||
{{< scss-docs name="btn-size-mixin" file="scss/mixins/_buttons.scss" >}}
|
||||
|
||||
### Sass loops
|
||||
|
||||
Button variants (for regular and outline buttons) use their respective mixins with our `$theme-colors` map to generate the modifier classes in `scss/_buttons.scss`.
|
||||
|
||||
{{< scss-docs name="btn-variant-loops" file="scss/_buttons.scss" >}}
|
||||
|
|
@ -1,739 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Cards
|
||||
description: Bootstrap's cards provide a flexible and extensible content container with multiple variants and options.
|
||||
group: components
|
||||
toc: true
|
||||
---
|
||||
|
||||
## About
|
||||
|
||||
A **card** is a flexible and extensible content container. It includes options for headers and footers, a wide variety of content, contextual background colors, and powerful display options. If you're familiar with Bootstrap 3, cards replace our old panels, wells, and thumbnails. Similar functionality to those components is available as modifier classes for cards.
|
||||
|
||||
## Example
|
||||
|
||||
Cards are built with as little markup and styles as possible, but still manage to deliver a ton of control and customization. Built with flexbox, they offer easy alignment and mix well with other Bootstrap components. They have no `margin` by default, so use [spacing utilities]({{< docsref "/utilities/spacing" >}}) as needed.
|
||||
|
||||
Below is an example of a basic card with mixed content and a fixed width. Cards have no fixed width to start, so they'll naturally fill the full width of its parent element. This is easily customized with our various [sizing options](#sizing).
|
||||
|
||||
{{< example >}}
|
||||
<div class="card" style="width: 18rem;">
|
||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
|
||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Content types
|
||||
|
||||
Cards support a wide variety of content, including images, text, list groups, links, and more. Below are examples of what's supported.
|
||||
|
||||
### Body
|
||||
|
||||
The building block of a card is the `.card-body`. Use it whenever you need a padded section within a card.
|
||||
|
||||
{{< example >}}
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
This is some text within a card body.
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Titles, text, and links
|
||||
|
||||
Card titles are used by adding `.card-title` to a `<h*>` tag. In the same way, links are added and placed next to each other by adding `.card-link` to an `<a>` tag.
|
||||
|
||||
Subtitles are used by adding a `.card-subtitle` to a `<h*>` tag. If the `.card-title` and the `.card-subtitle` items are placed in a `.card-body` item, the card title and subtitle are aligned nicely.
|
||||
|
||||
{{< example >}}
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
|
||||
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
|
||||
<a href="#" class="card-link">Card link</a>
|
||||
<a href="#" class="card-link">Another link</a>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Images
|
||||
|
||||
`.card-img-top` 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.
|
||||
|
||||
{{< example >}}
|
||||
<div class="card" style="width: 18rem;">
|
||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### List groups
|
||||
|
||||
Create lists of content in a card with a flush list group.
|
||||
|
||||
{{< example >}}
|
||||
<div class="card" style="width: 18rem;">
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">An item</li>
|
||||
<li class="list-group-item">A second item</li>
|
||||
<li class="list-group-item">A third item</li>
|
||||
</ul>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-header">
|
||||
Featured
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">An item</li>
|
||||
<li class="list-group-item">A second item</li>
|
||||
<li class="list-group-item">A third item</li>
|
||||
</ul>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<div class="card" style="width: 18rem;">
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">An item</li>
|
||||
<li class="list-group-item">A second item</li>
|
||||
<li class="list-group-item">A third item</li>
|
||||
</ul>
|
||||
<div class="card-footer">
|
||||
Card footer
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Kitchen sink
|
||||
|
||||
Mix and match multiple content types to create the card you need, or throw everything in there. Shown below are image styles, blocks, text styles, and a list group—all wrapped in a fixed-width card.
|
||||
|
||||
{{< example >}}
|
||||
<div class="card" style="width: 18rem;">
|
||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">An item</li>
|
||||
<li class="list-group-item">A second item</li>
|
||||
<li class="list-group-item">A third item</li>
|
||||
</ul>
|
||||
<div class="card-body">
|
||||
<a href="#" class="card-link">Card link</a>
|
||||
<a href="#" class="card-link">Another link</a>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Header and footer
|
||||
|
||||
Add an optional header and/or footer within a card.
|
||||
|
||||
{{< example >}}
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Featured
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Special title treatment</h5>
|
||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Card headers can be styled by adding `.card-header` to `<h*>` elements.
|
||||
|
||||
{{< example >}}
|
||||
<div class="card">
|
||||
<h5 class="card-header">Featured</h5>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Special title treatment</h5>
|
||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Quote
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<blockquote class="blockquote mb-0">
|
||||
<p>A well-known quote, contained in a blockquote element.</p>
|
||||
<footer class="blockquote-footer">Someone famous in <cite title="Source Title">Source Title</cite></footer>
|
||||
</blockquote>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<div class="card text-center">
|
||||
<div class="card-header">
|
||||
Featured
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Special title treatment</h5>
|
||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
||||
</div>
|
||||
<div class="card-footer text-muted">
|
||||
2 days ago
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Sizing
|
||||
|
||||
Cards assume no specific `width` to start, so they'll be 100% wide unless otherwise stated. You can change this as needed with custom CSS, grid classes, grid Sass mixins, or utilities.
|
||||
|
||||
### Using grid markup
|
||||
|
||||
Using the grid, wrap cards in columns and rows as needed.
|
||||
|
||||
{{< example >}}
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Special title treatment</h5>
|
||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Special title treatment</h5>
|
||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Using utilities
|
||||
|
||||
Use our handful of [available sizing utilities]({{< docsref "/utilities/sizing" >}}) to quickly set a card's width.
|
||||
|
||||
{{< example >}}
|
||||
<div class="card w-75">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
||||
<a href="#" class="btn btn-primary">Button</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card w-50">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
||||
<a href="#" class="btn btn-primary">Button</a>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Using custom CSS
|
||||
|
||||
Use custom CSS in your stylesheets or as inline styles to set a width.
|
||||
|
||||
{{< example >}}
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Special title treatment</h5>
|
||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Text alignment
|
||||
|
||||
You can quickly change the text alignment of any card—in its entirety or specific parts—with our [text align classes]({{< docsref "/utilities/text#text-alignment" >}}).
|
||||
|
||||
{{< example >}}
|
||||
<div class="card" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Special title treatment</h5>
|
||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card text-center" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Special title treatment</h5>
|
||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card text-end" style="width: 18rem;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Special title treatment</h5>
|
||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Navigation
|
||||
|
||||
Add some navigation to a card's header (or block) with Bootstrap's [nav components]({{< docsref "/components/navs-tabs" >}}).
|
||||
|
||||
{{< example >}}
|
||||
<div class="card text-center">
|
||||
<div class="card-header">
|
||||
<ul class="nav nav-tabs card-header-tabs">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="true" href="#">Active</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Link</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link disabled">Disabled</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Special title treatment</h5>
|
||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<div class="card text-center">
|
||||
<div class="card-header">
|
||||
<ul class="nav nav-pills card-header-pills">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="#">Active</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Link</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link disabled">Disabled</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Special title treatment</h5>
|
||||
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
|
||||
<a href="#" class="btn btn-primary">Go somewhere</a>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Images
|
||||
|
||||
Cards include a few options for working with images. Choose from appending "image caps" at either end of a card, overlaying images with card content, or simply embedding the image in a card.
|
||||
|
||||
### Image caps
|
||||
|
||||
Similar to headers and footers, cards can include top and bottom "image caps"—images at the top or bottom of a card.
|
||||
|
||||
{{< example >}}
|
||||
<div class="card mb-3">
|
||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
|
||||
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
|
||||
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
|
||||
</div>
|
||||
{{< placeholder width="100%" height="180" class="card-img-bottom" text="Image cap" >}}
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Image overlays
|
||||
|
||||
Turn an image into a card background and overlay your card's text. Depending on the image, you may or may not need additional styles or utilities.
|
||||
|
||||
{{< example >}}
|
||||
<div class="card text-bg-dark">
|
||||
{{< placeholder width="100%" height="270" class="bd-placeholder-img-lg card-img" text="Card image" >}}
|
||||
<div class="card-img-overlay">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
|
||||
<p class="card-text"><small>Last updated 3 mins ago</small></p>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< callout info >}}
|
||||
Note that content should not be larger than the height of the image. If content is larger than the image the content will be displayed outside the image.
|
||||
{{< /callout >}}
|
||||
|
||||
## Horizontal
|
||||
|
||||
Using a combination of grid and utility classes, cards can be made horizontal in a mobile-friendly and responsive way. In the example below, we remove the grid gutters with `.g-0` and use `.col-md-*` classes to make the card horizontal at the `md` breakpoint. Further adjustments may be needed depending on your card content.
|
||||
|
||||
{{< example >}}
|
||||
<div class="card mb-3" style="max-width: 540px;">
|
||||
<div class="row g-0">
|
||||
<div class="col-md-4">
|
||||
{{< placeholder width="100%" height="250" text="Image" class="img-fluid rounded-start" >}}
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
|
||||
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Card styles
|
||||
|
||||
Cards include various options for customizing their backgrounds, borders, and color.
|
||||
|
||||
### Background and color
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
Set a `background-color` with contrasting foreground `color` with [our `.text-bg-{color}` helpers]({{< docsref "helpers/color-background" >}}). Previously it was required to manually pair your choice of [`.text-{color}`]({{< docsref "/utilities/colors" >}}) and [`.bg-{color}`]({{< docsref "/utilities/background" >}}) utilities for styling, which you still may use if you prefer.
|
||||
|
||||
{{< example >}}
|
||||
{{< card.inline >}}
|
||||
{{- range (index $.Site.Data "theme-colors") }}
|
||||
<div class="card text-bg-{{ .name }} mb-3" style="max-width: 18rem;">
|
||||
<div class="card-header">Header</div>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{{ .name | title }} card title</h5>
|
||||
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
|
||||
</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{< /card.inline >}}
|
||||
{{< /example >}}
|
||||
|
||||
{{< callout info >}}
|
||||
{{< partial "callout-warning-color-assistive-technologies.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
### Border
|
||||
|
||||
Use [border utilities]({{< docsref "/utilities/borders" >}}) to change just the `border-color` of a card. Note that you can put `.text-{color}` classes on the parent `.card` or a subset of the card's contents as shown below.
|
||||
|
||||
{{< example >}}
|
||||
{{< card.inline >}}
|
||||
{{- range (index $.Site.Data "theme-colors") }}
|
||||
<div class="card border-{{ .name }} mb-3" style="max-width: 18rem;">
|
||||
<div class="card-header">Header</div>
|
||||
<div class="card-body{{ if not .contrast_color }} text-{{ .name }}{{ end }}">
|
||||
<h5 class="card-title">{{ .name | title }} card title</h5>
|
||||
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
|
||||
</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{< /card.inline >}}
|
||||
{{< /example >}}
|
||||
|
||||
### Mixins utilities
|
||||
|
||||
You can also change the borders on the card header and footer as needed, and even remove their `background-color` with `.bg-transparent`.
|
||||
|
||||
{{< example >}}
|
||||
<div class="card border-success mb-3" style="max-width: 18rem;">
|
||||
<div class="card-header bg-transparent border-success">Header</div>
|
||||
<div class="card-body text-success">
|
||||
<h5 class="card-title">Success card title</h5>
|
||||
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
|
||||
</div>
|
||||
<div class="card-footer bg-transparent border-success">Footer</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Card layout
|
||||
|
||||
In addition to styling the content within cards, Bootstrap includes a few options for laying out series of cards. For the time being, **these layout options are not yet responsive**.
|
||||
|
||||
### Card groups
|
||||
|
||||
Use card groups to render cards as a single, attached element with equal width and height columns. Card groups start off stacked and use `display: flex;` to become attached with uniform dimensions starting at the `sm` breakpoint.
|
||||
|
||||
{{< example >}}
|
||||
<div class="card-group">
|
||||
<div class="card">
|
||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
|
||||
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
|
||||
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
|
||||
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
When using card groups with footers, their content will automatically line up.
|
||||
|
||||
{{< example >}}
|
||||
<div class="card-group">
|
||||
<div class="card">
|
||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<small class="text-muted">Last updated 3 mins ago</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<small class="text-muted">Last updated 3 mins ago</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<small class="text-muted">Last updated 3 mins ago</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Grid cards
|
||||
|
||||
Use the Bootstrap grid system and its [`.row-cols` classes]({{< docsref "/layout/grid#row-columns" >}}) to control how many grid columns (wrapped around your cards) you show per row. For example, here's `.row-cols-1` laying out the cards on one column, and `.row-cols-md-2` splitting four cards to equal width across multiple rows, from the medium breakpoint up.
|
||||
|
||||
{{< example >}}
|
||||
<div class="row row-cols-1 row-cols-md-2 g-4">
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Change it to `.row-cols-3` and you'll see the fourth card wrap.
|
||||
|
||||
{{< example >}}
|
||||
<div class="row row-cols-1 row-cols-md-3 g-4">
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
When you need equal height, add `.h-100` to the cards. If you want equal heights by default, you can set `$card-height: 100%` in Sass.
|
||||
|
||||
{{< example >}}
|
||||
<div class="row row-cols-1 row-cols-md-3 g-4">
|
||||
<div class="col">
|
||||
<div class="card h-100">
|
||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card h-100">
|
||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a short card.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card h-100">
|
||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card h-100">
|
||||
{{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Just like with card groups, card footers will automatically line up.
|
||||
|
||||
{{< example >}}
|
||||
<div class="row row-cols-1 row-cols-md-3 g-4">
|
||||
<div class="col">
|
||||
<div class="card h-100">
|
||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<small class="text-muted">Last updated 3 mins ago</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card h-100">
|
||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<small class="text-muted">Last updated 3 mins ago</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card h-100">
|
||||
{{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card title</h5>
|
||||
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<small class="text-muted">Last updated 3 mins ago</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Masonry
|
||||
|
||||
In `v4` we used a CSS-only technique to mimic the behavior of [Masonry](https://masonry.desandro.com/)-like columns, but this technique came with lots of unpleasant [side effects](https://github.com/twbs/bootstrap/pull/28922). If you want to have this type of layout in `v5`, you can just make use of Masonry plugin. **Masonry is not included in Bootstrap**, but we've made a [demo example]({{< docsref "/examples/masonry" >}}) to help you get started.
|
||||
|
||||
## CSS
|
||||
|
||||
### Variables
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
As part of Bootstrap's evolving CSS variables approach, cards now use local CSS variables on `.card` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
|
||||
|
||||
{{< scss-docs name="card-css-vars" file="scss/_card.scss" >}}
|
||||
|
||||
### Sass variables
|
||||
|
||||
{{< scss-docs name="card-variables" file="scss/_variables.scss" >}}
|
||||
|
|
@ -1,385 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Carousel
|
||||
description: A slideshow component for cycling through elements—images or slides of text—like a carousel.
|
||||
group: components
|
||||
toc: true
|
||||
---
|
||||
|
||||
## How it works
|
||||
|
||||
The carousel is a slideshow for cycling through a series of content, built with CSS 3D transforms and a bit of JavaScript. It works with a series of images, text, or custom markup. It also includes support for previous/next controls and indicators.
|
||||
|
||||
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.).
|
||||
|
||||
{{< 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.
|
||||
|
||||
## Example
|
||||
|
||||
Carousels don't automatically normalize slide dimensions. As such, you may need to use additional utilities or custom styles to appropriately size content. While carousels support previous/next controls and indicators, they're not explicitly required. Add and customize as you see fit.
|
||||
|
||||
**The `.active` class needs to be added to one of the slides** otherwise the carousel will not be visible. Also be sure to set a unique `id` on the `.carousel` for optional controls, especially if you're using multiple carousels on a single page. Control and indicator elements must have a `data-bs-target` attribute (or `href` for links) that matches the `id` of the `.carousel` element.
|
||||
|
||||
### Slides only
|
||||
|
||||
Here's a carousel with slides only. Note the presence of the `.d-block` and `.w-100` on carousel images to prevent browser default image alignment.
|
||||
|
||||
{{< example >}}
|
||||
<div id="carouselExampleSlidesOnly" class="carousel slide" data-bs-ride="carousel">
|
||||
<div class="carousel-inner">
|
||||
<div class="carousel-item active">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" >}}
|
||||
</div>
|
||||
<div class="carousel-item">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" >}}
|
||||
</div>
|
||||
<div class="carousel-item">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### With controls
|
||||
|
||||
Adding in the previous and next controls. We recommend using `<button>` elements, but you can also use `<a>` elements with `role="button"`.
|
||||
|
||||
{{< example >}}
|
||||
<div id="carouselExampleControls" class="carousel slide" data-bs-ride="carousel">
|
||||
<div class="carousel-inner">
|
||||
<div class="carousel-item active">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" >}}
|
||||
</div>
|
||||
<div class="carousel-item">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" >}}
|
||||
</div>
|
||||
<div class="carousel-item">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
|
||||
</div>
|
||||
</div>
|
||||
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="prev">
|
||||
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">Previous</span>
|
||||
</button>
|
||||
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="next">
|
||||
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">Next</span>
|
||||
</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### With indicators
|
||||
|
||||
You can also add the indicators to the carousel, alongside the controls, too.
|
||||
|
||||
{{< example >}}
|
||||
<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="true">
|
||||
<div class="carousel-indicators">
|
||||
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
|
||||
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
|
||||
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
|
||||
</div>
|
||||
<div class="carousel-inner">
|
||||
<div class="carousel-item active">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" >}}
|
||||
</div>
|
||||
<div class="carousel-item">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" >}}
|
||||
</div>
|
||||
<div class="carousel-item">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
|
||||
</div>
|
||||
</div>
|
||||
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
|
||||
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">Previous</span>
|
||||
</button>
|
||||
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
|
||||
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">Next</span>
|
||||
</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### 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]({{< docsref "/utilities/display" >}}). We hide them initially with `.d-none` and bring them back on medium-sized devices with `.d-md-block`.
|
||||
|
||||
{{< example >}}
|
||||
<div id="carouselExampleCaptions" class="carousel slide" data-bs-ride="false">
|
||||
<div class="carousel-indicators">
|
||||
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
|
||||
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="1" aria-label="Slide 2"></button>
|
||||
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="2" aria-label="Slide 3"></button>
|
||||
</div>
|
||||
<div class="carousel-inner">
|
||||
<div class="carousel-item active">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" >}}
|
||||
<div class="carousel-caption d-none d-md-block">
|
||||
<h5>First slide label</h5>
|
||||
<p>Some representative placeholder content for the first slide.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="carousel-item">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" >}}
|
||||
<div class="carousel-caption d-none d-md-block">
|
||||
<h5>Second slide label</h5>
|
||||
<p>Some representative placeholder content for the second slide.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="carousel-item">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
|
||||
<div class="carousel-caption d-none d-md-block">
|
||||
<h5>Third slide label</h5>
|
||||
<p>Some representative placeholder content for the third slide.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide="prev">
|
||||
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">Previous</span>
|
||||
</button>
|
||||
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide="next">
|
||||
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">Next</span>
|
||||
</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Crossfade
|
||||
|
||||
Add `.carousel-fade` to your carousel to animate slides with a fade transition instead of a slide. Depending on your carousel content (e.g., text only slides), you may want to add `.bg-body` or some custom CSS to the `.carousel-item`s for proper crossfading.
|
||||
|
||||
{{< example >}}
|
||||
<div id="carouselExampleFade" class="carousel slide carousel-fade" data-bs-ride="carousel">
|
||||
<div class="carousel-inner">
|
||||
<div class="carousel-item active">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" >}}
|
||||
</div>
|
||||
<div class="carousel-item">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" >}}
|
||||
</div>
|
||||
<div class="carousel-item">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
|
||||
</div>
|
||||
</div>
|
||||
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleFade" data-bs-slide="prev">
|
||||
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">Previous</span>
|
||||
</button>
|
||||
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleFade" data-bs-slide="next">
|
||||
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">Next</span>
|
||||
</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Individual `.carousel-item` interval
|
||||
|
||||
Add `data-bs-interval=""` to a `.carousel-item` to change the amount of time to delay between automatically cycling to the next item.
|
||||
|
||||
{{< example >}}
|
||||
<div id="carouselExampleInterval" class="carousel slide" data-bs-ride="carousel">
|
||||
<div class="carousel-inner">
|
||||
<div class="carousel-item active" data-bs-interval="10000">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" >}}
|
||||
</div>
|
||||
<div class="carousel-item" data-bs-interval="2000">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" >}}
|
||||
</div>
|
||||
<div class="carousel-item">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
|
||||
</div>
|
||||
</div>
|
||||
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleInterval" data-bs-slide="prev">
|
||||
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">Previous</span>
|
||||
</button>
|
||||
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleInterval" data-bs-slide="next">
|
||||
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">Next</span>
|
||||
</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Disable touch swiping
|
||||
|
||||
Carousels support swiping left/right on touchscreen devices to move between slides. This can be disabled using the `data-bs-touch` attribute. The example below also does not include the `data-bs-ride` attribute so it doesn't autoplay.
|
||||
|
||||
{{< example >}}
|
||||
<div id="carouselExampleControlsNoTouching" class="carousel slide" data-bs-touch="false">
|
||||
<div class="carousel-inner">
|
||||
<div class="carousel-item active">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#555" background="#777" text="First slide" >}}
|
||||
</div>
|
||||
<div class="carousel-item">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#444" background="#666" text="Second slide" >}}
|
||||
</div>
|
||||
<div class="carousel-item">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#333" background="#555" text="Third slide" >}}
|
||||
</div>
|
||||
</div>
|
||||
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleControlsNoTouching" data-bs-slide="prev">
|
||||
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">Previous</span>
|
||||
</button>
|
||||
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleControlsNoTouching" data-bs-slide="next">
|
||||
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">Next</span>
|
||||
</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Dark variant
|
||||
|
||||
Add `.carousel-dark` to the `.carousel` for darker controls, indicators, and captions. Controls have been inverted from their default white fill with the `filter` CSS property. Captions and controls have additional Sass variables that customize the `color` and `background-color`.
|
||||
|
||||
{{< example >}}
|
||||
<div id="carouselExampleDark" class="carousel carousel-dark slide" data-bs-ride="carousel">
|
||||
<div class="carousel-indicators">
|
||||
<button type="button" data-bs-target="#carouselExampleDark" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
|
||||
<button type="button" data-bs-target="#carouselExampleDark" data-bs-slide-to="1" aria-label="Slide 2"></button>
|
||||
<button type="button" data-bs-target="#carouselExampleDark" data-bs-slide-to="2" aria-label="Slide 3"></button>
|
||||
</div>
|
||||
<div class="carousel-inner">
|
||||
<div class="carousel-item active" data-bs-interval="10000">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#aaa" background="#f5f5f5" text="First slide" >}}
|
||||
<div class="carousel-caption d-none d-md-block">
|
||||
<h5>First slide label</h5>
|
||||
<p>Some representative placeholder content for the first slide.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="carousel-item" data-bs-interval="2000">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#bbb" background="#eee" text="Second slide" >}}
|
||||
<div class="carousel-caption d-none d-md-block">
|
||||
<h5>Second slide label</h5>
|
||||
<p>Some representative placeholder content for the second slide.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="carousel-item">
|
||||
{{< placeholder width="800" height="400" class="bd-placeholder-img-lg d-block w-100" color="#999" background="#e5e5e5" text="Third slide" >}}
|
||||
<div class="carousel-caption d-none d-md-block">
|
||||
<h5>Third slide label</h5>
|
||||
<p>Some representative placeholder content for the third slide.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleDark" data-bs-slide="prev">
|
||||
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">Previous</span>
|
||||
</button>
|
||||
<button class="carousel-control-next" type="button" data-bs-target="#carouselExampleDark" data-bs-slide="next">
|
||||
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">Next</span>
|
||||
</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Custom transition
|
||||
|
||||
The transition duration of `.carousel-item` can be changed with the `$carousel-transition-duration` Sass variable before compiling or custom styles if you're using the compiled CSS. If multiple transitions are applied, make sure the transform transition is defined first (e.g. `transition: transform 2s ease, opacity .5s ease-out`).
|
||||
|
||||
## Sass
|
||||
|
||||
### Variables
|
||||
|
||||
Variables for all carousels:
|
||||
|
||||
{{< scss-docs name="carousel-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
Variables for the [dark carousel](#dark-variant):
|
||||
|
||||
{{< scss-docs name="carousel-dark-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
## Usage
|
||||
|
||||
### Via data attributes
|
||||
|
||||
Use data attributes to easily control the position of the carousel. `data-bs-slide` accepts the keywords `prev` or `next`, which alters the slide position relative to its current position. Alternatively, use `data-bs-slide-to` to pass a raw slide index to the carousel `data-bs-slide-to="2"`, which shifts the slide position to a particular index beginning with `0`.
|
||||
|
||||
The `data-bs-ride="carousel"` attribute is used to mark a carousel as animating starting at page load. If you don't use `data-bs-ride="carousel"` to initialize your carousel, you have to initialize it yourself. **It cannot be used in combination with (redundant and unnecessary) explicit JavaScript initialization of the same carousel.**
|
||||
|
||||
### Via JavaScript
|
||||
|
||||
Call carousel manually with:
|
||||
|
||||
```js
|
||||
const carousel = new bootstrap.Carousel('#myCarousel')
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
{{< markdown >}}
|
||||
{{< partial "js-data-attributes.md" >}}
|
||||
{{< /markdown >}}
|
||||
|
||||
{{< bs-table >}}
|
||||
| Name | Type | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `interval` | number | `5000` | The amount of time to delay between automatically cycling an item. |
|
||||
| `keyboard` | boolean | `true` | Whether the carousel should react to keyboard events. |
|
||||
| `pause` | string, boolean | `"hover"` | If set to `"hover"`, pauses the cycling of the carousel on `mouseenter` and resumes the cycling of the carousel on `mouseleave`. If set to `false`, hovering over the carousel won't pause it. On touch-enabled devices, when set to `"hover"`, cycling will pause on `touchend` (once the user finished interacting with the carousel) for two intervals, before automatically resuming. This is in addition to the mouse behavior. |
|
||||
| `ride` | string, boolean | `false` | If set to `true`, autoplays the carousel after the user manually cycles the first item. If set to `"carousel"`, autoplays the carousel on load. |
|
||||
| `touch` | boolean | `true` | Whether the carousel should support left/right swipe interactions on touchscreen devices. |
|
||||
| `wrap` | boolean | `true` | Whether the carousel should cycle continuously or have hard stops. |
|
||||
{{< /bs-table >}}
|
||||
|
||||
### Methods
|
||||
|
||||
{{< callout danger >}}
|
||||
{{< partial "callout-danger-async-methods.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
You can create a carousel instance with the carousel constructor, for example, to initialize with additional options and start cycling through items:
|
||||
|
||||
```js
|
||||
const myCarouselElement = document.querySelector('#myCarousel')
|
||||
const carousel = new bootstrap.Carousel(myCarouselElement, {
|
||||
interval: 2000,
|
||||
wrap: false
|
||||
})
|
||||
```
|
||||
|
||||
{{< bs-table >}}
|
||||
| Method | Description |
|
||||
| --- | --- |
|
||||
| `cycle` | Cycles through the carousel items from left to right. |
|
||||
| `dispose` | Destroys an element's carousel. (Removes stored data on the DOM element) |
|
||||
| `getInstance` | Static method which allows you to get the carousel instance associated to a DOM element, you can use it like this: `bootstrap.Carousel.getInstance(element)`. |
|
||||
| `getOrCreateInstance` | Static method which returns a carousel instance associated to a DOM element or create a new one in case it wasn't initialized. You can use it like this: `bootstrap.Carousel.getOrCreateInstance(element)`. |
|
||||
| `next` | Cycles to the next item. **Returns to the caller before the next item has been shown** (e.g., before the `slid.bs.carousel` event occurs). |
|
||||
| `nextWhenVisible` | Don't cycle carousel to next when the page isn't visible or the carousel or its parent isn't visible. **Returns to the caller before the target item has been shown**. |
|
||||
| `pause` | Stops the carousel from cycling through items. |
|
||||
| `prev` | Cycles to the previous item. **Returns to the caller before the previous item has been shown** (e.g., before the `slid.bs.carousel` event occurs). |
|
||||
| `to` | Cycles the carousel to a particular frame (0 based, similar to an array). **Returns to the caller before the target item has been shown** (e.g., before the `slid.bs.carousel` event occurs). |
|
||||
{{< /bs-table >}}
|
||||
|
||||
### Events
|
||||
|
||||
Bootstrap's carousel class exposes two events for hooking into carousel functionality. Both events have the following additional properties:
|
||||
|
||||
- `direction`: The direction in which the carousel is sliding (either `"left"` or `"right"`).
|
||||
- `relatedTarget`: The DOM element that is being slid into place as the active item.
|
||||
- `from`: The index of the current item
|
||||
- `to`: The index of the next item
|
||||
|
||||
All carousel events are fired at the carousel itself (i.e. at the `<div class="carousel">`).
|
||||
|
||||
{{< bs-table >}}
|
||||
| Event type | Description |
|
||||
| --- | --- |
|
||||
| `slid.bs.carousel` | Fired when the carousel has completed its slide transition. |
|
||||
| `slide.bs.carousel` | Fires immediately when the `slide` instance method is invoked. |
|
||||
{{< /bs-table >}}
|
||||
|
||||
```js
|
||||
const myCarousel = document.getElementById('myCarousel')
|
||||
|
||||
myCarousel.addEventListener('slide.bs.carousel', event => {
|
||||
// do something...
|
||||
})
|
||||
```
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Close button
|
||||
description: A generic close button for dismissing content like modals and alerts.
|
||||
group: components
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Example
|
||||
|
||||
Provide an option to dismiss or close a component with `.btn-close`. Default styling is limited, but highly customizable. Modify the Sass variables to replace the default `background-image`. **Be sure to include text for screen readers**, as we've done with `aria-label`.
|
||||
|
||||
{{< example >}}
|
||||
<button type="button" class="btn-close" aria-label="Close"></button>
|
||||
{{< /example >}}
|
||||
|
||||
## Disabled state
|
||||
|
||||
Disabled close buttons change their `opacity`. We've also applied `pointer-events: none` and `user-select: none` to preventing hover and active states from triggering.
|
||||
|
||||
{{< example >}}
|
||||
<button type="button" class="btn-close" disabled aria-label="Close"></button>
|
||||
{{< /example >}}
|
||||
|
||||
## White variant
|
||||
|
||||
Change the default `.btn-close` to be white with the `.btn-close-white` class. This class uses the `filter` property to invert the `background-image`.
|
||||
|
||||
{{< example class="bg-dark" >}}
|
||||
<button type="button" class="btn-close btn-close-white" aria-label="Close"></button>
|
||||
<button type="button" class="btn-close btn-close-white" disabled aria-label="Close"></button>
|
||||
{{< /example >}}
|
||||
|
||||
## Sass
|
||||
|
||||
### Variables
|
||||
|
||||
{{< scss-docs name="close-variables" file="scss/_variables.scss" >}}
|
||||
|
|
@ -1,198 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Collapse
|
||||
description: Toggle the visibility of content across your project with a few classes and our JavaScript plugins.
|
||||
group: components
|
||||
toc: true
|
||||
---
|
||||
|
||||
## How it works
|
||||
|
||||
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.
|
||||
|
||||
{{< callout info >}}
|
||||
{{< partial "callout-info-prefersreducedmotion.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
## Example
|
||||
|
||||
Click the buttons below to show and hide another element via class changes:
|
||||
|
||||
- `.collapse` hides content
|
||||
- `.collapsing` is applied during transitions
|
||||
- `.collapse.show` shows content
|
||||
|
||||
Generally, we recommend using a button with the `data-bs-target` attribute. While not recommended from a semantic point of view, you can also use a link with the `href` attribute (and a `role="button"`). In both cases, the `data-bs-toggle="collapse"` is required.
|
||||
|
||||
{{< example >}}
|
||||
<p>
|
||||
<a class="btn btn-primary" data-bs-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
|
||||
Link with href
|
||||
</a>
|
||||
<button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
|
||||
Button with data-bs-target
|
||||
</button>
|
||||
</p>
|
||||
<div class="collapse" id="collapseExample">
|
||||
<div class="card card-body">
|
||||
Some placeholder content for the collapse component. This panel is hidden by default but revealed when the user activates the relevant trigger.
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Horizontal
|
||||
|
||||
The collapse plugin also supports horizontal collapsing. Add the `.collapse-horizontal` modifier class to transition the `width` instead of `height` and set a `width` on the immediate child element. Feel free to write your own custom Sass, use inline styles, or use our [width utilities]({{< docsref "/utilities/sizing" >}}).
|
||||
|
||||
{{< callout info >}}
|
||||
Please note that while the example below has a `min-height` set to avoid excessive repaints in our docs, this is not explicitly required. **Only the `width` on the child element is required.**
|
||||
{{< /callout >}}
|
||||
|
||||
{{< example >}}
|
||||
<p>
|
||||
<button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#collapseWidthExample" aria-expanded="false" aria-controls="collapseWidthExample">
|
||||
Toggle width collapse
|
||||
</button>
|
||||
</p>
|
||||
<div style="min-height: 120px;">
|
||||
<div class="collapse collapse-horizontal" id="collapseWidthExample">
|
||||
<div class="card card-body" style="width: 300px;">
|
||||
This is some placeholder content for a horizontal collapse. It's hidden by default and shown when triggered.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Multiple targets
|
||||
|
||||
A `<button>` or `<a>` can show and hide multiple elements by referencing them with a selector in its `href` or `data-bs-target` attribute.
|
||||
Multiple `<button>` or `<a>` can show and hide an element if they each reference it with their `href` or `data-bs-target` attribute
|
||||
|
||||
{{< example >}}
|
||||
<p>
|
||||
<a class="btn btn-primary" data-bs-toggle="collapse" href="#multiCollapseExample1" role="button" aria-expanded="false" aria-controls="multiCollapseExample1">Toggle first element</a>
|
||||
<button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#multiCollapseExample2" aria-expanded="false" aria-controls="multiCollapseExample2">Toggle second element</button>
|
||||
<button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target=".multi-collapse" aria-expanded="false" aria-controls="multiCollapseExample1 multiCollapseExample2">Toggle both elements</button>
|
||||
</p>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="collapse multi-collapse" id="multiCollapseExample1">
|
||||
<div class="card card-body">
|
||||
Some placeholder content for the first collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="collapse multi-collapse" id="multiCollapseExample2">
|
||||
<div class="card card-body">
|
||||
Some placeholder content for the second collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Accessibility
|
||||
|
||||
Be sure to add `aria-expanded` to the control element. This attribute explicitly conveys the current state of the collapsible element tied to the control to screen readers and similar assistive technologies. If the collapsible element is closed by default, the attribute on the control element should have a value of `aria-expanded="false"`. If you've set the collapsible element to be open by default using the `show` class, set `aria-expanded="true"` on the control instead. The plugin will automatically toggle this attribute on the control based on whether or not the collapsible element has been opened or closed (via JavaScript, or because the user triggered another control element also tied to the same collapsible element). If the control element's HTML element is not a button (e.g., an `<a>` or `<div>`), the attribute `role="button"` should be added to the element.
|
||||
|
||||
If your control element is targeting a single collapsible element – i.e. the `data-bs-target` attribute is pointing to an `id` selector – you should add the `aria-controls` attribute to the control element, containing the `id` of the collapsible element. Modern screen readers and similar assistive technologies make use of this attribute to provide users with additional shortcuts to navigate directly to the collapsible element itself.
|
||||
|
||||
Note that Bootstrap's current implementation does not cover the various *optional* keyboard interactions described in the [ARIA Authoring Practices Guide accordion pattern](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/) - you will need to include these yourself with custom JavaScript.
|
||||
|
||||
## Sass
|
||||
|
||||
### Variables
|
||||
|
||||
{{< scss-docs name="collapse-transition" file="scss/_variables.scss" >}}
|
||||
|
||||
### Classes
|
||||
|
||||
Collapse transition classes can be found in `scss/_transitions.scss` as these are shared across multiple components (collapse and accordion).
|
||||
|
||||
{{< scss-docs name="collapse-classes" file="scss/_transitions.scss" >}}
|
||||
|
||||
## Usage
|
||||
|
||||
The collapse plugin utilizes a few classes to handle the heavy lifting:
|
||||
|
||||
- `.collapse` hides the content
|
||||
- `.collapse.show` shows the content
|
||||
- `.collapsing` is added when the transition starts, and removed when it finishes
|
||||
|
||||
These classes can be found in `_transitions.scss`.
|
||||
|
||||
### Via data attributes
|
||||
|
||||
Just add `data-bs-toggle="collapse"` and a `data-bs-target` to the element to automatically assign control of one or more collapsible elements. The `data-bs-target` attribute accepts a CSS selector to apply the collapse to. Be sure to add the class `collapse` to the collapsible element. If you'd like it to default open, add the additional class `show`.
|
||||
|
||||
To add accordion-like group management to a collapsible area, add the data attribute `data-bs-parent="#selector"`. Refer to the [accordion page]({{< docsref "/components/accordion" >}}) for more information.
|
||||
|
||||
### Via JavaScript
|
||||
|
||||
Enable manually with:
|
||||
|
||||
```js
|
||||
const collapseElementList = document.querySelectorAll('.collapse')
|
||||
const collapseList = [...collapseElementList].map(collapseEl => new bootstrap.Collapse(collapseEl))
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
{{< markdown >}}
|
||||
{{< partial "js-data-attributes.md" >}}
|
||||
{{< /markdown >}}
|
||||
|
||||
{{< bs-table "table" >}}
|
||||
| Name | Type | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
`parent` | selector, DOM element | `null` | If parent is provided, then all collapsible elements under the specified parent will be closed when this collapsible item is shown. (similar to traditional accordion behavior - this is dependent on the `card` class). The attribute has to be set on the target collapsible area. |
|
||||
`toggle` | boolean | `true` | Toggles the collapsible element on invocation. |
|
||||
{{< /bs-table >}}
|
||||
|
||||
### Methods
|
||||
|
||||
{{< callout danger >}}
|
||||
{{< partial "callout-danger-async-methods.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
Activates your content as a collapsible element. Accepts an optional options `object`.
|
||||
|
||||
You can create a collapse instance with the constructor, for example:
|
||||
|
||||
```js
|
||||
const bsCollapse = new bootstrap.Collapse('#myCollapse', {
|
||||
toggle: false
|
||||
})
|
||||
```
|
||||
|
||||
{{< bs-table >}}
|
||||
| Method | Description |
|
||||
| --- | --- |
|
||||
| `dispose` | Destroys an element's collapse. (Removes stored data on the DOM element) |
|
||||
| `getInstance` | Static method which allows you to get the collapse instance associated to a DOM element, you can use it like this: `bootstrap.Collapse.getInstance(element)`. |
|
||||
| `getOrCreateInstance` | Static method which returns a collapse instance associated to a DOM element or create a new one in case it wasn't initialized. You can use it like this: `bootstrap.Collapse.getOrCreateInstance(element)`. |
|
||||
| `hide` | Hides a collapsible element. **Returns to the caller before the collapsible element has actually been hidden** (e.g., before the `hidden.bs.collapse` event occurs). |
|
||||
| `show` | Shows a collapsible element. **Returns to the caller before the collapsible element has actually been shown** (e.g., before the `shown.bs.collapse` event occurs). |
|
||||
| `toggle` | Toggles a collapsible element to shown or hidden. **Returns to the caller before the collapsible element has actually been shown or hidden** (i.e. before the `shown.bs.collapse` or `hidden.bs.collapse` event occurs). |
|
||||
{{< /bs-table >}}
|
||||
|
||||
### Events
|
||||
|
||||
Bootstrap's collapse class exposes a few events for hooking into collapse functionality.
|
||||
|
||||
{{< bs-table >}}
|
||||
| Event type | Description |
|
||||
| --- | --- |
|
||||
| `hide.bs.collapse` | This event is fired immediately when the `hide` method has been called. |
|
||||
| `hidden.bs.collapse` | This event is fired when a collapse element has been hidden from the user (will wait for CSS transitions to complete). |
|
||||
| `show.bs.collapse` | This event fires immediately when the `show` instance method is called. |
|
||||
| `shown.bs.collapse` | This event is fired when a collapse element has been made visible to the user (will wait for CSS transitions to complete). |
|
||||
{{< /bs-table >}}
|
||||
|
||||
```js
|
||||
const myCollapsible = document.getElementById('myCollapsible')
|
||||
myCollapsible.addEventListener('hidden.bs.collapse', event => {
|
||||
// do something...
|
||||
})
|
||||
```
|
||||
|
|
@ -1,813 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Navbar
|
||||
description: Documentation and examples for Bootstrap's powerful, responsive navigation header, the navbar. Includes support for branding, navigation, and more, including support for our collapse plugin.
|
||||
group: components
|
||||
toc: true
|
||||
---
|
||||
|
||||
## How it works
|
||||
|
||||
Here's what you need to know before getting started with the navbar:
|
||||
|
||||
- Navbars require a wrapping `.navbar` with `.navbar-expand{-sm|-md|-lg|-xl|-xxl}` for responsive collapsing and [color scheme](#color-schemes) classes.
|
||||
- Navbars and their contents are fluid by default. Change the [container](#containers) to limit their horizontal width in different ways.
|
||||
- Use our [spacing]({{< docsref "/utilities/spacing" >}}) and [flex]({{< docsref "/utilities/flex" >}}) utility classes for controlling spacing and alignment within navbars.
|
||||
- Navbars are responsive by default, but you can easily modify them to change that. Responsive behavior depends on our Collapse JavaScript plugin.
|
||||
- Ensure accessibility by using a `<nav>` element or, if using a more generic element such as a `<div>`, add a `role="navigation"` to every navbar to explicitly identify it as a landmark region for users of assistive technologies.
|
||||
- Indicate the current item by using `aria-current="page"` for the current page or `aria-current="true"` for the current item in a set.
|
||||
- **New in v5.2.0:** Navbars can be themed with CSS variables that are scoped to the `.navbar` base class. `.navbar-light` has been deprecated and `.navbar-dark` has been rewritten to override CSS variables instead of adding additional styles.
|
||||
|
||||
{{< callout info >}}
|
||||
{{< partial "callout-info-prefersreducedmotion.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
## Supported content
|
||||
|
||||
Navbars come with built-in support for a handful of sub-components. Choose from the following as needed:
|
||||
|
||||
- `.navbar-brand` for your company, product, or project name.
|
||||
- `.navbar-nav` for a full-height and lightweight navigation (including support for dropdowns).
|
||||
- `.navbar-toggler` for use with our collapse plugin and other [navigation toggling](#responsive-behaviors) behaviors.
|
||||
- Flex and spacing utilities for any form controls and actions.
|
||||
- `.navbar-text` for adding vertically centered strings of text.
|
||||
- `.collapse.navbar-collapse` for grouping and hiding navbar contents by a parent breakpoint.
|
||||
- Add an optional `.navbar-scroll` to set a `max-height` and [scroll expanded navbar content](#scrolling).
|
||||
|
||||
Here's an example of all the sub-components included in a responsive light-themed navbar that automatically collapses at the `lg` (large) breakpoint.
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar navbar-expand-lg bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Navbar</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Link</a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Dropdown
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link disabled">Disabled</a>
|
||||
</li>
|
||||
</ul>
|
||||
<form class="d-flex" role="search">
|
||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
This example uses [background]({{< docsref "/utilities/background" >}}) (`bg-light`) and [spacing]({{< docsref "/utilities/spacing" >}}) (`me-auto`, `mb-2`, `mb-lg-0`, `me-2`) utility classes.
|
||||
|
||||
### Brand
|
||||
|
||||
The `.navbar-brand` can be applied to most elements, but an anchor works best, as some elements might require utility classes or custom styles.
|
||||
|
||||
#### Text
|
||||
|
||||
Add your text within an element with the `.navbar-brand` class.
|
||||
|
||||
{{< example >}}
|
||||
<!-- As a link -->
|
||||
<nav class="navbar bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Navbar</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- As a heading -->
|
||||
<nav class="navbar bg-light">
|
||||
<div class="container-fluid">
|
||||
<span class="navbar-brand mb-0 h1">Navbar</span>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
#### Image
|
||||
|
||||
You can replace the text within the `.navbar-brand` with an `<img>`.
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar bg-light">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="#">
|
||||
<img src="/docs/{{< param docs_version >}}/assets/brand/bootstrap-logo.svg" alt="Bootstrap" width="30" height="24">
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
#### Image and text
|
||||
|
||||
You can also make use of some additional utilities to add an image and text at the same time. Note the addition of `.d-inline-block` and `.align-text-top` on the `<img>`.
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">
|
||||
<img src="/docs/{{< param docs_version >}}/assets/brand/bootstrap-logo.svg" alt="Logo" width="30" height="24" class="d-inline-block align-text-top">
|
||||
Bootstrap
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
### Nav
|
||||
|
||||
Navbar navigation links build on our `.nav` options with their own modifier class and require the use of [toggler classes](#toggler) for proper responsive styling. **Navigation in navbars will also grow to occupy as much horizontal space as possible** to keep your navbar contents securely aligned.
|
||||
|
||||
Add the `.active` class on `.nav-link` to indicate the current page.
|
||||
|
||||
Please note that you should also add the `aria-current` attribute on the active `.nav-link`.
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar navbar-expand-lg bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Navbar</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Features</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Pricing</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link disabled">Disabled</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
And because we use classes for our navs, you can avoid the list-based approach entirely if you like.
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar navbar-expand-lg bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Navbar</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
|
||||
<div class="navbar-nav">
|
||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
||||
<a class="nav-link" href="#">Features</a>
|
||||
<a class="nav-link" href="#">Pricing</a>
|
||||
<a class="nav-link disabled">Disabled</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
You can also use dropdowns in your navbar. Dropdown menus require a wrapping element for positioning, so be sure to use separate and nested elements for `.nav-item` and `.nav-link` as shown below.
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar navbar-expand-lg bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Navbar</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNavDropdown">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Features</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Pricing</a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Dropdown link
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
### Forms
|
||||
|
||||
Place various form controls and components within a navbar:
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar bg-light">
|
||||
<div class="container-fluid">
|
||||
<form class="d-flex" role="search">
|
||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
Immediate child elements of `.navbar` use flex layout and will default to `justify-content: space-between`. Use additional [flex utilities]({{< docsref "/utilities/flex" >}}) as needed to adjust this behavior.
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand">Navbar</a>
|
||||
<form class="d-flex" role="search">
|
||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
Input groups work, too. If your navbar is an entire form, or mostly a form, you can use the `<form>` element as the container and save some HTML.
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar bg-light">
|
||||
<form class="container-fluid">
|
||||
<div class="input-group">
|
||||
<span class="input-group-text" id="basic-addon1">@</span>
|
||||
<input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
|
||||
</div>
|
||||
</form>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
Various buttons are supported as part of these navbar forms, too. This is also a great reminder that vertical alignment utilities can be used to align different sized elements.
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar bg-light">
|
||||
<form class="container-fluid justify-content-start">
|
||||
<button class="btn btn-outline-success me-2" type="button">Main button</button>
|
||||
<button class="btn btn-sm btn-outline-secondary" type="button">Smaller button</button>
|
||||
</form>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
### Text
|
||||
|
||||
Navbars may contain bits of text with the help of `.navbar-text`. This class adjusts vertical alignment and horizontal spacing for strings of text.
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar bg-light">
|
||||
<div class="container-fluid">
|
||||
<span class="navbar-text">
|
||||
Navbar text with an inline element
|
||||
</span>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
Mix and match with other components and utilities as needed.
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar navbar-expand-lg bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Navbar w/ text</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarText">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Features</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Pricing</a>
|
||||
</li>
|
||||
</ul>
|
||||
<span class="navbar-text">
|
||||
Navbar text with an inline element
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
## Color schemes
|
||||
|
||||
{{< callout warning >}}
|
||||
**New in v5.2.0:** Navbar theming is now powered by CSS variables and `.navbar-light` has been deprecated. CSS variables are applied to `.navbar`, defaulting to the "light" appearance, and can be overridden with `.navbar-dark`.
|
||||
{{< /callout >}}
|
||||
|
||||
Navbar themes are easier than ever thanks to Bootstrap's combination of Sass and CSS variables. The default is our "light navbar" for use with light background colors, but you can also apply `.navbar-dark` for dark background colors. Then, customize with `.bg-*` utilities.
|
||||
|
||||
<div class="bd-example">
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Navbar</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarColor01">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Features</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Pricing</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">About</a>
|
||||
</li>
|
||||
</ul>
|
||||
<form class="d-flex" role="search">
|
||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-light" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Navbar</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor02" aria-controls="navbarColor02" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarColor02">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Features</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Pricing</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">About</a>
|
||||
</li>
|
||||
</ul>
|
||||
<form class="d-flex" role="search">
|
||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-light" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<nav class="navbar navbar-expand-lg" style="background-color: #e3f2fd;">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Navbar</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor03" aria-controls="navbarColor03" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarColor03">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Features</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Pricing</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">About</a>
|
||||
</li>
|
||||
</ul>
|
||||
<form class="d-flex" role="search">
|
||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-primary" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
```html
|
||||
<nav class="navbar navbar-dark bg-dark">
|
||||
<!-- Navbar content -->
|
||||
</nav>
|
||||
|
||||
<nav class="navbar navbar-dark bg-primary">
|
||||
<!-- Navbar content -->
|
||||
</nav>
|
||||
|
||||
<nav class="navbar" style="background-color: #e3f2fd;">
|
||||
<!-- Navbar content -->
|
||||
</nav>
|
||||
```
|
||||
|
||||
## Containers
|
||||
|
||||
Although it's not required, you can wrap a navbar in a `.container` to center it on a page–though note that an inner container is still required. Or you can add a container inside the `.navbar` to only center the contents of a [fixed or static top navbar](#placement).
|
||||
|
||||
{{< example >}}
|
||||
<div class="container">
|
||||
<nav class="navbar navbar-expand-lg bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Navbar</a>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Use any of the responsive containers to change how wide the content in your navbar is presented.
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar navbar-expand-lg bg-light">
|
||||
<div class="container-md">
|
||||
<a class="navbar-brand" href="#">Navbar</a>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
## Placement
|
||||
|
||||
Use our [position utilities]({{< docsref "/utilities/position" >}}) to place navbars in non-static positions. Choose from fixed to the top, fixed to the bottom, stickied to the top (scrolls with the page until it reaches the top, then stays there), or stickied to the bottom (scrolls with the page until it reaches the bottom, then stays there).
|
||||
|
||||
Fixed navbars use `position: fixed`, meaning they're pulled from the normal flow of the DOM and may require custom CSS (e.g., `padding-top` on the `<body>`) to prevent overlap with other elements.
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Default</a>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar fixed-top bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Fixed top</a>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar fixed-bottom bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Fixed bottom</a>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar sticky-top bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Sticky top</a>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar sticky-bottom bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Sticky bottom</a>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
## Scrolling
|
||||
|
||||
Add `.navbar-nav-scroll` to a `.navbar-nav` (or other navbar sub-component) to enable vertical scrolling within the toggleable contents of a collapsed navbar. By default, scrolling kicks in at `75vh` (or 75% of the viewport height), but you can override that with the local CSS custom property `--bs-navbar-height` or custom styles. At larger viewports when the navbar is expanded, content will appear as it does in a default navbar.
|
||||
|
||||
Please note that this behavior comes with a potential drawback of `overflow`—when setting `overflow-y: auto` (required to scroll the content here), `overflow-x` is the equivalent of `auto`, which will crop some horizontal content.
|
||||
|
||||
Here's an example navbar using `.navbar-nav-scroll` with `style="--bs-scroll-height: 100px;"`, with some extra margin utilities for optimum spacing.
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar navbar-expand-lg bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Navbar scroll</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarScroll" aria-controls="navbarScroll" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarScroll">
|
||||
<ul class="navbar-nav me-auto my-2 my-lg-0 navbar-nav-scroll" style="--bs-scroll-height: 100px;">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Link</a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Link
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link disabled">Link</a>
|
||||
</li>
|
||||
</ul>
|
||||
<form class="d-flex" role="search">
|
||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
## Responsive behaviors
|
||||
|
||||
Navbars can use `.navbar-toggler`, `.navbar-collapse`, and `.navbar-expand{-sm|-md|-lg|-xl|-xxl}` classes to determine when their content collapses behind a button. In combination with other utilities, you can easily choose when to show or hide particular elements.
|
||||
|
||||
For navbars that never collapse, add the `.navbar-expand` class on the navbar. For navbars that always collapse, don't add any `.navbar-expand` class.
|
||||
|
||||
### Toggler
|
||||
|
||||
Navbar togglers are left-aligned by default, but should they follow a sibling element like a `.navbar-brand`, they'll automatically be aligned to the far right. Reversing your markup will reverse the placement of the toggler. Below are examples of different toggle styles.
|
||||
|
||||
With no `.navbar-brand` shown at the smallest breakpoint:
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar navbar-expand-lg bg-light">
|
||||
<div class="container-fluid">
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
|
||||
<a class="navbar-brand" href="#">Hidden brand</a>
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Link</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link disabled">Disabled</a>
|
||||
</li>
|
||||
</ul>
|
||||
<form class="d-flex" role="search">
|
||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
With a brand name shown on the left and toggler on the right:
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar navbar-expand-lg bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Navbar</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarTogglerDemo02">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Link</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link disabled">Disabled</a>
|
||||
</li>
|
||||
</ul>
|
||||
<form class="d-flex" role="search">
|
||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
With a toggler on the left and brand name on the right:
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar navbar-expand-lg bg-light">
|
||||
<div class="container-fluid">
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="#">Navbar</a>
|
||||
<div class="collapse navbar-collapse" id="navbarTogglerDemo03">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Link</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link disabled">Disabled</a>
|
||||
</li>
|
||||
</ul>
|
||||
<form class="d-flex" role="search">
|
||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
### External content
|
||||
|
||||
Sometimes you want to use the collapse plugin to trigger a container element for content that structurally sits outside of the `.navbar` . Because our plugin works on the `id` and `data-bs-target` matching, that's easily done!
|
||||
|
||||
{{< example >}}
|
||||
<div class="collapse" id="navbarToggleExternalContent">
|
||||
<div class="bg-dark p-4">
|
||||
<h5 class="text-white h4">Collapsed content</h5>
|
||||
<span class="text-muted">Toggleable via the navbar brand.</span>
|
||||
</div>
|
||||
</div>
|
||||
<nav class="navbar navbar-dark bg-dark">
|
||||
<div class="container-fluid">
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
When you do this, we recommend including additional JavaScript to move the focus programmatically to the container when it is opened. Otherwise, keyboard users and users of assistive technologies will likely have a hard time finding the newly revealed content - particularly if the container that was opened comes *before* the toggler in the document's structure. We also recommend making sure that the toggler has the `aria-controls` attribute, pointing to the `id` of the content container. In theory, this allows assistive technology users to jump directly from the toggler to the container it controls–but support for this is currently quite patchy.
|
||||
|
||||
### Offcanvas
|
||||
|
||||
Transform your expanding and collapsing navbar into an offcanvas drawer with the [offcanvas component]({{< docsref "/components/offcanvas" >}}). We extend both the offcanvas default styles and use our `.navbar-expand-*` classes to create a dynamic and flexible navigation sidebar.
|
||||
|
||||
In the example below, to create an offcanvas navbar that is always collapsed across all breakpoints, omit the `.navbar-expand-*` class entirely.
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar bg-light fixed-top">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Offcanvas navbar</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasNavbar" aria-controls="offcanvasNavbar">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasNavbar" aria-labelledby="offcanvasNavbarLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="offcanvasNavbarLabel">Offcanvas</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<ul class="navbar-nav justify-content-end flex-grow-1 pe-3">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Link</a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Dropdown
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<form class="d-flex mt-3" role="search">
|
||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
To create an offcanvas navbar that expands into a normal navbar at a specific breakpoint like `lg`, use `.navbar-expand-lg`.
|
||||
|
||||
```html
|
||||
<nav class="navbar navbar-expand-lg bg-light fixed-top">
|
||||
<a class="navbar-brand" href="#">Offcanvas navbar</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#navbarOffcanvasLg" aria-controls="navbarOffcanvasLg">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="offcanvas offcanvas-end" tabindex="-1" id="navbarOffcanvasLg" aria-labelledby="navbarOffcanvasLgLabel">
|
||||
...
|
||||
</div>
|
||||
</nav>
|
||||
```
|
||||
|
||||
When using offcanvas in a dark navbar, be aware that you may need to have a dark background on the offcanvas content to avoid the text becoming illegible. In the example below, we add `.navbar-dark` and `.bg-dark` to the `.navbar`, `.text-bg-dark` to the `.offcanvas`, `.dropdown-menu-dark` to `.dropdown-menu`, and `.btn-close-white` to `.btn-close` for proper styling with a dark offcanvas.
|
||||
|
||||
{{< example >}}
|
||||
<nav class="navbar navbar-dark bg-dark fixed-top">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Offcanvas dark navbar</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasDarkNavbar" aria-controls="offcanvasDarkNavbar">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="offcanvas offcanvas-end text-bg-dark" tabindex="-1" id="offcanvasDarkNavbar" aria-labelledby="offcanvasDarkNavbarLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="offcanvasDarkNavbarLabel">Dark offcanvas</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<ul class="navbar-nav justify-content-end flex-grow-1 pe-3">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Link</a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Dropdown
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-dark">
|
||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<form class="d-flex mt-3" role="search">
|
||||
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-success" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
## CSS
|
||||
|
||||
### Variables
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
As part of Bootstrap's evolving CSS variables approach, navbars now use local CSS variables on `.navbar` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
|
||||
|
||||
{{< scss-docs name="navbar-css-vars" file="scss/_navbar.scss" >}}
|
||||
|
||||
Some additional CSS variables are also present on `.navbar-nav`:
|
||||
|
||||
{{< scss-docs name="navbar-nav-css-vars" file="scss/_navbar.scss" >}}
|
||||
|
||||
Customization through CSS variables can be seen on the `.navbar-dark` class where we override specific values without adding duplicate CSS selectors.
|
||||
|
||||
{{< scss-docs name="navbar-dark-css-vars" file="scss/_navbar.scss" >}}
|
||||
|
||||
### Sass variables
|
||||
|
||||
Variables for all navbars:
|
||||
|
||||
{{< scss-docs name="navbar-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
Variables for the [dark navbar](#color-schemes):
|
||||
|
||||
{{< scss-docs name="navbar-dark-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
### Sass loop
|
||||
|
||||
[Responsive navbar expand/collapse classes](#responsive-behaviors) (e.g., `.navbar-expand-lg`) are combined with the `$breakpoints` map and generated through a loop in `scss/_navbar.scss`.
|
||||
|
||||
{{< scss-docs name="navbar-expand-loop" file="scss/_navbar.scss" >}}
|
||||
|
|
@ -1,353 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Offcanvas
|
||||
description: Build hidden sidebars into your project for navigation, shopping carts, and more with a few classes and our JavaScript plugin.
|
||||
group: components
|
||||
toc: true
|
||||
---
|
||||
|
||||
## How it works
|
||||
|
||||
Offcanvas is a sidebar component that can be toggled via JavaScript to appear from the left, right, top, or bottom edge of the viewport. Buttons or anchors are used as triggers that are attached to specific elements you toggle, and `data` attributes are used to invoke our JavaScript.
|
||||
|
||||
- Offcanvas shares some of the same JavaScript code as modals. Conceptually, they are quite similar, but they are separate plugins.
|
||||
- Similarly, some [source Sass](#sass) variables for offcanvas's styles and dimensions are inherited from the modal's variables.
|
||||
- When shown, offcanvas includes a default backdrop that can be clicked to hide the offcanvas.
|
||||
- Similar to modals, only one offcanvas can be shown at a time.
|
||||
|
||||
**Heads up!** Given how CSS handles animations, you cannot use `margin` or `translate` on an `.offcanvas` element. Instead, use the class as an independent wrapping element.
|
||||
|
||||
{{< callout info >}}
|
||||
{{< partial "callout-info-prefersreducedmotion.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
## Examples
|
||||
|
||||
### Offcanvas components
|
||||
|
||||
Below is an offcanvas example that is shown by default (via `.show` on `.offcanvas`). Offcanvas includes support for a header with a close button and an optional body class for some initial `padding`. We suggest that you include offcanvas headers with dismiss actions whenever possible, or provide an explicit dismiss action.
|
||||
|
||||
{{< example class="bd-example-offcanvas p-0 bg-light overflow-hidden" >}}
|
||||
<div class="offcanvas offcanvas-start show" tabindex="-1" id="offcanvas" aria-labelledby="offcanvasLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="offcanvasLabel">Offcanvas</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
Content for the offcanvas goes here. You can place just about any Bootstrap component or custom elements here.
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Live demo
|
||||
|
||||
Use the buttons below to show and hide an offcanvas element via JavaScript that toggles the `.show` class on an element with the `.offcanvas` class.
|
||||
|
||||
- `.offcanvas` hides content (default)
|
||||
- `.offcanvas.show` shows content
|
||||
|
||||
You can use a link with the `href` attribute, or a button with the `data-bs-target` attribute. In both cases, the `data-bs-toggle="offcanvas"` is required.
|
||||
|
||||
{{< example >}}
|
||||
<a class="btn btn-primary" data-bs-toggle="offcanvas" href="#offcanvasExample" role="button" aria-controls="offcanvasExample">
|
||||
Link with href
|
||||
</a>
|
||||
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasExample" aria-controls="offcanvasExample">
|
||||
Button with data-bs-target
|
||||
</button>
|
||||
|
||||
<div class="offcanvas offcanvas-start" tabindex="-1" id="offcanvasExample" aria-labelledby="offcanvasExampleLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="offcanvasExampleLabel">Offcanvas</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<div class="">
|
||||
Some text as placeholder. In real life you can have the elements you have chosen. Like, text, images, lists, etc.
|
||||
</div>
|
||||
<div class="dropdown mt-3">
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown">
|
||||
Dropdown button
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Body scrolling
|
||||
|
||||
Scrolling the `<body>` element is disabled when an offcanvas and its backdrop are visible. Use the `data-bs-scroll` attribute to enable `<body>` scrolling.
|
||||
|
||||
{{< example >}}
|
||||
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasScrolling" aria-controls="offcanvasScrolling">Enable body scrolling</button>
|
||||
|
||||
<div class="offcanvas offcanvas-start" data-bs-scroll="true" data-bs-backdrop="false" tabindex="-1" id="offcanvasScrolling" aria-labelledby="offcanvasScrollingLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="offcanvasScrollingLabel">Offcanvas with body scrolling</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<p>Try scrolling the rest of the page to see this option in action.</p>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Body scrolling and backdrop
|
||||
|
||||
You can also enable `<body>` scrolling with a visible backdrop.
|
||||
|
||||
{{< example >}}
|
||||
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasWithBothOptions" aria-controls="offcanvasWithBothOptions">Enable both scrolling & backdrop</button>
|
||||
|
||||
<div class="offcanvas offcanvas-start" data-bs-scroll="true" tabindex="-1" id="offcanvasWithBothOptions" aria-labelledby="offcanvasWithBothOptionsLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="offcanvasWithBothOptionsLabel">Backdrop with scrolling</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<p>Try scrolling the rest of the page to see this option in action.</p>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Static backdrop
|
||||
|
||||
When backdrop is set to static, the offcanvas will not close when clicking outside of it.
|
||||
|
||||
{{< example >}}
|
||||
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#staticBackdrop" aria-controls="staticBackdrop">
|
||||
Toggle static offcanvas
|
||||
</button>
|
||||
|
||||
<div class="offcanvas offcanvas-start" data-bs-backdrop="static" tabindex="-1" id="staticBackdrop" aria-labelledby="staticBackdropLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="staticBackdropLabel">Offcanvas</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<div>
|
||||
I will not close if you click outside of me.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Dark offcanvas
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
Change the appearance of offcanvases with utilities to better match them to different contexts like dark navbars. Here we add `.text-bg-dark` to the `.offcanvas` and `.btn-close-white` to `.btn-close` for proper styling with a dark offcanvas. If you have dropdowns within, consider also adding `.dropdown-menu-dark` to `.dropdown-menu`.
|
||||
|
||||
{{< example class="bd-example-offcanvas p-0 bg-light overflow-hidden" >}}
|
||||
<div class="offcanvas offcanvas-start show text-bg-dark" tabindex="-1" id="offcanvasDark" aria-labelledby="offcanvasDarkLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="offcanvasDarkLabel">Offcanvas</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="offcanvasDark" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<p>Place offcanvas content here.</p>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Responsive
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
Responsive offcanvas classes hide content outside the viewport from a specified breakpoint and down. Above that breakpoint, the contents within will behave as usual. For example, `.offcanvas-lg` hides content in an offcanvas below the `lg` breakpoint, but shows the content above the `lg` breakpoint.
|
||||
|
||||
{{< example >}}
|
||||
<button class="btn btn-primary d-lg-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasResponsive" aria-controls="offcanvasResponsive">Toggle offcanvas</button>
|
||||
|
||||
<div class="alert alert-info d-none d-lg-block">Resize your browser to show the responsive offcanvas toggle.</div>
|
||||
|
||||
<div class="offcanvas-lg offcanvas-end" tabindex="-1" id="offcanvasResponsive" aria-labelledby="offcanvasResponsiveLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="offcanvasResponsiveLabel">Responsive offcanvas</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#offcanvasResponsive" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<p class="mb-0">This is content within an <code>.offcanvas-lg</code>.</p>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Responsive offcanvas classes are available across for each breakpoint.
|
||||
|
||||
- `.offcanvas`
|
||||
- `.offcanvas-sm`
|
||||
- `.offcanvas-md`
|
||||
- `.offcanvas-lg`
|
||||
- `.offcanvas-xl`
|
||||
- `.offcanvas-xxl`
|
||||
|
||||
## Placement
|
||||
|
||||
There's no default placement for offcanvas components, so you must add one of the modifier classes below.
|
||||
|
||||
- `.offcanvas-start` places offcanvas on the left of the viewport (shown above)
|
||||
- `.offcanvas-end` places offcanvas on the right of the viewport
|
||||
- `.offcanvas-top` places offcanvas on the top of the viewport
|
||||
- `.offcanvas-bottom` places offcanvas on the bottom of the viewport
|
||||
|
||||
Try the top, right, and bottom examples out below.
|
||||
|
||||
{{< example >}}
|
||||
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasTop" aria-controls="offcanvasTop">Toggle top offcanvas</button>
|
||||
|
||||
<div class="offcanvas offcanvas-top" tabindex="-1" id="offcanvasTop" aria-labelledby="offcanvasTopLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="offcanvasTopLabel">Offcanvas top</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
...
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasRight" aria-controls="offcanvasRight">Toggle right offcanvas</button>
|
||||
|
||||
<div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasRight" aria-labelledby="offcanvasRightLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="offcanvasRightLabel">Offcanvas right</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
...
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasBottom" aria-controls="offcanvasBottom">Toggle bottom offcanvas</button>
|
||||
|
||||
<div class="offcanvas offcanvas-bottom" tabindex="-1" id="offcanvasBottom" aria-labelledby="offcanvasBottomLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="offcanvasBottomLabel">Offcanvas bottom</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body small">
|
||||
...
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Accessibility
|
||||
|
||||
Since the offcanvas panel is conceptually a modal dialog, be sure to add `aria-labelledby="..."`—referencing the offcanvas title—to `.offcanvas`. Note that you don’t need to add `role="dialog"` since we already add it via JavaScript.
|
||||
|
||||
## CSS
|
||||
|
||||
### Variables
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
As part of Bootstrap's evolving CSS variables approach, offcanvas now uses local CSS variables on `.offcanvas` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
|
||||
|
||||
{{< scss-docs name="offcanvas-css-vars" file="scss/_offcanvas.scss" >}}
|
||||
|
||||
### Sass variables
|
||||
|
||||
{{< scss-docs name="offcanvas-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
## Usage
|
||||
|
||||
The offcanvas plugin utilizes a few classes and attributes to handle the heavy lifting:
|
||||
|
||||
- `.offcanvas` hides the content
|
||||
- `.offcanvas.show` shows the content
|
||||
- `.offcanvas-start` hides the offcanvas on the left
|
||||
- `.offcanvas-end` hides the offcanvas on the right
|
||||
- `.offcanvas-top` hides the offcanvas on the top
|
||||
- `.offcanvas-bottom` hides the offcanvas on the bottom
|
||||
|
||||
Add a dismiss button with the `data-bs-dismiss="offcanvas"` attribute, which triggers the JavaScript functionality. Be sure to use the `<button>` element with it for proper behavior across all devices.
|
||||
|
||||
### Via data attributes
|
||||
|
||||
#### Toggle
|
||||
|
||||
Add `data-bs-toggle="offcanvas"` and a `data-bs-target` or `href` to the element to automatically assign control of one offcanvas element. The `data-bs-target` attribute accepts a CSS selector to apply the offcanvas to. Be sure to add the class `offcanvas` to the offcanvas element. If you'd like it to default open, add the additional class `show`.
|
||||
|
||||
#### Dismiss
|
||||
|
||||
{{% js-dismiss "offcanvas" %}}
|
||||
|
||||
{{< callout warning >}}
|
||||
While both ways to dismiss an offcanvas are supported, keep in mind that dismissing from outside an offcanvas does not match the [ARIA Authoring Practices Guide dialog (modal) pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialogmodal/). Do this at your own risk.
|
||||
{{< /callout >}}
|
||||
|
||||
### Via JavaScript
|
||||
|
||||
Enable manually with:
|
||||
|
||||
```js
|
||||
const offcanvasElementList = document.querySelectorAll('.offcanvas')
|
||||
const offcanvasList = [...offcanvasElementList].map(offcanvasEl => new bootstrap.Offcanvas(offcanvasEl))
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
{{< markdown >}}
|
||||
{{< partial "js-data-attributes.md" >}}
|
||||
{{< /markdown >}}
|
||||
|
||||
{{< bs-table "table" >}}
|
||||
| Name | Type | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `backdrop` | boolean or the string `static` | `true` | Apply a backdrop on body while offcanvas is open. Alternatively, specify `static` for a backdrop which doesn't close the offcanvas when clicked. |
|
||||
| `keyboard` | boolean | `true` | Closes the offcanvas when escape key is pressed. |
|
||||
| `scroll` | boolean | `false` | Allow body scrolling while offcanvas is open. |
|
||||
{{< /bs-table >}}
|
||||
|
||||
### Methods
|
||||
|
||||
{{< callout danger >}}
|
||||
{{< partial "callout-danger-async-methods.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
Activates your content as an offcanvas element. Accepts an optional options `object`.
|
||||
|
||||
You can create an offcanvas instance with the constructor, for example:
|
||||
|
||||
```js
|
||||
const bsOffcanvas = new bootstrap.Offcanvas('#myOffcanvas')
|
||||
```
|
||||
|
||||
{{< bs-table "table" >}}
|
||||
| Method | Description |
|
||||
| --- | --- |
|
||||
| `getInstance` | *Static* method which allows you to get the offcanvas instance associated with a DOM element. |
|
||||
| `getOrCreateInstance` | *Static* method which allows you to get the offcanvas instance associated with a DOM element, or create a new one in case it wasn't initialized. |
|
||||
| `hide` | Hides an offcanvas element. **Returns to the caller before the offcanvas element has actually been hidden** (i.e. before the `hidden.bs.offcanvas` event occurs). |
|
||||
| `show` | Shows an offcanvas element. **Returns to the caller before the offcanvas element has actually been shown** (i.e. before the `shown.bs.offcanvas` event occurs). |
|
||||
| `toggle` | Toggles an offcanvas element to shown or hidden. **Returns to the caller before the offcanvas element has actually been shown or hidden** (i.e. before the `shown.bs.offcanvas` or `hidden.bs.offcanvas` event occurs). |
|
||||
{{< /bs-table >}}
|
||||
|
||||
### Events
|
||||
|
||||
Bootstrap's offcanvas class exposes a few events for hooking into offcanvas functionality.
|
||||
|
||||
{{< bs-table "table" >}}
|
||||
| Event type | Description |
|
||||
| --- | --- |
|
||||
| `hide.bs.offcanvas` | This event is fired immediately when the `hide` method has been called. |
|
||||
| `hidden.bs.offcanvas` | This event is fired when an offcanvas element has been hidden from the user (will wait for CSS transitions to complete). |
|
||||
| `hidePrevented.bs.offcanvas` | This event is fired when the offcanvas is shown, its backdrop is `static` and a click outside of the offcanvas is performed. The event is also fired when the escape key is pressed and the `keyboard` option is set to `false`. |
|
||||
| `show.bs.offcanvas` | This event fires immediately when the `show` instance method is called. |
|
||||
| `shown.bs.offcanvas` | This event is fired when an offcanvas element has been made visible to the user (will wait for CSS transitions to complete). |
|
||||
{{< /bs-table >}}
|
||||
|
||||
```js
|
||||
const myOffcanvas = document.getElementById('myOffcanvas')
|
||||
myOffcanvas.addEventListener('hidden.bs.offcanvas', event => {
|
||||
// do something...
|
||||
})
|
||||
```
|
||||
|
|
@ -1,177 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Pagination
|
||||
description: Documentation and examples for showing pagination to indicate a series of related content exists across multiple pages.
|
||||
group: components
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
We use a large block of connected links for our pagination, making links hard to miss and easily scalable—all while providing large hit areas. Pagination is built with list HTML elements so screen readers can announce the number of available links. Use a wrapping `<nav>` element to identify it as a navigation section to screen readers and other assistive technologies.
|
||||
|
||||
In addition, as pages likely have more than one such navigation section, it's advisable to provide a descriptive `aria-label` for the `<nav>` to reflect its purpose. For example, if the pagination component is used to navigate between a set of search results, an appropriate label could be `aria-label="Search results pages"`.
|
||||
|
||||
{{< example >}}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination">
|
||||
<li class="page-item"><a class="page-link" href="#">Previous</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">Next</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
## Working with icons
|
||||
|
||||
Looking to use an icon or symbol in place of text for some pagination links? Be sure to provide proper screen reader support with `aria` attributes.
|
||||
|
||||
{{< example >}}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination">
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#" aria-label="Previous">
|
||||
<span aria-hidden="true">«</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#" aria-label="Next">
|
||||
<span aria-hidden="true">»</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
## Disabled and active states
|
||||
|
||||
Pagination links are customizable for different circumstances. Use `.disabled` for links that appear un-clickable and `.active` to indicate the current page.
|
||||
|
||||
While the `.disabled` class uses `pointer-events: none` to _try_ to disable the link functionality of `<a>`s, that CSS property is not yet standardized and doesn't account for keyboard navigation. As such, you should always add `tabindex="-1"` on disabled links and use custom JavaScript to fully disable their functionality.
|
||||
|
||||
{{< example >}}
|
||||
<nav aria-label="...">
|
||||
<ul class="pagination">
|
||||
<li class="page-item disabled">
|
||||
<a class="page-link">Previous</a>
|
||||
</li>
|
||||
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
||||
<li class="page-item active" aria-current="page">
|
||||
<a class="page-link" href="#">2</a>
|
||||
</li>
|
||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#">Next</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
You can optionally swap out active or disabled anchors for `<span>`, or omit the anchor in the case of the prev/next arrows, to remove click functionality and prevent keyboard focus while retaining intended styles.
|
||||
|
||||
{{< example >}}
|
||||
<nav aria-label="...">
|
||||
<ul class="pagination">
|
||||
<li class="page-item disabled">
|
||||
<span class="page-link">Previous</span>
|
||||
</li>
|
||||
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
||||
<li class="page-item active" aria-current="page">
|
||||
<span class="page-link">2</span>
|
||||
</li>
|
||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#">Next</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
## Sizing
|
||||
|
||||
Fancy larger or smaller pagination? Add `.pagination-lg` or `.pagination-sm` for additional sizes.
|
||||
|
||||
{{< example >}}
|
||||
<nav aria-label="...">
|
||||
<ul class="pagination pagination-lg">
|
||||
<li class="page-item active" aria-current="page">
|
||||
<span class="page-link">1</span>
|
||||
</li>
|
||||
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<nav aria-label="...">
|
||||
<ul class="pagination pagination-sm">
|
||||
<li class="page-item active" aria-current="page">
|
||||
<span class="page-link">1</span>
|
||||
</li>
|
||||
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
## Alignment
|
||||
|
||||
Change the alignment of pagination components with [flexbox utilities]({{< docsref "/utilities/flex" >}}). For example, with `.justify-content-center`:
|
||||
|
||||
{{< example >}}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center">
|
||||
<li class="page-item disabled">
|
||||
<a class="page-link">Previous</a>
|
||||
</li>
|
||||
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#">Next</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
Or with `.justify-content-end`:
|
||||
|
||||
{{< example >}}
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-end">
|
||||
<li class="page-item disabled">
|
||||
<a class="page-link">Previous</a>
|
||||
</li>
|
||||
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#">Next</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
{{< /example >}}
|
||||
|
||||
## CSS
|
||||
|
||||
### Variables
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
As part of Bootstrap's evolving CSS variables approach, pagination now uses local CSS variables on `.pagination` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
|
||||
|
||||
{{< scss-docs name="pagination-css-vars" file="scss/_pagination.scss" >}}
|
||||
|
||||
### Sass variables
|
||||
|
||||
{{< scss-docs name="pagination-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
### Sass mixins
|
||||
|
||||
{{< scss-docs name="pagination-mixin" file="scss/mixins/_pagination.scss" >}}
|
||||
|
|
@ -1,145 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Placeholders
|
||||
description: Use loading placeholders for your components or pages to indicate something may still be loading.
|
||||
group: components
|
||||
toc: true
|
||||
added: "5.1"
|
||||
---
|
||||
|
||||
## About
|
||||
|
||||
Placeholders can be used to enhance the experience of your application. They're built only with HTML and CSS, meaning you don't need any JavaScript to create them. You will, however, need some custom JavaScript to toggle their visibility. Their appearance, color, and sizing can be easily customized with our utility classes.
|
||||
|
||||
## Example
|
||||
|
||||
In the example below, we take a typical card component and recreate it with placeholders applied to create a "loading card". Size and proportions are the same between the two.
|
||||
|
||||
<div class="bd-example bd-example-placeholder-cards d-flex justify-content-around">
|
||||
<div class="card">
|
||||
{{< placeholder width="100%" height="180" class="card-img-top" text="false" background="#20c997" >}}
|
||||
<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>
|
||||
|
||||
<div class="card" aria-hidden="true">
|
||||
{{< placeholder width="100%" height="180" class="card-img-top" text="false" >}}
|
||||
<div class="card-body">
|
||||
<div class="h5 card-title placeholder-glow">
|
||||
<span class="placeholder col-6"></span>
|
||||
</div>
|
||||
<p class="card-text placeholder-glow">
|
||||
<span class="placeholder col-7"></span>
|
||||
<span class="placeholder col-4"></span>
|
||||
<span class="placeholder col-4"></span>
|
||||
<span class="placeholder col-6"></span>
|
||||
<span class="placeholder col-8"></span>
|
||||
</p>
|
||||
<a href="#" tabindex="-1" class="btn btn-primary disabled placeholder col-6"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
```html
|
||||
<div class="card">
|
||||
<img src="..." class="card-img-top" alt="...">
|
||||
|
||||
<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>
|
||||
|
||||
<div class="card" aria-hidden="true">
|
||||
<img src="..." class="card-img-top" alt="...">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title placeholder-glow">
|
||||
<span class="placeholder col-6"></span>
|
||||
</h5>
|
||||
<p class="card-text placeholder-glow">
|
||||
<span class="placeholder col-7"></span>
|
||||
<span class="placeholder col-4"></span>
|
||||
<span class="placeholder col-4"></span>
|
||||
<span class="placeholder col-6"></span>
|
||||
<span class="placeholder col-8"></span>
|
||||
</p>
|
||||
<a href="#" tabindex="-1" class="btn btn-primary disabled placeholder col-6"></a>
|
||||
</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
## How it works
|
||||
|
||||
Create placeholders with the `.placeholder` class and a grid column class (e.g., `.col-6`) to set the `width`. They can replace the text inside an element or be added as a modifier class to an existing component.
|
||||
|
||||
We apply additional styling to `.btn`s via `::before` to ensure the `height` is respected. You may extend this pattern for other situations as needed, or add a ` ` within the element to reflect the height when actual text is rendered in its place.
|
||||
|
||||
{{< example >}}
|
||||
<p aria-hidden="true">
|
||||
<span class="placeholder col-6"></span>
|
||||
</p>
|
||||
|
||||
<a href="#" tabindex="-1" class="btn btn-primary disabled placeholder col-4" aria-hidden="true"></a>
|
||||
{{< /example >}}
|
||||
|
||||
{{< callout info >}}
|
||||
The use of `aria-hidden="true"` only indicates that the element should be hidden to screen readers. The *loading* behavior of the placeholder depends on how authors will actually use the placeholder styles, how they plan to update things, etc. Some JavaScript code may be needed to *swap* the state of the placeholder and inform AT users of the update.
|
||||
{{< /callout >}}
|
||||
|
||||
### Width
|
||||
|
||||
You can change the `width` through grid column classes, width utilities, or inline styles.
|
||||
|
||||
{{< example >}}
|
||||
<span class="placeholder col-6"></span>
|
||||
<span class="placeholder w-75"></span>
|
||||
<span class="placeholder" style="width: 25%;"></span>
|
||||
{{< /example >}}
|
||||
|
||||
### Color
|
||||
|
||||
By default, the `placeholder` uses `currentColor`. This can be overridden with a custom color or utility class.
|
||||
|
||||
{{< example >}}
|
||||
<span class="placeholder col-12"></span>
|
||||
{{< placeholders.inline >}}
|
||||
{{- range (index $.Site.Data "theme-colors") }}
|
||||
<span class="placeholder col-12 bg-{{ .name }}"></span>
|
||||
{{- end -}}
|
||||
{{< /placeholders.inline >}}
|
||||
{{< /example >}}
|
||||
|
||||
### Sizing
|
||||
|
||||
The size of `.placeholder`s are based on the typographic style of the parent element. Customize them with sizing modifiers: `.placeholder-lg`, `.placeholder-sm`, or `.placeholder-xs`.
|
||||
|
||||
{{< example >}}
|
||||
<span class="placeholder col-12 placeholder-lg"></span>
|
||||
<span class="placeholder col-12"></span>
|
||||
<span class="placeholder col-12 placeholder-sm"></span>
|
||||
<span class="placeholder col-12 placeholder-xs"></span>
|
||||
{{< /example >}}
|
||||
|
||||
### Animation
|
||||
|
||||
Animate placeholders with `.placeholder-glow` or `.placeholder-wave` to better convey the perception of something being _actively_ loaded.
|
||||
|
||||
{{< example >}}
|
||||
<p class="placeholder-glow">
|
||||
<span class="placeholder col-12"></span>
|
||||
</p>
|
||||
|
||||
<p class="placeholder-wave">
|
||||
<span class="placeholder col-12"></span>
|
||||
</p>
|
||||
{{< /example >}}
|
||||
|
||||
## Sass
|
||||
|
||||
### Variables
|
||||
|
||||
{{< scss-docs name="placeholders" file="scss/_variables.scss" >}}
|
||||
|
|
@ -1,284 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Popovers
|
||||
description: Documentation and examples for adding Bootstrap popovers, like those found in iOS, to any element on your site.
|
||||
group: components
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Things to know when using the popover plugin:
|
||||
|
||||
- Popovers rely on the third party library [Popper](https://popper.js.org/) for positioning. You must include [popper.min.js]({{< param "cdn.popper" >}}) before `bootstrap.js`, or use one `bootstrap.bundle.min.js` which contains Popper.
|
||||
- Popovers require the [popover plugin]({{< docsref "/components/popovers" >}}) as a dependency.
|
||||
- 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).
|
||||
- Triggering popovers on hidden elements will not work.
|
||||
- Popovers for `.disabled` or `disabled` elements must be triggered on a wrapper element.
|
||||
- When triggered from anchors that wrap across multiple lines, popovers will be centered between the anchors' overall width. Use `.text-nowrap` on your `<a>`s to avoid this behavior.
|
||||
- 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.
|
||||
|
||||
{{< callout info >}}
|
||||
{{< partial "callout-info-sanitizer.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
{{< callout info >}}
|
||||
{{< partial "callout-info-prefersreducedmotion.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
Keep reading to see how popovers work with some examples.
|
||||
|
||||
## Examples
|
||||
|
||||
### Enable popovers
|
||||
|
||||
As mentioned above, you must initialize popovers before they can be used. One way to initialize all popovers on a page would be to select them by their `data-bs-toggle` attribute, like so:
|
||||
|
||||
```js
|
||||
const popoverTriggerList = document.querySelectorAll('[data-bs-toggle="popover"]')
|
||||
const popoverList = [...popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl))
|
||||
```
|
||||
|
||||
### Live demo
|
||||
|
||||
We use JavaScript similar to the snippet above to render the following live popover. Titles are set via `data-bs-title` and body content is set via `data-bs-content`.
|
||||
|
||||
{{< callout warning >}}
|
||||
{{< partial "callout-warning-data-bs-title-vs-title.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
{{< example stackblitz_add_js="true" >}}
|
||||
<button type="button" class="btn btn-lg btn-danger" data-bs-toggle="popover" data-bs-title="Popover title" data-bs-content="And here's some amazing content. It's very engaging. Right?">Click to toggle popover</button>
|
||||
{{< /example >}}
|
||||
|
||||
### Four directions
|
||||
|
||||
Four options are available: top, right, bottom, and left. Directions are mirrored when using Bootstrap in RTL. Set `data-bs-placement` to change the direction.
|
||||
|
||||
{{< example stackblitz_add_js="true" >}}
|
||||
<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="top" data-bs-content="Top popover">
|
||||
Popover on top
|
||||
</button>
|
||||
<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="right" data-bs-content="Right popover">
|
||||
Popover on right
|
||||
</button>
|
||||
<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="bottom" data-bs-content="Bottom popover">
|
||||
Popover on bottom
|
||||
</button>
|
||||
<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="left" data-bs-content="Left popover">
|
||||
Popover on left
|
||||
</button>
|
||||
{{< /example >}}
|
||||
|
||||
### Custom `container`
|
||||
|
||||
When you have some styles on a parent element that interfere with a popover, you'll want to specify a custom `container` so that the popover's HTML appears within that element instead. This is common in responsive tables, input groups, and the like.
|
||||
|
||||
```js
|
||||
const popover = new bootstrap.Popover('.example-popover', {
|
||||
container: 'body'
|
||||
})
|
||||
```
|
||||
|
||||
Another situation where you'll want to set an explicit custom `container` are popovers inside a [modal dialog]({{< docsref "/components/modal" >}}), to make sure that the popover itself is appended to the modal. This is particularly important for popovers that contain interactive elements – modal dialogs will trap focus, so unless the popover is a child element of the modal, users won't be able to focus or activate these interactive elements.
|
||||
|
||||
```js
|
||||
const popover = new bootstrap.Popover('.example-popover', {
|
||||
container: '.modal-body'
|
||||
})
|
||||
```
|
||||
|
||||
### Custom popovers
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
You can customize the appearance of popovers using [CSS variables](#variables). We set a custom class with `data-bs-custom-class="custom-popover"` to scope our custom appearance and use it to override some of the local CSS variables.
|
||||
|
||||
{{< scss-docs name="custom-popovers" file="site/assets/scss/_component-examples.scss" >}}
|
||||
|
||||
{{< example class="custom-popover-demo" stackblitz_add_js="true" >}}
|
||||
<button type="button" class="btn btn-secondary"
|
||||
data-bs-toggle="popover" data-bs-placement="right"
|
||||
data-bs-custom-class="custom-popover"
|
||||
data-bs-title="Custom popover"
|
||||
data-bs-content="This popover is themed via CSS variables.">
|
||||
Custom popover
|
||||
</button>
|
||||
{{< /example >}}
|
||||
|
||||
### 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.
|
||||
|
||||
{{< 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.
|
||||
{{< /callout >}}
|
||||
|
||||
{{< example stackblitz_add_js="true" >}}
|
||||
<a tabindex="0" class="btn btn-lg btn-danger" role="button" data-bs-toggle="popover" data-bs-trigger="focus" data-bs-title="Dismissible popover" data-bs-content="And here's some amazing content. It's very engaging. Right?">Dismissible popover</a>
|
||||
{{< /example >}}
|
||||
|
||||
```js
|
||||
const popover = new bootstrap.Popover('.popover-dismiss', {
|
||||
trigger: 'focus'
|
||||
})
|
||||
```
|
||||
|
||||
### Disabled elements
|
||||
|
||||
Elements with the `disabled` attribute aren't interactive, meaning users cannot hover or click them to trigger a popover (or tooltip). As a workaround, you'll want to trigger the popover from a wrapper `<div>` or `<span>`, ideally made keyboard-focusable using `tabindex="0"`.
|
||||
|
||||
For disabled popover triggers, you may also prefer `data-bs-trigger="hover focus"` so that the popover appears as immediate visual feedback to your users as they may not expect to _click_ on a disabled element.
|
||||
|
||||
{{< example stackblitz_add_js="true" >}}
|
||||
<span class="d-inline-block" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-content="Disabled popover">
|
||||
<button class="btn btn-primary" type="button" disabled>Disabled button</button>
|
||||
</span>
|
||||
{{< /example >}}
|
||||
|
||||
## CSS
|
||||
|
||||
### Variables
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
As part of Bootstrap’s evolving CSS variables approach, popovers now use local CSS variables on `.popover` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
|
||||
|
||||
{{< scss-docs name="popover-css-vars" file="scss/_popover.scss" >}}
|
||||
|
||||
### Sass variables
|
||||
|
||||
{{< scss-docs name="popover-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
## Usage
|
||||
|
||||
Enable popovers via JavaScript:
|
||||
|
||||
```js
|
||||
const exampleEl = document.getElementById('example')
|
||||
const popover = new bootstrap.Popover(exampleEl, options)
|
||||
```
|
||||
|
||||
{{< 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.
|
||||
|
||||
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 `allowList` of 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.
|
||||
{{< /callout >}}
|
||||
|
||||
### Options
|
||||
|
||||
{{< markdown >}}
|
||||
{{< partial "js-data-attributes.md" >}}
|
||||
{{< /markdown >}}
|
||||
|
||||
{{< callout warning >}}
|
||||
Note that for security reasons the `sanitize`, `sanitizeFn`, and `allowList` options cannot be supplied using data attributes.
|
||||
{{< /callout >}}
|
||||
|
||||
{{< bs-table "table" >}}
|
||||
| Name | Type | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `allowList` | object | [Default value]({{< docsref "/getting-started/javascript#sanitizer" >}}) | Object which contains allowed attributes and tags. |
|
||||
| `animation` | boolean | `true` | Apply a CSS fade transition to the popover. |
|
||||
| `boundary` | string, element | `'clippingParents'` | Overflow constraint boundary of the popover (applies only to Popper's preventOverflow modifier). By default, it's `'clippingParents'` and can accept an HTMLElement reference (via JavaScript only). For more information refer to Popper's [detectOverflow docs](https://popper.js.org/docs/v2/utils/detect-overflow/#boundary). |
|
||||
| `container` | string, element, false | `false` | Appends the popover to a specific element. Example: `container: 'body'`. This option is particularly useful in that it allows you to position the popover in the flow of the document near the triggering element - which will prevent the popover from floating away from the triggering element during a window resize. |
|
||||
| `content` | string, element, function | `''` | Default content value if `data-bs-content` attribute isn't present. If a function is given, it will be called with its `this` reference set to the element that the popover is attached to. |
|
||||
| `customClass` | string, function | `''` | Add classes to the popover when it is shown. Note that these classes will be added in addition to any classes specified in the template. To add multiple classes, separate them with spaces: `'class-1 class-2'`. You can also pass a function that should return a single string containing additional class names. |
|
||||
| `delay` | number, object | `0` | Delay showing and hiding the popover (ms)—doesn't apply to manual trigger type. If a number is supplied, delay is applied to both hide/show. Object structure is: `delay: { "show": 500, "hide": 100 }`. |
|
||||
| `fallbackPlacements` | string, array | `['top', 'right', 'bottom', 'left']` | Define fallback placements by providing a list of placements in array (in order of preference). For more information refer to Popper's [behavior docs](https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements). |
|
||||
| `html` | boolean | `false` | Allow HTML in the popover. If true, HTML tags in the popover's `title` will be rendered in the popover. If false, `innerText` property will be used to insert content into the DOM. Use text if you're worried about XSS attacks. |
|
||||
| `offset` | number, string, function | `[0, 0]` | Offset of the popover relative to its target. You can pass a string in data attributes with comma separated values like: `data-bs-offset="10,20"`. When a function is used to determine the offset, it is called with an object containing the popper placement, the reference, and popper rects as its first argument. The triggering element DOM node is passed as the second argument. The function must return an array with two numbers: [skidding](https://popper.js.org/docs/v2/modifiers/offset/#skidding-1), [distance](https://popper.js.org/docs/v2/modifiers/offset/#distance-1). For more information refer to Popper's [offset docs](https://popper.js.org/docs/v2/modifiers/offset/#options). |
|
||||
| `placement` | string, function | `'top'` | How to position the popover: auto, top, bottom, left, right. When `auto` is specified, it will dynamically reorient the popover. When a function is used to determine the placement, it is called with the popover DOM node as its first argument and the triggering element DOM node as its second. The `this` context is set to the popover instance. |
|
||||
| `popperConfig` | null, object, function | `null` | To change Bootstrap's default Popper config, see [Popper's configuration](https://popper.js.org/docs/v2/constructors/#options). When a function is used to create the Popper configuration, it's called with an object that contains the Bootstrap's default Popper configuration. It helps you use and merge the default with your own configuration. The function must return a configuration object for Popper. |
|
||||
| `sanitize` | boolean | `true` | Enable or disable the sanitization. If activated `'template'`, `'content'` and `'title'` options will be sanitized. |
|
||||
| `sanitizeFn` | null, function | `null` | Here you can supply your own sanitize function. This can be useful if you prefer to use a dedicated library to perform sanitization. |
|
||||
| `selector` | string, false | `false` | If a selector is provided, popover objects will be delegated to the specified targets. In practice, this is used to also apply popovers to dynamically added DOM elements (`jQuery.on` support). See [this issue]({{< param repo >}}/issues/4215) and [an informative example](https://codepen.io/Johann-S/pen/djJYPb). **Note**: `title` attribute must not be used as a selector. |
|
||||
| `template` | string | `'<div class="popover" role="popover"><div class="popover-arrow"></div><div class="popover-inner"></div></div>'` | Base HTML to use when creating the popover. The popover's `title` will be injected into the `.popover-inner`. `.popover-arrow` will become the popover's arrow. The outermost wrapper element should have the `.popover` class and `role="popover"`. |
|
||||
| `title` | string, element, function | `''` | Default title value if `title` attribute isn't present. If a function is given, it will be called with its `this` reference set to the element that the popover is attached to. |
|
||||
| `trigger` | string | `'hover focus'` | How popover is triggered: click, hover, focus, manual. You may pass multiple triggers; separate them with a space. `'manual'` indicates that the popover will be triggered programmatically via the `.popover('show')`, `.popover('hide')` and `.popover('toggle')` methods; this value cannot be combined with any other trigger. `'hover'` on its own will result in popovers that cannot be triggered via the keyboard, and should only be used if alternative methods for conveying the same information for keyboard users is present. |
|
||||
{{< /bs-table >}}
|
||||
|
||||
{{< callout info >}}
|
||||
#### Data attributes for individual popovers
|
||||
|
||||
Options for individual popovers can alternatively be specified through the use of data attributes, as explained above.
|
||||
{{< /callout >}}
|
||||
|
||||
#### Using function with `popperConfig`
|
||||
|
||||
```js
|
||||
const popover = new bootstrap.Popover(element, {
|
||||
popperConfig(defaultBsPopperConfig) {
|
||||
// const newPopperConfig = {...}
|
||||
// use defaultBsPopperConfig if needed...
|
||||
// return newPopperConfig
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Methods
|
||||
|
||||
{{< callout danger >}}
|
||||
{{< partial "callout-danger-async-methods.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
{{< bs-table "table" >}}
|
||||
| Method | Description |
|
||||
| --- | --- |
|
||||
| `disable` | Removes the ability for an element's popover to be shown. The popover will only be able to be shown if it is re-enabled. |
|
||||
| `dispose` | Hides and destroys an element's popover (Removes stored data on the DOM element). Popovers that use delegation (which are created using [the `selector` option](#options)) cannot be individually destroyed on descendant trigger elements. |
|
||||
| `enable` | Gives an element's popover the ability to be shown. **Popovers are enabled by default.** |
|
||||
| `getInstance` | _Static_ method which allows you to get the popover instance associated with a DOM element. |
|
||||
| `getOrCreateInstance` | *Static* method which allows you to get the popover instance associated with a DOM element, or create a new one in case it wasn't initialized. |
|
||||
| `hide` | Hides an element's popover. **Returns to the caller before the popover has actually been hidden** (i.e. before the `hidden.bs.popover` event occurs). This is considered a "manual" triggering of the popover. |
|
||||
| `setContent` | Gives a way to change the popover's content after its initialization. |
|
||||
| `show` | Reveals an element's popover. **Returns to the caller before the popover has actually been shown** (i.e. before the `shown.bs.popover` event occurs). This is considered a "manual" triggering of the popover. Popovers whose title and content are both zero-length are never displayed. |
|
||||
| `toggle` | Toggles an element's popover. **Returns to the caller before the popover has actually been shown or hidden** (i.e. before the `shown.bs.popover` or `hidden.bs.popover` event occurs). This is considered a "manual" triggering of the popover. |
|
||||
| `toggleEnabled` | Toggles the ability for an element's popover to be shown or hidden. |
|
||||
| `update` | Updates the position of an element's popover. |
|
||||
{{< /bs-table >}}
|
||||
|
||||
|
||||
```js
|
||||
// getOrCreateInstance example
|
||||
const popover = bootstrap.Popover.getOrCreateInstance('#example') // Returns a Bootstrap popover instance
|
||||
|
||||
// setContent example
|
||||
myPopover.setContent({
|
||||
'.popover-header': 'another title',
|
||||
'.popover-body': 'another content'
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
{{< callout info >}}
|
||||
The `setContent` method accepts an `object` argument, where each property-key is a valid `string` selector within the popover template, and each related property-value can be `string` | `element` | `function` | `null`
|
||||
{{< /callout >}}
|
||||
|
||||
### Events
|
||||
|
||||
{{< bs-table >}}
|
||||
| Event | Description |
|
||||
| --- | --- |
|
||||
| `hide.bs.popover` | This event is fired immediately when the `hide` instance method has been called. |
|
||||
| `hidden.bs.popover` | This event is fired when the popover has finished being hidden from the user (will wait for CSS transitions to complete). |
|
||||
| `inserted.bs.popover` | This event is fired after the `show.bs.popover` event when the popover template has been added to the DOM. |
|
||||
| `show.bs.popover` | This event fires immediately when the `show` instance method is called. |
|
||||
| `shown.bs.popover` | This event is fired when the popover has been made visible to the user (will wait for CSS transitions to complete). |
|
||||
{{< /bs-table >}}
|
||||
|
||||
```js
|
||||
const myPopoverTrigger = document.getElementById('myPopover')
|
||||
myPopoverTrigger.addEventListener('hidden.bs.popover', () => {
|
||||
// do something...
|
||||
})
|
||||
```
|
||||
|
|
@ -1,154 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Progress
|
||||
description: Documentation and examples for using Bootstrap custom progress bars featuring support for stacked bars, animated backgrounds, and text labels.
|
||||
group: components
|
||||
toc: true
|
||||
---
|
||||
|
||||
## How it works
|
||||
|
||||
Progress components are built with two HTML elements, some CSS to set the width, and a few attributes. We don't use [the HTML5 `<progress>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/progress), ensuring you can stack progress bars, animate them, and place text labels over them.
|
||||
|
||||
- We use the `.progress` as a wrapper to indicate the max value of the progress bar.
|
||||
- We use the inner `.progress-bar` to indicate the progress so far.
|
||||
- The `.progress-bar` requires an inline style, utility class, or custom CSS to set their width.
|
||||
- The `.progress-bar` also requires some `role` and `aria` attributes to make it accessible, including an accessible name (using `aria-label`, `aria-labelledby`, or similar).
|
||||
|
||||
Put that all together, and you have the following examples.
|
||||
|
||||
{{< example >}}
|
||||
<div class="progress">
|
||||
<div class="progress-bar" role="progressbar" aria-label="Basic example" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<div class="progress">
|
||||
<div class="progress-bar" role="progressbar" aria-label="Basic example" style="width: 25%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<div class="progress">
|
||||
<div class="progress-bar" role="progressbar" aria-label="Basic example" style="width: 50%" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<div class="progress">
|
||||
<div class="progress-bar" role="progressbar" aria-label="Basic example" style="width: 75%" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<div class="progress">
|
||||
<div class="progress-bar" role="progressbar" aria-label="Basic example" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Bootstrap provides a handful of [utilities for setting width]({{< docsref "/utilities/sizing" >}}). Depending on your needs, these may help with quickly configuring progress.
|
||||
|
||||
{{< example >}}
|
||||
<div class="progress">
|
||||
<div class="progress-bar w-75" role="progressbar" aria-label="Basic example" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Labels
|
||||
|
||||
Add labels to your progress bars by placing text within the `.progress-bar`.
|
||||
|
||||
{{< example >}}
|
||||
<div class="progress">
|
||||
<div class="progress-bar" role="progressbar" aria-label="Example with label" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">25%</div>
|
||||
</div>
|
||||
{{< /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.
|
||||
|
||||
{{< example >}}
|
||||
<div class="progress" style="height: 1px;">
|
||||
<div class="progress-bar" role="progressbar" aria-label="Example 1px high" 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" aria-label="Example 20px high" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Backgrounds
|
||||
|
||||
Use background utility classes to change the appearance of individual progress bars.
|
||||
|
||||
{{< example >}}
|
||||
<div class="progress">
|
||||
<div class="progress-bar bg-success" role="progressbar" aria-label="Success example" style="width: 25%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<div class="progress">
|
||||
<div class="progress-bar bg-info" role="progressbar" aria-label="Info example" style="width: 50%" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<div class="progress">
|
||||
<div class="progress-bar bg-warning" role="progressbar" aria-label="Warning example" style="width: 75%" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<div class="progress">
|
||||
<div class="progress-bar bg-danger" role="progressbar" aria-label="Danger example" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< callout info >}}
|
||||
{{< partial "callout-warning-color-assistive-technologies.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
## Multiple bars
|
||||
|
||||
Include multiple progress bars in a progress component if you need.
|
||||
|
||||
{{< example >}}
|
||||
<div class="progress">
|
||||
<div class="progress-bar" role="progressbar" aria-label="Segment one" style="width: 15%" aria-valuenow="15" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
<div class="progress-bar bg-success" role="progressbar" aria-label="Segment two" style="width: 30%" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
<div class="progress-bar bg-info" role="progressbar" aria-label="Segment three" style="width: 20%" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Striped
|
||||
|
||||
Add `.progress-bar-striped` to any `.progress-bar` to apply a stripe via CSS gradient over the progress bar's background color.
|
||||
|
||||
{{< example >}}
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-striped" role="progressbar" aria-label="Default striped example" style="width: 10%" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-striped bg-success" role="progressbar" aria-label="Success striped example" style="width: 25%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-striped bg-info" role="progressbar" aria-label="Info striped example" style="width: 50%" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-striped bg-warning" role="progressbar" aria-label="Warning striped example" style="width: 75%" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-striped bg-danger" role="progressbar" aria-label="Danger striped example" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Animated stripes
|
||||
|
||||
The striped gradient can also be animated. Add `.progress-bar-animated` to `.progress-bar` to animate the stripes right to left via CSS3 animations.
|
||||
|
||||
{{< example >}}
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-label="Animated striped example" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 75%"></div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## CSS
|
||||
|
||||
### Variables
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
As part of Bootstrap's evolving CSS variables approach, progress bars now use local CSS variables on `.progress` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
|
||||
|
||||
{{< scss-docs name="progress-css-vars" file="scss/_progress.scss" >}}
|
||||
|
||||
### Sass variables
|
||||
|
||||
{{< scss-docs name="progress-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
### Keyframes
|
||||
|
||||
Used for creating the CSS animations for `.progress-bar-animated`. Included in `scss/_progress-bar.scss`.
|
||||
|
||||
{{< scss-docs name="progress-keyframes" file="scss/_progress.scss" >}}
|
||||
|
|
@ -1,213 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Spinners
|
||||
description: Indicate the loading state of a component or page with Bootstrap spinners, built entirely with HTML, CSS, and no JavaScript.
|
||||
group: components
|
||||
toc: true
|
||||
---
|
||||
|
||||
## About
|
||||
|
||||
Bootstrap "spinners" can be used to show the loading state in your projects. They're built only with HTML and CSS, meaning you don't need any JavaScript to create them. You will, however, need some custom JavaScript to toggle their visibility. Their appearance, alignment, and sizing can be easily customized with our amazing utility classes.
|
||||
|
||||
For accessibility purposes, each loader here includes `role="status"` and a nested `<span class="visually-hidden">Loading...</span>`.
|
||||
|
||||
{{< callout info >}}
|
||||
{{< partial "callout-info-prefersreducedmotion.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
## Border spinner
|
||||
|
||||
Use the border spinners for a lightweight loading indicator.
|
||||
|
||||
{{< example >}}
|
||||
<div class="spinner-border" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Colors
|
||||
|
||||
The border spinner uses `currentColor` for its `border-color`, meaning you can customize the color with [text color utilities][color]. You can use any of our text color utilities on the standard spinner.
|
||||
|
||||
{{< example >}}
|
||||
{{< spinner.inline >}}
|
||||
{{- range (index $.Site.Data "theme-colors") }}
|
||||
<div class="spinner-border text-{{ .name }}" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{< /spinner.inline >}}
|
||||
{{< /example >}}
|
||||
|
||||
{{< callout info >}}
|
||||
**Why not use `border-color` utilities?** Each border spinner specifies a `transparent` border for at least one side, so `.border-{color}` utilities would override that.
|
||||
{{< /callout >}}
|
||||
|
||||
## Growing spinner
|
||||
|
||||
If you don't fancy a border spinner, switch to the grow spinner. While it doesn't technically spin, it does repeatedly grow!
|
||||
|
||||
{{< example >}}
|
||||
<div class="spinner-grow" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Once again, this spinner is built with `currentColor`, so you can easily change its appearance with [text color utilities][color]. Here it is in blue, along with the supported variants.
|
||||
|
||||
{{< example >}}
|
||||
{{< spinner.inline >}}
|
||||
{{- range (index $.Site.Data "theme-colors") }}
|
||||
<div class="spinner-grow text-{{ .name }}" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{< /spinner.inline >}}
|
||||
{{< /example >}}
|
||||
|
||||
## Alignment
|
||||
|
||||
Spinners in Bootstrap are built with `rem`s, `currentColor`, and `display: inline-flex`. This means they can easily be resized, recolored, and quickly aligned.
|
||||
|
||||
### Margin
|
||||
|
||||
Use [margin utilities][margin] like `.m-5` for easy spacing.
|
||||
|
||||
{{< example >}}
|
||||
<div class="spinner-border m-5" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Placement
|
||||
|
||||
Use [flexbox utilities][flex], [float utilities][float], or [text alignment][text] utilities to place spinners exactly where you need them in any situation.
|
||||
|
||||
#### Flex
|
||||
|
||||
{{< example >}}
|
||||
<div class="d-flex justify-content-center">
|
||||
<div class="spinner-border" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<div class="d-flex align-items-center">
|
||||
<strong>Loading...</strong>
|
||||
<div class="spinner-border ms-auto" role="status" aria-hidden="true"></div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
#### Floats
|
||||
|
||||
{{< example >}}
|
||||
<div class="clearfix">
|
||||
<div class="spinner-border float-end" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
#### Text align
|
||||
|
||||
{{< example >}}
|
||||
<div class="text-center">
|
||||
<div class="spinner-border" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Size
|
||||
|
||||
Add `.spinner-border-sm` and `.spinner-grow-sm` to make a smaller spinner that can quickly be used within other components.
|
||||
|
||||
{{< example >}}
|
||||
<div class="spinner-border spinner-border-sm" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
<div class="spinner-grow spinner-grow-sm" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Or, use custom CSS or inline styles to change the dimensions as needed.
|
||||
|
||||
{{< example >}}
|
||||
<div class="spinner-border" style="width: 3rem; height: 3rem;" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
<div class="spinner-grow" style="width: 3rem; height: 3rem;" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Buttons
|
||||
|
||||
Use spinners within buttons to indicate an action is currently processing or taking place. You may also swap the text out of the spinner element and utilize button text as needed.
|
||||
|
||||
{{< example >}}
|
||||
<button class="btn btn-primary" type="button" disabled>
|
||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</button>
|
||||
<button class="btn btn-primary" type="button" disabled>
|
||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||
Loading...
|
||||
</button>
|
||||
{{< /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="visually-hidden">Loading...</span>
|
||||
</button>
|
||||
<button class="btn btn-primary" type="button" disabled>
|
||||
<span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
|
||||
Loading...
|
||||
</button>
|
||||
{{< /example >}}
|
||||
|
||||
## CSS
|
||||
|
||||
### Variables
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
As part of Bootstrap's evolving CSS variables approach, spinners now use local CSS variables on `.spinner-border` and `.spinner-grow` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
|
||||
|
||||
Border spinner variables:
|
||||
|
||||
{{< scss-docs name="spinner-border-css-vars" file="scss/_spinners.scss" >}}
|
||||
|
||||
Growing spinner variables:
|
||||
|
||||
{{< scss-docs name="spinner-grow-css-vars" file="scss/_spinners.scss" >}}
|
||||
|
||||
For both spinners, small spinner modifier classes are used to update the values of these CSS variables as needed. For example, the `.spinner-border-sm` class does the following:
|
||||
|
||||
{{< scss-docs name="spinner-border-sm-css-vars" file="scss/_spinners.scss" >}}
|
||||
|
||||
### Sass variables
|
||||
|
||||
{{< scss-docs name="spinner-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
### Keyframes
|
||||
|
||||
Used for creating the CSS animations for our spinners. Included in `scss/_spinners.scss`.
|
||||
|
||||
{{< scss-docs name="spinner-border-keyframes" file="scss/_spinners.scss" >}}
|
||||
|
||||
{{< scss-docs name="spinner-grow-keyframes" file="scss/_spinners.scss" >}}
|
||||
|
||||
|
||||
[color]: {{< docsref "/utilities/colors" >}}
|
||||
[display]: {{< docsref "/utilities/display" >}}
|
||||
[flex]: {{< docsref "/utilities/flex" >}}
|
||||
[float]: {{< docsref "/utilities/float" >}}
|
||||
[margin]: {{< docsref "/utilities/spacing" >}}
|
||||
[sizing]: {{< docsref "/utilities/sizing" >}}
|
||||
[text]: {{< docsref "/utilities/text" >}}
|
||||
|
|
@ -1,401 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Toasts
|
||||
description: Push notifications to your visitors with a toast, a lightweight and easily customizable alert message.
|
||||
group: components
|
||||
toc: true
|
||||
---
|
||||
|
||||
Toasts are lightweight notifications designed to mimic the push notifications that have been popularized by mobile and desktop operating systems. They're built with flexbox, so they're easy to align and position.
|
||||
|
||||
## Overview
|
||||
|
||||
Things to know when using the toast plugin:
|
||||
|
||||
- Toasts are opt-in for performance reasons, so **you must initialize them yourself**.
|
||||
- Toasts will automatically hide if you do not specify `autohide: false`.
|
||||
|
||||
{{< callout info >}}
|
||||
{{< partial "callout-info-prefersreducedmotion.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic
|
||||
|
||||
To encourage extensible and predictable toasts, we recommend a header and body. Toast headers use `display: flex`, allowing easy alignment of content thanks to our margin and flexbox utilities.
|
||||
|
||||
Toasts are as flexible as you need and have very little required markup. At a minimum, we require a single element to contain your "toasted" content and strongly encourage a dismiss button.
|
||||
|
||||
{{< example class="bg-light" >}}
|
||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="toast-header">
|
||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
||||
<strong class="me-auto">Bootstrap</strong>
|
||||
<small>11 mins ago</small>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="toast-body">
|
||||
Hello, world! This is a toast message.
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< callout warning >}}
|
||||
Previously, our scripts dynamically added the `.hide` class to completely hide a toast (with `display:none`, rather than just with `opacity:0`). This is now not necessary anymore. However, for backwards compatibility, our script will continue to toggle the class (even though there is no practical need for it) until the next major version.
|
||||
{{< /callout >}}
|
||||
|
||||
### Live example
|
||||
|
||||
Click the button below to show a toast (positioned with our utilities in the lower right corner) that has been hidden by default.
|
||||
|
||||
<div class="toast-container position-fixed bottom-0 end-0 p-3">
|
||||
<div id="liveToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="toast-header">
|
||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
||||
<strong class="me-auto">Bootstrap</strong>
|
||||
<small>11 mins ago</small>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="toast-body">
|
||||
Hello, world! This is a toast message.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bd-example">
|
||||
<button type="button" class="btn btn-primary" id="liveToastBtn">Show live toast</button>
|
||||
</div>
|
||||
|
||||
```html
|
||||
<button type="button" class="btn btn-primary" id="liveToastBtn">Show live toast</button>
|
||||
|
||||
<div class="toast-container position-fixed bottom-0 end-0 p-3">
|
||||
<div id="liveToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="toast-header">
|
||||
<img src="..." class="rounded me-2" alt="...">
|
||||
<strong class="me-auto">Bootstrap</strong>
|
||||
<small>11 mins ago</small>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="toast-body">
|
||||
Hello, world! This is a toast message.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
We use the following JavaScript to trigger our live toast demo:
|
||||
|
||||
```js
|
||||
const toastTrigger = document.getElementById('liveToastBtn')
|
||||
const toastLiveExample = document.getElementById('liveToast')
|
||||
if (toastTrigger) {
|
||||
toastTrigger.addEventListener('click', () => {
|
||||
const toast = new bootstrap.Toast(toastLiveExample)
|
||||
|
||||
toast.show()
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
### Translucent
|
||||
|
||||
Toasts are slightly translucent to blend in with what's below them.
|
||||
|
||||
{{< example class="bg-dark" >}}
|
||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="toast-header">
|
||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
||||
<strong class="me-auto">Bootstrap</strong>
|
||||
<small class="text-muted">11 mins ago</small>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="toast-body">
|
||||
Hello, world! This is a toast message.
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Stacking
|
||||
|
||||
You can stack toasts by wrapping them in a toast container, which will vertically add some spacing.
|
||||
|
||||
{{< example class="bg-light" >}}
|
||||
<div class="toast-container position-static">
|
||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="toast-header">
|
||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
||||
<strong class="me-auto">Bootstrap</strong>
|
||||
<small class="text-muted">just now</small>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="toast-body">
|
||||
See? Just like this.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="toast-header">
|
||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
||||
<strong class="me-auto">Bootstrap</strong>
|
||||
<small class="text-muted">2 seconds ago</small>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="toast-body">
|
||||
Heads up, toasts will stack automatically
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Custom content
|
||||
|
||||
Customize your toasts by removing sub-components, tweaking them with [utilities]({{< docsref "/utilities/api" >}}), or by adding your own markup. Here we've created a simpler toast by removing the default `.toast-header`, adding a custom hide icon from [Bootstrap Icons]({{< param icons >}}), and using some [flexbox utilities]({{< docsref "/utilities/flex" >}}) to adjust the layout.
|
||||
|
||||
{{< example class="bg-light" >}}
|
||||
<div class="toast align-items-center" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="d-flex">
|
||||
<div class="toast-body">
|
||||
Hello, world! This is a toast message.
|
||||
</div>
|
||||
<button type="button" class="btn-close me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Alternatively, you can also add additional controls and components to toasts.
|
||||
|
||||
{{< example class="bg-light" >}}
|
||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="toast-body">
|
||||
Hello, world! This is a toast message.
|
||||
<div class="mt-2 pt-2 border-top">
|
||||
<button type="button" class="btn btn-primary btn-sm">Take action</button>
|
||||
<button type="button" class="btn btn-secondary btn-sm" data-bs-dismiss="toast">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Color schemes
|
||||
|
||||
Building on the above example, you can create different toast color schemes with our [color]({{< docsref "/utilities/colors" >}}) and [background]({{< docsref "/utilities/background" >}}) utilities. Here we've added `.text-bg-primary` to the `.toast`, and then added `.btn-close-white` to our close button. For a crisp edge, we remove the default border with `.border-0`.
|
||||
|
||||
{{< example class="bg-light" >}}
|
||||
<div class="toast align-items-center text-bg-primary border-0" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="d-flex">
|
||||
<div class="toast-body">
|
||||
Hello, world! This is a toast message.
|
||||
</div>
|
||||
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Placement
|
||||
|
||||
Place toasts with custom CSS as you need them. The top right is often used for notifications, as is the top middle. If you're only ever going to show one toast at a time, put the positioning styles right on the `.toast`.
|
||||
|
||||
{{< example stackblitz_add_js="true" >}}
|
||||
<form>
|
||||
<div class="mb-3">
|
||||
<label for="selectToastPlacement">Toast placement</label>
|
||||
<select class="form-select mt-2" id="selectToastPlacement">
|
||||
<option value="" selected>Select a position...</option>
|
||||
<option value="top-0 start-0">Top left</option>
|
||||
<option value="top-0 start-50 translate-middle-x">Top center</option>
|
||||
<option value="top-0 end-0">Top right</option>
|
||||
<option value="top-50 start-0 translate-middle-y">Middle left</option>
|
||||
<option value="top-50 start-50 translate-middle">Middle center</option>
|
||||
<option value="top-50 end-0 translate-middle-y">Middle right</option>
|
||||
<option value="bottom-0 start-0">Bottom left</option>
|
||||
<option value="bottom-0 start-50 translate-middle-x">Bottom center</option>
|
||||
<option value="bottom-0 end-0">Bottom right</option>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
<div aria-live="polite" aria-atomic="true" class="bg-dark position-relative bd-example-toasts">
|
||||
<div class="toast-container p-3" id="toastPlacement">
|
||||
<div class="toast">
|
||||
<div class="toast-header">
|
||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
||||
<strong class="me-auto">Bootstrap</strong>
|
||||
<small>11 mins ago</small>
|
||||
</div>
|
||||
<div class="toast-body">
|
||||
Hello, world! This is a toast message.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
For systems that generate more notifications, consider using a wrapping element so they can easily stack.
|
||||
|
||||
{{< example class="bg-dark bd-example-toasts p-0" >}}
|
||||
<div aria-live="polite" aria-atomic="true" class="position-relative">
|
||||
<!-- Position it: -->
|
||||
<!-- - `.toast-container` for spacing between toasts -->
|
||||
<!-- - `top-0` & `end-0` to position the toasts in the upper right corner -->
|
||||
<!-- - `.p-3` to prevent the toasts from sticking to the edge of the container -->
|
||||
<div class="toast-container top-0 end-0 p-3">
|
||||
|
||||
<!-- Then put toasts within -->
|
||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="toast-header">
|
||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
||||
<strong class="me-auto">Bootstrap</strong>
|
||||
<small class="text-muted">just now</small>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="toast-body">
|
||||
See? Just like this.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="toast-header">
|
||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
||||
<strong class="me-auto">Bootstrap</strong>
|
||||
<small class="text-muted">2 seconds ago</small>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="toast-body">
|
||||
Heads up, toasts will stack automatically
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
You can also get fancy with flexbox utilities to align toasts horizontally and/or vertically.
|
||||
|
||||
{{< example class="bg-dark bd-example-toasts d-flex" >}}
|
||||
<!-- Flexbox container for aligning the toasts -->
|
||||
<div aria-live="polite" aria-atomic="true" class="d-flex justify-content-center align-items-center w-100">
|
||||
|
||||
<!-- Then put toasts within -->
|
||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="toast-header">
|
||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
||||
<strong class="me-auto">Bootstrap</strong>
|
||||
<small>11 mins ago</small>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="toast-body">
|
||||
Hello, world! This is a toast message.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Accessibility
|
||||
|
||||
Toasts are intended to be small interruptions to your visitors or users, so to help those with screen readers and similar assistive technologies, you should wrap your toasts in an [`aria-live` region](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions). Changes to live regions (such as injecting/updating a toast component) are automatically announced by screen readers without needing to move the user's focus or otherwise interrupt the user. Additionally, include `aria-atomic="true"` to ensure that the entire toast is always announced as a single (atomic) unit, rather than just announcing what was changed (which could lead to problems if you only update part of the toast's content, or if displaying the same toast content at a later point in time). If the information needed is important for the process, e.g. for a list of errors in a form, then use the [alert component]({{< docsref "/components/alerts" >}}) instead of toast.
|
||||
|
||||
Note that the live region needs to be present in the markup *before* the toast is generated or updated. If you dynamically generate both at the same time and inject them into the page, they will generally not be announced by assistive technologies.
|
||||
|
||||
You also need to adapt the `role` and `aria-live` level depending on the content. If it's an important message like an error, use `role="alert" aria-live="assertive"`, otherwise use `role="status" aria-live="polite"` attributes.
|
||||
|
||||
As the content you're displaying changes, be sure to update the [`delay` timeout](#options) so that users have enough time to read the toast.
|
||||
|
||||
```html
|
||||
<div class="toast" role="alert" aria-live="polite" aria-atomic="true" data-bs-delay="10000">
|
||||
<div role="alert" aria-live="assertive" aria-atomic="true">...</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
When using `autohide: false`, you must add a close button to allow users to dismiss the toast.
|
||||
|
||||
{{< example class="bg-light" >}}
|
||||
<div role="alert" aria-live="assertive" aria-atomic="true" class="toast" data-bs-autohide="false">
|
||||
<div class="toast-header">
|
||||
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
|
||||
<strong class="me-auto">Bootstrap</strong>
|
||||
<small>11 mins ago</small>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="toast-body">
|
||||
Hello, world! This is a toast message.
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
While technically it's possible to add focusable/actionable controls (such as additional buttons or links) in your toast, you should avoid doing this for autohiding toasts. Even if you give the toast a long [`delay` timeout](#options), keyboard and assistive technology users may find it difficult to reach the toast in time to take action (since toasts don't receive focus when they are displayed). If you absolutely must have further controls, we recommend using a toast with `autohide: false`.
|
||||
|
||||
## CSS
|
||||
|
||||
### Variables
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
As part of Bootstrap's evolving CSS variables approach, toasts now use local CSS variables on `.toast` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
|
||||
|
||||
{{< scss-docs name="toast-css-vars" file="scss/_toasts.scss" >}}
|
||||
|
||||
### Sass variables
|
||||
|
||||
{{< scss-docs name="toast-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
## Usage
|
||||
|
||||
Initialize toasts via JavaScript:
|
||||
|
||||
```js
|
||||
const toastElList = document.querySelectorAll('.toast')
|
||||
const toastList = [...toastElList].map(toastEl => new bootstrap.Toast(toastEl, option))
|
||||
```
|
||||
|
||||
### Triggers
|
||||
|
||||
{{% js-dismiss "toast" %}}
|
||||
|
||||
### Options
|
||||
|
||||
{{< markdown >}}
|
||||
{{< partial "js-data-attributes.md" >}}
|
||||
{{< /markdown >}}
|
||||
|
||||
{{< bs-table "table" >}}
|
||||
| Name | Type | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `animation` | boolean | `true` | Apply a CSS fade transition to the toast. |
|
||||
| `autohide` | boolean | `true` | Automatically hide the toast after the delay. |
|
||||
| `delay` | number | `5000` | Delay in milliseconds before hiding the toast. |
|
||||
{{< /bs-table >}}
|
||||
|
||||
### Methods
|
||||
|
||||
{{< callout danger >}}
|
||||
{{< partial "callout-danger-async-methods.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
{{< bs-table "table" >}}
|
||||
| Method | Description |
|
||||
| --- | --- |
|
||||
| `dispose` | Hides an element's toast. Your toast will remain on the DOM but won't show anymore. |
|
||||
| `getInstance` | *Static* method which allows you to get the toast instance associated with a DOM element. <br> For example: `const myToastEl = document.getElementById('myToastEl')` `const myToast = bootstrap.Toast.getInstance(myToastEl)` Returns a Bootstrap toast instance. |
|
||||
| `getOrCreateInstance` | *Static* method which allows you to get the toast instance associated with a DOM element, or create a new one, in case it wasn't initialized. <br>`const myToastEl = document.getElementById('myToastEl')` `const myToast = bootstrap.Toast.getOrCreateInstance(myToastEl)` Returns a Bootstrap toast instance. |
|
||||
| `hide` | Hides an element's toast. **Returns to the caller before the toast has actually been hidden** (i.e. before the `hidden.bs.toast` event occurs). You have to manually call this method if you made `autohide` to `false`. |
|
||||
| `isShown` | Returns a boolean according to toast's visibility state. |
|
||||
| `show` | Reveals an element's toast. **Returns to the caller before the toast has actually been shown** (i.e. before the `shown.bs.toast` event occurs). You have to manually call this method, instead your toast won't show. |
|
||||
{{< /bs-table >}}
|
||||
|
||||
### Events
|
||||
|
||||
{{< bs-table "table" >}}
|
||||
| Event | Description |
|
||||
| --- | --- |
|
||||
| `hide.bs.toast` | This event is fired immediately when the `hide` instance method has been called. |
|
||||
| `hidden.bs.toast` | This event is fired when the toast has finished being hidden from the user. |
|
||||
| `show.bs.toast` | This event fires immediately when the `show` instance method is called. |
|
||||
| `shown.bs.toast` | This event is fired when the toast has been made visible to the user. |
|
||||
{{< /bs-table >}}
|
||||
|
||||
```js
|
||||
const myToastEl = document.getElementById('myToast')
|
||||
myToastEl.addEventListener('hidden.bs.toast', () => {
|
||||
// do something...
|
||||
})
|
||||
```
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Figures
|
||||
description: Documentation and examples for displaying related images and text with the figure component in Bootstrap.
|
||||
group: content
|
||||
toc: true
|
||||
---
|
||||
|
||||
Anytime you need to display a piece of content—like an image with an optional caption, consider using a `<figure>`.
|
||||
|
||||
Use the included `.figure`, `.figure-img` and `.figure-caption` classes to provide some baseline styles for the HTML5 `<figure>` and `<figcaption>` elements. Images in figures have no explicit size, so be sure to add the `.img-fluid` class to your `<img>` to make it responsive.
|
||||
|
||||
{{< example >}}
|
||||
<figure class="figure">
|
||||
{{< placeholder width="400" height="300" class="figure-img img-fluid rounded" >}}
|
||||
<figcaption class="figure-caption">A caption for the above image.</figcaption>
|
||||
</figure>
|
||||
{{< /example >}}
|
||||
|
||||
Aligning the figure's caption is easy with our [text utilities]({{< docsref "/utilities/text#text-alignment" >}}).
|
||||
|
||||
{{< example >}}
|
||||
<figure class="figure">
|
||||
{{< placeholder width="400" height="300" class="figure-img img-fluid rounded" >}}
|
||||
<figcaption class="figure-caption text-end">A caption for the above image.</figcaption>
|
||||
</figure>
|
||||
{{< /example >}}
|
||||
|
||||
## Sass
|
||||
|
||||
### Variables
|
||||
|
||||
{{< scss-docs name="figure-variables" file="scss/_variables.scss" >}}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Images
|
||||
description: Documentation and examples for opting images into responsive behavior (so they never become wider than their parent) and add lightweight styles to them—all via classes.
|
||||
group: content
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Responsive images
|
||||
|
||||
Images in Bootstrap are made responsive with `.img-fluid`. This applies `max-width: 100%;` and `height: auto;` to the image so that it scales with the parent width.
|
||||
|
||||
{{< example >}}
|
||||
{{< placeholder width="100%" height="250" class="bd-placeholder-img-lg img-fluid" text="Responsive image" >}}
|
||||
{{< /example >}}
|
||||
|
||||
## Image thumbnails
|
||||
|
||||
In addition to our [border-radius utilities]({{< docsref "/utilities/borders" >}}), you can use `.img-thumbnail` to give an image a rounded 1px border appearance.
|
||||
|
||||
{{< example >}}
|
||||
{{< placeholder width="200" height="200" class="img-thumbnail" title="A generic square placeholder image with a white border around it, making it resemble a photograph taken with an old instant camera" >}}
|
||||
{{< /example >}}
|
||||
|
||||
## Aligning images
|
||||
|
||||
Align images with the [helper float classes]({{< docsref "/utilities/float" >}}) or [text alignment classes]({{< docsref "/utilities/text#text-alignment" >}}). `block`-level images can be centered using [the `.mx-auto` margin utility class]({{< docsref "/utilities/spacing#horizontal-centering" >}}).
|
||||
|
||||
{{< example >}}
|
||||
{{< placeholder width="200" height="200" class="rounded float-start" >}}
|
||||
{{< placeholder width="200" height="200" class="rounded float-end" >}}
|
||||
{{< /example >}}
|
||||
|
||||
|
||||
{{< example >}}
|
||||
{{< placeholder width="200" height="200" class="rounded mx-auto d-block" >}}
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<div class="text-center">
|
||||
{{< placeholder width="200" height="200" class="rounded" >}}
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
|
||||
## Picture
|
||||
|
||||
If you are using the `<picture>` element to specify multiple `<source>` elements for a specific `<img>`, make sure to add the `.img-*` classes to the `<img>` and not to the `<picture>` tag.
|
||||
|
||||
```html
|
||||
<picture>
|
||||
<source srcset="..." type="image/svg+xml">
|
||||
<img src="..." class="img-fluid img-thumbnail" alt="...">
|
||||
</picture>
|
||||
```
|
||||
|
||||
## Sass
|
||||
|
||||
### Variables
|
||||
|
||||
Variables are available for image thumbnails.
|
||||
|
||||
{{< scss-docs name="thumbnail-variables" file="scss/_variables.scss" >}}
|
||||
|
|
@ -1,151 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Color
|
||||
description: Bootstrap is supported by an extensive color system that themes our styles and components. This enables more comprehensive customization and extension for any project.
|
||||
group: customize
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Theme colors
|
||||
|
||||
We use a subset of all colors to create a smaller color palette for generating color schemes, also available as Sass variables and a Sass map in Bootstrap's `scss/_variables.scss` file.
|
||||
|
||||
<div class="row">
|
||||
{{< theme-colors.inline >}}
|
||||
{{- range (index $.Site.Data "theme-colors") }}
|
||||
<div class="col-md-4">
|
||||
<div class="p-3 mb-3 bg-{{ .name }} {{ if .contrast_color }}text-{{ .contrast_color }}{{ else }}text-white{{ end }}">{{ .name | title }}</div>
|
||||
</div>
|
||||
{{ end -}}
|
||||
{{< /theme-colors.inline >}}
|
||||
</div>
|
||||
|
||||
All these colors are available as a Sass map, `$theme-colors`.
|
||||
|
||||
{{< scss-docs name="theme-colors-map" file="scss/_variables.scss" >}}
|
||||
|
||||
Check out [our Sass maps and loops docs]({{< docsref "/customize/sass#maps-and-loops" >}}) for how to modify these colors.
|
||||
|
||||
## All colors
|
||||
|
||||
All Bootstrap colors are available as Sass variables and a Sass map in `scss/_variables.scss` file. To avoid increased file sizes, we don't create text or background color classes for each of these variables. Instead, we choose a subset of these colors for a [theme palette](#theme-colors).
|
||||
|
||||
Be sure to monitor contrast ratios as you customize colors. As shown below, we've added three contrast ratios to each of the main colors—one for the swatch's current colors, one for against white, and one for against black.
|
||||
|
||||
<div class="row font-monospace">
|
||||
{{< theme-colors.inline >}}
|
||||
{{- range $color := $.Site.Data.colors }}
|
||||
{{- if (and (not (eq $color.name "white")) (not (eq $color.name "gray")) (not (eq $color.name "gray-dark"))) }}
|
||||
<div class="col-md-4 mb-3">
|
||||
<div class="p-3 mb-2 position-relative swatch-{{ $color.name }}">
|
||||
<strong class="d-block">${{ $color.name }}</strong>
|
||||
{{ $color.hex }}
|
||||
</div>
|
||||
{{ range (seq 100 100 900) }}
|
||||
<div class="p-3 bd-{{ $color.name }}-{{ . }}">${{ $color.name }}-{{ . }}</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
|
||||
<div class="col-md-4 mb-3">
|
||||
<div class="p-3 mb-2 position-relative swatch-gray-500">
|
||||
<strong class="d-block">$gray-500</strong>
|
||||
#adb5bd
|
||||
</div>
|
||||
{{- range $.Site.Data.grays }}
|
||||
<div class="p-3 bd-gray-{{ .name }}">$gray-{{ .name }}</div>
|
||||
{{ end -}}
|
||||
</div>
|
||||
{{< /theme-colors.inline >}}
|
||||
|
||||
<div class="col-md-4 mb-3">
|
||||
<div class="p-3 mb-2 bd-black text-white">
|
||||
<strong class="d-block">$black</strong>
|
||||
#000
|
||||
</div>
|
||||
<div class="p-3 mb-2 bd-white border">
|
||||
<strong class="d-block">$white</strong>
|
||||
#fff
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
### Notes on Sass
|
||||
|
||||
Sass cannot programmatically generate variables, so we manually created variables for every tint and shade ourselves. We specify the midpoint value (e.g., `$blue-500`) and use custom color functions to tint (lighten) or shade (darken) our colors via Sass's `mix()` color function.
|
||||
|
||||
Using `mix()` is not the same as `lighten()` and `darken()`—the former blends the specified color with white or black, while the latter only adjusts the lightness value of each color. The result is a much more complete suite of colors, as [shown in this CodePen demo](https://codepen.io/emdeoh/pen/zYOQOPB).
|
||||
|
||||
Our `tint-color()` and `shade-color()` functions use `mix()` alongside our `$theme-color-interval` variable, which specifies a stepped percentage value for each mixed color we produce. See the `scss/_functions.scss` and `scss/_variables.scss` files for the full source code.
|
||||
|
||||
## Color Sass maps
|
||||
|
||||
Bootstrap's source Sass files include three maps to help you quickly and easily loop over a list of colors and their hex values.
|
||||
|
||||
- `$colors` lists all our available base (`500`) colors
|
||||
- `$theme-colors` lists all semantically named theme colors (shown below)
|
||||
- `$grays` lists all tints and shades of gray
|
||||
|
||||
Within `scss/_variables.scss`, you'll find Bootstrap's color variables and Sass map. Here's an example of the `$colors` Sass map:
|
||||
|
||||
{{< scss-docs name="colors-map" file="scss/_variables.scss" >}}
|
||||
|
||||
Add, remove, or modify values within the map to update how they're used in many other components. Unfortunately at this time, not _every_ component utilizes this Sass map. Future updates will strive to improve upon this. Until then, plan on making use of the `${color}` variables and this Sass map.
|
||||
|
||||
### Example
|
||||
|
||||
Here's how you can use these in your Sass:
|
||||
|
||||
```scss
|
||||
.alpha { color: $purple; }
|
||||
.beta {
|
||||
color: $yellow-300;
|
||||
background-color: $indigo-900;
|
||||
}
|
||||
```
|
||||
|
||||
[Color]({{< docsref "/utilities/colors" >}}) and [background]({{< docsref "/utilities/background" >}}) utility classes are also available for setting `color` and `background-color` using the `500` color values.
|
||||
|
||||
## Generating utilities
|
||||
|
||||
{{< added-in "5.1.0" >}}
|
||||
|
||||
Bootstrap doesn't include `color` and `background-color` utilities for every color variable, but you can generate these yourself with our [utility API]({{< docsref "/utilities/api" >}}) and our extended Sass maps added in v5.1.0.
|
||||
|
||||
1. To start, make sure you've imported our functions, variables, mixins, and utilities.
|
||||
2. Use our `map-merge-multiple()` function to quickly merge multiple Sass maps together in a new map.
|
||||
3. Merge this new combined map to extend any utility with a `{color}-{level}` class name.
|
||||
|
||||
Here's an example that generates text color utilities (e.g., `.text-purple-500`) using the above steps.
|
||||
|
||||
```scss
|
||||
@import "bootstrap/scss/functions";
|
||||
@import "bootstrap/scss/variables";
|
||||
@import "bootstrap/scss/maps";
|
||||
@import "bootstrap/scss/mixins";
|
||||
@import "bootstrap/scss/utilities";
|
||||
|
||||
$all-colors: map-merge-multiple($blues, $indigos, $purples, $pinks, $reds, $oranges, $yellows, $greens, $teals, $cyans);
|
||||
|
||||
$utilities: map-merge(
|
||||
$utilities,
|
||||
(
|
||||
"color": map-merge(
|
||||
map-get($utilities, "color"),
|
||||
(
|
||||
values: map-merge(
|
||||
map-get(map-get($utilities, "color"), "values"),
|
||||
(
|
||||
$all-colors
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
@import "bootstrap/scss/utilities/api";
|
||||
```
|
||||
|
||||
This will generate new `.text-{color}-{level}` utilities for every color and level. You can do the same for any other utility and property as well.
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Components
|
||||
description: Learn how and why we build nearly all our components responsively and with base and modifier classes.
|
||||
group: customize
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Base classes
|
||||
|
||||
Bootstrap's components are largely built with a base-modifier nomenclature. We group as many shared properties as possible into a base class, like `.btn`, and then group individual styles for each variant into modifier classes, like `.btn-primary` or `.btn-success`.
|
||||
|
||||
To build our modifier classes, we use Sass's `@each` loops to iterate over a Sass map. This is especially helpful for generating variants of a component by our `$theme-colors` and creating responsive variants for each breakpoint. As you customize these Sass maps and recompile, you'll automatically see your changes reflected in these loops.
|
||||
|
||||
Check out [our Sass maps and loops docs]({{< docsref "/customize/sass#maps-and-loops" >}}) for how to customize these loops and extend Bootstrap's base-modifier approach to your own code.
|
||||
|
||||
## Modifiers
|
||||
|
||||
Many of Bootstrap's components are built with a base-modifier class approach. This means the bulk of the styling is contained to a base class (e.g., `.btn`) while style variations are confined to modifier classes (e.g., `.btn-danger`). These modifier classes are built from the `$theme-colors` map to make customizing the number and name of our modifier classes.
|
||||
|
||||
Here are two examples of how we loop over the `$theme-colors` map to generate modifiers to the `.alert` and `.list-group` components.
|
||||
|
||||
{{< scss-docs name="alert-modifiers" file="scss/_alert.scss" >}}
|
||||
|
||||
{{< scss-docs name="list-group-modifiers" file="scss/_list-group.scss" >}}
|
||||
|
||||
## Responsive
|
||||
|
||||
These Sass loops aren't limited to color maps, either. You can also generate responsive variations of your components. Take for example our responsive alignment of the dropdowns where we mix an `@each` loop for the `$grid-breakpoints` Sass map with a media query include.
|
||||
|
||||
{{< scss-docs name="responsive-breakpoints" file="scss/_dropdown.scss" >}}
|
||||
|
||||
Should you modify your `$grid-breakpoints`, your changes will apply to all the loops iterating over that map.
|
||||
|
||||
{{< scss-docs name="grid-breakpoints" file="scss/_variables.scss" >}}
|
||||
|
||||
For more information and examples on how to modify our Sass maps and variables, please refer to [the Sass section of the Grid documentation]({{< docsref "/layout/grid#sass" >}}).
|
||||
|
||||
## Creating your own
|
||||
|
||||
We encourage you to adopt these guidelines when building with Bootstrap to create your own components. We've extended this approach ourselves to the custom components in our documentation and examples. Components like our callouts are built just like our provided components with base and modifier classes.
|
||||
|
||||
<div class="bd-example">
|
||||
<div class="bd-callout my-0">
|
||||
<strong>This is a callout.</strong> We built it custom for our docs so our messages to you stand out. It has three variants via modifier classes.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
```html
|
||||
<div class="callout">...</div>
|
||||
```
|
||||
|
||||
In your CSS, you'd have something like the following where the bulk of the styling is done via `.callout`. Then, the unique styles between each variant is controlled via modifier class.
|
||||
|
||||
```scss
|
||||
// Base class
|
||||
.callout {}
|
||||
|
||||
// Modifier classes
|
||||
.callout-info {}
|
||||
.callout-warning {}
|
||||
.callout-danger {}
|
||||
```
|
||||
|
||||
For the callouts, that unique styling is just a `border-left-color`. When you combine that base class with one of those modifier classes, you get your complete component family:
|
||||
|
||||
{{< callout info >}}
|
||||
**This is an info callout.** Example text to show it in action.
|
||||
{{< /callout >}}
|
||||
|
||||
{{< callout warning >}}
|
||||
**This is a warning callout.** Example text to show it in action.
|
||||
{{< /callout >}}
|
||||
|
||||
{{< callout danger >}}
|
||||
**This is a danger callout.** Example text to show it in action.
|
||||
{{< /callout >}}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: CSS variables
|
||||
description: Use Bootstrap's CSS custom properties for fast and forward-looking design and development.
|
||||
group: customize
|
||||
toc: true
|
||||
---
|
||||
|
||||
Bootstrap includes many [CSS custom properties (variables)](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) in its compiled CSS for real-time customization without the need to recompile Sass. These provide easy access to commonly used values like our theme colors, breakpoints, and primary font stacks when working in your browser's inspector, a code sandbox, or general prototyping.
|
||||
|
||||
**All our custom properties are prefixed with `bs-`** to avoid conflicts with third party CSS.
|
||||
|
||||
## Root variables
|
||||
|
||||
Here are the variables we include (note that the `:root` is required) that can be accessed anywhere Bootstrap's CSS is loaded. They're located in our `_root.scss` file and included in our compiled dist files.
|
||||
|
||||
```css
|
||||
{{< root.inline >}}
|
||||
{{- $css := readFile "dist/css/bootstrap.css" -}}
|
||||
{{- $match := findRE ":root {([^}]*)}" $css 1 -}}
|
||||
|
||||
{{- if (eq (len $match) 0) -}}
|
||||
{{- errorf "Got no matches for :root in %q!" $.Page.Path -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- index $match 0 -}}
|
||||
|
||||
{{< /root.inline >}}
|
||||
```
|
||||
|
||||
## Component variables
|
||||
|
||||
Bootstrap 5 is increasingly making use of custom properties as local variables for various components. This way we reduce our compiled CSS, ensure styles aren't inherited in places like nested tables, and allow some basic restyling and extending of Bootstrap components after Sass compilation.
|
||||
|
||||
Have a look at our table documentation for some [insight into how we're using CSS variables]({{< docsref "/content/tables#how-do-the-variants-and-accented-tables-work" >}}). Our [navbars also use CSS variables]({{< docsref "/components/navbar#css" >}}) as of v5.2.0. We're also using CSS variables across our grids—primarily for gutters the [new opt-in CSS grid]({{< docsref "/layout/css-grid" >}})—with more component usage coming in the future.
|
||||
|
||||
Whenever possible, we'll assign CSS variables at the base component level (e.g., `.navbar` for navbar and its sub-components). This reduces guessing on where and how to customize, and allows for easy modifications by our team in future updates.
|
||||
|
||||
## Prefix
|
||||
|
||||
Most CSS variables use a prefix to avoid collisions with your own codebase. This prefix is in addition to the `--` that's required on every CSS variable.
|
||||
|
||||
Customize the prefix via the `$prefix` Sass variable. By default, it's set to `bs-` (note the trailing dash).
|
||||
|
||||
## Examples
|
||||
|
||||
CSS variables offer similar flexibility to Sass's variables, but without the need for compilation before being served to the browser. For example, here we're resetting our page's font and link styles with CSS variables.
|
||||
|
||||
```css
|
||||
body {
|
||||
font: 1rem/1.5 var(--bs-font-sans-serif);
|
||||
}
|
||||
a {
|
||||
color: var(--bs-blue);
|
||||
}
|
||||
```
|
||||
|
||||
## Grid breakpoints
|
||||
|
||||
While we include our grid breakpoints as CSS variables (except for `xs`), be aware that **CSS variables do not work in media queries**. This is by design in the CSS spec for variables, but may change in coming years with support for `env()` variables. Check out [this Stack Overflow answer](https://stackoverflow.com/a/47212942) for some helpful links. In the meantime, you can use these variables in other CSS situations, as well as in your JavaScript.
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Customize
|
||||
description: Learn how to theme, customize, and extend Bootstrap with Sass, a boatload of global options, an expansive color system, and more.
|
||||
group: customize
|
||||
toc: false
|
||||
aliases: "/docs/5.2/customize/"
|
||||
sections:
|
||||
- title: Sass
|
||||
description: Utilize our source Sass files to take advantage of variables, maps, mixins, and functions.
|
||||
- title: Options
|
||||
description: Customize Bootstrap with built-in variables to easily toggle global CSS preferences.
|
||||
- title: Color
|
||||
description: Learn about and customize the color systems that support the entire toolkit.
|
||||
- title: Components
|
||||
description: Learn how we build nearly all our components responsively and with base and modifier classes.
|
||||
- title: CSS variables
|
||||
description: Use Bootstrap's CSS custom properties for fast and forward-looking design and development.
|
||||
- title: Optimize
|
||||
description: Keep your projects lean, responsive, and maintainable so you can deliver the best experience.
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
There are multiple ways to customize Bootstrap. Your best path can depend on your project, the complexity of your build tools, the version of Bootstrap you're using, browser support, and more.
|
||||
|
||||
Our two preferred methods are:
|
||||
|
||||
1. Using Bootstrap [via package manager]({{< docsref "/getting-started/download#package-managers" >}}) so you can use and extend our source files.
|
||||
2. Using Bootstrap's compiled distribution files or [jsDelivr]({{< docsref "/getting-started/download#cdn-via-jsdelivr" >}}) so you can add onto or override Bootstrap's styles.
|
||||
|
||||
While we cannot go into details here on how to use every package manager, we can give some guidance on [using Bootstrap with your own Sass compiler]({{< docsref "/customize/sass" >}}).
|
||||
|
||||
For those who want to use the distribution files, review the [getting started page]({{< docsref "/getting-started/introduction" >}}) for how to include those files and an example HTML page. From there, consult the docs for the layout, components, and behaviors you'd like to use.
|
||||
|
||||
As you familiarize yourself with Bootstrap, continue exploring this section for more details on how to utilize our global options, making use of and changing our color system, how we build our components, how to use our growing list of CSS custom properties, and how to optimize your code when building with Bootstrap.
|
||||
|
||||
## CSPs and embedded SVGs
|
||||
|
||||
Several Bootstrap components include embedded SVGs in our CSS to style components consistently and easily across browsers and devices. **For organizations with more strict <abbr title="Content Security Policy">CSP</abbr> configurations**, we've documented all instances of our embedded SVGs (all of which are applied via `background-image`) so you can more thoroughly review your options.
|
||||
|
||||
- [Accordion]({{< docsref "/components/accordion" >}})
|
||||
- [Carousel controls]({{< docsref "/components/carousel#with-controls" >}})
|
||||
- [Close button]({{< docsref "/components/close-button" >}}) (used in alerts and modals)
|
||||
- [Form checkboxes and radio buttons]({{< docsref "/forms/checks-radios" >}})
|
||||
- [Form switches]({{< docsref "/forms/checks-radios#switches" >}})
|
||||
- [Form validation icons]({{< docsref "/forms/validation#server-side" >}})
|
||||
- [Navbar toggle buttons]({{< docsref "/components/navbar#responsive-behaviors" >}})
|
||||
- [Select menus]({{< docsref "/forms/select" >}})
|
||||
|
||||
Based on [community conversation](https://github.com/twbs/bootstrap/issues/25394), some options for addressing this in your own codebase include [replacing the URLs with locally hosted assets]({{< docsref "/getting-started/webpack#extracting-svg-files" >}}), removing the images and using inline images (not possible in all components), and modifying your CSP. Our recommendation is to carefully review your own security policies and decide on the best path forward, if necessary.
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
"extends": [
|
||||
"stylelint-config-twbs-bootstrap"
|
||||
],
|
||||
"rules": {
|
||||
"at-rule-no-vendor-prefix": null,
|
||||
"comment-empty-line-before": null,
|
||||
"media-feature-name-no-vendor-prefix": null,
|
||||
"property-disallowed-list": null,
|
||||
"property-no-vendor-prefix": null,
|
||||
"selector-no-qualifying-type": null,
|
||||
"selector-no-vendor-prefix": null,
|
||||
"value-no-vendor-prefix": null
|
||||
}
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
---
|
||||
layout: single
|
||||
title: Examples
|
||||
description: Quickly get a project started with any of our examples ranging from using parts of the framework to custom components and layouts.
|
||||
aliases: "/examples/"
|
||||
---
|
||||
|
||||
{{< list-examples.inline >}}
|
||||
{{ range $entry := $.Site.Data.examples -}}
|
||||
<div class="row g-lg-5 mb-5">
|
||||
<div class="bd-content col-lg-3">
|
||||
<h2 id="{{ $entry.category | urlize }}">{{ $entry.category }}</h2>
|
||||
<p>{{ $entry.description }}</p>
|
||||
{{ if eq $entry.category "RTL" -}}
|
||||
<div class="bd-callout bd-callout-warning small">
|
||||
<p>
|
||||
<strong>RTL is still experimental</strong> and will evolve with feedback. Spotted something or have an improvement to suggest?
|
||||
</p>
|
||||
<p><a href="{{ $.Site.Params.repo }}/issues/new/choose">Please open an issue.</a></p>
|
||||
</div>
|
||||
{{ end -}}
|
||||
</div>
|
||||
|
||||
<div class="col-lg-9">
|
||||
{{ range $i, $example := $entry.examples -}}
|
||||
{{- $len := len $entry.examples -}}
|
||||
{{ if (eq $i 0) }}<div class="row">{{ end }}
|
||||
<div class="col-sm-6 col-md-4 mb-3">
|
||||
<a class="d-block" href="/docs/{{ $.Site.Params.docs_version }}/examples/{{ $example.name | urlize }}/"{{ if in $example.name "RTL" }} hreflang="ar"{{ end }}>
|
||||
<img class="img-thumbnail mb-3" srcset="/docs/{{ $.Site.Params.docs_version }}/assets/img/examples/{{ $example.name | urlize }}.png,
|
||||
/docs/{{ $.Site.Params.docs_version }}/assets/img/examples/{{ $example.name | urlize }}@2x.png 2x"
|
||||
src="/docs/{{ $.Site.Params.docs_version }}/assets/img/examples/{{ $example.name | urlize }}.png"
|
||||
alt=""
|
||||
width="480" height="300"
|
||||
loading="lazy">
|
||||
<h3 class="h5 mb-1">{{ $example.name }}</h3>
|
||||
</a>
|
||||
<p class="text-muted">{{ $example.description }}</p>
|
||||
</div>
|
||||
{{ if (eq (add $i 1) $len) }}</div>{{ end }}
|
||||
{{ end -}}
|
||||
</div>
|
||||
</div>
|
||||
{{ end -}}
|
||||
{{< /list-examples.inline >}}
|
||||
|
|
@ -1,253 +0,0 @@
|
|||
---
|
||||
layout: examples
|
||||
title: قالب لوحة القيادة
|
||||
direction: rtl
|
||||
extra_css:
|
||||
- "../dashboard/dashboard.rtl.css"
|
||||
extra_js:
|
||||
- src: "https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/feather.min.js"
|
||||
integrity: "sha384-uO3SXW5IuS1ZpFPKugNNWqTZRRglnUJK6UAZ/gxOX80nxEkN9NcGZTftn6RzhGWE"
|
||||
- src: "https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js"
|
||||
integrity: "sha384-zNy6FEbO50N+Cg5wap8IKA4M/ZnLJgzc6w2NqACZaK0u0FXfOWRRJOnQtpZun8ha"
|
||||
- src: "dashboard.js"
|
||||
---
|
||||
|
||||
<header class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
|
||||
<a class="navbar-brand col-md-3 col-lg-2 me-0 px-3 fs-6" href="#">اسم الشركة</a>
|
||||
<button class="navbar-toggler position-absolute d-md-none collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#sidebarMenu" aria-controls="sidebarMenu" aria-expanded="false" aria-label="عرض/إخفاء لوحة التنقل">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<input class="form-control form-control-dark w-100 rounded-0 border-0" type="text" placeholder="بحث" aria-label="بحث">
|
||||
<div class="navbar-nav">
|
||||
<div class="nav-item text-nowrap">
|
||||
<a class="nav-link px-3" href="#">تسجيل الخروج</a>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
|
||||
<div class="position-sticky pt-3 sidebar-sticky">
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">
|
||||
<span data-feather="home" class="align-text-bottom"></span>
|
||||
لوحة القيادة
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<span data-feather="file" class="align-text-bottom"></span>
|
||||
الطلبات
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<span data-feather="shopping-cart" class="align-text-bottom"></span>
|
||||
المنتجات
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<span data-feather="users" class="align-text-bottom"></span>
|
||||
الزبائن
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<span data-feather="bar-chart-2" class="align-text-bottom"></span>
|
||||
التقارير
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<span data-feather="layers" class="align-text-bottom"></span>
|
||||
التكاملات
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted text-uppercase">
|
||||
<span>التقارير المحفوظة</span>
|
||||
<a class="link-secondary" href="#" aria-label="إضافة تقرير جديد">
|
||||
<span data-feather="plus-circle" class="align-text-bottom"></span>
|
||||
</a>
|
||||
</h6>
|
||||
<ul class="nav flex-column mb-2">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<span data-feather="file-text" class="align-text-bottom"></span>
|
||||
الشهر الحالي
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<span data-feather="file-text" class="align-text-bottom"></span>
|
||||
الربع الأخير
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<span data-feather="file-text" class="align-text-bottom"></span>
|
||||
التفاعل الإجتماعي
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<span data-feather="file-text" class="align-text-bottom"></span>
|
||||
مبيعات نهاية العام
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h1 class="h2">لوحة القيادة</h1>
|
||||
<div class="btn-toolbar mb-2 mb-md-0">
|
||||
<div class="btn-group me-2">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary">مشاركة</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary">تصدير</button>
|
||||
</div>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary dropdown-toggle">
|
||||
<span data-feather="calendar" class="align-text-bottom"></span>
|
||||
هذا الأسبوع
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<canvas class="my-4 w-100" id="myChart" width="900" height="380"></canvas>
|
||||
|
||||
<h2>عنوان القسم</h2>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">عنوان</th>
|
||||
<th scope="col">عنوان</th>
|
||||
<th scope="col">عنوان</th>
|
||||
<th scope="col">عنوان</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1,001</td>
|
||||
<td>بيانات</td>
|
||||
<td>عشوائية</td>
|
||||
<td>تثري</td>
|
||||
<td>الجدول</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,002</td>
|
||||
<td>تثري</td>
|
||||
<td>مبهة</td>
|
||||
<td>تصميم</td>
|
||||
<td>تنسيق</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,003</td>
|
||||
<td>عشوائية</td>
|
||||
<td>غنية</td>
|
||||
<td>قيمة</td>
|
||||
<td>مفيدة</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,003</td>
|
||||
<td>معلومات</td>
|
||||
<td>تثري</td>
|
||||
<td>توضيحية</td>
|
||||
<td>عشوائية</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,004</td>
|
||||
<td>الجدول</td>
|
||||
<td>بيانات</td>
|
||||
<td>تنسيق</td>
|
||||
<td>قيمة</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,005</td>
|
||||
<td>قيمة</td>
|
||||
<td>مبهة</td>
|
||||
<td>الجدول</td>
|
||||
<td>تثري</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,006</td>
|
||||
<td>قيمة</td>
|
||||
<td>توضيحية</td>
|
||||
<td>غنية</td>
|
||||
<td>عشوائية</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,007</td>
|
||||
<td>تثري</td>
|
||||
<td>مفيدة</td>
|
||||
<td>معلومات</td>
|
||||
<td>مبهة</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,008</td>
|
||||
<td>بيانات</td>
|
||||
<td>عشوائية</td>
|
||||
<td>تثري</td>
|
||||
<td>الجدول</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,009</td>
|
||||
<td>تثري</td>
|
||||
<td>مبهة</td>
|
||||
<td>تصميم</td>
|
||||
<td>تنسيق</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,010</td>
|
||||
<td>عشوائية</td>
|
||||
<td>غنية</td>
|
||||
<td>قيمة</td>
|
||||
<td>مفيدة</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,011</td>
|
||||
<td>معلومات</td>
|
||||
<td>تثري</td>
|
||||
<td>توضيحية</td>
|
||||
<td>عشوائية</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,012</td>
|
||||
<td>الجدول</td>
|
||||
<td>تثري</td>
|
||||
<td>تنسيق</td>
|
||||
<td>قيمة</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,013</td>
|
||||
<td>قيمة</td>
|
||||
<td>مبهة</td>
|
||||
<td>الجدول</td>
|
||||
<td>تصميم</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,014</td>
|
||||
<td>قيمة</td>
|
||||
<td>توضيحية</td>
|
||||
<td>غنية</td>
|
||||
<td>عشوائية</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,015</td>
|
||||
<td>بيانات</td>
|
||||
<td>مفيدة</td>
|
||||
<td>معلومات</td>
|
||||
<td>الجدول</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
body {
|
||||
font-size: .875rem;
|
||||
}
|
||||
|
||||
.feather {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sidebar
|
||||
*/
|
||||
|
||||
.sidebar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
/* rtl:raw:
|
||||
right: 0;
|
||||
*/
|
||||
bottom: 0;
|
||||
/* rtl:remove */
|
||||
left: 0;
|
||||
z-index: 100; /* Behind the navbar */
|
||||
padding: 48px 0 0; /* Height of navbar */
|
||||
box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
|
||||
}
|
||||
|
||||
@media (max-width: 767.98px) {
|
||||
.sidebar {
|
||||
top: 5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-sticky {
|
||||
height: calc(100vh - 48px);
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
|
||||
}
|
||||
|
||||
.sidebar .nav-link {
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.sidebar .nav-link .feather {
|
||||
margin-right: 4px;
|
||||
color: #727272;
|
||||
}
|
||||
|
||||
.sidebar .nav-link.active {
|
||||
color: #2470dc;
|
||||
}
|
||||
|
||||
.sidebar .nav-link:hover .feather,
|
||||
.sidebar .nav-link.active .feather {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.sidebar-heading {
|
||||
font-size: .75rem;
|
||||
}
|
||||
|
||||
/*
|
||||
* Navbar
|
||||
*/
|
||||
|
||||
.navbar-brand {
|
||||
padding-top: .75rem;
|
||||
padding-bottom: .75rem;
|
||||
background-color: rgba(0, 0, 0, .25);
|
||||
box-shadow: inset -1px 0 0 rgba(0, 0, 0, .25);
|
||||
}
|
||||
|
||||
.navbar .navbar-toggler {
|
||||
top: .25rem;
|
||||
right: 1rem;
|
||||
}
|
||||
|
||||
.navbar .form-control {
|
||||
padding: .75rem 1rem;
|
||||
}
|
||||
|
||||
.form-control-dark {
|
||||
color: #fff;
|
||||
background-color: rgba(255, 255, 255, .1);
|
||||
border-color: rgba(255, 255, 255, .1);
|
||||
}
|
||||
|
||||
.form-control-dark:focus {
|
||||
border-color: transparent;
|
||||
box-shadow: 0 0 0 3px rgba(255, 255, 255, .25);
|
||||
}
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
body {
|
||||
font-size: .875rem;
|
||||
}
|
||||
|
||||
.feather {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sidebar
|
||||
*/
|
||||
|
||||
.sidebar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 100; /* Behind the navbar */
|
||||
padding: 48px 0 0; /* Height of navbar */
|
||||
box-shadow: inset 1px 0 0 rgba(0, 0, 0, .1);
|
||||
}
|
||||
|
||||
@media (max-width: 767.98px) {
|
||||
.sidebar {
|
||||
top: 5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-sticky {
|
||||
height: calc(100vh - 48px);
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
|
||||
}
|
||||
|
||||
.sidebar .nav-link {
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.sidebar .nav-link .feather {
|
||||
margin-left: 4px;
|
||||
color: #727272;
|
||||
}
|
||||
|
||||
.sidebar .nav-link.active {
|
||||
color: #2470dc;
|
||||
}
|
||||
|
||||
.sidebar .nav-link:hover .feather,
|
||||
.sidebar .nav-link.active .feather {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.sidebar-heading {
|
||||
font-size: .75rem;
|
||||
}
|
||||
|
||||
/*
|
||||
* Navbar
|
||||
*/
|
||||
|
||||
.navbar-brand {
|
||||
padding-top: .75rem;
|
||||
padding-bottom: .75rem;
|
||||
background-color: rgba(0, 0, 0, .25);
|
||||
box-shadow: inset 1px 0 0 rgba(0, 0, 0, .25);
|
||||
}
|
||||
|
||||
.navbar .navbar-toggler {
|
||||
top: .25rem;
|
||||
left: 1rem;
|
||||
}
|
||||
|
||||
.navbar .form-control {
|
||||
padding: .75rem 1rem;
|
||||
}
|
||||
|
||||
.form-control-dark {
|
||||
color: #fff;
|
||||
background-color: rgba(255, 255, 255, .1);
|
||||
border-color: rgba(255, 255, 255, .1);
|
||||
}
|
||||
|
||||
.form-control-dark:focus {
|
||||
border-color: transparent;
|
||||
box-shadow: 0 0 0 3px rgba(255, 255, 255, .25);
|
||||
}
|
||||
|
|
@ -1,252 +0,0 @@
|
|||
---
|
||||
layout: examples
|
||||
title: Dashboard Template
|
||||
extra_css:
|
||||
- "dashboard.css"
|
||||
extra_js:
|
||||
- src: "https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/feather.min.js"
|
||||
integrity: "sha384-uO3SXW5IuS1ZpFPKugNNWqTZRRglnUJK6UAZ/gxOX80nxEkN9NcGZTftn6RzhGWE"
|
||||
- src: "https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js"
|
||||
integrity: "sha384-zNy6FEbO50N+Cg5wap8IKA4M/ZnLJgzc6w2NqACZaK0u0FXfOWRRJOnQtpZun8ha"
|
||||
- src: "dashboard.js"
|
||||
---
|
||||
|
||||
<header class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
|
||||
<a class="navbar-brand col-md-3 col-lg-2 me-0 px-3 fs-6" href="#">Company name</a>
|
||||
<button class="navbar-toggler position-absolute d-md-none collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#sidebarMenu" aria-controls="sidebarMenu" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<input class="form-control form-control-dark w-100 rounded-0 border-0" type="text" placeholder="Search" aria-label="Search">
|
||||
<div class="navbar-nav">
|
||||
<div class="nav-item text-nowrap">
|
||||
<a class="nav-link px-3" href="#">Sign out</a>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
|
||||
<div class="position-sticky pt-3 sidebar-sticky">
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">
|
||||
<span data-feather="home" class="align-text-bottom"></span>
|
||||
Dashboard
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<span data-feather="file" class="align-text-bottom"></span>
|
||||
Orders
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<span data-feather="shopping-cart" class="align-text-bottom"></span>
|
||||
Products
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<span data-feather="users" class="align-text-bottom"></span>
|
||||
Customers
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<span data-feather="bar-chart-2" class="align-text-bottom"></span>
|
||||
Reports
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<span data-feather="layers" class="align-text-bottom"></span>
|
||||
Integrations
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted text-uppercase">
|
||||
<span>Saved reports</span>
|
||||
<a class="link-secondary" href="#" aria-label="Add a new report">
|
||||
<span data-feather="plus-circle" class="align-text-bottom"></span>
|
||||
</a>
|
||||
</h6>
|
||||
<ul class="nav flex-column mb-2">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<span data-feather="file-text" class="align-text-bottom"></span>
|
||||
Current month
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<span data-feather="file-text" class="align-text-bottom"></span>
|
||||
Last quarter
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<span data-feather="file-text" class="align-text-bottom"></span>
|
||||
Social engagement
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">
|
||||
<span data-feather="file-text" class="align-text-bottom"></span>
|
||||
Year-end sale
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h1 class="h2">Dashboard</h1>
|
||||
<div class="btn-toolbar mb-2 mb-md-0">
|
||||
<div class="btn-group me-2">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary">Share</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary">Export</button>
|
||||
</div>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary dropdown-toggle">
|
||||
<span data-feather="calendar" class="align-text-bottom"></span>
|
||||
This week
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<canvas class="my-4 w-100" id="myChart" width="900" height="380"></canvas>
|
||||
|
||||
<h2>Section title</h2>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">Header</th>
|
||||
<th scope="col">Header</th>
|
||||
<th scope="col">Header</th>
|
||||
<th scope="col">Header</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1,001</td>
|
||||
<td>random</td>
|
||||
<td>data</td>
|
||||
<td>placeholder</td>
|
||||
<td>text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,002</td>
|
||||
<td>placeholder</td>
|
||||
<td>irrelevant</td>
|
||||
<td>visual</td>
|
||||
<td>layout</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,003</td>
|
||||
<td>data</td>
|
||||
<td>rich</td>
|
||||
<td>dashboard</td>
|
||||
<td>tabular</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,003</td>
|
||||
<td>information</td>
|
||||
<td>placeholder</td>
|
||||
<td>illustrative</td>
|
||||
<td>data</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,004</td>
|
||||
<td>text</td>
|
||||
<td>random</td>
|
||||
<td>layout</td>
|
||||
<td>dashboard</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,005</td>
|
||||
<td>dashboard</td>
|
||||
<td>irrelevant</td>
|
||||
<td>text</td>
|
||||
<td>placeholder</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,006</td>
|
||||
<td>dashboard</td>
|
||||
<td>illustrative</td>
|
||||
<td>rich</td>
|
||||
<td>data</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,007</td>
|
||||
<td>placeholder</td>
|
||||
<td>tabular</td>
|
||||
<td>information</td>
|
||||
<td>irrelevant</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,008</td>
|
||||
<td>random</td>
|
||||
<td>data</td>
|
||||
<td>placeholder</td>
|
||||
<td>text</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,009</td>
|
||||
<td>placeholder</td>
|
||||
<td>irrelevant</td>
|
||||
<td>visual</td>
|
||||
<td>layout</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,010</td>
|
||||
<td>data</td>
|
||||
<td>rich</td>
|
||||
<td>dashboard</td>
|
||||
<td>tabular</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,011</td>
|
||||
<td>information</td>
|
||||
<td>placeholder</td>
|
||||
<td>illustrative</td>
|
||||
<td>data</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,012</td>
|
||||
<td>text</td>
|
||||
<td>placeholder</td>
|
||||
<td>layout</td>
|
||||
<td>dashboard</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,013</td>
|
||||
<td>dashboard</td>
|
||||
<td>irrelevant</td>
|
||||
<td>text</td>
|
||||
<td>visual</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,014</td>
|
||||
<td>dashboard</td>
|
||||
<td>illustrative</td>
|
||||
<td>rich</td>
|
||||
<td>data</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1,015</td>
|
||||
<td>random</td>
|
||||
<td>tabular</td>
|
||||
<td>information</td>
|
||||
<td>text</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,338 +0,0 @@
|
|||
---
|
||||
layout: examples
|
||||
title: Dropdowns
|
||||
extra_css:
|
||||
- "dropdowns.css"
|
||||
body_class: ""
|
||||
---
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
|
||||
<symbol id="bootstrap" viewBox="0 0 118 94">
|
||||
<title>Bootstrap</title>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.509 0c-6.733 0-11.715 5.893-11.492 12.284.214 6.14-.064 14.092-2.066 20.577C8.943 39.365 5.547 43.485 0 44.014v5.972c5.547.529 8.943 4.649 10.951 11.153 2.002 6.485 2.28 14.437 2.066 20.577C12.794 88.106 17.776 94 24.51 94H93.5c6.733 0 11.714-5.893 11.491-12.284-.214-6.14.064-14.092 2.066-20.577 2.009-6.504 5.396-10.624 10.943-11.153v-5.972c-5.547-.529-8.934-4.649-10.943-11.153-2.002-6.484-2.28-14.437-2.066-20.577C105.214 5.894 100.233 0 93.5 0H24.508zM80 57.863C80 66.663 73.436 72 62.543 72H44a2 2 0 01-2-2V24a2 2 0 012-2h18.437c9.083 0 15.044 4.92 15.044 12.474 0 5.302-4.01 10.049-9.119 10.88v.277C75.317 46.394 80 51.21 80 57.863zM60.521 28.34H49.948v14.934h8.905c6.884 0 10.68-2.772 10.68-7.727 0-4.643-3.264-7.207-9.012-7.207zM49.948 49.2v16.458H60.91c7.167 0 10.964-2.876 10.964-8.281 0-5.406-3.903-8.178-11.425-8.178H49.948z"></path>
|
||||
</symbol>
|
||||
|
||||
<symbol id="exclamation-triangle-fill" viewBox="0 0 16 16">
|
||||
<path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="check2" viewBox="0 0 16 16">
|
||||
<path d="M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="check2-circle" viewBox="0 0 16 16">
|
||||
<path d="M2.5 8a5.5 5.5 0 0 1 8.25-4.764.5.5 0 0 0 .5-.866A6.5 6.5 0 1 0 14.5 8a.5.5 0 0 0-1 0 5.5 5.5 0 1 1-11 0z"/>
|
||||
<path d="M15.354 3.354a.5.5 0 0 0-.708-.708L8 9.293 5.354 6.646a.5.5 0 1 0-.708.708l3 3a.5.5 0 0 0 .708 0l7-7z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="bookmark-star" viewBox="0 0 16 16">
|
||||
<path d="M7.84 4.1a.178.178 0 0 1 .32 0l.634 1.285a.178.178 0 0 0 .134.098l1.42.206c.145.021.204.2.098.303L9.42 6.993a.178.178 0 0 0-.051.158l.242 1.414a.178.178 0 0 1-.258.187l-1.27-.668a.178.178 0 0 0-.165 0l-1.27.668a.178.178 0 0 1-.257-.187l.242-1.414a.178.178 0 0 0-.05-.158l-1.03-1.001a.178.178 0 0 1 .098-.303l1.42-.206a.178.178 0 0 0 .134-.098L7.84 4.1z"/>
|
||||
<path d="M2 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v13.5a.5.5 0 0 1-.777.416L8 13.101l-5.223 2.815A.5.5 0 0 1 2 15.5V2zm2-1a1 1 0 0 0-1 1v12.566l4.723-2.482a.5.5 0 0 1 .554 0L13 14.566V2a1 1 0 0 0-1-1H4z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="grid-fill" viewBox="0 0 16 16">
|
||||
<path d="M1 2.5A1.5 1.5 0 0 1 2.5 1h3A1.5 1.5 0 0 1 7 2.5v3A1.5 1.5 0 0 1 5.5 7h-3A1.5 1.5 0 0 1 1 5.5v-3zm8 0A1.5 1.5 0 0 1 10.5 1h3A1.5 1.5 0 0 1 15 2.5v3A1.5 1.5 0 0 1 13.5 7h-3A1.5 1.5 0 0 1 9 5.5v-3zm-8 8A1.5 1.5 0 0 1 2.5 9h3A1.5 1.5 0 0 1 7 10.5v3A1.5 1.5 0 0 1 5.5 15h-3A1.5 1.5 0 0 1 1 13.5v-3zm8 0A1.5 1.5 0 0 1 10.5 9h3a1.5 1.5 0 0 1 1.5 1.5v3a1.5 1.5 0 0 1-1.5 1.5h-3A1.5 1.5 0 0 1 9 13.5v-3z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="stars" viewBox="0 0 16 16">
|
||||
<path d="M7.657 6.247c.11-.33.576-.33.686 0l.645 1.937a2.89 2.89 0 0 0 1.829 1.828l1.936.645c.33.11.33.576 0 .686l-1.937.645a2.89 2.89 0 0 0-1.828 1.829l-.645 1.936a.361.361 0 0 1-.686 0l-.645-1.937a2.89 2.89 0 0 0-1.828-1.828l-1.937-.645a.361.361 0 0 1 0-.686l1.937-.645a2.89 2.89 0 0 0 1.828-1.828l.645-1.937zM3.794 1.148a.217.217 0 0 1 .412 0l.387 1.162c.173.518.579.924 1.097 1.097l1.162.387a.217.217 0 0 1 0 .412l-1.162.387A1.734 1.734 0 0 0 4.593 5.69l-.387 1.162a.217.217 0 0 1-.412 0L3.407 5.69A1.734 1.734 0 0 0 2.31 4.593l-1.162-.387a.217.217 0 0 1 0-.412l1.162-.387A1.734 1.734 0 0 0 3.407 2.31l.387-1.162zM10.863.099a.145.145 0 0 1 .274 0l.258.774c.115.346.386.617.732.732l.774.258a.145.145 0 0 1 0 .274l-.774.258a1.156 1.156 0 0 0-.732.732l-.258.774a.145.145 0 0 1-.274 0l-.258-.774a1.156 1.156 0 0 0-.732-.732L9.1 2.137a.145.145 0 0 1 0-.274l.774-.258c.346-.115.617-.386.732-.732L10.863.1z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="film" viewBox="0 0 16 16">
|
||||
<path d="M0 1a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1V1zm4 0v6h8V1H4zm8 8H4v6h8V9zM1 1v2h2V1H1zm2 3H1v2h2V4zM1 7v2h2V7H1zm2 3H1v2h2v-2zm-2 3v2h2v-2H1zM15 1h-2v2h2V1zm-2 3v2h2V4h-2zm2 3h-2v2h2V7zm-2 3v2h2v-2h-2zm2 3h-2v2h2v-2z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="joystick" viewBox="0 0 16 16">
|
||||
<path d="M10 2a2 2 0 0 1-1.5 1.937v5.087c.863.083 1.5.377 1.5.726 0 .414-.895.75-2 .75s-2-.336-2-.75c0-.35.637-.643 1.5-.726V3.937A2 2 0 1 1 10 2z"/>
|
||||
<path d="M0 9.665v1.717a1 1 0 0 0 .553.894l6.553 3.277a2 2 0 0 0 1.788 0l6.553-3.277a1 1 0 0 0 .553-.894V9.665c0-.1-.06-.19-.152-.23L9.5 6.715v.993l5.227 2.178a.125.125 0 0 1 .001.23l-5.94 2.546a2 2 0 0 1-1.576 0l-5.94-2.546a.125.125 0 0 1 .001-.23L6.5 7.708l-.013-.988L.152 9.435a.25.25 0 0 0-.152.23z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="music-note-beamed" viewBox="0 0 16 16">
|
||||
<path d="M6 13c0 1.105-1.12 2-2.5 2S1 14.105 1 13c0-1.104 1.12-2 2.5-2s2.5.896 2.5 2zm9-2c0 1.105-1.12 2-2.5 2s-2.5-.895-2.5-2 1.12-2 2.5-2 2.5.895 2.5 2z"/>
|
||||
<path fill-rule="evenodd" d="M14 11V2h1v9h-1zM6 3v10H5V3h1z"/>
|
||||
<path d="M5 2.905a1 1 0 0 1 .9-.995l8-.8a1 1 0 0 1 1.1.995V3L5 4V2.905z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="files" viewBox="0 0 16 16">
|
||||
<path d="M13 0H6a2 2 0 0 0-2 2 2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h7a2 2 0 0 0 2-2 2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zm0 13V4a2 2 0 0 0-2-2H5a1 1 0 0 1 1-1h7a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1zM3 4a1 1 0 0 1 1-1h7a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="image-fill" viewBox="0 0 16 16">
|
||||
<path d="M.002 3a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-12a2 2 0 0 1-2-2V3zm1 9v1a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9.5l-3.777-1.947a.5.5 0 0 0-.577.093l-3.71 3.71-2.66-1.772a.5.5 0 0 0-.63.062L1.002 12zm5-6.5a1.5 1.5 0 1 0-3 0 1.5 1.5 0 0 0 3 0z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="trash" viewBox="0 0 16 16">
|
||||
<path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z"/>
|
||||
<path fill-rule="evenodd" d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="question-circle" viewBox="0 0 16 16">
|
||||
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
|
||||
<path d="M5.255 5.786a.237.237 0 0 0 .241.247h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286zm1.557 5.763c0 .533.425.927 1.01.927.609 0 1.028-.394 1.028-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="arrow-left-short" viewBox="0 0 16 16">
|
||||
<path fill-rule="evenodd" d="M12 8a.5.5 0 0 1-.5.5H5.707l2.147 2.146a.5.5 0 0 1-.708.708l-3-3a.5.5 0 0 1 0-.708l3-3a.5.5 0 1 1 .708.708L5.707 7.5H11.5a.5.5 0 0 1 .5.5z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="arrow-right-short" viewBox="0 0 16 16">
|
||||
<path fill-rule="evenodd" d="M4 8a.5.5 0 0 1 .5-.5h5.793L8.146 5.354a.5.5 0 1 1 .708-.708l3 3a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708-.708L10.293 8.5H4.5A.5.5 0 0 1 4 8z"/>
|
||||
</symbol>
|
||||
</svg>
|
||||
|
||||
<div class="d-flex gap-5 justify-content-center">
|
||||
<ul class="dropdown-menu position-static d-grid gap-1 p-2 rounded-3 mx-0 shadow w-220px">
|
||||
<li><a class="dropdown-item rounded-2 active" href="#">Action</a></li>
|
||||
<li><a class="dropdown-item rounded-2" href="#">Another action</a></li>
|
||||
<li><a class="dropdown-item rounded-2" href="#">Something else here</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item rounded-2" href="#">Separated link</a></li>
|
||||
</ul>
|
||||
<ul class="dropdown-menu dropdown-menu-dark position-static d-grid gap-1 p-2 rounded-3 mx-0 border-0 shadow w-220px">
|
||||
<li><a class="dropdown-item rounded-2 active" href="#">Action</a></li>
|
||||
<li><a class="dropdown-item rounded-2" href="#">Another action</a></li>
|
||||
<li><a class="dropdown-item rounded-2" href="#">Something else here</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item rounded-2" href="#">Separated link</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="b-example-divider"></div>
|
||||
|
||||
<div class="d-flex gap-5 justify-content-center">
|
||||
<div class="dropdown-menu d-block position-static pt-0 mx-0 rounded-3 shadow overflow-hidden w-280px">
|
||||
<form class="p-2 mb-2 bg-light border-bottom">
|
||||
<input type="search" class="form-control" autocomplete="false" placeholder="Type to filter...">
|
||||
</form>
|
||||
<ul class="list-unstyled mb-0">
|
||||
<li><a class="dropdown-item d-flex align-items-center gap-2 py-2" href="#">
|
||||
<span class="d-inline-block bg-success rounded-circle p-1"></span>
|
||||
Action
|
||||
</a></li>
|
||||
<li><a class="dropdown-item d-flex align-items-center gap-2 py-2" href="#">
|
||||
<span class="d-inline-block bg-primary rounded-circle p-1"></span>
|
||||
Another action
|
||||
</a></li>
|
||||
<li><a class="dropdown-item d-flex align-items-center gap-2 py-2" href="#">
|
||||
<span class="d-inline-block bg-danger rounded-circle p-1"></span>
|
||||
Something else here
|
||||
</a></li>
|
||||
<li><a class="dropdown-item d-flex align-items-center gap-2 py-2" href="#">
|
||||
<span class="d-inline-block bg-info rounded-circle p-1"></span>
|
||||
Separated link
|
||||
</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="dropdown-menu dropdown-menu-dark d-block position-static border-0 pt-0 mx-0 rounded-3 shadow overflow-hidden w-280px">
|
||||
<form class="p-2 mb-2 bg-dark border-bottom border-dark">
|
||||
<input type="search" class="form-control form-control-dark" autocomplete="false" placeholder="Type to filter...">
|
||||
</form>
|
||||
<ul class="list-unstyled mb-0">
|
||||
<li><a class="dropdown-item d-flex align-items-center gap-2 py-2" href="#">
|
||||
<span class="d-inline-block bg-success rounded-circle p-1"></span>
|
||||
Action
|
||||
</a></li>
|
||||
<li><a class="dropdown-item d-flex align-items-center gap-2 py-2" href="#">
|
||||
<span class="d-inline-block bg-primary rounded-circle p-1"></span>
|
||||
Another action
|
||||
</a></li>
|
||||
<li><a class="dropdown-item d-flex align-items-center gap-2 py-2" href="#">
|
||||
<span class="d-inline-block bg-danger rounded-circle p-1"></span>
|
||||
Something else here
|
||||
</a></li>
|
||||
<li><a class="dropdown-item d-flex align-items-center gap-2 py-2" href="#">
|
||||
<span class="d-inline-block bg-info rounded-circle p-1"></span>
|
||||
Separated link
|
||||
</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="b-example-divider"></div>
|
||||
|
||||
<div class="d-flex gap-5 justify-content-center">
|
||||
<ul class="dropdown-menu d-block position-static mx-0 shadow w-220px">
|
||||
<li>
|
||||
<a class="dropdown-item d-flex gap-2 align-items-center" href="#">
|
||||
<svg class="bi" width="16" height="16"><use xlink:href="#files"/></svg>
|
||||
Documents
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item d-flex gap-2 align-items-center" href="#">
|
||||
<svg class="bi" width="16" height="16"><use xlink:href="#image-fill"/></svg>
|
||||
Photos
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item d-flex gap-2 align-items-center" href="#">
|
||||
<svg class="bi" width="16" height="16"><use xlink:href="#film"/></svg>
|
||||
Movies
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item d-flex gap-2 align-items-center" href="#">
|
||||
<svg class="bi" width="16" height="16"><use xlink:href="#music-note-beamed"/></svg>
|
||||
Music
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item d-flex gap-2 align-items-center" href="#">
|
||||
<svg class="bi" width="16" height="16"><use xlink:href="#joystick"/></svg>
|
||||
Games
|
||||
</a>
|
||||
</li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li>
|
||||
<a class="dropdown-item dropdown-item-danger d-flex gap-2 align-items-center" href="#">
|
||||
<svg class="bi" width="16" height="16"><use xlink:href="#trash"/></svg>
|
||||
Trash
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="dropdown-menu dropdown-menu-dark d-block position-static mx-0 border-0 shadow w-220px">
|
||||
<li>
|
||||
<a class="dropdown-item d-flex gap-2 align-items-center" href="#">
|
||||
<svg class="bi" width="16" height="16"><use xlink:href="#files"/></svg>
|
||||
Documents
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item d-flex gap-2 align-items-center" href="#">
|
||||
<svg class="bi" width="16" height="16"><use xlink:href="#image-fill"/></svg>
|
||||
Photos
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item d-flex gap-2 align-items-center" href="#">
|
||||
<svg class="bi" width="16" height="16"><use xlink:href="#film"/></svg>
|
||||
Movies
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item d-flex gap-2 align-items-center" href="#">
|
||||
<svg class="bi" width="16" height="16"><use xlink:href="#music-note-beamed"/></svg>
|
||||
Music
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item d-flex gap-2 align-items-center" href="#">
|
||||
<svg class="bi" width="16" height="16"><use xlink:href="#joystick"/></svg>
|
||||
Games
|
||||
</a>
|
||||
</li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li>
|
||||
<a class="dropdown-item d-flex gap-2 align-items-center" href="#">
|
||||
<svg class="bi" width="16" height="16"><use xlink:href="#trash"/></svg>
|
||||
Trash
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="b-example-divider"></div>
|
||||
|
||||
<div class="dropdown-menu d-block position-static p-2 shadow rounded-3 w-340px">
|
||||
<div class="d-grid gap-1">
|
||||
<div class="cal">
|
||||
<div class="cal-month">
|
||||
<button class="btn cal-btn" type="button">
|
||||
<svg class="bi" width="16" height="16"><use xlink:href="#arrow-left-short"/></svg>
|
||||
</button>
|
||||
<strong class="cal-month-name">June</strong>
|
||||
<select class="form-select cal-month-name d-none">
|
||||
<option value="January">January</option>
|
||||
<option value="February">February</option>
|
||||
<option value="March">March</option>
|
||||
<option value="April">April</option>
|
||||
<option value="May">May</option>
|
||||
<option selected value="June">June</option>
|
||||
<option value="July">July</option>
|
||||
<option value="August">August</option>
|
||||
<option value="September">September</option>
|
||||
<option value="October">October</option>
|
||||
<option value="November">November</option>
|
||||
<option value="December">December</option>
|
||||
</select>
|
||||
<button class="btn cal-btn" type="button">
|
||||
<svg class="bi" width="16" height="16"><use xlink:href="#arrow-right-short"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="cal-weekdays text-muted">
|
||||
<div class="cal-weekday">Sun</div>
|
||||
<div class="cal-weekday">Mon</div>
|
||||
<div class="cal-weekday">Tue</div>
|
||||
<div class="cal-weekday">Wed</div>
|
||||
<div class="cal-weekday">Thu</div>
|
||||
<div class="cal-weekday">Fri</div>
|
||||
<div class="cal-weekday">Sat</div>
|
||||
</div>
|
||||
<div class="cal-days">
|
||||
<button class="btn cal-btn" disabled type="button">30</button>
|
||||
<button class="btn cal-btn" disabled type="button">31</button>
|
||||
|
||||
<button class="btn cal-btn" type="button">1</button>
|
||||
<button class="btn cal-btn" type="button">2</button>
|
||||
<button class="btn cal-btn" type="button">3</button>
|
||||
<button class="btn cal-btn" type="button">4</button>
|
||||
<button class="btn cal-btn" type="button">5</button>
|
||||
<button class="btn cal-btn" type="button">6</button>
|
||||
<button class="btn cal-btn" type="button">7</button>
|
||||
|
||||
<button class="btn cal-btn" type="button">8</button>
|
||||
<button class="btn cal-btn" type="button">9</button>
|
||||
<button class="btn cal-btn" type="button">10</button>
|
||||
<button class="btn cal-btn" type="button">11</button>
|
||||
<button class="btn cal-btn" type="button">12</button>
|
||||
<button class="btn cal-btn" type="button">13</button>
|
||||
<button class="btn cal-btn" type="button">14</button>
|
||||
|
||||
<button class="btn cal-btn" type="button">15</button>
|
||||
<button class="btn cal-btn" type="button">16</button>
|
||||
<button class="btn cal-btn" type="button">17</button>
|
||||
<button class="btn cal-btn" type="button">18</button>
|
||||
<button class="btn cal-btn" type="button">19</button>
|
||||
<button class="btn cal-btn" type="button">20</button>
|
||||
<button class="btn cal-btn" type="button">21</button>
|
||||
|
||||
<button class="btn cal-btn" type="button">22</button>
|
||||
<button class="btn cal-btn" type="button">23</button>
|
||||
<button class="btn cal-btn" type="button">24</button>
|
||||
<button class="btn cal-btn" type="button">25</button>
|
||||
<button class="btn cal-btn" type="button">26</button>
|
||||
<button class="btn cal-btn" type="button">27</button>
|
||||
<button class="btn cal-btn" type="button">28</button>
|
||||
|
||||
<button class="btn cal-btn" type="button">29</button>
|
||||
<button class="btn cal-btn" type="button">30</button>
|
||||
<button class="btn cal-btn" type="button">31</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="b-example-divider"></div>
|
||||
|
||||
<div class="dropdown-menu position-static d-flex align-items-stretch p-3 rounded-3 shadow-lg w-600px">
|
||||
<nav class="d-grid gap-2 col-8">
|
||||
<a href="#" class="btn btn-hover-light rounded-2 d-flex align-items-center gap-3 py-2 px-3 lh-sm text-start">
|
||||
<svg class="bi" width="32" height="32"><use xlink:href="#image-fill"/></svg>
|
||||
<div>
|
||||
<strong class="d-block">Features</strong>
|
||||
<small>Take a tour through the product</small>
|
||||
</div>
|
||||
</a>
|
||||
<a href="#" class="btn btn-hover-light rounded-2 d-flex align-items-center gap-3 py-2 px-3 lh-sm text-start">
|
||||
<svg class="bi" width="32" height="32"><use xlink:href="#question-circle"/></svg>
|
||||
<div>
|
||||
<strong class="d-block">Support</strong>
|
||||
<small>Get help from our support crew</small>
|
||||
</div>
|
||||
</a>
|
||||
</nav>
|
||||
<div class="col-4">
|
||||
...
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
.themed-grid-col {
|
||||
padding-top: .75rem;
|
||||
padding-bottom: .75rem;
|
||||
background-color: rgba(86, 61, 124, .15);
|
||||
border: 1px solid rgba(86, 61, 124, .2);
|
||||
}
|
||||
|
||||
.themed-container {
|
||||
padding: .75rem;
|
||||
margin-bottom: 1.5rem;
|
||||
background-color: rgba(0, 123, 255, .15);
|
||||
border: 1px solid rgba(0, 123, 255, .2);
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 363 KiB |
|
|
@ -1,222 +0,0 @@
|
|||
---
|
||||
layout: examples
|
||||
title: List groups
|
||||
extra_css:
|
||||
- "list-groups.css"
|
||||
body_class: ""
|
||||
---
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
|
||||
<symbol id="bootstrap" viewBox="0 0 118 94">
|
||||
<title>Bootstrap</title>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.509 0c-6.733 0-11.715 5.893-11.492 12.284.214 6.14-.064 14.092-2.066 20.577C8.943 39.365 5.547 43.485 0 44.014v5.972c5.547.529 8.943 4.649 10.951 11.153 2.002 6.485 2.28 14.437 2.066 20.577C12.794 88.106 17.776 94 24.51 94H93.5c6.733 0 11.714-5.893 11.491-12.284-.214-6.14.064-14.092 2.066-20.577 2.009-6.504 5.396-10.624 10.943-11.153v-5.972c-5.547-.529-8.934-4.649-10.943-11.153-2.002-6.484-2.28-14.437-2.066-20.577C105.214 5.894 100.233 0 93.5 0H24.508zM80 57.863C80 66.663 73.436 72 62.543 72H44a2 2 0 01-2-2V24a2 2 0 012-2h18.437c9.083 0 15.044 4.92 15.044 12.474 0 5.302-4.01 10.049-9.119 10.88v.277C75.317 46.394 80 51.21 80 57.863zM60.521 28.34H49.948v14.934h8.905c6.884 0 10.68-2.772 10.68-7.727 0-4.643-3.264-7.207-9.012-7.207zM49.948 49.2v16.458H60.91c7.167 0 10.964-2.876 10.964-8.281 0-5.406-3.903-8.178-11.425-8.178H49.948z"></path>
|
||||
</symbol>
|
||||
|
||||
<symbol id="calendar-event" viewBox="0 0 16 16">
|
||||
<path d="M11 6.5a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5v-1z"/>
|
||||
<path d="M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4H1z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="alarm" viewBox="0 0 16 16">
|
||||
<path d="M8.5 5.5a.5.5 0 0 0-1 0v3.362l-1.429 2.38a.5.5 0 1 0 .858.515l1.5-2.5A.5.5 0 0 0 8.5 9V5.5z"/>
|
||||
<path d="M6.5 0a.5.5 0 0 0 0 1H7v1.07a7.001 7.001 0 0 0-3.273 12.474l-.602.602a.5.5 0 0 0 .707.708l.746-.746A6.97 6.97 0 0 0 8 16a6.97 6.97 0 0 0 3.422-.892l.746.746a.5.5 0 0 0 .707-.708l-.601-.602A7.001 7.001 0 0 0 9 2.07V1h.5a.5.5 0 0 0 0-1h-3zm1.038 3.018a6.093 6.093 0 0 1 .924 0 6 6 0 1 1-.924 0zM0 3.5c0 .753.333 1.429.86 1.887A8.035 8.035 0 0 1 4.387 1.86 2.5 2.5 0 0 0 0 3.5zM13.5 1c-.753 0-1.429.333-1.887.86a8.035 8.035 0 0 1 3.527 3.527A2.5 2.5 0 0 0 13.5 1z"/>
|
||||
</symbol>
|
||||
|
||||
<symbol id="list-check" viewBox="0 0 16 16">
|
||||
<path fill-rule="evenodd" d="M5 11.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zM3.854 2.146a.5.5 0 0 1 0 .708l-1.5 1.5a.5.5 0 0 1-.708 0l-.5-.5a.5.5 0 1 1 .708-.708L2 3.293l1.146-1.147a.5.5 0 0 1 .708 0zm0 4a.5.5 0 0 1 0 .708l-1.5 1.5a.5.5 0 0 1-.708 0l-.5-.5a.5.5 0 1 1 .708-.708L2 7.293l1.146-1.147a.5.5 0 0 1 .708 0zm0 4a.5.5 0 0 1 0 .708l-1.5 1.5a.5.5 0 0 1-.708 0l-.5-.5a.5.5 0 0 1 .708-.708l.146.147 1.146-1.147a.5.5 0 0 1 .708 0z"/>
|
||||
</symbol>
|
||||
</svg>
|
||||
|
||||
<div class="list-group w-auto">
|
||||
<a href="#" class="list-group-item list-group-item-action d-flex gap-3 py-3" aria-current="true">
|
||||
<img src="https://github.com/twbs.png" alt="twbs" width="32" height="32" class="rounded-circle flex-shrink-0">
|
||||
<div class="d-flex gap-2 w-100 justify-content-between">
|
||||
<div>
|
||||
<h6 class="mb-0">List group item heading</h6>
|
||||
<p class="mb-0 opacity-75">Some placeholder content in a paragraph.</p>
|
||||
</div>
|
||||
<small class="opacity-50 text-nowrap">now</small>
|
||||
</div>
|
||||
</a>
|
||||
<a href="#" class="list-group-item list-group-item-action d-flex gap-3 py-3" aria-current="true">
|
||||
<img src="https://github.com/twbs.png" alt="twbs" width="32" height="32" class="rounded-circle flex-shrink-0">
|
||||
<div class="d-flex gap-2 w-100 justify-content-between">
|
||||
<div>
|
||||
<h6 class="mb-0">Another title here</h6>
|
||||
<p class="mb-0 opacity-75">Some placeholder content in a paragraph that goes a little longer so it wraps to a new line.</p>
|
||||
</div>
|
||||
<small class="opacity-50 text-nowrap">3d</small>
|
||||
</div>
|
||||
</a>
|
||||
<a href="#" class="list-group-item list-group-item-action d-flex gap-3 py-3" aria-current="true">
|
||||
<img src="https://github.com/twbs.png" alt="twbs" width="32" height="32" class="rounded-circle flex-shrink-0">
|
||||
<div class="d-flex gap-2 w-100 justify-content-between">
|
||||
<div>
|
||||
<h6 class="mb-0">Third heading</h6>
|
||||
<p class="mb-0 opacity-75">Some placeholder content in a paragraph.</p>
|
||||
</div>
|
||||
<small class="opacity-50 text-nowrap">1w</small>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="b-example-divider"></div>
|
||||
|
||||
<div class="d-flex gap-5 justify-content-center">
|
||||
<div class="list-group mx-0 w-auto">
|
||||
<label class="list-group-item d-flex gap-2">
|
||||
<input class="form-check-input flex-shrink-0" type="checkbox" value="" checked>
|
||||
<span>
|
||||
First checkbox
|
||||
<small class="d-block text-muted">With support text underneath to add more detail</small>
|
||||
</span>
|
||||
</label>
|
||||
<label class="list-group-item d-flex gap-2">
|
||||
<input class="form-check-input flex-shrink-0" type="checkbox" value="">
|
||||
<span>
|
||||
Second checkbox
|
||||
<small class="d-block text-muted">Some other text goes here</small>
|
||||
</span>
|
||||
</label>
|
||||
<label class="list-group-item d-flex gap-2">
|
||||
<input class="form-check-input flex-shrink-0" type="checkbox" value="">
|
||||
<span>
|
||||
Third checkbox
|
||||
<small class="d-block text-muted">And we end with another snippet of text</small>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="list-group mx-0 w-auto">
|
||||
<label class="list-group-item d-flex gap-2">
|
||||
<input class="form-check-input flex-shrink-0" type="radio" name="listGroupRadios" id="listGroupRadios1" value="" checked>
|
||||
<span>
|
||||
First radio
|
||||
<small class="d-block text-muted">With support text underneath to add more detail</small>
|
||||
</span>
|
||||
</label>
|
||||
<label class="list-group-item d-flex gap-2">
|
||||
<input class="form-check-input flex-shrink-0" type="radio" name="listGroupRadios" id="listGroupRadios2" value="">
|
||||
<span>
|
||||
Second radio
|
||||
<small class="d-block text-muted">Some other text goes here</small>
|
||||
</span>
|
||||
</label>
|
||||
<label class="list-group-item d-flex gap-2">
|
||||
<input class="form-check-input flex-shrink-0" type="radio" name="listGroupRadios" id="listGroupRadios3" value="">
|
||||
<span>
|
||||
Third radio
|
||||
<small class="d-block text-muted">And we end with another snippet of text</small>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="b-example-divider"></div>
|
||||
|
||||
<div class="list-group w-auto">
|
||||
<label class="list-group-item d-flex gap-3">
|
||||
<input class="form-check-input flex-shrink-0" type="checkbox" value="" checked style="font-size: 1.375em;">
|
||||
<span class="pt-1 form-checked-content">
|
||||
<strong>Finish sales report</strong>
|
||||
<small class="d-block text-muted">
|
||||
<svg class="bi me-1" width="1em" height="1em"><use xlink:href="#calendar-event"/></svg>
|
||||
1:00–2:00pm
|
||||
</small>
|
||||
</span>
|
||||
</label>
|
||||
<label class="list-group-item d-flex gap-3">
|
||||
<input class="form-check-input flex-shrink-0" type="checkbox" value="" style="font-size: 1.375em;">
|
||||
<span class="pt-1 form-checked-content">
|
||||
<strong>Weekly All Hands</strong>
|
||||
<small class="d-block text-muted">
|
||||
<svg class="bi me-1" width="1em" height="1em"><use xlink:href="#calendar-event"/></svg>
|
||||
2:00–2:30pm
|
||||
</small>
|
||||
</span>
|
||||
</label>
|
||||
<label class="list-group-item d-flex gap-3">
|
||||
<input class="form-check-input flex-shrink-0" type="checkbox" value="" style="font-size: 1.375em;">
|
||||
<span class="pt-1 form-checked-content">
|
||||
<strong>Out of office</strong>
|
||||
<small class="d-block text-muted">
|
||||
<svg class="bi me-1" width="1em" height="1em"><use xlink:href="#alarm"/></svg>
|
||||
Tomorrow
|
||||
</small>
|
||||
</span>
|
||||
</label>
|
||||
<label class="list-group-item d-flex gap-3 bg-light">
|
||||
<input class="form-check-input form-check-input-placeholder bg-light flex-shrink-0 pe-none" disabled type="checkbox" value="" style="font-size: 1.375em;">
|
||||
<span class="pt-1 form-checked-content">
|
||||
<span contenteditable="true" class="w-100">Add new task...</span>
|
||||
<small class="d-block text-muted">
|
||||
<svg class="bi me-1" width="1em" height="1em"><use xlink:href="#list-check"/></svg>
|
||||
Choose list...
|
||||
</small>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="b-example-divider"></div>
|
||||
|
||||
<div class="list-group list-group-checkable d-grid gap-2 border-0 w-auto">
|
||||
<input class="list-group-item-check pe-none" type="radio" name="listGroupCheckableRadios" id="listGroupCheckableRadios1" value="" checked>
|
||||
<label class="list-group-item rounded-3 py-3" for="listGroupCheckableRadios1">
|
||||
First radio
|
||||
<span class="d-block small opacity-50">With support text underneath to add more detail</span>
|
||||
</label>
|
||||
|
||||
<input class="list-group-item-check pe-none" type="radio" name="listGroupCheckableRadios" id="listGroupCheckableRadios2" value="">
|
||||
<label class="list-group-item rounded-3 py-3" for="listGroupCheckableRadios2">
|
||||
Second radio
|
||||
<span class="d-block small opacity-50">Some other text goes here</span>
|
||||
</label>
|
||||
|
||||
<input class="list-group-item-check pe-none" type="radio" name="listGroupCheckableRadios" id="listGroupCheckableRadios3" value="">
|
||||
<label class="list-group-item rounded-3 py-3" for="listGroupCheckableRadios3">
|
||||
Third radio
|
||||
<span class="d-block small opacity-50">And we end with another snippet of text</span>
|
||||
</label>
|
||||
|
||||
<input class="list-group-item-check pe-none" type="radio" name="listGroupCheckableRadios" id="listGroupCheckableRadios4" value="" disabled>
|
||||
<label class="list-group-item rounded-3 py-3" for="listGroupCheckableRadios4">
|
||||
Fourth disabled radio
|
||||
<span class="d-block small opacity-50">This option is disabled</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="b-example-divider"></div>
|
||||
|
||||
<div class="list-group list-group-radio d-grid gap-2 border-0 w-auto">
|
||||
<div class="position-relative">
|
||||
<input class="form-check-input position-absolute top-50 end-0 me-3 fs-5" type="radio" name="listGroupRadioGrid" id="listGroupRadioGrid1" value="" checked>
|
||||
<label class="list-group-item py-3 pe-5" for="listGroupRadioGrid1">
|
||||
<strong class="fw-semibold">First radio</strong>
|
||||
<span class="d-block small opacity-75">With support text underneath to add more detail</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="position-relative">
|
||||
<input class="form-check-input position-absolute top-50 end-0 me-3 fs-5" type="radio" name="listGroupRadioGrid" id="listGroupRadioGrid2" value="">
|
||||
<label class="list-group-item py-3 pe-5" for="listGroupRadioGrid2">
|
||||
<strong class="fw-semibold">Second radio</strong>
|
||||
<span class="d-block small opacity-75">Some other text goes here</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="position-relative">
|
||||
<input class="form-check-input position-absolute top-50 end-0 me-3 fs-5" type="radio" name="listGroupRadioGrid" id="listGroupRadioGrid3" value="">
|
||||
<label class="list-group-item py-3 pe-5" for="listGroupRadioGrid3">
|
||||
<strong class="fw-semibold">Third radio</strong>
|
||||
<span class="d-block small opacity-75">And we end with another snippet of text</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="position-relative">
|
||||
<input class="form-check-input position-absolute top-50 end-0 me-3 fs-5" type="radio" name="listGroupRadioGrid" id="listGroupRadioGrid4" value="" disabled>
|
||||
<label class="list-group-item py-3 pe-5" for="listGroupRadioGrid4">
|
||||
<strong class="fw-semibold">Fourth disabled radio</strong>
|
||||
<span class="d-block small opacity-75">This option is disabled</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
body {
|
||||
background-image: linear-gradient(180deg, #eee, #fff 100px, #fff);
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 960px;
|
||||
}
|
||||
|
||||
.pricing-header {
|
||||
max-width: 700px;
|
||||
}
|
||||
|
|
@ -1,148 +0,0 @@
|
|||
---
|
||||
layout: examples
|
||||
title: Product example
|
||||
extra_css:
|
||||
- "product.css"
|
||||
---
|
||||
|
||||
<header class="site-header sticky-top py-1">
|
||||
<nav class="container d-flex flex-column flex-md-row justify-content-between">
|
||||
<a class="py-2" href="#" aria-label="Product">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="d-block mx-auto" role="img" viewBox="0 0 24 24"><title>Product</title><circle cx="12" cy="12" r="10"/><path d="M14.31 8l5.74 9.94M9.69 8h11.48M7.38 12l5.74-9.94M9.69 16L3.95 6.06M14.31 16H2.83m13.79-4l-5.74 9.94"/></svg>
|
||||
</a>
|
||||
<a class="py-2 d-none d-md-inline-block" href="#">Tour</a>
|
||||
<a class="py-2 d-none d-md-inline-block" href="#">Product</a>
|
||||
<a class="py-2 d-none d-md-inline-block" href="#">Features</a>
|
||||
<a class="py-2 d-none d-md-inline-block" href="#">Enterprise</a>
|
||||
<a class="py-2 d-none d-md-inline-block" href="#">Support</a>
|
||||
<a class="py-2 d-none d-md-inline-block" href="#">Pricing</a>
|
||||
<a class="py-2 d-none d-md-inline-block" href="#">Cart</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<div class="position-relative overflow-hidden p-3 p-md-5 m-md-3 text-center bg-light">
|
||||
<div class="col-md-5 p-lg-5 mx-auto my-5">
|
||||
<h1 class="display-4 fw-normal">Punny headline</h1>
|
||||
<p class="lead fw-normal">And an even wittier subheading to boot. Jumpstart your marketing efforts with this example based on Apple’s marketing pages.</p>
|
||||
<a class="btn btn-outline-secondary" href="#">Coming soon</a>
|
||||
</div>
|
||||
<div class="product-device shadow-sm d-none d-md-block"></div>
|
||||
<div class="product-device product-device-2 shadow-sm d-none d-md-block"></div>
|
||||
</div>
|
||||
|
||||
<div class="d-md-flex flex-md-equal w-100 my-md-3 ps-md-3">
|
||||
<div class="text-bg-dark me-md-3 pt-3 px-3 pt-md-5 px-md-5 text-center overflow-hidden">
|
||||
<div class="my-3 py-3">
|
||||
<h2 class="display-5">Another headline</h2>
|
||||
<p class="lead">And an even wittier subheading.</p>
|
||||
</div>
|
||||
<div class="bg-light shadow-sm mx-auto" style="width: 80%; height: 300px; border-radius: 21px 21px 0 0;"></div>
|
||||
</div>
|
||||
<div class="bg-light me-md-3 pt-3 px-3 pt-md-5 px-md-5 text-center overflow-hidden">
|
||||
<div class="my-3 p-3">
|
||||
<h2 class="display-5">Another headline</h2>
|
||||
<p class="lead">And an even wittier subheading.</p>
|
||||
</div>
|
||||
<div class="bg-dark shadow-sm mx-auto" style="width: 80%; height: 300px; border-radius: 21px 21px 0 0;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-md-flex flex-md-equal w-100 my-md-3 ps-md-3">
|
||||
<div class="bg-light me-md-3 pt-3 px-3 pt-md-5 px-md-5 text-center overflow-hidden">
|
||||
<div class="my-3 p-3">
|
||||
<h2 class="display-5">Another headline</h2>
|
||||
<p class="lead">And an even wittier subheading.</p>
|
||||
</div>
|
||||
<div class="bg-dark shadow-sm mx-auto" style="width: 80%; height: 300px; border-radius: 21px 21px 0 0;"></div>
|
||||
</div>
|
||||
<div class="text-bg-primary me-md-3 pt-3 px-3 pt-md-5 px-md-5 text-center overflow-hidden">
|
||||
<div class="my-3 py-3">
|
||||
<h2 class="display-5">Another headline</h2>
|
||||
<p class="lead">And an even wittier subheading.</p>
|
||||
</div>
|
||||
<div class="bg-light shadow-sm mx-auto" style="width: 80%; height: 300px; border-radius: 21px 21px 0 0;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-md-flex flex-md-equal w-100 my-md-3 ps-md-3">
|
||||
<div class="bg-light me-md-3 pt-3 px-3 pt-md-5 px-md-5 text-center overflow-hidden">
|
||||
<div class="my-3 p-3">
|
||||
<h2 class="display-5">Another headline</h2>
|
||||
<p class="lead">And an even wittier subheading.</p>
|
||||
</div>
|
||||
<div class="bg-body shadow-sm mx-auto" style="width: 80%; height: 300px; border-radius: 21px 21px 0 0;"></div>
|
||||
</div>
|
||||
<div class="bg-light me-md-3 pt-3 px-3 pt-md-5 px-md-5 text-center overflow-hidden">
|
||||
<div class="my-3 py-3">
|
||||
<h2 class="display-5">Another headline</h2>
|
||||
<p class="lead">And an even wittier subheading.</p>
|
||||
</div>
|
||||
<div class="bg-body shadow-sm mx-auto" style="width: 80%; height: 300px; border-radius: 21px 21px 0 0;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-md-flex flex-md-equal w-100 my-md-3 ps-md-3">
|
||||
<div class="bg-light me-md-3 pt-3 px-3 pt-md-5 px-md-5 text-center overflow-hidden">
|
||||
<div class="my-3 p-3">
|
||||
<h2 class="display-5">Another headline</h2>
|
||||
<p class="lead">And an even wittier subheading.</p>
|
||||
</div>
|
||||
<div class="bg-body shadow-sm mx-auto" style="width: 80%; height: 300px; border-radius: 21px 21px 0 0;"></div>
|
||||
</div>
|
||||
<div class="bg-light me-md-3 pt-3 px-3 pt-md-5 px-md-5 text-center overflow-hidden">
|
||||
<div class="my-3 py-3">
|
||||
<h2 class="display-5">Another headline</h2>
|
||||
<p class="lead">And an even wittier subheading.</p>
|
||||
</div>
|
||||
<div class="bg-body shadow-sm mx-auto" style="width: 80%; height: 300px; border-radius: 21px 21px 0 0;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="container py-5">
|
||||
<div class="row">
|
||||
<div class="col-12 col-md">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="d-block mb-2" role="img" viewBox="0 0 24 24"><title>Product</title><circle cx="12" cy="12" r="10"/><path d="M14.31 8l5.74 9.94M9.69 8h11.48M7.38 12l5.74-9.94M9.69 16L3.95 6.06M14.31 16H2.83m13.79-4l-5.74 9.94"/></svg>
|
||||
<small class="d-block mb-3 text-muted">© 2017–{{< year >}}</small>
|
||||
</div>
|
||||
<div class="col-6 col-md">
|
||||
<h5>Features</h5>
|
||||
<ul class="list-unstyled text-small">
|
||||
<li><a class="link-secondary" href="#">Cool stuff</a></li>
|
||||
<li><a class="link-secondary" href="#">Random feature</a></li>
|
||||
<li><a class="link-secondary" href="#">Team feature</a></li>
|
||||
<li><a class="link-secondary" href="#">Stuff for developers</a></li>
|
||||
<li><a class="link-secondary" href="#">Another one</a></li>
|
||||
<li><a class="link-secondary" href="#">Last time</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-6 col-md">
|
||||
<h5>Resources</h5>
|
||||
<ul class="list-unstyled text-small">
|
||||
<li><a class="link-secondary" href="#">Resource name</a></li>
|
||||
<li><a class="link-secondary" href="#">Resource</a></li>
|
||||
<li><a class="link-secondary" href="#">Another resource</a></li>
|
||||
<li><a class="link-secondary" href="#">Final resource</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-6 col-md">
|
||||
<h5>Resources</h5>
|
||||
<ul class="list-unstyled text-small">
|
||||
<li><a class="link-secondary" href="#">Business</a></li>
|
||||
<li><a class="link-secondary" href="#">Education</a></li>
|
||||
<li><a class="link-secondary" href="#">Government</a></li>
|
||||
<li><a class="link-secondary" href="#">Gaming</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-6 col-md">
|
||||
<h5>About</h5>
|
||||
<ul class="list-unstyled text-small">
|
||||
<li><a class="link-secondary" href="#">Team</a></li>
|
||||
<li><a class="link-secondary" href="#">Locations</a></li>
|
||||
<li><a class="link-secondary" href="#">Privacy</a></li>
|
||||
<li><a class="link-secondary" href="#">Terms</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
---
|
||||
layout: examples
|
||||
title: Signin Template
|
||||
extra_css:
|
||||
- "signin.css"
|
||||
body_class: "text-center"
|
||||
include_js: false
|
||||
---
|
||||
|
||||
<main class="form-signin w-100 m-auto">
|
||||
<form>
|
||||
<img class="mb-4" src="/docs/{{< param docs_version >}}/assets/brand/bootstrap-logo.svg" alt="" width="72" height="57">
|
||||
<h1 class="h3 mb-3 fw-normal">Please sign in</h1>
|
||||
|
||||
<div class="form-floating">
|
||||
<input type="email" class="form-control" id="floatingInput" placeholder="name@example.com">
|
||||
<label for="floatingInput">Email address</label>
|
||||
</div>
|
||||
<div class="form-floating">
|
||||
<input type="password" class="form-control" id="floatingPassword" placeholder="Password">
|
||||
<label for="floatingPassword">Password</label>
|
||||
</div>
|
||||
|
||||
<div class="checkbox mb-3">
|
||||
<label>
|
||||
<input type="checkbox" value="remember-me"> Remember me
|
||||
</label>
|
||||
</div>
|
||||
<button class="w-100 btn btn-lg btn-primary" type="submit">Sign in</button>
|
||||
<p class="mt-5 mb-3 text-muted">© 2017–{{< year >}}</p>
|
||||
</form>
|
||||
</main>
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
---
|
||||
layout: examples
|
||||
title: Starter Template
|
||||
extra_css:
|
||||
- "starter-template.css"
|
||||
---
|
||||
|
||||
<div class="col-lg-8 mx-auto p-4 py-md-5">
|
||||
<header class="d-flex align-items-center pb-3 mb-5 border-bottom">
|
||||
<a href="/" class="d-flex align-items-center text-dark text-decoration-none">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="32" class="me-2" viewBox="0 0 118 94" role="img"><title>Bootstrap</title><path fill-rule="evenodd" clip-rule="evenodd" d="M24.509 0c-6.733 0-11.715 5.893-11.492 12.284.214 6.14-.064 14.092-2.066 20.577C8.943 39.365 5.547 43.485 0 44.014v5.972c5.547.529 8.943 4.649 10.951 11.153 2.002 6.485 2.28 14.437 2.066 20.577C12.794 88.106 17.776 94 24.51 94H93.5c6.733 0 11.714-5.893 11.491-12.284-.214-6.14.064-14.092 2.066-20.577 2.009-6.504 5.396-10.624 10.943-11.153v-5.972c-5.547-.529-8.934-4.649-10.943-11.153-2.002-6.484-2.28-14.437-2.066-20.577C105.214 5.894 100.233 0 93.5 0H24.508zM80 57.863C80 66.663 73.436 72 62.543 72H44a2 2 0 01-2-2V24a2 2 0 012-2h18.437c9.083 0 15.044 4.92 15.044 12.474 0 5.302-4.01 10.049-9.119 10.88v.277C75.317 46.394 80 51.21 80 57.863zM60.521 28.34H49.948v14.934h8.905c6.884 0 10.68-2.772 10.68-7.727 0-4.643-3.264-7.207-9.012-7.207zM49.948 49.2v16.458H60.91c7.167 0 10.964-2.876 10.964-8.281 0-5.406-3.903-8.178-11.425-8.178H49.948z" fill="currentColor"></path></svg>
|
||||
<span class="fs-4">Starter template</span>
|
||||
</a>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<h1>Get started with Bootstrap</h1>
|
||||
<p class="fs-5 col-md-8">Quickly and easily get started with Bootstrap's compiled, production-ready files with this barebones example featuring some basic HTML and helpful links. Download all our examples to get started.</p>
|
||||
|
||||
<div class="mb-5">
|
||||
<a href="{{< docsref "/examples" >}}" class="btn btn-primary btn-lg px-4">Download examples</a>
|
||||
</div>
|
||||
|
||||
<hr class="col-3 col-md-2 mb-5">
|
||||
|
||||
<div class="row g-5">
|
||||
<div class="col-md-6">
|
||||
<h2>Starter projects</h2>
|
||||
<p>Ready to beyond the starter template? Check out these open source projects that you can quickly duplicate to a new GitHub repository.</p>
|
||||
<ul class="icon-list ps-0">
|
||||
<li class="d-flex align-items-start mb-1"><a href="https://github.com/twbs/bootstrap-npm-starter" rel="noopener" target="_blank">Bootstrap npm starter</a></li>
|
||||
<li class="text-muted d-flex align-items-start mb-1">Bootstrap Parcel starter (coming soon!)</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<h2>Guides</h2>
|
||||
<p>Read more detailed instructions and documentation on using or contributing to Bootstrap.</p>
|
||||
<ul class="icon-list ps-0">
|
||||
<li class="d-flex align-items-start mb-1"><a href="{{< docsref "/getting-started/introduction" >}}">Bootstrap quick start guide</a></li>
|
||||
<li class="d-flex align-items-start mb-1"><a href="{{< docsref "/getting-started/webpack" >}}">Bootstrap Webpack guide</a></li>
|
||||
<li class="d-flex align-items-start mb-1"><a href="{{< docsref "/getting-started/parcel" >}}">Bootstrap Parcel guide</a></li>
|
||||
<li class="d-flex align-items-start mb-1"><a href="{{< docsref "/getting-started/vite" >}}">Bootstrap Vite guide</a></li>
|
||||
<li class="d-flex align-items-start mb-1"><a href="{{< docsref "/getting-started/contribute" >}}">Contributing to Bootstrap</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<footer class="pt-5 my-5 text-muted border-top">
|
||||
Created by the Bootstrap team · © {{< year >}}
|
||||
</footer>
|
||||
</div>
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
.icon-list li::before {
|
||||
display: block;
|
||||
flex-shrink: 0;
|
||||
width: 1.5em;
|
||||
height: 1.5em;
|
||||
margin-right: .5rem;
|
||||
content: "";
|
||||
background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23212529' viewBox='0 0 16 16'%3E%3Cpath d='M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0zM4.5 7.5a.5.5 0 0 0 0 1h5.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3a.5.5 0 0 0 0-.708l-3-3a.5.5 0 1 0-.708.708L10.293 7.5H4.5z'/%3E%3C/svg%3E") no-repeat center center / 100% auto;
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
---
|
||||
layout: examples
|
||||
title: Sticky Footer Template
|
||||
extra_css:
|
||||
- "sticky-footer.css"
|
||||
html_class: "h-100"
|
||||
body_class: "d-flex flex-column h-100"
|
||||
include_js: false
|
||||
---
|
||||
|
||||
<!-- Begin page content -->
|
||||
<main class="flex-shrink-0">
|
||||
<div class="container">
|
||||
<h1 class="mt-5">Sticky footer</h1>
|
||||
<p class="lead">Pin a footer to the bottom of the viewport in desktop browsers with this custom HTML and CSS.</p>
|
||||
<p>Use <a href="{{< docsref "/examples/sticky-footer-navbar" >}}">the sticky footer with a fixed navbar</a> if need be, too.</p>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="footer mt-auto py-3 bg-light">
|
||||
<div class="container">
|
||||
<span class="text-muted">Place sticky footer content here.</span>
|
||||
</div>
|
||||
</footer>
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Icons
|
||||
description: Guidance and suggestions for using external icon libraries with Bootstrap.
|
||||
group: extend
|
||||
---
|
||||
|
||||
While Bootstrap doesn't include an icon set by default, we do have our own comprehensive icon library called Bootstrap Icons. Feel free to use them or any other icon set in your project. We've included details for Bootstrap Icons and other preferred icon sets below.
|
||||
|
||||
While most icon sets include multiple file formats, we prefer SVG implementations for their improved accessibility and vector support.
|
||||
|
||||
## Bootstrap Icons
|
||||
|
||||
Bootstrap Icons is a growing library of SVG icons that are designed by [@mdo](https://github.com/mdo) and maintained by [the Bootstrap Team](https://github.com/orgs/twbs/people). The beginnings of this icon set come from Bootstrap's very own components—our forms, carousels, and more. Bootstrap has very few icon needs out of the box, so we didn't need much. However, once we got going, we couldn't stop making more.
|
||||
|
||||
Oh, and did we mention they're completely open source? Licensed under MIT, just like Bootstrap, our icon set is available to everyone.
|
||||
|
||||
[Learn more about Bootstrap Icons]({{< param icons >}}), including how to install them and recommended usage.
|
||||
|
||||
## Alternatives
|
||||
|
||||
We've tested and used these icon sets ourselves as preferred alternatives to Bootstrap Icons.
|
||||
|
||||
{{< markdown >}}
|
||||
{{< icons.inline >}}
|
||||
{{- $type := .Get "type" | default "preferred" -}}
|
||||
|
||||
{{- range (index .Site.Data.icons $type) }}
|
||||
- [{{ .name }}]({{ .website }})
|
||||
{{- end }}
|
||||
{{< /icons.inline >}}
|
||||
{{< /markdown >}}
|
||||
|
||||
## More options
|
||||
|
||||
While we haven't tried these out ourselves, they do look promising and provide multiple formats, including SVG.
|
||||
|
||||
{{< markdown >}}
|
||||
{{< icons.inline type="more" />}}
|
||||
{{< /markdown >}}
|
||||
|
|
@ -1,307 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Checks and radios
|
||||
description: Create consistent cross-browser and cross-device checkboxes and radios with our completely rewritten checks component.
|
||||
group: forms
|
||||
aliases: "/docs/5.2/forms/checks/"
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Approach
|
||||
|
||||
Browser default checkboxes and radios are replaced with the help of `.form-check`, a series of classes for both input types that improves the layout and behavior of their HTML elements, that provide greater customization and cross browser consistency. Checkboxes are for selecting one or several options in a list, while radios are for selecting one option from many.
|
||||
|
||||
Structurally, our `<input>`s and `<label>`s are sibling elements as opposed to an `<input>` within a `<label>`. This is slightly more verbose as you must specify `id` and `for` attributes to relate the `<input>` and `<label>`. We use the sibling selector (`~`) for all our `<input>` states, like `:checked` or `:disabled`. When combined with the `.form-check-label` class, we can easily style the text for each item based on the `<input>`'s state.
|
||||
|
||||
Our checks use custom Bootstrap icons to indicate checked or indeterminate states.
|
||||
|
||||
## Checks
|
||||
|
||||
{{< example >}}
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
|
||||
<label class="form-check-label" for="flexCheckDefault">
|
||||
Default checkbox
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="" id="flexCheckChecked" checked>
|
||||
<label class="form-check-label" for="flexCheckChecked">
|
||||
Checked checkbox
|
||||
</label>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Indeterminate
|
||||
|
||||
Checkboxes can utilize the `:indeterminate` pseudo class when manually set via JavaScript (there is no available HTML attribute for specifying it).
|
||||
|
||||
{{< example class="bd-example-indeterminate" stackblitz_add_js="true" >}}
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="" id="flexCheckIndeterminate">
|
||||
<label class="form-check-label" for="flexCheckIndeterminate">
|
||||
Indeterminate checkbox
|
||||
</label>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Disabled
|
||||
|
||||
Add the `disabled` attribute and the associated `<label>`s are automatically styled to match with a lighter color to help indicate the input's state.
|
||||
|
||||
{{< example class="bd-example-indeterminate" stackblitz_add_js="true" >}}
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="" id="flexCheckIndeterminateDisabled" disabled>
|
||||
<label class="form-check-label" for="flexCheckIndeterminateDisabled">
|
||||
Disabled indeterminate checkbox
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="" id="flexCheckDisabled" disabled>
|
||||
<label class="form-check-label" for="flexCheckDisabled">
|
||||
Disabled checkbox
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="" id="flexCheckCheckedDisabled" checked disabled>
|
||||
<label class="form-check-label" for="flexCheckCheckedDisabled">
|
||||
Disabled checked checkbox
|
||||
</label>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Radios
|
||||
|
||||
{{< example >}}
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="flexRadioDefault" id="flexRadioDefault1">
|
||||
<label class="form-check-label" for="flexRadioDefault1">
|
||||
Default radio
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="flexRadioDefault" id="flexRadioDefault2" checked>
|
||||
<label class="form-check-label" for="flexRadioDefault2">
|
||||
Default checked radio
|
||||
</label>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Disabled
|
||||
|
||||
Add the `disabled` attribute and the associated `<label>`s are automatically styled to match with a lighter color to help indicate the input's state.
|
||||
|
||||
{{< example >}}
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="flexRadioDisabled" id="flexRadioDisabled" disabled>
|
||||
<label class="form-check-label" for="flexRadioDisabled">
|
||||
Disabled radio
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="flexRadioDisabled" id="flexRadioCheckedDisabled" checked disabled>
|
||||
<label class="form-check-label" for="flexRadioCheckedDisabled">
|
||||
Disabled checked radio
|
||||
</label>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Switches
|
||||
|
||||
A switch has the markup of a custom checkbox but uses the `.form-switch` class to render a toggle switch. Consider using `role="switch"` to more accurately convey the nature of the control to assistive technologies that support this role. In older assistive technologies, it will simply be announced as a regular checkbox as a fallback. Switches also support the `disabled` attribute.
|
||||
|
||||
{{< example >}}
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="flexSwitchCheckDefault">
|
||||
<label class="form-check-label" for="flexSwitchCheckDefault">Default switch checkbox input</label>
|
||||
</div>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="flexSwitchCheckChecked" checked>
|
||||
<label class="form-check-label" for="flexSwitchCheckChecked">Checked switch checkbox input</label>
|
||||
</div>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="flexSwitchCheckDisabled" disabled>
|
||||
<label class="form-check-label" for="flexSwitchCheckDisabled">Disabled switch checkbox input</label>
|
||||
</div>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="flexSwitchCheckCheckedDisabled" checked disabled>
|
||||
<label class="form-check-label" for="flexSwitchCheckCheckedDisabled">Disabled checked switch checkbox input</label>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Default (stacked)
|
||||
|
||||
By default, any number of checkboxes and radios that are immediate sibling will be vertically stacked and appropriately spaced with `.form-check`.
|
||||
|
||||
{{< example >}}
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="" id="defaultCheck1">
|
||||
<label class="form-check-label" for="defaultCheck1">
|
||||
Default checkbox
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="" id="defaultCheck2" disabled>
|
||||
<label class="form-check-label" for="defaultCheck2">
|
||||
Disabled checkbox
|
||||
</label>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios1" value="option1" checked>
|
||||
<label class="form-check-label" for="exampleRadios1">
|
||||
Default radio
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios2" value="option2">
|
||||
<label class="form-check-label" for="exampleRadios2">
|
||||
Second default radio
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios3" value="option3" disabled>
|
||||
<label class="form-check-label" for="exampleRadios3">
|
||||
Disabled radio
|
||||
</label>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Inline
|
||||
|
||||
Group checkboxes or radios on the same horizontal row by adding `.form-check-inline` to any `.form-check`.
|
||||
|
||||
{{< example >}}
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option1">
|
||||
<label class="form-check-label" for="inlineCheckbox1">1</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" id="inlineCheckbox2" value="option2">
|
||||
<label class="form-check-label" for="inlineCheckbox2">2</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" id="inlineCheckbox3" value="option3" disabled>
|
||||
<label class="form-check-label" for="inlineCheckbox3">3 (disabled)</label>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
|
||||
<label class="form-check-label" for="inlineRadio1">1</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2">
|
||||
<label class="form-check-label" for="inlineRadio2">2</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3" disabled>
|
||||
<label class="form-check-label" for="inlineRadio3">3 (disabled)</label>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Reverse
|
||||
|
||||
Put your checkboxes, radios, and switches on the opposite side with the `.form-check-reverse` modifier class.
|
||||
|
||||
{{< example >}}
|
||||
<div class="form-check form-check-reverse">
|
||||
<input class="form-check-input" type="checkbox" value="" id="reverseCheck1">
|
||||
<label class="form-check-label" for="reverseCheck1">
|
||||
Reverse checkbox
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check form-check-reverse">
|
||||
<input class="form-check-input" type="checkbox" value="" id="reverseCheck2" disabled>
|
||||
<label class="form-check-label" for="reverseCheck2">
|
||||
Disabled reverse checkbox
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check form-switch form-check-reverse">
|
||||
<input class="form-check-input" type="checkbox" id="flexSwitchCheckReverse">
|
||||
<label class="form-check-label" for="flexSwitchCheckReverse">Reverse switch checkbox input</label>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Without labels
|
||||
|
||||
Omit the wrapping `.form-check` for checkboxes and radios that have no label text. Remember to still provide some form of accessible name for assistive technologies (for instance, using `aria-label`). See the [forms overview accessibility]({{< docsref "/forms/overview#accessibility" >}}) section for details.
|
||||
|
||||
{{< example >}}
|
||||
<div>
|
||||
<input class="form-check-input" type="checkbox" id="checkboxNoLabel" value="" aria-label="...">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<input class="form-check-input" type="radio" name="radioNoLabel" id="radioNoLabel1" value="" aria-label="...">
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Toggle buttons
|
||||
|
||||
Create button-like checkboxes and radio buttons by using `.btn` styles rather than `.form-check-label` on the `<label>` elements. These toggle buttons can further be grouped in a [button group]({{< docsref "/components/button-group" >}}) if needed.
|
||||
|
||||
### Checkbox toggle buttons
|
||||
|
||||
{{< example >}}
|
||||
<input type="checkbox" class="btn-check" id="btn-check" autocomplete="off">
|
||||
<label class="btn btn-primary" for="btn-check">Single toggle</label>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<input type="checkbox" class="btn-check" id="btn-check-2" checked autocomplete="off">
|
||||
<label class="btn btn-primary" for="btn-check-2">Checked</label>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<input type="checkbox" class="btn-check" id="btn-check-3" autocomplete="off" disabled>
|
||||
<label class="btn btn-primary" for="btn-check-3">Disabled</label>
|
||||
{{< /example >}}
|
||||
|
||||
{{< callout info >}}
|
||||
Visually, these checkbox toggle buttons are identical to the [button plugin toggle buttons]({{< docsref "/components/buttons#button-plugin" >}}). However, they are conveyed differently by assistive technologies: the checkbox toggles will be announced by screen readers as "checked"/"not checked" (since, despite their appearance, they are fundamentally still checkboxes), whereas the button plugin toggle buttons will be announced as "button"/"button pressed". The choice between these two approaches will depend on the type of toggle you are creating, and whether or not the toggle will make sense to users when announced as a checkbox or as an actual button.
|
||||
{{< /callout >}}
|
||||
|
||||
### Radio toggle buttons
|
||||
|
||||
{{< example >}}
|
||||
<input type="radio" class="btn-check" name="options" id="option1" autocomplete="off" checked>
|
||||
<label class="btn btn-secondary" for="option1">Checked</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="options" id="option2" autocomplete="off">
|
||||
<label class="btn btn-secondary" for="option2">Radio</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="options" id="option3" autocomplete="off" disabled>
|
||||
<label class="btn btn-secondary" for="option3">Disabled</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="options" id="option4" autocomplete="off">
|
||||
<label class="btn btn-secondary" for="option4">Radio</label>
|
||||
{{< /example >}}
|
||||
|
||||
### Outlined styles
|
||||
|
||||
Different variants of `.btn`, such at the various outlined styles, are supported.
|
||||
|
||||
{{< example >}}
|
||||
<input type="checkbox" class="btn-check" id="btn-check-outlined" autocomplete="off">
|
||||
<label class="btn btn-outline-primary" for="btn-check-outlined">Single toggle</label><br>
|
||||
|
||||
<input type="checkbox" class="btn-check" id="btn-check-2-outlined" checked autocomplete="off">
|
||||
<label class="btn btn-outline-secondary" for="btn-check-2-outlined">Checked</label><br>
|
||||
|
||||
<input type="radio" class="btn-check" name="options-outlined" id="success-outlined" autocomplete="off" checked>
|
||||
<label class="btn btn-outline-success" for="success-outlined">Checked success radio</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="options-outlined" id="danger-outlined" autocomplete="off">
|
||||
<label class="btn btn-outline-danger" for="danger-outlined">Danger radio</label>
|
||||
{{< /example >}}
|
||||
|
||||
## Sass
|
||||
|
||||
### Variables
|
||||
|
||||
{{< scss-docs name="form-check-variables" file="scss/_variables.scss" >}}
|
||||
|
|
@ -1,152 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Floating labels
|
||||
description: Create beautifully simple form labels that float over your input fields.
|
||||
group: forms
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Example
|
||||
|
||||
Wrap a pair of `<input class="form-control">` and `<label>` elements in `.form-floating` to enable floating labels with Bootstrap's textual form fields. A `placeholder` is required on each `<input>` as our method of CSS-only floating labels uses the `:placeholder-shown` pseudo-element. Also note that the `<input>` must come first so we can utilize a sibling selector (e.g., `~`).
|
||||
|
||||
{{< example >}}
|
||||
<div class="form-floating mb-3">
|
||||
<input type="email" class="form-control" id="floatingInput" placeholder="name@example.com">
|
||||
<label for="floatingInput">Email address</label>
|
||||
</div>
|
||||
<div class="form-floating">
|
||||
<input type="password" class="form-control" id="floatingPassword" placeholder="Password">
|
||||
<label for="floatingPassword">Password</label>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
When there's a `value` already defined, `<label>`s will automatically adjust to their floated position.
|
||||
|
||||
{{< example >}}
|
||||
<form class="form-floating">
|
||||
<input type="email" class="form-control" id="floatingInputValue" placeholder="name@example.com" value="test@example.com">
|
||||
<label for="floatingInputValue">Input with value</label>
|
||||
</form>
|
||||
{{< /example >}}
|
||||
|
||||
Form validation styles also work as expected.
|
||||
|
||||
{{< example >}}
|
||||
<form class="form-floating">
|
||||
<input type="email" class="form-control is-invalid" id="floatingInputInvalid" placeholder="name@example.com" value="test@example.com">
|
||||
<label for="floatingInputInvalid">Invalid input</label>
|
||||
</form>
|
||||
{{< /example >}}
|
||||
|
||||
## Textareas
|
||||
|
||||
By default, `<textarea>`s with `.form-control` will be the same height as `<input>`s.
|
||||
|
||||
{{< example >}}
|
||||
<div class="form-floating">
|
||||
<textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea"></textarea>
|
||||
<label for="floatingTextarea">Comments</label>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
To set a custom height on your `<textarea>`, do not use the `rows` attribute. Instead, set an explicit `height` (either inline or via custom CSS).
|
||||
|
||||
{{< example >}}
|
||||
<div class="form-floating">
|
||||
<textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea2" style="height: 100px"></textarea>
|
||||
<label for="floatingTextarea2">Comments</label>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Selects
|
||||
|
||||
Other than `.form-control`, floating labels are only available on `.form-select`s. They work in the same way, but unlike `<input>`s, they'll always show the `<label>` in its floated state. **Selects with `size` and `multiple` are not supported.**
|
||||
|
||||
{{< example >}}
|
||||
<div class="form-floating">
|
||||
<select class="form-select" id="floatingSelect" aria-label="Floating label select example">
|
||||
<option selected>Open this select menu</option>
|
||||
<option value="1">One</option>
|
||||
<option value="2">Two</option>
|
||||
<option value="3">Three</option>
|
||||
</select>
|
||||
<label for="floatingSelect">Works with selects</label>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Readonly plaintext
|
||||
|
||||
Floating labels also support `.form-control-plaintext`, which can be helpful for toggling from an editable `<input>` to a plaintext value without affecting the page layout.
|
||||
|
||||
{{< example >}}
|
||||
<div class="form-floating mb-3">
|
||||
<input type="email" readonly class="form-control-plaintext" id="floatingEmptyPlaintextInput" placeholder="name@example.com">
|
||||
<label for="floatingEmptyPlaintextInput">Empty input</label>
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
<input type="email" readonly class="form-control-plaintext" id="floatingPlaintextInput" placeholder="name@example.com" value="name@example.com">
|
||||
<label for="floatingPlaintextInput">Input with value</label>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Input groups
|
||||
|
||||
Floating labels also support `.input-group`.
|
||||
|
||||
{{< example >}}
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text">@</span>
|
||||
<div class="form-floating">
|
||||
<input type="text" class="form-control" id="floatingInputGroup1" placeholder="Username">
|
||||
<label for="floatingInputGroup1">Username</label>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
When using `.input-group` and `.form-floating` along with form validation, the `-feedback` should be placed outside of the `.form-floating`, but inside of the `.input-group`. This means that the feedback will need to be shown using javascript.
|
||||
|
||||
{{< example >}}
|
||||
<div class="input-group has-validation">
|
||||
<span class="input-group-text">@</span>
|
||||
<div class="form-floating is-invalid">
|
||||
<input type="text" class="form-control is-invalid" id="floatingInputGroup2" placeholder="Username" required>
|
||||
<label for="floatingInputGroup2">Username</label>
|
||||
</div>
|
||||
<div class="invalid-feedback">
|
||||
Please choose a username.
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Layout
|
||||
|
||||
When working with the Bootstrap grid system, be sure to place form elements within column classes.
|
||||
|
||||
{{< example >}}
|
||||
<div class="row g-2">
|
||||
<div class="col-md">
|
||||
<div class="form-floating">
|
||||
<input type="email" class="form-control" id="floatingInputGrid" placeholder="name@example.com" value="mdo@example.com">
|
||||
<label for="floatingInputGrid">Email address</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<div class="form-floating">
|
||||
<select class="form-select" id="floatingSelectGrid">
|
||||
<option selected>Open this select menu</option>
|
||||
<option value="1">One</option>
|
||||
<option value="2">Two</option>
|
||||
<option value="3">Three</option>
|
||||
</select>
|
||||
<label for="floatingSelectGrid">Works with selects</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Sass
|
||||
|
||||
### Variables
|
||||
|
||||
{{< scss-docs name="form-floating-variables" file="scss/_variables.scss" >}}
|
||||
|
|
@ -1,152 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Form controls
|
||||
description: Give textual form controls like `<input>`s and `<textarea>`s an upgrade with custom styles, sizing, focus states, and more.
|
||||
group: forms
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Example
|
||||
|
||||
{{< example >}}
|
||||
<div class="mb-3">
|
||||
<label for="exampleFormControlInput1" class="form-label">Email address</label>
|
||||
<input type="email" class="form-control" id="exampleFormControlInput1" placeholder="name@example.com">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="exampleFormControlTextarea1" class="form-label">Example textarea</label>
|
||||
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Sizing
|
||||
|
||||
Set heights using classes like `.form-control-lg` and `.form-control-sm`.
|
||||
|
||||
{{< example >}}
|
||||
<input class="form-control form-control-lg" type="text" placeholder=".form-control-lg" aria-label=".form-control-lg example">
|
||||
<input class="form-control" type="text" placeholder="Default input" aria-label="default input example">
|
||||
<input class="form-control form-control-sm" type="text" placeholder=".form-control-sm" aria-label=".form-control-sm example">
|
||||
{{< /example >}}
|
||||
|
||||
## Disabled
|
||||
|
||||
Add the `disabled` boolean attribute on an input to give it a grayed out appearance, remove pointer events, and prevent focusing.
|
||||
|
||||
{{< example >}}
|
||||
<input class="form-control" type="text" placeholder="Disabled input" aria-label="Disabled input example" disabled>
|
||||
<input class="form-control" type="text" value="Disabled readonly input" aria-label="Disabled input example" disabled readonly>
|
||||
{{< /example >}}
|
||||
|
||||
## Readonly
|
||||
|
||||
Add the `readonly` boolean attribute on an input to prevent modification of the input's value. `readonly` inputs can still be focused and selected, while `disabled` inputs cannot.
|
||||
|
||||
{{< example >}}
|
||||
<input class="form-control" type="text" value="Readonly input here..." aria-label="readonly input example" readonly>
|
||||
{{< /example >}}
|
||||
|
||||
## Readonly plain text
|
||||
|
||||
If you want to have `<input readonly>` elements in your form styled as plain text, replace `.form-control` with `.form-control-plaintext` to remove the default form field styling and preserve the correct `margin` and `padding`.
|
||||
|
||||
{{< example >}}
|
||||
<div class="mb-3 row">
|
||||
<label for="staticEmail" class="col-sm-2 col-form-label">Email</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" readonly class="form-control-plaintext" id="staticEmail" value="email@example.com">
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3 row">
|
||||
<label for="inputPassword" class="col-sm-2 col-form-label">Password</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="password" class="form-control" id="inputPassword">
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<form class="row g-3">
|
||||
<div class="col-auto">
|
||||
<label for="staticEmail2" class="visually-hidden">Email</label>
|
||||
<input type="text" readonly class="form-control-plaintext" id="staticEmail2" value="email@example.com">
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label for="inputPassword2" class="visually-hidden">Password</label>
|
||||
<input type="password" class="form-control" id="inputPassword2" placeholder="Password">
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button type="submit" class="btn btn-primary mb-3">Confirm identity</button>
|
||||
</div>
|
||||
</form>
|
||||
{{< /example >}}
|
||||
|
||||
## File input
|
||||
|
||||
{{< example >}}
|
||||
<div class="mb-3">
|
||||
<label for="formFile" class="form-label">Default file input example</label>
|
||||
<input class="form-control" type="file" id="formFile">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="formFileMultiple" class="form-label">Multiple files input example</label>
|
||||
<input class="form-control" type="file" id="formFileMultiple" multiple>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="formFileDisabled" class="form-label">Disabled file input example</label>
|
||||
<input class="form-control" type="file" id="formFileDisabled" disabled>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="formFileSm" class="form-label">Small file input example</label>
|
||||
<input class="form-control form-control-sm" id="formFileSm" type="file">
|
||||
</div>
|
||||
<div>
|
||||
<label for="formFileLg" class="form-label">Large file input example</label>
|
||||
<input class="form-control form-control-lg" id="formFileLg" type="file">
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Color
|
||||
|
||||
Set the `type="color"` and add `.form-control-color` to the `<input>`. We use the modifier class to set fixed `height`s and override some inconsistencies between browsers.
|
||||
|
||||
{{< example >}}
|
||||
<label for="exampleColorInput" class="form-label">Color picker</label>
|
||||
<input type="color" class="form-control form-control-color" id="exampleColorInput" value="#563d7c" title="Choose your color">
|
||||
{{< /example >}}
|
||||
|
||||
## Datalists
|
||||
|
||||
Datalists allow you to create a group of `<option>`s that can be accessed (and autocompleted) from within an `<input>`. These are similar to `<select>` elements, but come with more menu styling limitations and differences. While most browsers and operating systems include some support for `<datalist>` elements, their styling is inconsistent at best.
|
||||
|
||||
Learn more about [support for datalist elements](https://caniuse.com/datalist).
|
||||
|
||||
{{< example >}}
|
||||
<label for="exampleDataList" class="form-label">Datalist example</label>
|
||||
<input class="form-control" list="datalistOptions" id="exampleDataList" placeholder="Type to search...">
|
||||
<datalist id="datalistOptions">
|
||||
<option value="San Francisco">
|
||||
<option value="New York">
|
||||
<option value="Seattle">
|
||||
<option value="Los Angeles">
|
||||
<option value="Chicago">
|
||||
</datalist>
|
||||
{{< /example >}}
|
||||
|
||||
## Sass
|
||||
|
||||
### Variables
|
||||
|
||||
`$input-*` are shared across most of our form controls (and not buttons).
|
||||
|
||||
{{< scss-docs name="form-input-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
`$form-label-*` and `$form-text-*` are for our `<label>`s and `.form-text` component.
|
||||
|
||||
{{< scss-docs name="form-label-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
{{< scss-docs name="form-text-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
`$form-file-*` are for file input.
|
||||
|
||||
{{< scss-docs name="form-file-variables" file="scss/_variables.scss" >}}
|
||||
|
|
@ -1,316 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Input group
|
||||
description: Easily extend form controls by adding text, buttons, or button groups on either side of textual inputs, custom selects, and custom file inputs.
|
||||
group: forms
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Basic example
|
||||
|
||||
Place one add-on or button on either side of an input. You may also place one on both sides of an input. Remember to place `<label>`s outside the input group.
|
||||
|
||||
{{< example >}}
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="basic-addon1">@</span>
|
||||
<input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="basic-addon2">
|
||||
<span class="input-group-text" id="basic-addon2">@example.com</span>
|
||||
</div>
|
||||
|
||||
<label for="basic-url" class="form-label">Your vanity URL</label>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="basic-addon3">https://example.com/users/</span>
|
||||
<input type="text" class="form-control" id="basic-url" aria-describedby="basic-addon3">
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text">$</span>
|
||||
<input type="text" class="form-control" aria-label="Amount (to the nearest dollar)">
|
||||
<span class="input-group-text">.00</span>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control" placeholder="Username" aria-label="Username">
|
||||
<span class="input-group-text">@</span>
|
||||
<input type="text" class="form-control" placeholder="Server" aria-label="Server">
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">With textarea</span>
|
||||
<textarea class="form-control" aria-label="With textarea"></textarea>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Wrapping
|
||||
|
||||
Input groups wrap by default via `flex-wrap: wrap` in order to accommodate custom form field validation within an input group. You may disable this with `.flex-nowrap`.
|
||||
|
||||
{{< example >}}
|
||||
<div class="input-group flex-nowrap">
|
||||
<span class="input-group-text" id="addon-wrapping">@</span>
|
||||
<input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="addon-wrapping">
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Sizing
|
||||
|
||||
Add the relative form sizing classes to the `.input-group` itself and contents within will automatically resize—no need for repeating the form control size classes on each element.
|
||||
|
||||
**Sizing on the individual input group elements isn't supported.**
|
||||
|
||||
{{< example >}}
|
||||
<div class="input-group input-group-sm mb-3">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm">Small</span>
|
||||
<input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-sm">
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="inputGroup-sizing-default">Default</span>
|
||||
<input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-default">
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-lg">
|
||||
<span class="input-group-text" id="inputGroup-sizing-lg">Large</span>
|
||||
<input type="text" class="form-control" aria-label="Sizing example input" aria-describedby="inputGroup-sizing-lg">
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Checkboxes and radios
|
||||
|
||||
Place any checkbox or radio option within an input group's addon instead of text. We recommend adding `.mt-0` to the `.form-check-input` when there's no visible text next to the input.
|
||||
|
||||
{{< example >}}
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-text">
|
||||
<input class="form-check-input mt-0" type="checkbox" value="" aria-label="Checkbox for following text input">
|
||||
</div>
|
||||
<input type="text" class="form-control" aria-label="Text input with checkbox">
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<div class="input-group-text">
|
||||
<input class="form-check-input mt-0" type="radio" value="" aria-label="Radio button for following text input">
|
||||
</div>
|
||||
<input type="text" class="form-control" aria-label="Text input with radio button">
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Multiple inputs
|
||||
|
||||
While multiple `<input>`s are supported visually, validation styles are only available for input groups with a single `<input>`.
|
||||
|
||||
{{< example >}}
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">First and last name</span>
|
||||
<input type="text" aria-label="First name" class="form-control">
|
||||
<input type="text" aria-label="Last name" class="form-control">
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Multiple addons
|
||||
|
||||
Multiple add-ons are supported and can be mixed with checkbox and radio input versions.
|
||||
|
||||
{{< example >}}
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text">$</span>
|
||||
<span class="input-group-text">0.00</span>
|
||||
<input type="text" class="form-control" aria-label="Dollar amount (with dot and two decimal places)">
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" aria-label="Dollar amount (with dot and two decimal places)">
|
||||
<span class="input-group-text">$</span>
|
||||
<span class="input-group-text">0.00</span>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Button addons
|
||||
|
||||
{{< example >}}
|
||||
<div class="input-group mb-3">
|
||||
<button class="btn btn-outline-secondary" type="button" id="button-addon1">Button</button>
|
||||
<input type="text" class="form-control" placeholder="" aria-label="Example text with button addon" aria-describedby="button-addon1">
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="button-addon2">
|
||||
<button class="btn btn-outline-secondary" type="button" id="button-addon2">Button</button>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<button class="btn btn-outline-secondary" type="button">Button</button>
|
||||
<button class="btn btn-outline-secondary" type="button">Button</button>
|
||||
<input type="text" class="form-control" placeholder="" aria-label="Example text with two button addons">
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username with two button addons">
|
||||
<button class="btn btn-outline-secondary" type="button">Button</button>
|
||||
<button class="btn btn-outline-secondary" type="button">Button</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Buttons with dropdowns
|
||||
|
||||
{{< example >}}
|
||||
<div class="input-group mb-3">
|
||||
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="#">Separated link</a></li>
|
||||
</ul>
|
||||
<input type="text" class="form-control" aria-label="Text input with dropdown button">
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control" aria-label="Text input with dropdown button">
|
||||
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="#">Separated link</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="#">Action before</a></li>
|
||||
<li><a class="dropdown-item" href="#">Another action before</a></li>
|
||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="#">Separated link</a></li>
|
||||
</ul>
|
||||
<input type="text" class="form-control" aria-label="Text input with 2 dropdown buttons">
|
||||
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="#">Separated link</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Segmented buttons
|
||||
|
||||
{{< example >}}
|
||||
<div class="input-group mb-3">
|
||||
<button type="button" class="btn btn-outline-secondary">Action</button>
|
||||
<button type="button" class="btn btn-outline-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<span class="visually-hidden">Toggle Dropdown</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="#">Separated link</a></li>
|
||||
</ul>
|
||||
<input type="text" class="form-control" aria-label="Text input with segmented dropdown button">
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" aria-label="Text input with segmented dropdown button">
|
||||
<button type="button" class="btn btn-outline-secondary">Action</button>
|
||||
<button type="button" class="btn btn-outline-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<span class="visually-hidden">Toggle Dropdown</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="#">Separated link</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Custom forms
|
||||
|
||||
Input groups include support for custom selects and custom file inputs. Browser default versions of these are not supported.
|
||||
|
||||
### Custom select
|
||||
|
||||
{{< example >}}
|
||||
<div class="input-group mb-3">
|
||||
<label class="input-group-text" for="inputGroupSelect01">Options</label>
|
||||
<select class="form-select" id="inputGroupSelect01">
|
||||
<option selected>Choose...</option>
|
||||
<option value="1">One</option>
|
||||
<option value="2">Two</option>
|
||||
<option value="3">Three</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<select class="form-select" id="inputGroupSelect02">
|
||||
<option selected>Choose...</option>
|
||||
<option value="1">One</option>
|
||||
<option value="2">Two</option>
|
||||
<option value="3">Three</option>
|
||||
</select>
|
||||
<label class="input-group-text" for="inputGroupSelect02">Options</label>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<button class="btn btn-outline-secondary" type="button">Button</button>
|
||||
<select class="form-select" id="inputGroupSelect03" aria-label="Example select with button addon">
|
||||
<option selected>Choose...</option>
|
||||
<option value="1">One</option>
|
||||
<option value="2">Two</option>
|
||||
<option value="3">Three</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<select class="form-select" id="inputGroupSelect04" aria-label="Example select with button addon">
|
||||
<option selected>Choose...</option>
|
||||
<option value="1">One</option>
|
||||
<option value="2">Two</option>
|
||||
<option value="3">Three</option>
|
||||
</select>
|
||||
<button class="btn btn-outline-secondary" type="button">Button</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Custom file input
|
||||
|
||||
{{< example >}}
|
||||
<div class="input-group mb-3">
|
||||
<label class="input-group-text" for="inputGroupFile01">Upload</label>
|
||||
<input type="file" class="form-control" id="inputGroupFile01">
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<input type="file" class="form-control" id="inputGroupFile02">
|
||||
<label class="input-group-text" for="inputGroupFile02">Upload</label>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<button class="btn btn-outline-secondary" type="button" id="inputGroupFileAddon03">Button</button>
|
||||
<input type="file" class="form-control" id="inputGroupFile03" aria-describedby="inputGroupFileAddon03" aria-label="Upload">
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<input type="file" class="form-control" id="inputGroupFile04" aria-describedby="inputGroupFileAddon04" aria-label="Upload">
|
||||
<button class="btn btn-outline-secondary" type="button" id="inputGroupFileAddon04">Button</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Sass
|
||||
|
||||
### Variables
|
||||
|
||||
{{< scss-docs name="input-group-variables" file="scss/_variables.scss" >}}
|
||||
|
|
@ -1,329 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Layout
|
||||
description: Give your forms some structure—from inline to horizontal to custom grid implementations—with our form layout options.
|
||||
group: forms
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Forms
|
||||
|
||||
Every group of form fields should reside in a `<form>` element. Bootstrap provides no default styling for the `<form>` element, but there are some powerful browser features that are provided by default.
|
||||
|
||||
- New to browser forms? Consider reviewing [the MDN form docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) for an overview and complete list of available attributes.
|
||||
- `<button>`s within a `<form>` default to `type="submit"`, so strive to be specific and always include a `type`.
|
||||
|
||||
Since Bootstrap applies `display: block` and `width: 100%` to almost all our form controls, forms will by default stack vertically. Additional classes can be used to vary this layout on a per-form basis.
|
||||
|
||||
## Utilities
|
||||
|
||||
[Margin utilities]({{< docsref "/utilities/spacing" >}}) are the easiest way to add some structure to forms. They provide basic grouping of labels, controls, optional form text, and form validation messaging. We recommend sticking to `margin-bottom` utilities, and using a single direction throughout the form for consistency.
|
||||
|
||||
Feel free to build your forms however you like, with `<fieldset>`s, `<div>`s, or nearly any other element.
|
||||
|
||||
{{< example >}}
|
||||
<div class="mb-3">
|
||||
<label for="formGroupExampleInput" class="form-label">Example label</label>
|
||||
<input type="text" class="form-control" id="formGroupExampleInput" placeholder="Example input placeholder">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="formGroupExampleInput2" class="form-label">Another label</label>
|
||||
<input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Another input placeholder">
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Form grid
|
||||
|
||||
More complex forms can be built using our grid classes. Use these for form layouts that require multiple columns, varied widths, and additional alignment options. **Requires the `$enable-grid-classes` Sass variable to be enabled** (on by default).
|
||||
|
||||
{{< example >}}
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<input type="text" class="form-control" placeholder="First name" aria-label="First name">
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="text" class="form-control" placeholder="Last name" aria-label="Last name">
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Gutters
|
||||
|
||||
By adding [gutter modifier classes]({{< docsref "/layout/gutters" >}}), you can have control over the gutter width in as well the inline as block direction. **Also requires the `$enable-grid-classes` Sass variable to be enabled** (on by default).
|
||||
|
||||
{{< example >}}
|
||||
<div class="row g-3">
|
||||
<div class="col">
|
||||
<input type="text" class="form-control" placeholder="First name" aria-label="First name">
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="text" class="form-control" placeholder="Last name" aria-label="Last name">
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
More complex layouts can also be created with the grid system.
|
||||
|
||||
{{< example >}}
|
||||
<form class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label for="inputEmail4" class="form-label">Email</label>
|
||||
<input type="email" class="form-control" id="inputEmail4">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="inputPassword4" class="form-label">Password</label>
|
||||
<input type="password" class="form-control" id="inputPassword4">
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label for="inputAddress" class="form-label">Address</label>
|
||||
<input type="text" class="form-control" id="inputAddress" placeholder="1234 Main St">
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label for="inputAddress2" class="form-label">Address 2</label>
|
||||
<input type="text" class="form-control" id="inputAddress2" placeholder="Apartment, studio, or floor">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="inputCity" class="form-label">City</label>
|
||||
<input type="text" class="form-control" id="inputCity">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="inputState" class="form-label">State</label>
|
||||
<select id="inputState" class="form-select">
|
||||
<option selected>Choose...</option>
|
||||
<option>...</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label for="inputZip" class="form-label">Zip</label>
|
||||
<input type="text" class="form-control" id="inputZip">
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="gridCheck">
|
||||
<label class="form-check-label" for="gridCheck">
|
||||
Check me out
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<button type="submit" class="btn btn-primary">Sign in</button>
|
||||
</div>
|
||||
</form>
|
||||
{{< /example >}}
|
||||
|
||||
## Horizontal form
|
||||
|
||||
Create horizontal forms with the grid by adding the `.row` class to form groups and using the `.col-*-*` classes to specify the width of your labels and controls. Be sure to add `.col-form-label` to your `<label>`s as well so they're vertically centered with their associated form controls.
|
||||
|
||||
At times, you maybe need to use margin or padding utilities to create that perfect alignment you need. For example, we've removed the `padding-top` on our stacked radio inputs label to better align the text baseline.
|
||||
|
||||
{{< example >}}
|
||||
<form>
|
||||
<div class="row mb-3">
|
||||
<label for="inputEmail3" class="col-sm-2 col-form-label">Email</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="email" class="form-control" id="inputEmail3">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="inputPassword3" class="col-sm-2 col-form-label">Password</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="password" class="form-control" id="inputPassword3">
|
||||
</div>
|
||||
</div>
|
||||
<fieldset class="row mb-3">
|
||||
<legend class="col-form-label col-sm-2 pt-0">Radios</legend>
|
||||
<div class="col-sm-10">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="gridRadios" id="gridRadios1" value="option1" checked>
|
||||
<label class="form-check-label" for="gridRadios1">
|
||||
First radio
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="gridRadios" id="gridRadios2" value="option2">
|
||||
<label class="form-check-label" for="gridRadios2">
|
||||
Second radio
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check disabled">
|
||||
<input class="form-check-input" type="radio" name="gridRadios" id="gridRadios3" value="option3" disabled>
|
||||
<label class="form-check-label" for="gridRadios3">
|
||||
Third disabled radio
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-10 offset-sm-2">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="gridCheck1">
|
||||
<label class="form-check-label" for="gridCheck1">
|
||||
Example checkbox
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Sign in</button>
|
||||
</form>
|
||||
{{< /example >}}
|
||||
|
||||
### Horizontal form label sizing
|
||||
|
||||
Be sure to use `.col-form-label-sm` or `.col-form-label-lg` to your `<label>`s or `<legend>`s to correctly follow the size of `.form-control-lg` and `.form-control-sm`.
|
||||
|
||||
{{< example >}}
|
||||
<div class="row mb-3">
|
||||
<label for="colFormLabelSm" class="col-sm-2 col-form-label col-form-label-sm">Email</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="email" class="form-control form-control-sm" id="colFormLabelSm" placeholder="col-form-label-sm">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="colFormLabel" class="col-sm-2 col-form-label">Email</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="email" class="form-control" id="colFormLabel" placeholder="col-form-label">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label for="colFormLabelLg" class="col-sm-2 col-form-label col-form-label-lg">Email</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="email" class="form-control form-control-lg" id="colFormLabelLg" placeholder="col-form-label-lg">
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Column sizing
|
||||
|
||||
As shown in the previous examples, our grid system allows you to place any number of `.col`s within a `.row`. They'll split the available width equally between them. You may also pick a subset of your columns to take up more or less space, while the remaining `.col`s equally split the rest, with specific column classes like `.col-sm-7`.
|
||||
|
||||
{{< example >}}
|
||||
<div class="row g-3">
|
||||
<div class="col-sm-7">
|
||||
<input type="text" class="form-control" placeholder="City" aria-label="City">
|
||||
</div>
|
||||
<div class="col-sm">
|
||||
<input type="text" class="form-control" placeholder="State" aria-label="State">
|
||||
</div>
|
||||
<div class="col-sm">
|
||||
<input type="text" class="form-control" placeholder="Zip" aria-label="Zip">
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Auto-sizing
|
||||
|
||||
The example below uses a flexbox utility to vertically center the contents and changes `.col` to `.col-auto` so that your columns only take up as much space as needed. Put another way, the column sizes itself based on the contents.
|
||||
|
||||
{{< example >}}
|
||||
<form class="row gy-2 gx-3 align-items-center">
|
||||
<div class="col-auto">
|
||||
<label class="visually-hidden" for="autoSizingInput">Name</label>
|
||||
<input type="text" class="form-control" id="autoSizingInput" placeholder="Jane Doe">
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label class="visually-hidden" for="autoSizingInputGroup">Username</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-text">@</div>
|
||||
<input type="text" class="form-control" id="autoSizingInputGroup" placeholder="Username">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label class="visually-hidden" for="autoSizingSelect">Preference</label>
|
||||
<select class="form-select" id="autoSizingSelect">
|
||||
<option selected>Choose...</option>
|
||||
<option value="1">One</option>
|
||||
<option value="2">Two</option>
|
||||
<option value="3">Three</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="autoSizingCheck">
|
||||
<label class="form-check-label" for="autoSizingCheck">
|
||||
Remember me
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
{{< /example >}}
|
||||
|
||||
You can then remix that once again with size-specific column classes.
|
||||
|
||||
{{< example >}}
|
||||
<form class="row gx-3 gy-2 align-items-center">
|
||||
<div class="col-sm-3">
|
||||
<label class="visually-hidden" for="specificSizeInputName">Name</label>
|
||||
<input type="text" class="form-control" id="specificSizeInputName" placeholder="Jane Doe">
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="visually-hidden" for="specificSizeInputGroupUsername">Username</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-text">@</div>
|
||||
<input type="text" class="form-control" id="specificSizeInputGroupUsername" placeholder="Username">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<label class="visually-hidden" for="specificSizeSelect">Preference</label>
|
||||
<select class="form-select" id="specificSizeSelect">
|
||||
<option selected>Choose...</option>
|
||||
<option value="1">One</option>
|
||||
<option value="2">Two</option>
|
||||
<option value="3">Three</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="autoSizingCheck2">
|
||||
<label class="form-check-label" for="autoSizingCheck2">
|
||||
Remember me
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
{{< /example >}}
|
||||
|
||||
## Inline forms
|
||||
|
||||
Use the `.row-cols-*` classes to create responsive horizontal layouts. By adding [gutter modifier classes]({{< docsref "/layout/gutters" >}}), we'll have gutters in horizontal and vertical directions. On narrow mobile viewports, the `.col-12` helps stack the form controls and more. The `.align-items-center` aligns the form elements to the middle, making the `.form-check` align properly.
|
||||
|
||||
{{< example >}}
|
||||
<form class="row row-cols-lg-auto g-3 align-items-center">
|
||||
<div class="col-12">
|
||||
<label class="visually-hidden" for="inlineFormInputGroupUsername">Username</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-text">@</div>
|
||||
<input type="text" class="form-control" id="inlineFormInputGroupUsername" placeholder="Username">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<label class="visually-hidden" for="inlineFormSelectPref">Preference</label>
|
||||
<select class="form-select" id="inlineFormSelectPref">
|
||||
<option selected>Choose...</option>
|
||||
<option value="1">One</option>
|
||||
<option value="2">Two</option>
|
||||
<option value="3">Three</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="inlineFormCheck">
|
||||
<label class="form-check-label" for="inlineFormCheck">
|
||||
Remember me
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
{{< /example >}}
|
||||
|
|
@ -1,154 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Forms
|
||||
description: Examples and usage guidelines for form control styles, layout options, and custom components for creating a wide variety of forms.
|
||||
group: forms
|
||||
toc: true
|
||||
aliases: "/docs/5.2/forms/"
|
||||
sections:
|
||||
- title: Form control
|
||||
description: Style textual inputs and textareas with support for multiple states.
|
||||
- title: Select
|
||||
description: Improve browser default select elements with a custom initial appearance.
|
||||
- title: Checks & radios
|
||||
description: Use our custom radio buttons and checkboxes in forms for selecting input options.
|
||||
- title: Range
|
||||
description: Replace browser default range inputs with our custom version.
|
||||
- title: Input group
|
||||
description: Attach labels and buttons to your inputs for increased semantic value.
|
||||
- title: Floating labels
|
||||
description: Create beautifully simple form labels that float over your input fields.
|
||||
- title: Layout
|
||||
description: Create inline, horizontal, or complex grid-based layouts with your forms.
|
||||
- title: Validation
|
||||
description: Validate your forms with custom or native validation behaviors and styles.
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
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.
|
||||
|
||||
{{< example >}}
|
||||
<form>
|
||||
<div class="mb-3">
|
||||
<label for="exampleInputEmail1" class="form-label">Email address</label>
|
||||
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
|
||||
<div id="emailHelp" class="form-text">We'll never share your email with anyone else.</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="exampleInputPassword1" class="form-label">Password</label>
|
||||
<input type="password" class="form-control" id="exampleInputPassword1">
|
||||
</div>
|
||||
<div class="mb-3 form-check">
|
||||
<input type="checkbox" class="form-check-input" id="exampleCheck1">
|
||||
<label class="form-check-label" for="exampleCheck1">Check me out</label>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
||||
{{< /example >}}
|
||||
|
||||
## Form text
|
||||
|
||||
Block-level or inline-level form text can be created using `.form-text`.
|
||||
|
||||
{{< callout warning >}}
|
||||
##### Associating form text with form controls
|
||||
|
||||
Form text should be explicitly associated with the form control it relates to using the `aria-describedby` attribute. This will ensure that assistive technologies—such as screen readers—will announce this form text when the user focuses or enters the control.
|
||||
{{< /callout >}}
|
||||
|
||||
Form text below inputs can be styled with `.form-text`. If a block-level element will be used, a top margin is added for easy spacing from the inputs above.
|
||||
|
||||
{{< example >}}
|
||||
<label for="inputPassword5" class="form-label">Password</label>
|
||||
<input type="password" id="inputPassword5" class="form-control" aria-describedby="passwordHelpBlock">
|
||||
<div id="passwordHelpBlock" class="form-text">
|
||||
Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji.
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Inline text can use any typical inline HTML element (be it a `<span>`, `<small>`, or something else) with nothing more than the `.form-text` class.
|
||||
|
||||
{{< example >}}
|
||||
<div class="row g-3 align-items-center">
|
||||
<div class="col-auto">
|
||||
<label for="inputPassword6" class="col-form-label">Password</label>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<input type="password" id="inputPassword6" class="form-control" aria-describedby="passwordHelpInline">
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<span id="passwordHelpInline" class="form-text">
|
||||
Must be 8-20 characters long.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Disabled forms
|
||||
|
||||
Add the `disabled` boolean attribute on an input to prevent user interactions and make it appear lighter.
|
||||
|
||||
```html
|
||||
<input class="form-control" id="disabledInput" type="text" placeholder="Disabled input here..." disabled>
|
||||
```
|
||||
|
||||
Add the `disabled` attribute to a `<fieldset>` to disable all the controls within. Browsers treat all native form controls (`<input>`, `<select>`, and `<button>` elements) inside a `<fieldset disabled>` as disabled, preventing both keyboard and mouse interactions on them.
|
||||
|
||||
However, if your form also includes custom button-like elements such as `<a class="btn btn-*">...</a>`, these will only be given a style of `pointer-events: none`, meaning they are still focusable and operable using the keyboard. In this case, you must manually modify these controls by adding `tabindex="-1"` to prevent them from receiving focus and `aria-disabled="disabled"` to signal their state to assistive technologies.
|
||||
|
||||
{{< example >}}
|
||||
<form>
|
||||
<fieldset disabled>
|
||||
<legend>Disabled fieldset example</legend>
|
||||
<div class="mb-3">
|
||||
<label for="disabledTextInput" class="form-label">Disabled input</label>
|
||||
<input type="text" id="disabledTextInput" class="form-control" placeholder="Disabled input">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="disabledSelect" class="form-label">Disabled select menu</label>
|
||||
<select id="disabledSelect" class="form-select">
|
||||
<option>Disabled select</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="disabledFieldsetCheck" disabled>
|
||||
<label class="form-check-label" for="disabledFieldsetCheck">
|
||||
Can't check this
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
{{< /example >}}
|
||||
|
||||
## Accessibility
|
||||
|
||||
Ensure that all form controls have an appropriate accessible name so that their purpose can be conveyed to users of assistive technologies. The simplest way to achieve this is to use a `<label>` element, or—in the case of buttons—to include sufficiently descriptive text as part of the `<button>...</button>` content.
|
||||
|
||||
For situations where it's not possible to include a visible `<label>` or appropriate text content, there are alternative ways of still providing an accessible name, such as:
|
||||
|
||||
- `<label>` elements hidden using the `.visually-hidden` class
|
||||
- Pointing to an existing element that can act as a label using `aria-labelledby`
|
||||
- Providing a `title` attribute
|
||||
- Explicitly setting the accessible name on an element using `aria-label`
|
||||
|
||||
If none of these are present, assistive technologies may resort to using the `placeholder` attribute as a fallback for the accessible name on `<input>` and `<textarea>` elements. The examples in this section provide a few suggested, case-specific approaches.
|
||||
|
||||
While using visually hidden content (`.visually-hidden`, `aria-label`, and even `placeholder` content, which disappears once a form field has content) will benefit assistive technology users, a lack of visible label text may still be problematic for certain users. Some form of visible label is generally the best approach, both for accessibility and usability.
|
||||
|
||||
## Sass
|
||||
|
||||
Many form variables are set at a general level to be re-used and extended by individual form components. You'll see these most often as `$input-btn-*` and `$input-*` variables.
|
||||
|
||||
### Variables
|
||||
|
||||
`$input-btn-*` variables are shared global variables between our [buttons]({{< docsref "/components/buttons" >}}) and our form components. You'll find these frequently reassigned as values to other component-specific variables.
|
||||
|
||||
{{< scss-docs name="input-btn-variables" file="scss/_variables.scss" >}}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Range
|
||||
description: Use our custom range inputs for consistent cross-browser styling and built-in customization.
|
||||
group: forms
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Create custom `<input type="range">` controls with `.form-range`. The track (the background) and thumb (the value) are both styled to appear the same across browsers. As only Firefox supports "filling" their track from the left or right of the thumb as a means to visually indicate progress, we do not currently support it.
|
||||
|
||||
{{< example >}}
|
||||
<label for="customRange1" class="form-label">Example range</label>
|
||||
<input type="range" class="form-range" id="customRange1">
|
||||
{{< /example >}}
|
||||
|
||||
## Disabled
|
||||
|
||||
Add the `disabled` boolean attribute on an input to give it a grayed out appearance, remove pointer events, and prevent focusing.
|
||||
|
||||
{{< example >}}
|
||||
<label for="disabledRange" class="form-label">Disabled range</label>
|
||||
<input type="range" class="form-range" id="disabledRange" disabled>
|
||||
{{< /example >}}
|
||||
|
||||
## Min and max
|
||||
|
||||
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.
|
||||
|
||||
{{< example >}}
|
||||
<label for="customRange2" class="form-label">Example range</label>
|
||||
<input type="range" class="form-range" min="0" max="5" id="customRange2">
|
||||
{{< /example >}}
|
||||
|
||||
## Steps
|
||||
|
||||
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"`.
|
||||
|
||||
{{< example >}}
|
||||
<label for="customRange3" class="form-label">Example range</label>
|
||||
<input type="range" class="form-range" min="0" max="5" step="0.5" id="customRange3">
|
||||
{{< /example >}}
|
||||
|
||||
## Sass
|
||||
|
||||
### Variables
|
||||
|
||||
{{< scss-docs name="form-range-variables" file="scss/_variables.scss" >}}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Select
|
||||
description: Customize the native `<select>`s with custom CSS that changes the element's initial appearance.
|
||||
group: forms
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Default
|
||||
|
||||
Custom `<select>` menus need only a custom class, `.form-select` to trigger the custom styles. Custom styles are limited to the `<select>`'s initial appearance and cannot modify the `<option>`s due to browser limitations.
|
||||
|
||||
{{< example >}}
|
||||
<select class="form-select" aria-label="Default select example">
|
||||
<option selected>Open this select menu</option>
|
||||
<option value="1">One</option>
|
||||
<option value="2">Two</option>
|
||||
<option value="3">Three</option>
|
||||
</select>
|
||||
{{< /example >}}
|
||||
|
||||
## Sizing
|
||||
|
||||
You may also choose from small and large custom selects to match our similarly sized text inputs.
|
||||
|
||||
{{< example >}}
|
||||
<select class="form-select form-select-lg mb-3" aria-label=".form-select-lg example">
|
||||
<option selected>Open this select menu</option>
|
||||
<option value="1">One</option>
|
||||
<option value="2">Two</option>
|
||||
<option value="3">Three</option>
|
||||
</select>
|
||||
|
||||
<select class="form-select form-select-sm" aria-label=".form-select-sm example">
|
||||
<option selected>Open this select menu</option>
|
||||
<option value="1">One</option>
|
||||
<option value="2">Two</option>
|
||||
<option value="3">Three</option>
|
||||
</select>
|
||||
{{< /example >}}
|
||||
|
||||
The `multiple` attribute is also supported:
|
||||
|
||||
{{< example >}}
|
||||
<select class="form-select" multiple aria-label="multiple select example">
|
||||
<option selected>Open this select menu</option>
|
||||
<option value="1">One</option>
|
||||
<option value="2">Two</option>
|
||||
<option value="3">Three</option>
|
||||
</select>
|
||||
{{< /example >}}
|
||||
|
||||
As is the `size` attribute:
|
||||
|
||||
{{< example >}}
|
||||
<select class="form-select" size="3" aria-label="size 3 select example">
|
||||
<option selected>Open this select menu</option>
|
||||
<option value="1">One</option>
|
||||
<option value="2">Two</option>
|
||||
<option value="3">Three</option>
|
||||
</select>
|
||||
{{< /example >}}
|
||||
|
||||
## Disabled
|
||||
|
||||
Add the `disabled` boolean attribute on a select to give it a grayed out appearance and remove pointer events.
|
||||
|
||||
{{< example >}}
|
||||
<select class="form-select" aria-label="Disabled select example" disabled>
|
||||
<option selected>Open this select menu</option>
|
||||
<option value="1">One</option>
|
||||
<option value="2">Two</option>
|
||||
<option value="3">Three</option>
|
||||
</select>
|
||||
{{< /example >}}
|
||||
|
||||
## Sass
|
||||
|
||||
### Variables
|
||||
|
||||
{{< scss-docs name="form-select-variables" file="scss/_variables.scss" >}}
|
||||
|
|
@ -1,380 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Validation
|
||||
description: Provide valuable, actionable feedback to your users with HTML5 form validation, via browser default behaviors or custom styles and JavaScript.
|
||||
group: forms
|
||||
toc: true
|
||||
extra_js:
|
||||
- src: "/docs/5.2/assets/js/validate-forms.js"
|
||||
async: true
|
||||
---
|
||||
|
||||
{{< callout warning >}}
|
||||
We are aware that currently the client-side custom validation styles and tooltips are not accessible, since they are not exposed to assistive technologies. While we work on a solution, we'd recommend either using the server-side option or the default browser validation method.
|
||||
{{< /callout >}}
|
||||
|
||||
## How it works
|
||||
|
||||
Here's how form validation works with Bootstrap:
|
||||
|
||||
- HTML form validation is applied via CSS's two pseudo-classes, `:invalid` and `:valid`. It applies to `<input>`, `<select>`, and `<textarea>` elements.
|
||||
- Bootstrap scopes the `:invalid` and `:valid` styles to parent `.was-validated` class, usually applied to the `<form>`. Otherwise, any required field without a value shows up as invalid on page load. This way, you may choose when to activate them (typically after form submission is attempted).
|
||||
- To reset the appearance of the form (for instance, in the case of dynamic form submissions using AJAX), remove the `.was-validated` class from the `<form>` again after submission.
|
||||
- As a fallback, `.is-invalid` and `.is-valid` classes may be used instead of the pseudo-classes for [server-side validation](#server-side). They do not require a `.was-validated` parent class.
|
||||
- Due to constraints in how CSS works, we cannot (at present) apply styles to a `<label>` that comes before a form control in the DOM without the help of custom JavaScript.
|
||||
- All modern browsers support the [constraint validation API](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#the-constraint-validation-api), a series of JavaScript methods for validating form controls.
|
||||
- Feedback messages may utilize the [browser defaults](#browser-defaults) (different for each browser, and unstylable via CSS) or our custom feedback styles with additional HTML and CSS.
|
||||
- You may provide custom validity messages with `setCustomValidity` in JavaScript.
|
||||
|
||||
With that in mind, consider the following demos for our custom form validation styles, optional server-side classes, and browser defaults.
|
||||
|
||||
## Custom styles
|
||||
|
||||
For custom Bootstrap form validation messages, you'll need to add the `novalidate` boolean attribute to your `<form>`. This disables the browser default feedback tooltips, but still provides access to the form validation APIs in JavaScript. Try to submit the form below; our JavaScript will intercept the submit button and relay feedback to you. When attempting to submit, you'll see the `:invalid` and `:valid` styles applied to your form controls.
|
||||
|
||||
Custom feedback styles apply custom colors, borders, focus styles, and background icons to better communicate feedback. Background icons for `<select>`s are only available with `.form-select`, and not `.form-control`.
|
||||
|
||||
{{< example >}}
|
||||
<form class="row g-3 needs-validation" novalidate>
|
||||
<div class="col-md-4">
|
||||
<label for="validationCustom01" class="form-label">First name</label>
|
||||
<input type="text" class="form-control" id="validationCustom01" value="Mark" required>
|
||||
<div class="valid-feedback">
|
||||
Looks good!
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="validationCustom02" class="form-label">Last name</label>
|
||||
<input type="text" class="form-control" id="validationCustom02" value="Otto" required>
|
||||
<div class="valid-feedback">
|
||||
Looks good!
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="validationCustomUsername" class="form-label">Username</label>
|
||||
<div class="input-group has-validation">
|
||||
<span class="input-group-text" id="inputGroupPrepend">@</span>
|
||||
<input type="text" class="form-control" id="validationCustomUsername" aria-describedby="inputGroupPrepend" required>
|
||||
<div class="invalid-feedback">
|
||||
Please choose a username.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="validationCustom03" class="form-label">City</label>
|
||||
<input type="text" class="form-control" id="validationCustom03" required>
|
||||
<div class="invalid-feedback">
|
||||
Please provide a valid city.
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label for="validationCustom04" class="form-label">State</label>
|
||||
<select class="form-select" id="validationCustom04" required>
|
||||
<option selected disabled value="">Choose...</option>
|
||||
<option>...</option>
|
||||
</select>
|
||||
<div class="invalid-feedback">
|
||||
Please select a valid state.
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label for="validationCustom05" class="form-label">Zip</label>
|
||||
<input type="text" class="form-control" id="validationCustom05" required>
|
||||
<div class="invalid-feedback">
|
||||
Please provide a valid zip.
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="" id="invalidCheck" required>
|
||||
<label class="form-check-label" for="invalidCheck">
|
||||
Agree to terms and conditions
|
||||
</label>
|
||||
<div class="invalid-feedback">
|
||||
You must agree before submitting.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<button class="btn btn-primary" type="submit">Submit form</button>
|
||||
</div>
|
||||
</form>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example lang="js" show_preview="false" >}}
|
||||
{{< js.inline >}}
|
||||
{{- readFile (path.Join "site/static/docs" .Site.Params.docs_version "assets/js/validate-forms.js") -}}
|
||||
{{< /js.inline >}}
|
||||
{{< /example >}}
|
||||
|
||||
## Browser defaults
|
||||
|
||||
Not interested in custom validation feedback messages or writing JavaScript to change form behaviors? All good, you can use the browser defaults. Try submitting the form below. Depending on your browser and OS, you'll see a slightly different style of feedback.
|
||||
|
||||
While these feedback styles cannot be styled with CSS, you can still customize the feedback text through JavaScript.
|
||||
|
||||
{{< example >}}
|
||||
<form class="row g-3">
|
||||
<div class="col-md-4">
|
||||
<label for="validationDefault01" class="form-label">First name</label>
|
||||
<input type="text" class="form-control" id="validationDefault01" value="Mark" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="validationDefault02" class="form-label">Last name</label>
|
||||
<input type="text" class="form-control" id="validationDefault02" value="Otto" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="validationDefaultUsername" class="form-label">Username</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text" id="inputGroupPrepend2">@</span>
|
||||
<input type="text" class="form-control" id="validationDefaultUsername" aria-describedby="inputGroupPrepend2" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="validationDefault03" class="form-label">City</label>
|
||||
<input type="text" class="form-control" id="validationDefault03" required>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label for="validationDefault04" class="form-label">State</label>
|
||||
<select class="form-select" id="validationDefault04" required>
|
||||
<option selected disabled value="">Choose...</option>
|
||||
<option>...</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label for="validationDefault05" class="form-label">Zip</label>
|
||||
<input type="text" class="form-control" id="validationDefault05" required>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="" id="invalidCheck2" required>
|
||||
<label class="form-check-label" for="invalidCheck2">
|
||||
Agree to terms and conditions
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<button class="btn btn-primary" type="submit">Submit form</button>
|
||||
</div>
|
||||
</form>
|
||||
{{< /example >}}
|
||||
|
||||
## Server side
|
||||
|
||||
We recommend using client-side validation, but in case you require server-side validation, you can indicate invalid and valid form fields with `.is-invalid` and `.is-valid`. Note that `.invalid-feedback` is also supported with these classes.
|
||||
|
||||
For invalid fields, ensure that the invalid feedback/error message is associated with the relevant form field using `aria-describedby` (noting that this attribute allows more than one `id` to be referenced, in case the field already points to additional form text).
|
||||
|
||||
To fix [issues with border radius](https://github.com/twbs/bootstrap/issues/25110), input groups require an additional `.has-validation` class.
|
||||
|
||||
{{< example >}}
|
||||
<form class="row g-3">
|
||||
<div class="col-md-4">
|
||||
<label for="validationServer01" class="form-label">First name</label>
|
||||
<input type="text" class="form-control is-valid" id="validationServer01" value="Mark" required>
|
||||
<div class="valid-feedback">
|
||||
Looks good!
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="validationServer02" class="form-label">Last name</label>
|
||||
<input type="text" class="form-control is-valid" id="validationServer02" value="Otto" required>
|
||||
<div class="valid-feedback">
|
||||
Looks good!
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="validationServerUsername" class="form-label">Username</label>
|
||||
<div class="input-group has-validation">
|
||||
<span class="input-group-text" id="inputGroupPrepend3">@</span>
|
||||
<input type="text" class="form-control is-invalid" id="validationServerUsername" aria-describedby="inputGroupPrepend3 validationServerUsernameFeedback" required>
|
||||
<div id="validationServerUsernameFeedback" class="invalid-feedback">
|
||||
Please choose a username.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="validationServer03" class="form-label">City</label>
|
||||
<input type="text" class="form-control is-invalid" id="validationServer03" aria-describedby="validationServer03Feedback" required>
|
||||
<div id="validationServer03Feedback" class="invalid-feedback">
|
||||
Please provide a valid city.
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label for="validationServer04" class="form-label">State</label>
|
||||
<select class="form-select is-invalid" id="validationServer04" aria-describedby="validationServer04Feedback" required>
|
||||
<option selected disabled value="">Choose...</option>
|
||||
<option>...</option>
|
||||
</select>
|
||||
<div id="validationServer04Feedback" class="invalid-feedback">
|
||||
Please select a valid state.
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label for="validationServer05" class="form-label">Zip</label>
|
||||
<input type="text" class="form-control is-invalid" id="validationServer05" aria-describedby="validationServer05Feedback" required>
|
||||
<div id="validationServer05Feedback" class="invalid-feedback">
|
||||
Please provide a valid zip.
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input is-invalid" type="checkbox" value="" id="invalidCheck3" aria-describedby="invalidCheck3Feedback" required>
|
||||
<label class="form-check-label" for="invalidCheck3">
|
||||
Agree to terms and conditions
|
||||
</label>
|
||||
<div id="invalidCheck3Feedback" class="invalid-feedback">
|
||||
You must agree before submitting.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<button class="btn btn-primary" type="submit">Submit form</button>
|
||||
</div>
|
||||
</form>
|
||||
{{< /example >}}
|
||||
|
||||
## Supported elements
|
||||
|
||||
Validation styles are available for the following form controls and components:
|
||||
|
||||
- `<input>`s and `<textarea>`s with `.form-control` (including up to one `.form-control` in input groups)
|
||||
- `<select>`s with `.form-select`
|
||||
- `.form-check`s
|
||||
|
||||
{{< example >}}
|
||||
<form class="was-validated">
|
||||
<div class="mb-3">
|
||||
<label for="validationTextarea" class="form-label">Textarea</label>
|
||||
<textarea class="form-control" id="validationTextarea" placeholder="Required example textarea" required></textarea>
|
||||
<div class="invalid-feedback">
|
||||
Please enter a message in the textarea.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
<input type="checkbox" class="form-check-input" id="validationFormCheck1" required>
|
||||
<label class="form-check-label" for="validationFormCheck1">Check this checkbox</label>
|
||||
<div class="invalid-feedback">Example invalid feedback text</div>
|
||||
</div>
|
||||
|
||||
<div class="form-check">
|
||||
<input type="radio" class="form-check-input" id="validationFormCheck2" name="radio-stacked" required>
|
||||
<label class="form-check-label" for="validationFormCheck2">Toggle this radio</label>
|
||||
</div>
|
||||
<div class="form-check mb-3">
|
||||
<input type="radio" class="form-check-input" id="validationFormCheck3" name="radio-stacked" required>
|
||||
<label class="form-check-label" for="validationFormCheck3">Or toggle this other radio</label>
|
||||
<div class="invalid-feedback">More example invalid feedback text</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<select class="form-select" required aria-label="select example">
|
||||
<option value="">Open this select menu</option>
|
||||
<option value="1">One</option>
|
||||
<option value="2">Two</option>
|
||||
<option value="3">Three</option>
|
||||
</select>
|
||||
<div class="invalid-feedback">Example invalid select feedback</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<input type="file" class="form-control" aria-label="file example" required>
|
||||
<div class="invalid-feedback">Example invalid form file feedback</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<button class="btn btn-primary" type="submit" disabled>Submit form</button>
|
||||
</div>
|
||||
</form>
|
||||
{{< /example >}}
|
||||
|
||||
## Tooltips
|
||||
|
||||
If your form layout allows it, you can swap the `.{valid|invalid}-feedback` classes for `.{valid|invalid}-tooltip` classes to display validation feedback in a styled tooltip. Be sure to have a parent with `position: relative` on it for tooltip positioning. In the example below, our column classes have this already, but your project may require an alternative setup.
|
||||
|
||||
{{< example >}}
|
||||
<form class="row g-3 needs-validation" novalidate>
|
||||
<div class="col-md-4 position-relative">
|
||||
<label for="validationTooltip01" class="form-label">First name</label>
|
||||
<input type="text" class="form-control" id="validationTooltip01" value="Mark" required>
|
||||
<div class="valid-tooltip">
|
||||
Looks good!
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 position-relative">
|
||||
<label for="validationTooltip02" class="form-label">Last name</label>
|
||||
<input type="text" class="form-control" id="validationTooltip02" value="Otto" required>
|
||||
<div class="valid-tooltip">
|
||||
Looks good!
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 position-relative">
|
||||
<label for="validationTooltipUsername" class="form-label">Username</label>
|
||||
<div class="input-group has-validation">
|
||||
<span class="input-group-text" id="validationTooltipUsernamePrepend">@</span>
|
||||
<input type="text" class="form-control" id="validationTooltipUsername" aria-describedby="validationTooltipUsernamePrepend" required>
|
||||
<div class="invalid-tooltip">
|
||||
Please choose a unique and valid username.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 position-relative">
|
||||
<label for="validationTooltip03" class="form-label">City</label>
|
||||
<input type="text" class="form-control" id="validationTooltip03" required>
|
||||
<div class="invalid-tooltip">
|
||||
Please provide a valid city.
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3 position-relative">
|
||||
<label for="validationTooltip04" class="form-label">State</label>
|
||||
<select class="form-select" id="validationTooltip04" required>
|
||||
<option selected disabled value="">Choose...</option>
|
||||
<option>...</option>
|
||||
</select>
|
||||
<div class="invalid-tooltip">
|
||||
Please select a valid state.
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3 position-relative">
|
||||
<label for="validationTooltip05" class="form-label">Zip</label>
|
||||
<input type="text" class="form-control" id="validationTooltip05" required>
|
||||
<div class="invalid-tooltip">
|
||||
Please provide a valid zip.
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<button class="btn btn-primary" type="submit">Submit form</button>
|
||||
</div>
|
||||
</form>
|
||||
{{< /example >}}
|
||||
|
||||
## Sass
|
||||
|
||||
### Variables
|
||||
|
||||
{{< scss-docs name="form-feedback-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
### Mixins
|
||||
|
||||
Two mixins are combined together, through our [loop](#loop), to generate our form validation feedback styles.
|
||||
|
||||
{{< scss-docs name="form-validation-mixins" file="scss/mixins/_forms.scss" >}}
|
||||
|
||||
### Map
|
||||
|
||||
This is the validation Sass map from `_variables.scss`. Override or extend this to generate different or additional states.
|
||||
|
||||
{{< scss-docs name="form-validation-states" file="scss/_variables.scss" >}}
|
||||
|
||||
Maps of `$form-validation-states` can contain three optional parameters to override tooltips and focus styles.
|
||||
|
||||
### Loop
|
||||
|
||||
Used to iterate over `$form-validation-states` map values to generate our validation styles. Any modifications to the above Sass map will be reflected in your compiled CSS via this loop.
|
||||
|
||||
{{< scss-docs name="form-validation-states-loop" file="scss/forms/_validation.scss" >}}
|
||||
|
||||
### Customizing
|
||||
|
||||
Validation states can be customized via Sass with the `$form-validation-states` map. Located in our `_variables.scss` file, this Sass map is how we generate the default `valid`/`invalid` validation states. Included is a nested map for customizing each state's color, icon, tooltip color, and focus shadow. While no other states are supported by browsers, those using custom styles can easily add more complex form feedback.
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Accessibility
|
||||
description: A brief overview of Bootstrap's features and limitations for the creation of accessible content.
|
||||
group: getting-started
|
||||
toc: true
|
||||
---
|
||||
|
||||
Bootstrap provides an easy-to-use framework of ready-made styles, layout tools, and interactive components, allowing developers to create websites and applications that are visually appealing, functionally rich, and accessible out of the box.
|
||||
|
||||
## Overview and limitations
|
||||
|
||||
The overall accessibility of any project built with Bootstrap depends in large part on the author's markup, additional styling, and scripting they've included. However, provided that these have been implemented correctly, it should be perfectly possible to create websites and applications with Bootstrap that fulfill [<abbr title="Web Content Accessibility Guidelines">WCAG</abbr> 2.1](https://www.w3.org/TR/WCAG/) (A/AA/AAA), [Section 508](https://www.section508.gov/), and similar accessibility standards and requirements.
|
||||
|
||||
### Structural markup
|
||||
|
||||
Bootstrap's styling and layout can be applied to a wide range of markup structures. This documentation aims to provide developers with best practice examples to demonstrate the use of Bootstrap itself and illustrate appropriate semantic markup, including ways in which potential accessibility concerns can be addressed.
|
||||
|
||||
### Interactive components
|
||||
|
||||
Bootstrap's interactive components—such as modal dialogs, dropdown menus, and custom tooltips—are designed to work for touch, mouse, and keyboard users. Through the use of relevant [<abbr title="Web Accessibility Initiative">WAI</abbr>-<abbr title="Accessible Rich Internet Applications">ARIA</abbr>](https://www.w3.org/WAI/standards-guidelines/aria/) roles and attributes, these components should also be understandable and operable using assistive technologies (such as screen readers).
|
||||
|
||||
Because Bootstrap's components are purposely designed to be fairly generic, authors may need to include further <abbr title="Accessible Rich Internet Applications">ARIA</abbr> roles and attributes, as well as JavaScript behavior, to more accurately convey the precise nature and functionality of their component. This is usually noted in the documentation.
|
||||
|
||||
### Color contrast
|
||||
|
||||
Some combinations of colors that currently make up Bootstrap's default palette—used throughout the framework for things such as button variations, alert variations, form validation indicators—may lead to *insufficient* color contrast (below the recommended [WCAG 2.1 text color contrast ratio of 4.5:1](https://www.w3.org/TR/WCAG/#contrast-minimum) and the [WCAG 2.1 non-text color contrast ratio of 3:1](https://www.w3.org/TR/WCAG/#non-text-contrast)), particularly when used against a light background. Authors are encouraged to test their specific uses of color and, where necessary, manually modify/extend these default colors to ensure adequate color contrast ratios.
|
||||
|
||||
### Visually hidden content
|
||||
|
||||
Content which should be visually hidden, but remain accessible to assistive technologies such as screen readers, can be styled using the `.visually-hidden` class. This can be useful in situations where additional visual information or cues (such as meaning denoted through the use of color) need to also be conveyed to non-visual users.
|
||||
|
||||
```html
|
||||
<p class="text-danger">
|
||||
<span class="visually-hidden">Danger: </span>
|
||||
This action is not reversible
|
||||
</p>
|
||||
```
|
||||
|
||||
For visually hidden interactive controls, such as traditional "skip" links, use the `.visually-hidden-focusable` class. This will ensure that the control becomes visible once focused (for sighted keyboard users). **Watch out, compared to the equivalent `.sr-only` and `.sr-only-focusable` classes in past versions, Bootstrap 5's `.visually-hidden-focusable` is a standalone class, and must not be used in combination with the `.visually-hidden` class.**
|
||||
|
||||
```html
|
||||
<a class="visually-hidden-focusable" href="#content">Skip to main content</a>
|
||||
```
|
||||
|
||||
### Reduced motion
|
||||
|
||||
Bootstrap includes support for the [`prefers-reduced-motion` media feature](https://www.w3.org/TR/mediaqueries-5/#prefers-reduced-motion). In browsers/environments that allow the user to specify their preference for reduced motion, most CSS transition effects in Bootstrap (for instance, when a modal dialog is opened or closed, or the sliding animation in carousels) will be disabled, and meaningful animations (such as spinners) will be slowed down.
|
||||
|
||||
On browsers that support `prefers-reduced-motion`, and where the user has *not* explicitly signaled that they'd prefer reduced motion (i.e. where `prefers-reduced-motion: no-preference`), Bootstrap enables smooth scrolling using the `scroll-behavior` property.
|
||||
|
||||
## Additional resources
|
||||
|
||||
- [Web Content Accessibility Guidelines (WCAG) 2.1](https://www.w3.org/TR/WCAG/)
|
||||
- [The A11Y Project](https://www.a11yproject.com/)
|
||||
- [MDN accessibility documentation](https://developer.mozilla.org/en-US/docs/Web/Accessibility)
|
||||
- [Tenon.io Accessibility Checker](https://tenon.io/)
|
||||
- [Color Contrast Analyser (CCA)](https://www.tpgi.com/color-contrast-checker/)
|
||||
- ["HTML Codesniffer" bookmarklet for identifying accessibility issues](https://github.com/squizlabs/HTML_CodeSniffer)
|
||||
- [Microsoft Accessibility Insights](https://accessibilityinsights.io/)
|
||||
- [Deque Axe testing tools](https://www.deque.com/axe/)
|
||||
- [Introduction to Web Accessibility](https://www.w3.org/WAI/fundamentals/accessibility-intro/)
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Best practices
|
||||
description: Learn about some of the best practices we've gathered from years of working on and using Bootstrap.
|
||||
group: getting-started
|
||||
---
|
||||
|
||||
We've designed and developed Bootstrap to work in a number of environments. Here are some of the best practices we've gathered from years of working on and using it ourselves.
|
||||
|
||||
{{< callout info >}}
|
||||
**Heads up!** This copy is a work in progress.
|
||||
{{< /callout >}}
|
||||
|
||||
### General outline
|
||||
|
||||
- Working with CSS
|
||||
- Working with Sass files
|
||||
- Building new CSS components
|
||||
- Working with flexbox
|
||||
- Ask in [our GitHub Discussions](https://github.com/twbs/bootstrap/discussions)
|
||||
|
|
@ -1,119 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Download
|
||||
description: Download Bootstrap to get the compiled CSS and JavaScript, source code, or include it with your favorite package managers like npm, RubyGems, and more.
|
||||
group: getting-started
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Compiled CSS and JS
|
||||
|
||||
Download ready-to-use compiled code for **Bootstrap v{{< param current_version >}}** to easily drop into your project, which includes:
|
||||
|
||||
- Compiled and minified CSS bundles (see [CSS files comparison]({{< docsref "/getting-started/contents#css-files" >}}))
|
||||
- Compiled and minified JavaScript plugins (see [JS files comparison]({{< docsref "/getting-started/contents#js-files" >}}))
|
||||
|
||||
This doesn't include documentation, source files, or any optional JavaScript dependencies like Popper.
|
||||
|
||||
<a href="{{< param "download.dist" >}}" class="btn btn-bd-primary" onclick="ga('send', 'event', 'Getting started', 'Download', 'Download Bootstrap');">Download</a>
|
||||
|
||||
## Source files
|
||||
|
||||
Compile Bootstrap with your own asset pipeline by downloading our source Sass, JavaScript, and documentation files. This option requires some additional tooling:
|
||||
|
||||
- [Sass compiler]({{< docsref "/getting-started/contribute#sass" >}}) for compiling Sass source files into CSS files
|
||||
- [Autoprefixer](https://github.com/postcss/autoprefixer) for CSS vendor prefixing
|
||||
|
||||
Should you require our full set of [build tools]({{< docsref "/getting-started/contribute#tooling-setup" >}}), they are included for developing Bootstrap and its docs, but they're likely unsuitable for your own purposes.
|
||||
|
||||
<a href="{{< param "download.source" >}}" class="btn btn-bd-primary" onclick="ga('send', 'event', 'Getting started', 'Download', 'Download source');">Download source</a>
|
||||
|
||||
## Examples
|
||||
|
||||
If you want to download and examine our [examples]({{< docsref "/examples" >}}), you can grab the already built examples:
|
||||
|
||||
<a href="{{< param "download.dist_examples" >}}" class="btn btn-bd-primary" onclick="ga('send', 'event', 'Getting started', 'Download', 'Download Examples');">Download Examples</a>
|
||||
|
||||
## CDN via jsDelivr
|
||||
|
||||
Skip the download with [jsDelivr](https://www.jsdelivr.com/) to deliver cached version of Bootstrap's compiled CSS and JS to your project.
|
||||
|
||||
```html
|
||||
<link href="{{< param "cdn.css" >}}" rel="stylesheet" integrity="{{< param "cdn.css_hash" >}}" crossorigin="anonymous">
|
||||
<script src="{{< param "cdn.js_bundle" >}}" integrity="{{< param "cdn.js_bundle_hash" >}}" crossorigin="anonymous"></script>
|
||||
```
|
||||
|
||||
If you're using our compiled JavaScript and prefer to include Popper separately, add Popper before our JS, via a CDN preferably.
|
||||
|
||||
```html
|
||||
<script src="{{< param "cdn.popper" >}}" integrity="{{< param "cdn.popper_hash" >}}" crossorigin="anonymous"></script>
|
||||
<script src="{{< param "cdn.js" >}}" integrity="{{< param "cdn.js_hash" >}}" crossorigin="anonymous"></script>
|
||||
```
|
||||
|
||||
## Package managers
|
||||
|
||||
Pull in Bootstrap's **source files** into nearly any project with some of the most popular package managers. No matter the package manager, Bootstrap will **require a [Sass compiler]({{< docsref "/getting-started/contribute#sass" >}}) and [Autoprefixer](https://github.com/postcss/autoprefixer)** for a setup that matches our official compiled versions.
|
||||
|
||||
### npm
|
||||
|
||||
Install Bootstrap in your Node.js powered apps with [the npm package](https://www.npmjs.com/package/bootstrap):
|
||||
|
||||
```sh
|
||||
npm install bootstrap@{{< param "current_version" >}}
|
||||
```
|
||||
|
||||
`const bootstrap = require('bootstrap')` or `import bootstrap from 'bootstrap'` will load all of Bootstrap's plugins onto a `bootstrap` object.
|
||||
The `bootstrap` module itself exports all of our plugins. You can manually load Bootstrap's plugins individually by loading the `/js/dist/*.js` files under the package's top-level directory.
|
||||
|
||||
Bootstrap's `package.json` contains some additional metadata under the following keys:
|
||||
|
||||
- `sass` - path to Bootstrap's main [Sass](https://sass-lang.com/) source file
|
||||
- `style` - path to Bootstrap's non-minified CSS that's been compiled using the default settings (no customization)
|
||||
|
||||
{{< callout info >}}
|
||||
{{< partial "callout-info-npm-starter.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
### yarn
|
||||
|
||||
Install Bootstrap in your Node.js powered apps with [the yarn package](https://yarnpkg.com/en/package/bootstrap):
|
||||
|
||||
```sh
|
||||
yarn add bootstrap@{{< param "current_version" >}}
|
||||
```
|
||||
|
||||
### RubyGems
|
||||
|
||||
Install Bootstrap in your Ruby apps using [Bundler](https://bundler.io/) (**recommended**) and [RubyGems](https://rubygems.org/) by adding the following line to your [`Gemfile`](https://bundler.io/gemfile.html):
|
||||
|
||||
```ruby
|
||||
gem 'bootstrap', '~> {{< param current_ruby_version >}}'
|
||||
```
|
||||
|
||||
Alternatively, if you're not using Bundler, you can install the gem by running this command:
|
||||
|
||||
```sh
|
||||
gem install bootstrap -v {{< param current_ruby_version >}}
|
||||
```
|
||||
|
||||
[See the gem's README](https://github.com/twbs/bootstrap-rubygem/blob/master/README.md) for further details.
|
||||
|
||||
### Composer
|
||||
|
||||
You can also install and manage Bootstrap's Sass and JavaScript using [Composer](https://getcomposer.org/):
|
||||
|
||||
```sh
|
||||
composer require twbs/bootstrap:{{< param current_version >}}
|
||||
```
|
||||
|
||||
### NuGet
|
||||
|
||||
If you develop in .NET Framework, you can also install and manage Bootstrap's [CSS](https://www.nuget.org/packages/bootstrap/) or [Sass](https://www.nuget.org/packages/bootstrap.sass/) and JavaScript using [NuGet](https://www.nuget.org/). Newer projects should use [libman](https://docs.microsoft.com/en-us/aspnet/core/client-side/libman/) or another method as NuGet is designed for compiled code, not frontend assets.
|
||||
|
||||
```powershell
|
||||
Install-Package bootstrap
|
||||
```
|
||||
|
||||
```powershell
|
||||
Install-Package bootstrap.sass
|
||||
```
|
||||
|
|
@ -1,159 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: "Bootstrap & Parcel"
|
||||
description: The official guide for how to include and bundle Bootstrap's CSS and JavaScript in your project using Parcel.
|
||||
group: getting-started
|
||||
toc: true
|
||||
thumbnail: guides/bootstrap-parcel@2x.png
|
||||
---
|
||||
|
||||
<img class="mb-4 img-fluid rounded-3" srcset="/docs/{{< param docs_version >}}/assets/img/guides/bootstrap-parcel.png, /docs/{{< param docs_version >}}/assets/img/guides/bootstrap-parcel@2x.png 2x" src="/docs/{{< param docs_version >}}/assets/img/guides/bootstrap-parcel.png" width="2000" height="1000" alt="">
|
||||
|
||||
{{< callout >}}
|
||||
**Want to skip to the end?** Download the source code and working demo for this guide from the [twbs/examples repository](https://github.com/twbs/examples/tree/main/parcel). You can also [open the example in StackBlitz](https://stackblitz.com/github/twbs/examples/tree/main/parcel?file=index.html) but not run it because Parcel isn't currently supported there.
|
||||
{{< /callout >}}
|
||||
|
||||
## Setup
|
||||
|
||||
We're building a Parcel project with Bootstrap from scratch, so there are some prerequisites and up front steps before we can really get started. This guide requires you to have Node.js installed and some familiarity with the terminal.
|
||||
|
||||
1. **Create a project folder and setup npm.** We'll create the `my-project` folder and initialize npm with the `-y` argument to avoid it asking us all the interactive questions.
|
||||
|
||||
```sh
|
||||
mkdir my-project && cd my-project
|
||||
npm init -y
|
||||
```
|
||||
|
||||
2. **Install Parcel.** Unlike our Webpack guide, there's only a single build tool dependency here. Parcel will automatically install language transformers (like Sass) as it detects them. We use `--save-dev` to signal that this dependency is only for development use and not for production.
|
||||
|
||||
```sh
|
||||
npm i --save-dev parcel
|
||||
```
|
||||
|
||||
3. **Install Bootstrap.** Now we can install Bootstrap. We'll also install Popper since our dropdowns, popovers, and tooltips depend on it for their positioning. If you don't plan on using those components, you can omit Popper here.
|
||||
|
||||
```sh
|
||||
npm i --save bootstrap @popperjs/core
|
||||
```
|
||||
|
||||
Now that we have all the necessary dependencies installed, we can get to work creating the project files and importing Bootstrap.
|
||||
|
||||
## Project structure
|
||||
|
||||
We've already created the `my-project` folder and initialized npm. Now we'll also create our `src` folder, stylesheet, and JavaScript file to round out the project structure. Run the following from `my-project`, or manually create the folder and file structure shown below.
|
||||
|
||||
```sh
|
||||
mkdir {src,src/js,src/scss}
|
||||
touch src/index.html src/js/main.js src/scss/styles.scss
|
||||
```
|
||||
|
||||
When you're done, your complete project should look like this:
|
||||
|
||||
```text
|
||||
my-project/
|
||||
├── src/
|
||||
│ ├── js/
|
||||
│ │ └── main.js
|
||||
│ ├── scss/
|
||||
│ │ └── styles.scss
|
||||
│ └── index.html
|
||||
├── package-lock.json
|
||||
└── package.json
|
||||
```
|
||||
|
||||
At this point, everything is in the right place, but Parcel needs an HTML page and npm script to start our server.
|
||||
|
||||
## Configure Parcel
|
||||
|
||||
With dependencies installed and our project folder ready for us to start coding, we can now configure Parcel and run our project locally. Parcel itself requires no configuration file by design, but we do need an npm script and an HTML file to start our server.
|
||||
|
||||
1. **Fill in the `src/index.html` file.** Parcel needs a page to render, so we use our `index.html` page to set up some basic HTML, including our CSS and JavaScript files.
|
||||
|
||||
```html
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Bootstrap w/ Parcel</title>
|
||||
<link rel="stylesheet" href="scss/styles.scss">
|
||||
<script type="module" src="js/main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container py-4 px-3 mx-auto">
|
||||
<h1>Hello, Bootstrap and Parcel!</h1>
|
||||
<button class="btn btn-primary">Primary button</button>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
We're including a little bit of Bootstrap styling here with the `div class="container"` and `<button>` so that we see when Bootstrap's CSS is loaded by Webpack.
|
||||
|
||||
Parcel will automatically detect we're using Sass and install the [Sass Parcel plugin](https://parceljs.org/languages/sass/) to support it. However, if you wish, you can also manually run `npm i --save-dev @parcel/transformer-sass`.
|
||||
|
||||
2. **Add the Parcel npm scripts.** Open the `package.json` and add the following `start` script to the `scripts` object. We'll use this script to start our Parcel development server and render the HTML file we created after it's compiled into the `dist` directory.
|
||||
|
||||
```json
|
||||
{
|
||||
// ...
|
||||
"scripts": {
|
||||
"start": "parcel serve src/index.html --public-url / --dist-dir dist",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
3. **And finally, we can start Parcel.** From the `my-project` folder in your terminal, run that newly added npm script:
|
||||
|
||||
```sh
|
||||
npm start
|
||||
```
|
||||
|
||||
<img class="img-fluid" src="/docs/{{< param docs_version >}}/assets/img/guides/parcel-dev-server.png" alt="Parcel dev server running">
|
||||
|
||||
In the next and final section to this guide, we'll import all of Bootstrap's CSS and JavaScript.
|
||||
|
||||
## Import Bootstrap
|
||||
|
||||
Importing Bootstrap into Parcel requires two imports, one into our `styles.scss` and one into our `main.js`.
|
||||
|
||||
1. **Import Bootstrap's CSS.** Add the following to `src/scss/styles.scss` to import all of Bootstrap's source Sass.
|
||||
|
||||
```scss
|
||||
// Import all of Bootstrap's CSS
|
||||
@import "~bootstrap/scss/bootstrap";
|
||||
```
|
||||
|
||||
*You can also import our stylesheets individually if you want. [Read our Sass import docs]({{< docsref "/customize/sass#importing" >}}) for details.*
|
||||
|
||||
2. **Import Bootstrap's JS.** Add the following to `src/js/main.js` to import all of Bootstrap's JS. Popper will be imported automatically through Bootstrap.
|
||||
|
||||
<!-- eslint-skip -->
|
||||
```js
|
||||
// Import all of Bootstrap's JS
|
||||
import * as bootstrap from 'bootstrap'
|
||||
```
|
||||
|
||||
You can also import JavaScript plugins individually as needed to keep bundle sizes down:
|
||||
|
||||
<!-- eslint-skip -->
|
||||
```js
|
||||
import Alert from 'bootstrap/js/dist/alert'
|
||||
|
||||
// or, specify which plugins you need:
|
||||
import { Tooltip, Toast, Popover } from 'bootstrap'
|
||||
```
|
||||
|
||||
*[Read our JavaScript docs]({{< docsref "/getting-started/javascript/" >}}) for more information on how to use Bootstrap's plugins.*
|
||||
|
||||
3. **And you're done! 🎉** With Bootstrap's source Sass and JS fully loaded, your local development server should now look like this.
|
||||
|
||||
<img class="img-fluid" src="/docs/{{< param docs_version >}}/assets/img/guides/parcel-dev-server-bootstrap.png" alt="Parcel dev server running with Bootstrap">
|
||||
|
||||
Now you can start adding any Bootstrap components you want to use. Be sure to [check out the complete Parcel example project](https://github.com/twbs/examples/tree/main/parcel) for how to include additional custom Sass and optimize your build by importing only the parts of Bootstrap's CSS and JS that you need.
|
||||
|
||||
{{< markdown >}}
|
||||
{{< partial "guide-footer.md" >}}
|
||||
{{< /markdown >}}
|
||||
|
|
@ -1,182 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: RTL
|
||||
description: Learn how to enable support for right-to-left text in Bootstrap across our layout, components, and utilities.
|
||||
group: getting-started
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Get familiar
|
||||
|
||||
We recommend getting familiar with Bootstrap first by reading through our [Getting Started Introduction page]({{< docsref "/getting-started/introduction" >}}). Once you've run through it, continue reading here for how to enable RTL.
|
||||
|
||||
You may also want to read up on [the RTLCSS project](https://rtlcss.com/), as it powers our approach to RTL.
|
||||
|
||||
{{< callout warning >}}
|
||||
### Experimental feature
|
||||
|
||||
The RTL feature is still **experimental** and will probably evolve according to user feedback. Spotted something or have an improvement to suggest? [Open an issue]({{< param repo >}}/issues/new/choose), we'd love to get your insights.
|
||||
{{< /callout >}}
|
||||
|
||||
## Required HTML
|
||||
|
||||
There are two strict requirements for enabling RTL in Bootstrap-powered pages.
|
||||
|
||||
1. Set `dir="rtl"` on the `<html>` element.
|
||||
2. Add an appropriate `lang` attribute, like `lang="ar"`, on the `<html>` element.
|
||||
|
||||
From there, you'll need to include an RTL version of our CSS. For example, here's the stylesheet for our compiled and minified CSS with RTL enabled:
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="{{< param "cdn.css_rtl" >}}" integrity="{{< param "cdn.css_rtl_hash" >}}" crossorigin="anonymous">
|
||||
```
|
||||
|
||||
### Starter template
|
||||
|
||||
You can see the above requirements reflected in this modified RTL starter template.
|
||||
|
||||
```html
|
||||
<!doctype html>
|
||||
<html lang="ar" dir="rtl">
|
||||
<head>
|
||||
<!-- Required meta tags -->
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<!-- Bootstrap CSS -->
|
||||
<link rel="stylesheet" href="{{< param "cdn.css_rtl" >}}" integrity="{{< param "cdn.css_rtl_hash" >}}" crossorigin="anonymous">
|
||||
|
||||
<title>مرحبًا بالعالم!</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>مرحبًا بالعالم!</h1>
|
||||
|
||||
<!-- Optional JavaScript; choose one of the two! -->
|
||||
|
||||
<!-- Option 1: Bootstrap Bundle with Popper -->
|
||||
<script src="{{< param "cdn.js_bundle" >}}" integrity="{{< param "cdn.js_bundle_hash" >}}" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Option 2: Separate Popper and Bootstrap JS -->
|
||||
<!--
|
||||
<script src="{{< param "cdn.popper" >}}" integrity="{{< param "cdn.popper_hash" >}}" crossorigin="anonymous"></script>
|
||||
<script src="{{< param "cdn.js" >}}" integrity="{{< param "cdn.js_hash" >}}" crossorigin="anonymous"></script>
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
### RTL examples
|
||||
|
||||
Get started with one of our several [RTL examples]({{< docsref "/examples/#rtl" >}}).
|
||||
|
||||
## Approach
|
||||
|
||||
Our approach to building RTL support into Bootstrap comes with two important decisions that impact how we write and use our CSS:
|
||||
|
||||
1. **First, we decided to build it with the [RTLCSS](https://rtlcss.com/) project.** This gives us some powerful features for managing changes and overrides when moving from LTR to RTL. It also allows us to build two versions of Bootstrap from one codebase.
|
||||
|
||||
2. **Second, we've renamed a handful of directional classes to adopt a logical properties approach.** Most of you have already interacted with logical properties thanks to our flex utilities—they replace direction properties like `left` and `right` in favor `start` and `end`. That makes the class names and values appropriate for LTR and RTL without any overhead.
|
||||
|
||||
For example, instead of `.ml-3` for `margin-left`, use `.ms-3`.
|
||||
|
||||
Working with RTL, through our source Sass or compiled CSS, shouldn't be much different from our default LTR though.
|
||||
|
||||
## Customize from source
|
||||
|
||||
When it comes to [customization]({{< docsref "/customize/sass" >}}), the preferred way is to take advantage of variables, maps, and mixins. This approach works the same for RTL, even if it's post-processed from the compiled files, thanks to [how RTLCSS works](https://rtlcss.com/learn/getting-started/why-rtlcss/).
|
||||
|
||||
### Custom RTL values
|
||||
|
||||
Using [RTLCSS value directives](https://rtlcss.com/learn/usage-guide/value-directives/), you can make a variable output a different value for RTL. For example, to decrease the weight for `$font-weight-bold` throughout the codebase, you may use the `/*rtl: {value}*/` syntax:
|
||||
|
||||
```scss
|
||||
$font-weight-bold: 700 #{/* rtl:600 */} !default;
|
||||
```
|
||||
|
||||
Which would output to the following for our default CSS and RTL CSS:
|
||||
|
||||
```css
|
||||
/* bootstrap.css */
|
||||
dt {
|
||||
font-weight: 700 /* rtl:600 */;
|
||||
}
|
||||
|
||||
/* bootstrap.rtl.css */
|
||||
dt {
|
||||
font-weight: 600;
|
||||
}
|
||||
```
|
||||
|
||||
### Alternative font stack
|
||||
|
||||
In the case you're using a custom font, be aware that not all fonts support the non-Latin alphabet. To switch from Pan-European to Arabic family, you may need to use `/*rtl:insert: {value}*/` in your font stack to modify the names of font families.
|
||||
|
||||
For example, to switch from `Helvetica Neue` font for LTR to `Helvetica Neue Arabic` for RTL, your Sass code could look like this:
|
||||
|
||||
```scss
|
||||
$font-family-sans-serif:
|
||||
Helvetica Neue #{"/* rtl:insert:Arabic */"},
|
||||
// Cross-platform generic font family (default user interface font)
|
||||
system-ui,
|
||||
// Safari for macOS and iOS (San Francisco)
|
||||
-apple-system,
|
||||
// Chrome < 56 for macOS (San Francisco)
|
||||
BlinkMacSystemFont,
|
||||
// Windows
|
||||
"Segoe UI",
|
||||
// Android
|
||||
Roboto,
|
||||
// Basic web fallback
|
||||
Arial,
|
||||
// Linux
|
||||
"Noto Sans",
|
||||
// Sans serif fallback
|
||||
sans-serif,
|
||||
// Emoji fonts
|
||||
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !default;
|
||||
```
|
||||
|
||||
### LTR and RTL at the same time
|
||||
|
||||
Need both LTR and RTL on the same page? Thanks to [RTLCSS String Maps](https://rtlcss.com/learn/usage-guide/string-map/), this is pretty straightforward. Wrap your `@import`s with a class, and set a custom rename rule for RTLCSS:
|
||||
|
||||
```scss
|
||||
/* rtl:begin:options: {
|
||||
"autoRename": true,
|
||||
"stringMap":[ {
|
||||
"name": "ltr-rtl",
|
||||
"priority": 100,
|
||||
"search": ["ltr"],
|
||||
"replace": ["rtl"],
|
||||
"options": {
|
||||
"scope": "*",
|
||||
"ignoreCase": false
|
||||
}
|
||||
} ]
|
||||
} */
|
||||
.ltr {
|
||||
@import "../node_modules/bootstrap/scss/bootstrap";
|
||||
}
|
||||
/*rtl:end:options*/
|
||||
```
|
||||
|
||||
After running Sass then RTLCSS, each selector in your CSS files will be prepended by `.ltr`, and `.rtl` for RTL files. Now you're able to use both files on the same page, and simply use `.ltr` or `.rtl` on your components wrappers to use one or the other direction.
|
||||
|
||||
{{< callout warning >}}
|
||||
#### Edge cases and known limitations
|
||||
|
||||
While this approach is understandable, please pay attention to the following:
|
||||
|
||||
1. When switching `.ltr` and `.rtl`, make sure you add `dir` and `lang` attributes accordingly.
|
||||
2. Loading both files can be a real performance bottleneck: consider some [optimization]({{< docsref "/customize/optimize" >}}), and maybe try to [load one of those files asynchronously](https://www.filamentgroup.com/lab/load-css-simpler/).
|
||||
3. Nesting styles this way will prevent our `form-validation-state()` mixin from working as intended, thus require you tweak it a bit by yourself. [See #31223](https://github.com/twbs/bootstrap/issues/31223).
|
||||
{{< /callout >}}
|
||||
|
||||
## The breadcrumb case
|
||||
|
||||
The [breadcrumb separator]({{< docsref "/components/breadcrumb" >}}/#changing-the-separator) is the only case requiring its own brand-new variable— namely `$breadcrumb-divider-flipped` —defaulting to `$breadcrumb-divider`.
|
||||
|
||||
## Additional resources
|
||||
|
||||
- [RTLCSS](https://rtlcss.com/)
|
||||
- [RTL Styling 101](https://rtlstyling.com/posts/rtl-styling)
|
||||
|
|
@ -1,198 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: "Bootstrap & Vite"
|
||||
description: The official guide for how to include and bundle Bootstrap's CSS and JavaScript in your project using Vite.
|
||||
group: getting-started
|
||||
toc: true
|
||||
thumbnail: guides/bootstrap-vite@2x.png
|
||||
---
|
||||
|
||||
<img class="mb-4 img-fluid rounded-3" srcset="/docs/{{< param docs_version >}}/assets/img/guides/bootstrap-vite.png, /docs/{{< param docs_version >}}/assets/img/guides/bootstrap-vite@2x.png 2x" src="/docs/{{< param docs_version >}}/assets/img/guides/bootstrap-vite.png" width="2000" height="1000" alt="">
|
||||
|
||||
{{< callout >}}
|
||||
**Want to skip to the end?** Download the source code and working demo for this guide from the [twbs/examples repository](https://github.com/twbs/examples/tree/main/vite). You can also [open the example in StackBlitz](https://stackblitz.com/github/twbs/examples/tree/main/vite?file=index.html) for live editing.
|
||||
{{< /callout >}}
|
||||
|
||||
## Setup
|
||||
|
||||
We're building a Vite project with Bootstrap from scratch, so there are some prerequisites and up front steps before we can really get started. This guide requires you to have Node.js installed and some familiarity with the terminal.
|
||||
|
||||
1. **Create a project folder and setup npm.** We'll create the `my-project` folder and initialize npm with the `-y` argument to avoid it asking us all the interactive questions.
|
||||
|
||||
```sh
|
||||
mkdir my-project && cd my-project
|
||||
npm init -y
|
||||
```
|
||||
|
||||
2. **Install Vite.** Unlike our Webpack guide, there’s only a single build tool dependency here. We use `--save-dev` to signal that this dependency is only for development use and not for production.
|
||||
|
||||
```sh
|
||||
npm i --save-dev vite
|
||||
```
|
||||
|
||||
3. **Install Bootstrap.** Now we can install Bootstrap. We'll also install Popper since our dropdowns, popovers, and tooltips depend on it for their positioning. If you don't plan on using those components, you can omit Popper here.
|
||||
|
||||
```sh
|
||||
npm i --save bootstrap @popperjs/core
|
||||
```
|
||||
4. **Install additional dependency.** In addition to Vite and Bootstrap, we need another dependency (Sass) to properly import and bundle Bootstrap's CSS.
|
||||
|
||||
```sh
|
||||
npm i --save-dev sass
|
||||
```
|
||||
|
||||
Now that we have all the necessary dependencies installed and setup, we can get to work creating the project files and importing Bootstrap.
|
||||
|
||||
## Project structure
|
||||
|
||||
We've already created the `my-project` folder and initialized npm. Now we'll also create our `src` folder, stylesheet, and JavaScript file to round out the project structure. Run the following from `my-project`, or manually create the folder and file structure shown below.
|
||||
|
||||
```sh
|
||||
mkdir {src,src/js,src/scss}
|
||||
touch src/index.html src/js/main.js src/scss/styles.scss vite.config.js
|
||||
```
|
||||
|
||||
When you're done, your complete project should look like this:
|
||||
|
||||
```text
|
||||
my-project/
|
||||
├── src/
|
||||
│ ├── js/
|
||||
│ │ └── main.js
|
||||
│ └── scss/
|
||||
│ | └── styles.scss
|
||||
| └── index.html
|
||||
├── package-lock.json
|
||||
├── package.json
|
||||
└── vite.config.js
|
||||
```
|
||||
|
||||
At this point, everything is in the right place, but Vite won't work because we haven't filled in our `vite.config.js` yet.
|
||||
|
||||
## Configure Vite
|
||||
|
||||
With dependencies installed and our project folder ready for us to start coding, we can now configure Vite and run our project locally.
|
||||
|
||||
1. **Open `vite.config.js` in your editor.** Since it's blank, we'll need to add some boilerplate config to it so we can start our server. This part of the config tells Vite where to look for our project's JavaScript and how the development server should behave (pulling from the `src` folder with hot reload).
|
||||
|
||||
<!-- eslint-skip -->
|
||||
```js
|
||||
const path = require('path')
|
||||
|
||||
export default {
|
||||
root: path.resolve(__dirname, 'src'),
|
||||
server: {
|
||||
port: 8080,
|
||||
hot: true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
2. **Next we fill in `src/index.html`.** This is the HTML page Vite will load in the browser to utilize the bundled CSS and JS we'll add to it in later steps.
|
||||
|
||||
```html
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Bootstrap w/ Vite</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container py-4 px-3 mx-auto">
|
||||
<h1>Hello, Bootstrap and Vite!</h1>
|
||||
<button class="btn btn-primary">Primary button</button>
|
||||
</div>
|
||||
<script type="module" src="./js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
We're including a little bit of Bootstrap styling here with the `div class="container"` and `<button>` so that we see when Bootstrap's CSS is loaded by Vite.
|
||||
|
||||
3. **Now we need an npm script to run Vite.** Open `package.json` and add the `start` script shown below (you should already have the test script). We'll use this script to start our local Vite dev server.
|
||||
|
||||
```json
|
||||
{
|
||||
// ...
|
||||
"scripts": {
|
||||
"start": "vite",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
4. **And finally, we can start Vite.** From the `my-project` folder in your terminal, run that newly added npm script:
|
||||
|
||||
```sh
|
||||
npm start
|
||||
```
|
||||
|
||||
<img class="img-fluid" src="/docs/{{< param docs_version >}}/assets/img/guides/vite-dev-server.png" alt="Vite dev server running">
|
||||
|
||||
In the next and final section to this guide, we’ll import all of Bootstrap’s CSS and JavaScript.
|
||||
|
||||
## Import Bootstrap
|
||||
|
||||
1. **Set up Bootstrap's Sass import in `vite.config.js`.** Your configuration file is now complete and should match the snippet below. The only new part here is the `resolve` section—we use this to add an alias to our source files inside `node_modules` to keep imports as simple as possible.
|
||||
|
||||
<!-- eslint-skip -->
|
||||
```js
|
||||
const path = require('path')
|
||||
|
||||
export default {
|
||||
root: path.resolve(__dirname, 'src'),
|
||||
resolve: {
|
||||
alias: {
|
||||
'~bootstrap': path.resolve(__dirname, 'node_modules/bootstrap'),
|
||||
}
|
||||
},
|
||||
server: {
|
||||
port: 8080,
|
||||
hot: true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
2. **Now, let's import Bootstrap's CSS.** Add the following to `src/scss/styles.scss` to import all of Bootstrap's source Sass.
|
||||
|
||||
```scss
|
||||
// Import all of Bootstrap's CSS
|
||||
@import "~bootstrap/scss/bootstrap";
|
||||
```
|
||||
|
||||
*You can also import our stylesheets individually if you want. [Read our Sass import docs]({{< docsref "/customize/sass#importing" >}}) for details.*
|
||||
|
||||
3. **Next we load the CSS and import Bootstrap's JavaScript.** Add the following to `src/js/main.js` to load the CSS and import all of Bootstrap's JS. Popper will be imported automatically through Bootstrap.
|
||||
|
||||
<!-- eslint-skip -->
|
||||
```js
|
||||
// Import our custom CSS
|
||||
import '../scss/styles.scss'
|
||||
|
||||
// Import all of Bootstrap's JS
|
||||
import * as bootstrap from 'bootstrap'
|
||||
```
|
||||
|
||||
You can also import JavaScript plugins individually as needed to keep bundle sizes down:
|
||||
|
||||
<!-- eslint-skip -->
|
||||
```js
|
||||
import Alert from 'bootstrap/js/dist/alert';
|
||||
|
||||
// or, specify which plugins you need:
|
||||
import { Tooltip, Toast, Popover } from 'bootstrap';
|
||||
```
|
||||
|
||||
*[Read our JavaScript docs]({{< docsref "/getting-started/javascript/" >}}) for more information on how to use Bootstrap's plugins.*
|
||||
|
||||
4. **And you're done! 🎉** With Bootstrap's source Sass and JS fully loaded, your local development server should now look like this.
|
||||
|
||||
<img class="img-fluid" src="/docs/{{< param docs_version >}}/assets/img/guides/vite-dev-server-bootstrap.png" alt="Vite dev server running with Bootstrap">
|
||||
|
||||
Now you can start adding any Bootstrap components you want to use. Be sure to [check out the complete Vite example project](https://github.com/twbs/examples/tree/main/vite) for how to include additional custom Sass and optimize your build by importing only the parts of Bootstrap's CSS and JS that you need.
|
||||
|
||||
{{< markdown >}}
|
||||
{{< partial "guide-footer.md" >}}
|
||||
{{< /markdown >}}
|
||||
|
|
@ -1,322 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: "Bootstrap & Webpack"
|
||||
description: The official guide for how to include and bundle Bootstrap's CSS and JavaScript in your project using Webpack.
|
||||
group: getting-started
|
||||
toc: true
|
||||
thumbnail: guides/bootstrap-webpack@2x.png
|
||||
---
|
||||
|
||||
<img class="mb-4 img-fluid rounded-3" srcset="/docs/{{< param docs_version >}}/assets/img/guides/bootstrap-webpack.png, /docs/{{< param docs_version >}}/assets/img/guides/bootstrap-webpack@2x.png 2x" src="/docs/{{< param docs_version >}}/assets/img/guides/bootstrap-webpack.png" width="2000" height="1000" alt="">
|
||||
|
||||
{{< callout >}}
|
||||
**Want to skip to the end?** Download the source code and working demo for this guide from the [twbs/examples repository](https://github.com/twbs/examples/tree/main/webpack). You can also [open the example in StackBlitz](https://stackblitz.com/github/twbs/examples/tree/main/webpack?file=index.html) for live editing.
|
||||
{{< /callout >}}
|
||||
|
||||
## Setup
|
||||
|
||||
We're building a Webpack project with Bootstrap from scratch, so there are some prerequisites and up front steps before we can really get started. This guide requires you to have Node.js installed and some familiarity with the terminal.
|
||||
|
||||
1. **Create a project folder and setup npm.** We'll create the `my-project` folder and initialize npm with the `-y` argument to avoid it asking us all the interactive questions.
|
||||
|
||||
```sh
|
||||
mkdir my-project && cd my-project
|
||||
npm init -y
|
||||
```
|
||||
|
||||
2. **Install Webpack.** Next we need to install our Webpack development dependencies: `webpack` for the core of Webpack, `webpack-cli` so we can run Webpack commands from the terminal, and `webpack-dev-server` so we can run a local development server. We use `--save-dev` to signal that these dependencies are only for development use and not for production.
|
||||
|
||||
```sh
|
||||
npm i --save-dev webpack webpack-cli webpack-dev-server
|
||||
```
|
||||
|
||||
3. **Install Bootstrap.** Now we can install Bootstrap. We'll also install Popper since our dropdowns, popovers, and tooltips depend on it for their positioning. If you don't plan on using those components, you can omit Popper here.
|
||||
|
||||
```sh
|
||||
npm i --save bootstrap @popperjs/core
|
||||
```
|
||||
|
||||
4. **Install additional dependencies.** In addition to Webpack and Bootstrap, we need a few more dependencies to properly import and bundle Bootstrap's CSS and JS with Webpack. These include Sass, some loaders, and Autoprefixer.
|
||||
|
||||
```sh
|
||||
npm i --save-dev autoprefixer css-loader postcss-loader sass sass-loader style-loader
|
||||
```
|
||||
|
||||
Now that we have all the necessary dependencies installed, we can get to work creating the project files and importing Bootstrap.
|
||||
|
||||
## Project structure
|
||||
|
||||
We've already created the `my-project` folder and initialized npm. Now we'll also create our `src` and `dist` folders to round out the project structure. Run the following from `my-project`, or manually create the folder and file structure shown below.
|
||||
|
||||
```sh
|
||||
mkdir {dist,src,src/js,src/scss}
|
||||
touch dist/index.html src/js/main.js src/scss/styles.scss webpack.config.js
|
||||
```
|
||||
|
||||
When you're done, your complete project should look like this:
|
||||
|
||||
```text
|
||||
my-project/
|
||||
├── dist/
|
||||
│ └── index.html
|
||||
├── src/
|
||||
│ ├── js/
|
||||
│ │ └── main.js
|
||||
│ └── scss/
|
||||
│ └── styles.scss
|
||||
├── package-lock.json
|
||||
├── package.json
|
||||
└── webpack.config.js
|
||||
```
|
||||
|
||||
At this point, everything is in the right place, but Webpack won't work because we haven't filled in our `webpack.config.js` yet.
|
||||
|
||||
## Configure Webpack
|
||||
|
||||
With dependencies installed and our project folder ready for us to start coding, we can now configure Webpack and run our project locally.
|
||||
|
||||
1. **Open `webpack.config.js` in your editor.** Since it's blank, we'll need to add some boilerplate config to it so we can start our server. This part of the config tells Webpack where to look for our project's JavaScript, where to output the compiled code to (`dist`), and how the development server should behave (pulling from the `dist` folder with hot reload).
|
||||
|
||||
```js
|
||||
const path = require('path')
|
||||
|
||||
module.exports = {
|
||||
entry: './src/js/main.js',
|
||||
output: {
|
||||
filename: 'main.js',
|
||||
path: path.resolve(__dirname, 'dist')
|
||||
},
|
||||
devServer: {
|
||||
static: path.resolve(__dirname, 'dist'),
|
||||
port: 8080,
|
||||
hot: true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
2. **Next we fill in our `dist/index.html`.** This is the HTML page Webpack will load in the browser to utilize the bundled CSS and JS we'll add to it in later steps. Before we can do that, we have to give it something to render and include the `output` JS from the previous step.
|
||||
|
||||
```html
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Bootstrap w/ Webpack</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container py-4 px-3 mx-auto">
|
||||
<h1>Hello, Bootstrap and Webpack!</h1>
|
||||
<button class="btn btn-primary">Primary button</button>
|
||||
</div>
|
||||
<script src="./main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
We're including a little bit of Bootstrap styling here with the `div class="container"` and `<button>` so that we see when Bootstrap's CSS is loaded by Webpack.
|
||||
|
||||
3. **Now we need an npm script to run Webpack.** Open `package.json` and add the `start` script shown below (you should already have the test script). We'll use this script to start our local Webpack dev server.
|
||||
|
||||
```json
|
||||
{
|
||||
// ...
|
||||
"scripts": {
|
||||
"start": "webpack serve --mode development",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
4. **And finally, we can start Webpack.** From the `my-project` folder in your terminal, run that newly added npm script:
|
||||
|
||||
```sh
|
||||
npm start
|
||||
```
|
||||
|
||||
<img class="img-fluid" src="/docs/{{< param docs_version >}}/assets/img/guides/webpack-dev-server.png" alt="Webpack dev server running">
|
||||
|
||||
In the next and final section to this guide, we'll set up the Webpack loaders and import all of Bootstrap's CSS and JavaScript.
|
||||
|
||||
## Import Bootstrap
|
||||
|
||||
Importing Bootstrap into Webpack requires the loaders we installed in the first section. We've installed them with npm, but now Webpack needs to be configured to use them.
|
||||
|
||||
1. **Set up the loaders in `webpack.config.js`.** Your configuration file is now complete and should match the snippet below. The only new part here is the `module` section.
|
||||
|
||||
```js
|
||||
const path = require('path')
|
||||
|
||||
module.exports = {
|
||||
entry: './src/js/main.js',
|
||||
output: {
|
||||
filename: 'main.js',
|
||||
path: path.resolve(__dirname, 'dist')
|
||||
},
|
||||
devServer: {
|
||||
static: path.resolve(__dirname, 'dist'),
|
||||
port: 8080,
|
||||
hot: true
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.(scss)$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'style-loader'
|
||||
},
|
||||
{
|
||||
loader: 'css-loader'
|
||||
},
|
||||
{
|
||||
loader: 'postcss-loader',
|
||||
options: {
|
||||
postcssOptions: {
|
||||
plugins: () => [
|
||||
require('autoprefixer')
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
loader: 'sass-loader'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Here's a recap of why we need all these loaders. `style-loader` injects the CSS into a `<style>` element in the `<head>` of the HTML page, `css-loader` helps with using `@import` and `url()`, `postcss-loader` is required for Autoprefixer, and `sass-loader` allows us to use Sass.
|
||||
|
||||
2. **Now, let's import Bootstrap's CSS.** Add the following to `src/scss/styles.scss` to import all of Bootstrap's source Sass.
|
||||
|
||||
```scss
|
||||
// Import all of Bootstrap's CSS
|
||||
@import "~bootstrap/scss/bootstrap";
|
||||
```
|
||||
|
||||
*You can also import our stylesheets individually if you want. [Read our Sass import docs]({{< docsref "/customize/sass#importing" >}}) for details.*
|
||||
|
||||
3. **Next we load the CSS and import Bootstrap's JavaScript.** Add the following to `src/js/main.js` to load the CSS and import all of Bootstrap's JS. Popper will be imported automatically through Bootstrap.
|
||||
|
||||
<!-- eslint-skip -->
|
||||
```js
|
||||
// Import our custom CSS
|
||||
import '../scss/styles.scss'
|
||||
|
||||
// Import all of Bootstrap's JS
|
||||
import * as bootstrap from 'bootstrap'
|
||||
```
|
||||
|
||||
You can also import JavaScript plugins individually as needed to keep bundle sizes down:
|
||||
|
||||
<!-- eslint-skip -->
|
||||
```js
|
||||
import Alert from 'bootstrap/js/dist/alert'
|
||||
|
||||
// or, specify which plugins you need:
|
||||
import { Tooltip, Toast, Popover } from 'bootstrap'
|
||||
```
|
||||
|
||||
*[Read our JavaScript docs]({{< docsref "/getting-started/javascript/" >}}) for more information on how to use Bootstrap's plugins.*
|
||||
|
||||
4. **And you're done! 🎉** With Bootstrap's source Sass and JS fully loaded, your local development server should now look like this.
|
||||
|
||||
<img class="img-fluid" src="/docs/{{< param docs_version >}}/assets/img/guides/webpack-dev-server-bootstrap.png" alt="Webpack dev server running with Bootstrap">
|
||||
|
||||
Now you can start adding any Bootstrap components you want to use. Be sure to [check out the complete Webpack example project](https://github.com/twbs/examples/tree/main/webpack) for how to include additional custom Sass and optimize your build by importing only the parts of Bootstrap's CSS and JS that you need.
|
||||
|
||||
## Production optimizations
|
||||
|
||||
Depending on your setup, you may want to implement some additional security and speed optimizations useful for running the project in production. Note that these optimizations are not applied on [the Webpack example project](https://github.com/twbs/examples/tree/main/webpack) and are up to you to implement.
|
||||
|
||||
### Extracting CSS
|
||||
|
||||
The `style-loader` we configured above conveniently emits CSS into the bundle so that manually loading a CSS file in `dist/index.html` isn't necessary. This approach may not work with a strict Content Security Policy, however, and it may become a bottleneck in your application due to the large bundle size.
|
||||
|
||||
To separate the CSS so that we can load it directly from `dist/index.html`, use the `mini-css-extract-loader` Webpack plugin.
|
||||
|
||||
First, install the plugin:
|
||||
|
||||
```sh
|
||||
npm install --save-dev mini-css-extract-plugin
|
||||
```
|
||||
|
||||
Then instantiate and use the plugin in the Webpack configuration:
|
||||
|
||||
```diff
|
||||
--- a/webpack/webpack.config.js
|
||||
+++ b/webpack/webpack.config.js
|
||||
@@ -1,8 +1,10 @@
|
||||
+const miniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||
const path = require('path')
|
||||
|
||||
module.exports = {
|
||||
mode: 'development',
|
||||
entry: './src/js/main.js',
|
||||
+ plugins: [new miniCssExtractPlugin()],
|
||||
output: {
|
||||
filename: "main.js",
|
||||
path: path.resolve(__dirname, "dist"),
|
||||
@@ -18,8 +20,8 @@ module.exports = {
|
||||
test: /\.(scss)$/,
|
||||
use: [
|
||||
{
|
||||
- // Adds CSS to the DOM by injecting a `<style>` tag
|
||||
- loader: 'style-loader'
|
||||
+ // Extracts CSS for each JS file that includes CSS
|
||||
+ loader: miniCssExtractPlugin.loader
|
||||
},
|
||||
{
|
||||
```
|
||||
|
||||
After running `npm run build` again, there will be a new file `dist/main.css`, which will contain all of the CSS imported by `src/js/main.js`. If you view `dist/index.html` in your browser now, the style will be missing, as it is now in `dist/main.css`. You can include the generated CSS in `dist/index.html` like this:
|
||||
|
||||
```diff
|
||||
--- a/webpack/dist/index.html
|
||||
+++ b/webpack/dist/index.html
|
||||
@@ -3,6 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
+ <link rel="stylesheet" href="./main.css">
|
||||
<title>Bootstrap w/ Webpack</title>
|
||||
</head>
|
||||
<body>
|
||||
```
|
||||
|
||||
### Extracting SVG files
|
||||
|
||||
Bootstrap's CSS includes multiple references to SVG files via inline `data:` URIs. If you define a Content Security Policy for your project that blocks `data:` URIs for images, then these SVG files will not load. You can get around this problem by extracting the inline SVG files using Webpack's asset modules feature.
|
||||
|
||||
Configure Webpack to extract inline SVG files like this:
|
||||
|
||||
```diff
|
||||
--- a/webpack/webpack.config.js
|
||||
+++ b/webpack/webpack.config.js
|
||||
@@ -16,6 +16,14 @@ module.exports = {
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
+ {
|
||||
+ mimetype: 'image/svg+xml',
|
||||
+ scheme: 'data',
|
||||
+ type: 'asset/resource',
|
||||
+ generator: {
|
||||
+ filename: 'icons/[hash].svg'
|
||||
+ }
|
||||
+ },
|
||||
{
|
||||
test: /\.(scss)$/,
|
||||
use: [
|
||||
```
|
||||
|
||||
After running `npm run build` again, you'll find the SVG files extracted into `dist/icons` and properly referenced from CSS.
|
||||
|
||||
{{< markdown >}}
|
||||
{{< partial "guide-footer.md" >}}
|
||||
{{< /markdown >}}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Color & background
|
||||
description: Set a background color with contrasting foreground color.
|
||||
group: helpers
|
||||
toc: true
|
||||
added: "5.2"
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
Color and background helpers combine the power of our [`.text-*` utilities]({{< docsref "/utilities/colors" >}}) and [`.bg-*` utilities]({{< docsref "/utilities/background" >}}) in one class. Using our Sass `color-contrast()` function, we automatically determine a contrasting `color` for a particular `background-color`.
|
||||
|
||||
{{< callout warning >}}
|
||||
**Heads up!** There's currently no support for a CSS-native `color-contrast` function, so we use our own via Sass. This means that customizing our theme colors via CSS variables may cause color contrast issues with these utilities.
|
||||
{{< /callout >}}
|
||||
|
||||
{{< example >}}
|
||||
{{< text-bg.inline >}}
|
||||
{{- range (index $.Site.Data "theme-colors") }}
|
||||
<div class="text-bg-{{ .name }} p-3">{{ .name | title }} with contrasting color</div>
|
||||
{{- end -}}
|
||||
{{< /text-bg.inline >}}
|
||||
{{< /example >}}
|
||||
|
||||
## With components
|
||||
|
||||
Use them in place of combined `.text-*` and `.bg-*` classes, like on [badges]({{< docsref "/components/badge#background-colors" >}}):
|
||||
|
||||
{{< example >}}
|
||||
<span class="badge text-bg-primary">Primary</span>
|
||||
<span class="badge text-bg-info">Info</span>
|
||||
{{< /example >}}
|
||||
|
||||
Or on [cards]({{< docsref "/components/card#background-and-color" >}}):
|
||||
|
||||
{{< example >}}
|
||||
<div class="card text-bg-primary mb-3" style="max-width: 18rem;">
|
||||
<div class="card-header">Header</div>
|
||||
<div class="card-body">
|
||||
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card text-bg-info mb-3" style="max-width: 18rem;">
|
||||
<div class="card-header">Header</div>
|
||||
<div class="card-body">
|
||||
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Colored links
|
||||
description: Colored links with hover states
|
||||
group: helpers
|
||||
toc: false
|
||||
---
|
||||
|
||||
You can use the `.link-*` classes to colorize links. Unlike the [`.text-*` classes]({{< docsref "/utilities/colors" >}}), these classes have a `:hover` and `:focus` state.
|
||||
|
||||
{{< example >}}
|
||||
{{< colored-links.inline >}}
|
||||
{{- range (index $.Site.Data "theme-colors") }}
|
||||
<a href="#" class="link-{{ .name }}">{{ .name | title }} link</a>
|
||||
{{- end -}}
|
||||
{{< /colored-links.inline >}}
|
||||
{{< /example >}}
|
||||
|
||||
{{< callout info >}}
|
||||
Some of the link styles use a relatively light foreground color, and should only be used on a dark background in order to have sufficient contrast.
|
||||
{{< /callout >}}
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Stacks
|
||||
description: Shorthand helpers that build on top of our flexbox utilities to make component layout faster and easier than ever.
|
||||
group: helpers
|
||||
toc: true
|
||||
added: "5.1"
|
||||
---
|
||||
|
||||
Stacks offer a shortcut for applying a number of flexbox properties to quickly and easily create layouts in Bootstrap. All credit for the concept and implementation goes to the open source [Pylon project](https://almonk.github.io/pylon/).
|
||||
|
||||
{{< callout warning >}}
|
||||
Heads up! Support for gap utilities with flexbox was recently added to Safari, so consider verifying your intended browser support. Grid layout should have no issues. [Read more](https://caniuse.com/flexbox-gap).
|
||||
{{< /callout >}}
|
||||
|
||||
## Vertical
|
||||
|
||||
Use `.vstack` to create vertical layouts. Stacked items are full-width by default. Use `.gap-*` utilities to add space between items.
|
||||
|
||||
{{< example >}}
|
||||
<div class="vstack gap-3">
|
||||
<div class="bg-light border">First item</div>
|
||||
<div class="bg-light border">Second item</div>
|
||||
<div class="bg-light border">Third item</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Horizontal
|
||||
|
||||
Use `.hstack` for horizontal layouts. Stacked items are vertically centered by default and only take up their necessary width. Use `.gap-*` utilities to add space between items.
|
||||
|
||||
{{< example >}}
|
||||
<div class="hstack gap-3">
|
||||
<div class="bg-light border">First item</div>
|
||||
<div class="bg-light border">Second item</div>
|
||||
<div class="bg-light border">Third item</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Using horizontal margin utilities like `.ms-auto` as spacers:
|
||||
|
||||
{{< example >}}
|
||||
<div class="hstack gap-3">
|
||||
<div class="bg-light border">First item</div>
|
||||
<div class="bg-light border ms-auto">Second item</div>
|
||||
<div class="bg-light border">Third item</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
And with [vertical rules]({{< docsref "/helpers/vertical-rule" >}}):
|
||||
|
||||
{{< example >}}
|
||||
<div class="hstack gap-3">
|
||||
<div class="bg-light border">First item</div>
|
||||
<div class="bg-light border ms-auto">Second item</div>
|
||||
<div class="vr"></div>
|
||||
<div class="bg-light border">Third item</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Examples
|
||||
|
||||
Use `.vstack` to stack buttons and other elements:
|
||||
|
||||
{{< example >}}
|
||||
<div class="vstack gap-2 col-md-5 mx-auto">
|
||||
<button type="button" class="btn btn-secondary">Save changes</button>
|
||||
<button type="button" class="btn btn-outline-secondary">Cancel</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Create an inline form with `.hstack`:
|
||||
|
||||
{{< example >}}
|
||||
<div class="hstack gap-3">
|
||||
<input class="form-control me-auto" type="text" placeholder="Add your item here..." aria-label="Add your item here...">
|
||||
<button type="button" class="btn btn-secondary">Submit</button>
|
||||
<div class="vr"></div>
|
||||
<button type="button" class="btn btn-outline-danger">Reset</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Sass
|
||||
|
||||
{{< scss-docs name="stacks" file="scss/helpers/_stacks.scss" >}}
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Stretched link
|
||||
description: Make any HTML element or Bootstrap component clickable by "stretching" a nested link via CSS.
|
||||
group: helpers
|
||||
---
|
||||
|
||||
Add `.stretched-link` to a link to make its [containing block](https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block) clickable via a `::after` pseudo element. In most cases, this means that an element with `position: relative;` that contains a link with the `.stretched-link` class is clickable. Please note given [how CSS `position` works](https://www.w3.org/TR/CSS21/visuren.html#propdef-position), `.stretched-link` cannot be mixed with most table elements.
|
||||
|
||||
Cards have `position: relative` by default in Bootstrap, so in this case you can safely add the `.stretched-link` class to a link in the card without any other HTML changes.
|
||||
|
||||
Multiple links and tap targets are not recommended with stretched links. However, some `position` and `z-index` styles can help should this be required.
|
||||
|
||||
{{< example >}}
|
||||
<div class="card" style="width: 18rem;">
|
||||
{{< placeholder width="100%" height="180" class="card-img-top" text="false" title="Card image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card with stretched link</h5>
|
||||
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
|
||||
<a href="#" class="btn btn-primary stretched-link">Go somewhere</a>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Most custom components do not have `position: relative` by default, so we need to add the `.position-relative` here to prevent the link from stretching outside the parent element.
|
||||
|
||||
{{< example >}}
|
||||
<div class="d-flex position-relative">
|
||||
{{< placeholder width="144" height="144" class="flex-shrink-0 me-3" text="false" title="Generic placeholder image" >}}
|
||||
<div>
|
||||
<h5 class="mt-0">Custom component with stretched link</h5>
|
||||
<p>This is some placeholder content for the custom component. It is intended to mimic what some real-world content would look like, and we're using it here to give the component a bit of body and size.</p>
|
||||
<a href="#" class="stretched-link">Go somewhere</a>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<div class="row g-0 bg-light position-relative">
|
||||
<div class="col-md-6 mb-md-0 p-md-4">
|
||||
{{< placeholder width="100%" height="200" class="w-100" text="false" title="Generic placeholder image" >}}
|
||||
</div>
|
||||
<div class="col-md-6 p-4 ps-md-0">
|
||||
<h5 class="mt-0">Columns with stretched link</h5>
|
||||
<p>Another instance of placeholder content for this other custom component. It is intended to mimic what some real-world content would look like, and we're using it here to give the component a bit of body and size.</p>
|
||||
<a href="#" class="stretched-link">Go somewhere</a>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Identifying the containing block
|
||||
|
||||
If the stretched link doesn't seem to work, the [containing block](https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#Identifying_the_containing_block) will probably be the cause. The following CSS properties will make an element the containing block:
|
||||
|
||||
- A `position` value other than `static`
|
||||
- A `transform` or `perspective` value other than `none`
|
||||
- A `will-change` value of `transform` or `perspective`
|
||||
- A `filter` value other than `none` or a `will-change` value of `filter` (only works on Firefox)
|
||||
|
||||
{{< example >}}
|
||||
<div class="card" style="width: 18rem;">
|
||||
{{< placeholder width="100%" height="180" class="card-img-top" text="false" title="Card image cap" >}}
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Card with stretched links</h5>
|
||||
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
|
||||
<p class="card-text">
|
||||
<a href="#" class="stretched-link text-danger" style="position: relative;">Stretched link will not work here, because <code>position: relative</code> is added to the link</a>
|
||||
</p>
|
||||
<p class="card-text bg-light" style="transform: rotate(0);">
|
||||
This <a href="#" class="text-warning stretched-link">stretched link</a> will only be spread over the <code>p</code>-tag, because a transform is applied to it.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Vertical rule
|
||||
description: Use the custom vertical rule helper to create vertical dividers like the `<hr>` element.
|
||||
group: helpers
|
||||
toc: true
|
||||
added: "5.1"
|
||||
---
|
||||
|
||||
## How it works
|
||||
|
||||
Vertical rules are inspired by the `<hr>` element, allowing you to create vertical dividers in common layouts. They're styled just like `<hr>` elements:
|
||||
|
||||
- They're `1px` wide
|
||||
- They have `min-height` of `1em`
|
||||
- Their color is set via `currentColor` and `opacity`
|
||||
|
||||
Customize them with additional styles as needed.
|
||||
|
||||
## Example
|
||||
|
||||
{{< example >}}
|
||||
<div class="vr"></div>
|
||||
{{< /example >}}
|
||||
|
||||
Vertical rules scale their height in flex layouts:
|
||||
|
||||
{{< example >}}
|
||||
<div class="d-flex" style="height: 200px;">
|
||||
<div class="vr"></div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## With stacks
|
||||
|
||||
They can also be used in [stacks]({{< docsref "/helpers/stacks" >}}):
|
||||
|
||||
{{< example >}}
|
||||
<div class="hstack gap-3">
|
||||
<div class="bg-light border">First item</div>
|
||||
<div class="bg-light border ms-auto">Second item</div>
|
||||
<div class="vr"></div>
|
||||
<div class="bg-light border">Third item</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Visually hidden
|
||||
description: Use these helpers to visually hide elements but keep them accessible to assistive technologies.
|
||||
group: helpers
|
||||
aliases: "/docs/5.2/helpers/screen-readers/"
|
||||
---
|
||||
|
||||
Visually hide an element while still allowing it to be exposed to assistive technologies (such as screen readers) with `.visually-hidden`. Use `.visually-hidden-focusable` to visually hide an element by default, but to display it when it's focused (e.g. by a keyboard-only user). `.visually-hidden-focusable` can also be applied to a container–thanks to `:focus-within`, the container will be displayed when any child element of the container receives focus.
|
||||
|
||||
{{< example >}}
|
||||
<h2 class="visually-hidden">Title for screen readers</h2>
|
||||
<a class="visually-hidden-focusable" href="#content">Skip to main content</a>
|
||||
<div class="visually-hidden-focusable">A container with a <a href="#">focusable element</a>.</div>
|
||||
{{< /example >}}
|
||||
|
||||
Both `visually-hidden` and `visually-hidden-focusable` can also be used as mixins.
|
||||
|
||||
```scss
|
||||
// Usage as a mixin
|
||||
|
||||
.visually-hidden-title {
|
||||
@include visually-hidden;
|
||||
}
|
||||
|
||||
.skip-navigation {
|
||||
@include visually-hidden-focusable;
|
||||
}
|
||||
```
|
||||
|
|
@ -1,317 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Columns
|
||||
description: Learn how to modify columns with a handful of options for alignment, ordering, and offsetting thanks to our flexbox grid system. Plus, see how to use column classes to manage widths of non-grid elements.
|
||||
group: layout
|
||||
toc: true
|
||||
---
|
||||
|
||||
{{< callout info >}}
|
||||
**Heads up!** Be sure to [read the Grid page]({{< docsref "/layout/grid" >}}) first before diving into how to modify and customize your grid columns.
|
||||
{{< /callout >}}
|
||||
|
||||
## How they work
|
||||
|
||||
- **Columns build on the grid's flexbox architecture.** Flexbox means we have options for changing individual columns and [modifying groups of columns at the row level]({{< docsref "/layout/grid#row-columns" >}}). You choose how columns grow, shrink, or otherwise change.
|
||||
|
||||
- **When building grid layouts, all content goes in columns.** The hierarchy of Bootstrap's grid goes from [container]({{< docsref "/layout/containers" >}}) to row to column to your content. On rare occasions, you may combine content and column, but be aware there can be unintended consequences.
|
||||
|
||||
- **Bootstrap includes predefined classes for creating fast, responsive layouts.** With [six breakpoints]({{< docsref "/layout/breakpoints" >}}) and a dozen columns at each grid tier, we have dozens of classes already built for you to create your desired layouts. This can be disabled via Sass if you wish.
|
||||
|
||||
## Alignment
|
||||
|
||||
Use flexbox alignment utilities to vertically and horizontally align columns.
|
||||
|
||||
### Vertical alignment
|
||||
|
||||
{{< example class="bd-example-row bd-example-row-flex-cols" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row align-items-start">
|
||||
<div class="col">
|
||||
One of three columns
|
||||
</div>
|
||||
<div class="col">
|
||||
One of three columns
|
||||
</div>
|
||||
<div class="col">
|
||||
One of three columns
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
One of three columns
|
||||
</div>
|
||||
<div class="col">
|
||||
One of three columns
|
||||
</div>
|
||||
<div class="col">
|
||||
One of three columns
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-end">
|
||||
<div class="col">
|
||||
One of three columns
|
||||
</div>
|
||||
<div class="col">
|
||||
One of three columns
|
||||
</div>
|
||||
<div class="col">
|
||||
One of three columns
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example class="bd-example-row bd-example-row-flex-cols" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row">
|
||||
<div class="col align-self-start">
|
||||
One of three columns
|
||||
</div>
|
||||
<div class="col align-self-center">
|
||||
One of three columns
|
||||
</div>
|
||||
<div class="col align-self-end">
|
||||
One of three columns
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Horizontal alignment
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row justify-content-start">
|
||||
<div class="col-4">
|
||||
One of two columns
|
||||
</div>
|
||||
<div class="col-4">
|
||||
One of two columns
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-4">
|
||||
One of two columns
|
||||
</div>
|
||||
<div class="col-4">
|
||||
One of two columns
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-end">
|
||||
<div class="col-4">
|
||||
One of two columns
|
||||
</div>
|
||||
<div class="col-4">
|
||||
One of two columns
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-around">
|
||||
<div class="col-4">
|
||||
One of two columns
|
||||
</div>
|
||||
<div class="col-4">
|
||||
One of two columns
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-between">
|
||||
<div class="col-4">
|
||||
One of two columns
|
||||
</div>
|
||||
<div class="col-4">
|
||||
One of two columns
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-evenly">
|
||||
<div class="col-4">
|
||||
One of two columns
|
||||
</div>
|
||||
<div class="col-4">
|
||||
One of two columns
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Column wrapping
|
||||
|
||||
If more than 12 columns are placed within a single row, each group of extra columns will, as one unit, wrap onto a new line.
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-9">.col-9</div>
|
||||
<div class="col-4">.col-4<br>Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.</div>
|
||||
<div class="col-6">.col-6<br>Subsequent columns continue along the new line.</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Column breaks
|
||||
|
||||
Breaking columns to a new line in flexbox requires a small hack: add an element with `width: 100%` wherever you want to wrap your columns to a new line. Normally this is accomplished with multiple `.row`s, but not every implementation method can account for this.
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row">
|
||||
<div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
|
||||
<div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
|
||||
|
||||
<!-- Force next columns to break to new line -->
|
||||
<div class="w-100"></div>
|
||||
|
||||
<div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
|
||||
<div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
You may also apply this break at specific breakpoints with our [responsive display utilities]({{< docsref "/utilities/display" >}}).
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row">
|
||||
<div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
|
||||
<div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
|
||||
|
||||
<!-- Force next columns to break to new line at md breakpoint and up -->
|
||||
<div class="w-100 d-none d-md-block"></div>
|
||||
|
||||
<div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
|
||||
<div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Reordering
|
||||
|
||||
### Order classes
|
||||
|
||||
Use `.order-` classes for controlling the **visual order** of your content. These classes are responsive, so you can set the `order` by breakpoint (e.g., `.order-1.order-md-2`). Includes support for `1` through `5` across all six grid tiers.
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
First in DOM, no order applied
|
||||
</div>
|
||||
<div class="col order-5">
|
||||
Second in DOM, with a larger order
|
||||
</div>
|
||||
<div class="col order-1">
|
||||
Third in DOM, with an order of 1
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
There are also responsive `.order-first` and `.order-last` classes that change the `order` of an element by applying `order: -1` and `order: 6`, respectively. These classes can also be intermixed with the numbered `.order-*` classes as needed.
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row">
|
||||
<div class="col order-last">
|
||||
First in DOM, ordered last
|
||||
</div>
|
||||
<div class="col">
|
||||
Second in DOM, unordered
|
||||
</div>
|
||||
<div class="col order-first">
|
||||
Third in DOM, ordered first
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Offsetting columns
|
||||
|
||||
You can offset grid columns in two ways: our responsive `.offset-` grid classes and our [margin utilities]({{< docsref "/utilities/spacing" >}}). Grid classes are sized to match columns while margins are more useful for quick layouts where the width of the offset is variable.
|
||||
|
||||
#### Offset classes
|
||||
|
||||
Move columns to the right using `.offset-md-*` classes. These classes increase the left margin of a column by `*` columns. For example, `.offset-md-4` moves `.col-md-4` over four columns.
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row">
|
||||
<div class="col-md-4">.col-md-4</div>
|
||||
<div class="col-md-4 offset-md-4">.col-md-4 .offset-md-4</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-3 offset-md-3">.col-md-3 .offset-md-3</div>
|
||||
<div class="col-md-3 offset-md-3">.col-md-3 .offset-md-3</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 offset-md-3">.col-md-6 .offset-md-3</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
In addition to column clearing at responsive breakpoints, you may need to reset offsets. See this in action in [the grid example]({{< docsref "/examples/grid" >}}).
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row">
|
||||
<div class="col-sm-5 col-md-6">.col-sm-5 .col-md-6</div>
|
||||
<div class="col-sm-5 offset-sm-2 col-md-6 offset-md-0">.col-sm-5 .offset-sm-2 .col-md-6 .offset-md-0</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-5 col-lg-6">.col-sm-6 .col-md-5 .col-lg-6</div>
|
||||
<div class="col-sm-6 col-md-5 offset-md-2 col-lg-6 offset-lg-0">.col-sm-6 .col-md-5 .offset-md-2 .col-lg-6 .offset-lg-0</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
#### Margin utilities
|
||||
|
||||
With the move to flexbox in v4, you can use margin utilities like `.me-auto` to force sibling columns away from one another.
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row">
|
||||
<div class="col-md-4">.col-md-4</div>
|
||||
<div class="col-md-4 ms-auto">.col-md-4 .ms-auto</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-3 ms-md-auto">.col-md-3 .ms-md-auto</div>
|
||||
<div class="col-md-3 ms-md-auto">.col-md-3 .ms-md-auto</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-auto me-auto">.col-auto .me-auto</div>
|
||||
<div class="col-auto">.col-auto</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Standalone column classes
|
||||
|
||||
The `.col-*` classes can also be used outside a `.row` to give an element a specific width. Whenever column classes are used as non-direct children of a row, the paddings are omitted.
|
||||
|
||||
{{< example >}}
|
||||
<div class="col-3 bg-light p-3 border">
|
||||
.col-3: width of 25%
|
||||
</div>
|
||||
<div class="col-sm-9 bg-light p-3 border">
|
||||
.col-sm-9: width of 75% above sm breakpoint
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
The classes can be used together with utilities to create responsive floated images. Make sure to wrap the content in a [`.clearfix`]({{< docsref "/helpers/clearfix" >}}) wrapper to clear the float if the text is shorter.
|
||||
|
||||
{{< example >}}
|
||||
<div class="clearfix">
|
||||
{{< placeholder width="100%" height="210" class="col-md-6 float-md-end mb-3 ms-md-3" text="Responsive floated image" >}}
|
||||
|
||||
<p>
|
||||
A paragraph of placeholder text. We're using it here to show the use of the clearfix class. We're adding quite a few meaningless phrases here to demonstrate how the columns interact here with the floated image.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
As you can see the paragraphs gracefully wrap around the floated image. Now imagine how this would look with some actual content in here, rather than just this boring placeholder text that goes on and on, but actually conveys no tangible information at. It simply takes up space and should not really be read.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
And yet, here you are, still persevering in reading this placeholder text, hoping for some more insights, or some hidden easter egg of content. A joke, perhaps. Unfortunately, there's none of that here.
|
||||
</p>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
|
@ -1,267 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: CSS Grid
|
||||
description: Learn how to enable, use, and customize our alternate layout system built on CSS Grid with examples and code snippets.
|
||||
group: layout
|
||||
toc: true
|
||||
added: "5.1"
|
||||
---
|
||||
|
||||
Bootstrap's default grid system represents the culmination of over a decade of CSS layout techniques, tried and tested by millions of people. But, it was also created without many of the modern CSS features and techniques we're seeing in browsers like the new CSS Grid.
|
||||
|
||||
{{< callout warning >}}
|
||||
**Heads up—our CSS Grid system is experimental and opt-in as of v5.1.0!** We included it in our documentation's CSS to demonstrate it for you, but it's disabled by default. Keep reading to learn how to enable it in your projects.
|
||||
{{< /callout >}}
|
||||
|
||||
## How it works
|
||||
|
||||
With Bootstrap 5, we've added the option to enable a separate grid system that's built on CSS Grid, but with a Bootstrap twist. You still get classes you can apply on a whim to build responsive layouts, but with a different approach under the hood.
|
||||
|
||||
- **CSS Grid is opt-in.** Disable the default grid system by setting `$enable-grid-classes: false` and enable the CSS Grid by setting `$enable-cssgrid: true`. Then, recompile your Sass.
|
||||
|
||||
- **Replace instances of `.row` with `.grid`.** The `.grid` class sets `display: grid` and creates a `grid-template` that you build on with your HTML.
|
||||
|
||||
- **Replace `.col-*` classes with `.g-col-*` classes.** This is because our CSS Grid columns use the `grid-column` property instead of `width`.
|
||||
|
||||
- **Columns and gutter sizes are set via CSS variables.** Set these on the parent `.grid` and customize however you want, inline or in a stylesheet, with `--bs-columns` and `--bs-gap`.
|
||||
|
||||
In the future, Bootstrap will likely shift to a hybrid solution as the `gap` property has achieved nearly full browser support for flexbox.
|
||||
|
||||
## Key differences
|
||||
|
||||
Compared to the default grid system:
|
||||
|
||||
- Flex utilities don't affect the CSS Grid columns in the same way.
|
||||
|
||||
- Gaps replaces gutters. The `gap` property replaces the horizontal `padding` from our default grid system and functions more like `margin`.
|
||||
|
||||
- As such, unlike `.row`s, `.grid`s have no negative margins and margin utilities cannot be used to change the grid gutters. Grid gaps are applied horizontally and vertically by default. See the [customizing section](#customizing) for more details.
|
||||
|
||||
- Inline and custom styles should be viewed as replacements for modifier classes (e.g., `style="--bs-columns: 3;"` vs `class="row-cols-3"`).
|
||||
|
||||
- Nesting works similarly, but may require you to reset your column counts on each instance of a nested `.grid`. See the [nesting section](#nesting) for details.
|
||||
|
||||
## Examples
|
||||
|
||||
### Three columns
|
||||
|
||||
Three equal-width columns across all viewports and devices can be created by using the `.g-col-4` classes. Add [responsive classes](#responsive) to change the layout by viewport size.
|
||||
|
||||
{{< example class="bd-example-cssgrid" >}}
|
||||
<div class="grid text-center">
|
||||
<div class="g-col-4">.g-col-4</div>
|
||||
<div class="g-col-4">.g-col-4</div>
|
||||
<div class="g-col-4">.g-col-4</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Responsive
|
||||
|
||||
Use responsive classes to adjust your layout across viewports. Here we start with two columns on the narrowest viewports, and then grow to three columns on medium viewports and above.
|
||||
|
||||
{{< example class="bd-example-cssgrid" >}}
|
||||
<div class="grid text-center">
|
||||
<div class="g-col-6 g-col-md-4">.g-col-6 .g-col-md-4</div>
|
||||
<div class="g-col-6 g-col-md-4">.g-col-6 .g-col-md-4</div>
|
||||
<div class="g-col-6 g-col-md-4">.g-col-6 .g-col-md-4</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Compare that to this two column layout at all viewports.
|
||||
|
||||
{{< example class="bd-example-cssgrid" >}}
|
||||
<div class="grid text-center">
|
||||
<div class="g-col-6">.g-col-6</div>
|
||||
<div class="g-col-6">.g-col-6</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Wrapping
|
||||
|
||||
Grid items automatically wrap to the next line when there's no more room horizontally. Note that the `gap` applies to horizontal and vertical gaps between grid items.
|
||||
|
||||
{{< example class="bd-example-cssgrid" >}}
|
||||
<div class="grid text-center">
|
||||
<div class="g-col-6">.g-col-6</div>
|
||||
<div class="g-col-6">.g-col-6</div>
|
||||
|
||||
<div class="g-col-6">.g-col-6</div>
|
||||
<div class="g-col-6">.g-col-6</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Starts
|
||||
|
||||
Start classes aim to replace our default grid's offset classes, but they're not entirely the same. CSS Grid creates a grid template through styles that tell browsers to "start at this column" and "end at this column." Those properties are `grid-column-start` and `grid-column-end`. Start classes are shorthand for the former. Pair them with the column classes to size and align your columns however you need. Start classes begin at `1` as `0` is an invalid value for these properties.
|
||||
|
||||
{{< example class="bd-example-cssgrid" >}}
|
||||
<div class="grid text-center">
|
||||
<div class="g-col-3 g-start-2">.g-col-3 .g-start-2</div>
|
||||
<div class="g-col-4 g-start-6">.g-col-4 .g-start-6</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Auto columns
|
||||
|
||||
When there are no classes on the grid items (the immediate children of a `.grid`), each grid item will automatically be sized to one column.
|
||||
|
||||
{{< example class="bd-example-cssgrid" >}}
|
||||
<div class="grid text-center">
|
||||
<div>1</div>
|
||||
<div>1</div>
|
||||
<div>1</div>
|
||||
<div>1</div>
|
||||
<div>1</div>
|
||||
<div>1</div>
|
||||
<div>1</div>
|
||||
<div>1</div>
|
||||
<div>1</div>
|
||||
<div>1</div>
|
||||
<div>1</div>
|
||||
<div>1</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
This behavior can be mixed with grid column classes.
|
||||
|
||||
{{< example class="bd-example-cssgrid" >}}
|
||||
<div class="grid text-center">
|
||||
<div class="g-col-6">.g-col-6</div>
|
||||
<div>1</div>
|
||||
<div>1</div>
|
||||
<div>1</div>
|
||||
<div>1</div>
|
||||
<div>1</div>
|
||||
<div>1</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Nesting
|
||||
|
||||
Similar to our default grid system, our CSS Grid allows for easy nesting of `.grid`s. However, unlike the default, this grid inherits changes in the rows, columns, and gaps. Consider the example below:
|
||||
|
||||
- We override the default number of columns with a local CSS variable: `--bs-columns: 3`.
|
||||
- In the first auto-column, the column count is inherited and each column is one-third of the available width.
|
||||
- In the second auto-column, we've reset the column count on the nested `.grid` to 12 (our default).
|
||||
- The third auto-column has no nested content.
|
||||
|
||||
In practice this allows for more complex and custom layouts when compared to our default grid system.
|
||||
|
||||
{{< example class="bd-example-cssgrid" >}}
|
||||
<div class="grid text-center" style="--bs-columns: 3;">
|
||||
<div>
|
||||
First auto-column
|
||||
<div class="grid">
|
||||
<div>Auto-column</div>
|
||||
<div>Auto-column</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
Second auto-column
|
||||
<div class="grid" style="--bs-columns: 12;">
|
||||
<div class="g-col-6">6 of 12</div>
|
||||
<div class="g-col-4">4 of 12</div>
|
||||
<div class="g-col-2">2 of 12</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>Third auto-column</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Customizing
|
||||
|
||||
Customize the number of columns, the number of rows, and the width of the gaps with local CSS variables.
|
||||
|
||||
{{< bs-table "table" >}}
|
||||
| Variable | Fallback value | Description |
|
||||
| --- | --- | --- |
|
||||
| `--bs-rows` | `1` | The number of rows in your grid template |
|
||||
| `--bs-columns` | `12` | The number of columns in your grid template |
|
||||
| `--bs-gap` | `1.5rem` | The size of the gap between columns (vertical and horizontal) |
|
||||
{{< /bs-table >}}
|
||||
|
||||
These CSS variables have no default value; instead, they apply fallback values that are used _until_ a local instance is provided. For example, we use `var(--bs-rows, 1)` for our CSS Grid rows, which ignores `--bs-rows` because that hasn't been set anywhere yet. Once it is, the `.grid` instance will use that value instead of the fallback value of `1`.
|
||||
|
||||
### No grid classes
|
||||
|
||||
Immediate children elements of `.grid` are grid items, so they'll be sized without explicitly adding a `.g-col` class.
|
||||
|
||||
{{< example class="bd-example-cssgrid" >}}
|
||||
<div class="grid text-center" style="--bs-columns: 3;">
|
||||
<div>Auto-column</div>
|
||||
<div>Auto-column</div>
|
||||
<div>Auto-column</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Columns and gaps
|
||||
|
||||
Adjust the number of columns and the gap.
|
||||
|
||||
{{< example class="bd-example-cssgrid" >}}
|
||||
<div class="grid text-center" style="--bs-columns: 4; --bs-gap: 5rem;">
|
||||
<div class="g-col-2">.g-col-2</div>
|
||||
<div class="g-col-2">.g-col-2</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example class="bd-example-cssgrid" >}}
|
||||
<div class="grid text-center" style="--bs-columns: 10; --bs-gap: 1rem;">
|
||||
<div class="g-col-6">.g-col-6</div>
|
||||
<div class="g-col-4">.g-col-4</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Adding rows
|
||||
|
||||
Adding more rows and changing the placement of columns:
|
||||
|
||||
{{< example class="bd-example-cssgrid" >}}
|
||||
<div class="grid text-center" style="--bs-rows: 3; --bs-columns: 3;">
|
||||
<div>Auto-column</div>
|
||||
<div class="g-start-2" style="grid-row: 2">Auto-column</div>
|
||||
<div class="g-start-3" style="grid-row: 3">Auto-column</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Gaps
|
||||
|
||||
Change the vertical gaps only by modifying the `row-gap`. Note that we use `gap` on `.grid`s, but `row-gap` and `column-gap` can be modified as needed.
|
||||
|
||||
{{< example class="bd-example-cssgrid" >}}
|
||||
<div class="grid text-center" style="row-gap: 0;">
|
||||
<div class="g-col-6">.g-col-6</div>
|
||||
<div class="g-col-6">.g-col-6</div>
|
||||
|
||||
<div class="g-col-6">.g-col-6</div>
|
||||
<div class="g-col-6">.g-col-6</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Because of that, you can have different vertical and horizontal `gap`s, which can take a single value (all sides) or a pair of values (vertical and horizontal). This can be applied with an inline style for `gap`, or with our `--bs-gap` CSS variable.
|
||||
|
||||
{{< example class="bd-example-cssgrid" >}}
|
||||
<div class="grid text-center" style="--bs-gap: .25rem 1rem;">
|
||||
<div class="g-col-6">.g-col-6</div>
|
||||
<div class="g-col-6">.g-col-6</div>
|
||||
|
||||
<div class="g-col-6">.g-col-6</div>
|
||||
<div class="g-col-6">.g-col-6</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Sass
|
||||
|
||||
One limitation of the CSS Grid is that our default classes are still generated by two Sass variables, `$grid-columns` and `$grid-gutter-width`. This effectively predetermines the number of classes generated in our compiled CSS. You have two options here:
|
||||
|
||||
- Modify those default Sass variables and recompile your CSS.
|
||||
- Use inline or custom styles to augment the provided classes.
|
||||
|
||||
For example, you can increase the column count and change the gap size, and then size your "columns" with a mix of inline styles and predefined CSS Grid column classes (e.g., `.g-col-4`).
|
||||
|
||||
{{< example class="bd-example-cssgrid" >}}
|
||||
<div class="grid text-center" style="--bs-columns: 18; --bs-gap: .5rem;">
|
||||
<div style="grid-column: span 14;">14 columns</div>
|
||||
<div class="g-col-4">.g-col-4</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
|
@ -1,530 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Grid system
|
||||
description: Use our powerful mobile-first flexbox grid to build layouts of all shapes and sizes thanks to a twelve column system, six default responsive tiers, Sass variables and mixins, and dozens of predefined classes.
|
||||
group: layout
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Example
|
||||
|
||||
Bootstrap's grid system uses a series of containers, rows, and columns to layout and align content. It's built with [flexbox](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox) and is fully responsive. Below is an example and an in-depth explanation for how the grid system comes together.
|
||||
|
||||
{{< callout info >}}
|
||||
**New to or unfamiliar with flexbox?** [Read this CSS Tricks flexbox guide](https://css-tricks.com/snippets/css/a-guide-to-flexbox/#flexbox-background) for background, terminology, guidelines, and code snippets.
|
||||
{{< /callout >}}
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
Column
|
||||
</div>
|
||||
<div class="col">
|
||||
Column
|
||||
</div>
|
||||
<div class="col">
|
||||
Column
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
The above example creates three equal-width columns across all devices and viewports using our predefined grid classes. Those columns are centered in the page with the parent `.container`.
|
||||
|
||||
## How it works
|
||||
|
||||
Breaking it down, here's how the grid system comes together:
|
||||
|
||||
- **Our grid supports [six responsive breakpoints]({{< docsref "/layout/breakpoints" >}}).** Breakpoints are based on `min-width` media queries, meaning they affect that breakpoint and all those above it (e.g., `.col-sm-4` applies to `sm`, `md`, `lg`, `xl`, and `xxl`). This means you can control container and column sizing and behavior by each breakpoint.
|
||||
|
||||
- **Containers center and horizontally pad your content.** Use `.container` for a responsive pixel width, `.container-fluid` for `width: 100%` across all viewports and devices, or a responsive container (e.g., `.container-md`) for a combination of fluid and pixel widths.
|
||||
|
||||
- **Rows are wrappers for columns.** Each column has horizontal `padding` (called a gutter) for controlling the space between them. This `padding` is then counteracted on the rows with negative margins to ensure the content in your columns is visually aligned down the left side. Rows also support modifier classes to [uniformly apply column sizing](#row-columns) and [gutter classes]({{< docsref "/layout/gutters" >}}) to change the spacing of your content.
|
||||
|
||||
- **Columns are incredibly flexible.** There are 12 template columns available per row, allowing you to create different combinations of elements that span any number of columns. Column classes indicate the number of template columns to span (e.g., `col-4` spans four). `width`s are set in percentages so you always have the same relative sizing.
|
||||
|
||||
- **Gutters are also responsive and customizable.** [Gutter classes are available]({{< docsref "/layout/gutters" >}}) across all breakpoints, with all the same sizes as our [margin and padding spacing]({{< docsref "/utilities/spacing" >}}). Change horizontal gutters with `.gx-*` classes, vertical gutters with `.gy-*`, or all gutters with `.g-*` classes. `.g-0` is also available to remove gutters.
|
||||
|
||||
- **Sass variables, maps, and mixins power the grid.** If you don't want to use the predefined grid classes in Bootstrap, you can use our [grid's source Sass](#sass) to create your own with more semantic markup. We also include some CSS custom properties to consume these Sass variables for even greater flexibility for you.
|
||||
|
||||
Be aware of the limitations and [bugs around flexbox](https://github.com/philipwalton/flexbugs), like the [inability to use some HTML elements as flex containers](https://github.com/philipwalton/flexbugs#flexbug-9).
|
||||
|
||||
## Grid options
|
||||
|
||||
Bootstrap's grid system can adapt across all six default breakpoints, and any breakpoints you customize. The six default grid tiers are as follows:
|
||||
|
||||
- Extra small (xs)
|
||||
- Small (sm)
|
||||
- Medium (md)
|
||||
- Large (lg)
|
||||
- Extra large (xl)
|
||||
- Extra extra large (xxl)
|
||||
|
||||
As noted above, each of these breakpoints have their own container, unique class prefix, and modifiers. Here's how the grid changes across these breakpoints:
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table mb-4">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"></th>
|
||||
<th scope="col">
|
||||
xs<br>
|
||||
<span class="fw-normal"><576px</span>
|
||||
</th>
|
||||
<th scope="col">
|
||||
sm<br>
|
||||
<span class="fw-normal">≥576px</span>
|
||||
</th>
|
||||
<th scope="col">
|
||||
md<br>
|
||||
<span class="fw-normal">≥768px</span>
|
||||
</th>
|
||||
<th scope="col">
|
||||
lg<br>
|
||||
<span class="fw-normal">≥992px</span>
|
||||
</th>
|
||||
<th scope="col">
|
||||
xl<br>
|
||||
<span class="fw-normal">≥1200px</span>
|
||||
</th>
|
||||
<th scope="col">
|
||||
xxl<br>
|
||||
<span class="fw-normal">≥1400px</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="text-nowrap" scope="row">Container <code class="fw-normal">max-width</code></th>
|
||||
<td>None (auto)</td>
|
||||
<td>540px</td>
|
||||
<td>720px</td>
|
||||
<td>960px</td>
|
||||
<td>1140px</td>
|
||||
<td>1320px</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-nowrap" scope="row">Class prefix</th>
|
||||
<td><code>.col-</code></td>
|
||||
<td><code>.col-sm-</code></td>
|
||||
<td><code>.col-md-</code></td>
|
||||
<td><code>.col-lg-</code></td>
|
||||
<td><code>.col-xl-</code></td>
|
||||
<td><code>.col-xxl-</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-nowrap" scope="row"># of columns</th>
|
||||
<td colspan="6">12</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-nowrap" scope="row">Gutter width</th>
|
||||
<td colspan="6">1.5rem (.75rem on left and right)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-nowrap" scope="row">Custom gutters</th>
|
||||
<td colspan="6"><a href="{{< docsref "/layout/gutters" >}}">Yes</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-nowrap" scope="row">Nestable</th>
|
||||
<td colspan="6"><a href="#nesting">Yes</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-nowrap" scope="row">Column ordering</th>
|
||||
<td colspan="6"><a href="{{< docsref "/layout/columns#reordering" >}}">Yes</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
## Auto-layout columns
|
||||
|
||||
Utilize breakpoint-specific column classes for easy column sizing without an explicit numbered class like `.col-sm-6`.
|
||||
|
||||
### Equal-width
|
||||
|
||||
For example, here are two grid layouts that apply to every device and viewport, from `xs` to `xxl`. Add any number of unit-less classes for each breakpoint you need and every column will be the same width.
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
1 of 2
|
||||
</div>
|
||||
<div class="col">
|
||||
2 of 2
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
1 of 3
|
||||
</div>
|
||||
<div class="col">
|
||||
2 of 3
|
||||
</div>
|
||||
<div class="col">
|
||||
3 of 3
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Setting one column width
|
||||
|
||||
Auto-layout for flexbox grid columns also means you can set the width of one column and have the sibling columns automatically resize around it. You may use predefined grid classes (as shown below), grid mixins, or inline widths. Note that the other columns will resize no matter the width of the center column.
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
1 of 3
|
||||
</div>
|
||||
<div class="col-6">
|
||||
2 of 3 (wider)
|
||||
</div>
|
||||
<div class="col">
|
||||
3 of 3
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
1 of 3
|
||||
</div>
|
||||
<div class="col-5">
|
||||
2 of 3 (wider)
|
||||
</div>
|
||||
<div class="col">
|
||||
3 of 3
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Variable width content
|
||||
|
||||
Use `col-{breakpoint}-auto` classes to size columns based on the natural width of their content.
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row justify-content-md-center">
|
||||
<div class="col col-lg-2">
|
||||
1 of 3
|
||||
</div>
|
||||
<div class="col-md-auto">
|
||||
Variable width content
|
||||
</div>
|
||||
<div class="col col-lg-2">
|
||||
3 of 3
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
1 of 3
|
||||
</div>
|
||||
<div class="col-md-auto">
|
||||
Variable width content
|
||||
</div>
|
||||
<div class="col col-lg-2">
|
||||
3 of 3
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Responsive classes
|
||||
|
||||
Bootstrap's grid includes six tiers of predefined classes for building complex responsive layouts. Customize the size of your columns on extra small, small, medium, large, or extra large devices however you see fit.
|
||||
|
||||
### All breakpoints
|
||||
|
||||
For grids that are the same from the smallest of devices to the largest, use the `.col` and `.col-*` classes. Specify a numbered class when you need a particularly sized column; otherwise, feel free to stick to `.col`.
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row">
|
||||
<div class="col">col</div>
|
||||
<div class="col">col</div>
|
||||
<div class="col">col</div>
|
||||
<div class="col">col</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8">col-8</div>
|
||||
<div class="col-4">col-4</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Stacked to horizontal
|
||||
|
||||
Using a single set of `.col-sm-*` classes, you can create a basic grid system that starts out stacked and becomes horizontal at the small breakpoint (`sm`).
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row">
|
||||
<div class="col-sm-8">col-sm-8</div>
|
||||
<div class="col-sm-4">col-sm-4</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm">col-sm</div>
|
||||
<div class="col-sm">col-sm</div>
|
||||
<div class="col-sm">col-sm</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Mix and match
|
||||
|
||||
Don't want your columns to simply stack in some grid tiers? Use a combination of different classes for each tier as needed. See the example below for a better idea of how it all works.
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<!-- Stack the columns on mobile by making one full-width and the other half-width -->
|
||||
<div class="row">
|
||||
<div class="col-md-8">.col-md-8</div>
|
||||
<div class="col-6 col-md-4">.col-6 .col-md-4</div>
|
||||
</div>
|
||||
|
||||
<!-- Columns start at 50% wide on mobile and bump up to 33.3% wide on desktop -->
|
||||
<div class="row">
|
||||
<div class="col-6 col-md-4">.col-6 .col-md-4</div>
|
||||
<div class="col-6 col-md-4">.col-6 .col-md-4</div>
|
||||
<div class="col-6 col-md-4">.col-6 .col-md-4</div>
|
||||
</div>
|
||||
|
||||
<!-- Columns are always 50% wide, on mobile and desktop -->
|
||||
<div class="row">
|
||||
<div class="col-6">.col-6</div>
|
||||
<div class="col-6">.col-6</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
### Row columns
|
||||
|
||||
Use the responsive `.row-cols-*` classes to quickly set the number of columns that best render your content and layout. Whereas normal `.col-*` classes apply to the individual columns (e.g., `.col-md-4`), the row columns classes are set on the parent `.row` as a shortcut. With `.row-cols-auto` you can give the columns their natural width.
|
||||
|
||||
Use these row columns classes to quickly create basic grid layouts or to control your card layouts.
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row row-cols-2">
|
||||
<div class="col">Column</div>
|
||||
<div class="col">Column</div>
|
||||
<div class="col">Column</div>
|
||||
<div class="col">Column</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row row-cols-3">
|
||||
<div class="col">Column</div>
|
||||
<div class="col">Column</div>
|
||||
<div class="col">Column</div>
|
||||
<div class="col">Column</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row row-cols-auto">
|
||||
<div class="col">Column</div>
|
||||
<div class="col">Column</div>
|
||||
<div class="col">Column</div>
|
||||
<div class="col">Column</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row row-cols-4">
|
||||
<div class="col">Column</div>
|
||||
<div class="col">Column</div>
|
||||
<div class="col">Column</div>
|
||||
<div class="col">Column</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row row-cols-4">
|
||||
<div class="col">Column</div>
|
||||
<div class="col">Column</div>
|
||||
<div class="col-6">Column</div>
|
||||
<div class="col">Column</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-4">
|
||||
<div class="col">Column</div>
|
||||
<div class="col">Column</div>
|
||||
<div class="col">Column</div>
|
||||
<div class="col">Column</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
You can also use the accompanying Sass mixin, `row-cols()`:
|
||||
|
||||
```scss
|
||||
.element {
|
||||
// Three columns to start
|
||||
@include row-cols(3);
|
||||
|
||||
// Five columns from medium breakpoint up
|
||||
@include media-breakpoint-up(md) {
|
||||
@include row-cols(5);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Nesting
|
||||
|
||||
To nest your content with the default grid, add a new `.row` and set of `.col-sm-*` columns within an existing `.col-sm-*` column. Nested rows should include a set of columns that add up to 12 or fewer (it is not required that you use all 12 available columns).
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="container text-center">
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
Level 1: .col-sm-3
|
||||
</div>
|
||||
<div class="col-sm-9">
|
||||
<div class="row">
|
||||
<div class="col-8 col-sm-6">
|
||||
Level 2: .col-8 .col-sm-6
|
||||
</div>
|
||||
<div class="col-4 col-sm-6">
|
||||
Level 2: .col-4 .col-sm-6
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Sass
|
||||
|
||||
When using Bootstrap's source Sass files, you have the option of using Sass variables and mixins to create custom, semantic, and responsive page layouts. Our predefined grid classes use these same variables and mixins to provide a whole suite of ready-to-use classes for fast responsive layouts.
|
||||
|
||||
### Variables
|
||||
|
||||
Variables and maps determine the number of columns, the gutter width, and the media query point at which to begin floating columns. We use these to generate the predefined grid classes documented above, as well as for the custom mixins listed below.
|
||||
|
||||
```scss
|
||||
$grid-columns: 12;
|
||||
$grid-gutter-width: 1.5rem;
|
||||
$grid-row-columns: 6;
|
||||
```
|
||||
|
||||
{{< scss-docs name="grid-breakpoints" file="scss/_variables.scss" >}}
|
||||
|
||||
{{< scss-docs name="container-max-widths" file="scss/_variables.scss" >}}
|
||||
|
||||
### Mixins
|
||||
|
||||
Mixins are used in conjunction with the grid variables to generate semantic CSS for individual grid columns.
|
||||
|
||||
```scss
|
||||
// Creates a wrapper for a series of columns
|
||||
@include make-row();
|
||||
|
||||
// Make the element grid-ready (applying everything but the width)
|
||||
@include make-col-ready();
|
||||
|
||||
// Without optional size values, the mixin will create equal columns (similar to using .col)
|
||||
@include make-col();
|
||||
@include make-col($size, $columns: $grid-columns);
|
||||
|
||||
// Offset with margins
|
||||
@include make-col-offset($size, $columns: $grid-columns);
|
||||
```
|
||||
|
||||
### Example usage
|
||||
|
||||
You can modify the variables to your own custom values, or just use the mixins with their default values. Here's an example of using the default settings to create a two-column layout with a gap between.
|
||||
|
||||
```scss
|
||||
.example-container {
|
||||
@include make-container();
|
||||
// Make sure to define this width after the mixin to override
|
||||
// `width: 100%` generated by `make-container()`
|
||||
width: 800px;
|
||||
}
|
||||
|
||||
.example-row {
|
||||
@include make-row();
|
||||
}
|
||||
|
||||
.example-content-main {
|
||||
@include make-col-ready();
|
||||
|
||||
@include media-breakpoint-up(sm) {
|
||||
@include make-col(6);
|
||||
}
|
||||
@include media-breakpoint-up(lg) {
|
||||
@include make-col(8);
|
||||
}
|
||||
}
|
||||
|
||||
.example-content-secondary {
|
||||
@include make-col-ready();
|
||||
|
||||
@include media-breakpoint-up(sm) {
|
||||
@include make-col(6);
|
||||
}
|
||||
@include media-breakpoint-up(lg) {
|
||||
@include make-col(4);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
{{< example >}}
|
||||
<div class="example-container">
|
||||
<div class="example-row">
|
||||
<div class="example-content-main">Main content</div>
|
||||
<div class="example-content-secondary">Secondary content</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Customizing the grid
|
||||
|
||||
Using our built-in grid Sass variables and maps, it's possible to completely customize the predefined grid classes. Change the number of tiers, the media query dimensions, and the container widths—then recompile.
|
||||
|
||||
### Columns and gutters
|
||||
|
||||
The number of grid columns can be modified via Sass variables. `$grid-columns` is used to generate the widths (in percent) of each individual column while `$grid-gutter-width` sets the width for the column gutters. `$grid-row-columns` is used to set the maximum number of columns of `.row-cols-*`, any number over this limit is ignored.
|
||||
|
||||
```scss
|
||||
$grid-columns: 12 !default;
|
||||
$grid-gutter-width: 1.5rem !default;
|
||||
$grid-row-columns: 6 !default;
|
||||
```
|
||||
|
||||
### Grid tiers
|
||||
|
||||
Moving beyond the columns themselves, you may also customize the number of grid tiers. If you wanted just four grid tiers, you'd update the `$grid-breakpoints` and `$container-max-widths` to something like this:
|
||||
|
||||
```scss
|
||||
$grid-breakpoints: (
|
||||
xs: 0,
|
||||
sm: 480px,
|
||||
md: 768px,
|
||||
lg: 1024px
|
||||
);
|
||||
|
||||
$container-max-widths: (
|
||||
sm: 420px,
|
||||
md: 720px,
|
||||
lg: 960px
|
||||
);
|
||||
```
|
||||
|
||||
When making any changes to the Sass variables or maps, you'll need to save your changes and recompile. Doing so will output a brand-new set of predefined grid classes for column widths, offsets, and ordering. Responsive visibility utilities will also be updated to use the custom breakpoints. Make sure to set grid values in `px` (not `rem`, `em`, or `%`).
|
||||
|
|
@ -1,165 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Gutters
|
||||
description: Gutters are the padding between your columns, used to responsively space and align content in the Bootstrap grid system.
|
||||
group: layout
|
||||
toc: true
|
||||
---
|
||||
|
||||
## How they work
|
||||
|
||||
- **Gutters are the gaps between column content, created by horizontal `padding`.** We set `padding-right` and `padding-left` on each column, and use negative `margin` to offset that at the start and end of each row to align content.
|
||||
|
||||
- **Gutters start at `1.5rem` (`24px`) wide.** This allows us to match our grid to the [padding and margin spacers]({{< docsref "/utilities/spacing" >}}) scale.
|
||||
|
||||
- **Gutters can be responsively adjusted.** Use breakpoint-specific gutter classes to modify horizontal gutters, vertical gutters, and all gutters.
|
||||
|
||||
## Horizontal gutters
|
||||
|
||||
`.gx-*` classes can be used to control the horizontal gutter widths. The `.container` or `.container-fluid` parent may need to be adjusted if larger gutters are used too to avoid unwanted overflow, using a matching padding utility. For example, in the following example we've increased the padding with `.px-4`:
|
||||
|
||||
{{< example >}}
|
||||
<div class="container px-4 text-center">
|
||||
<div class="row gx-5">
|
||||
<div class="col">
|
||||
<div class="p-3 border bg-light">Custom column padding</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="p-3 border bg-light">Custom column padding</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
An alternative solution is to add a wrapper around the `.row` with the `.overflow-hidden` class:
|
||||
|
||||
{{< example >}}
|
||||
<div class="container overflow-hidden text-center">
|
||||
<div class="row gx-5">
|
||||
<div class="col">
|
||||
<div class="p-3 border bg-light">Custom column padding</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="p-3 border bg-light">Custom column padding</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Vertical gutters
|
||||
|
||||
`.gy-*` classes can be used to control the vertical gutter widths within a row when columns wrap to new lines. Like the horizontal gutters, the vertical gutters can cause some overflow below the `.row` at the end of a page. If this occurs, you add a wrapper around `.row` with the `.overflow-hidden` class:
|
||||
|
||||
{{< example >}}
|
||||
<div class="container overflow-hidden text-center">
|
||||
<div class="row gy-5">
|
||||
<div class="col-6">
|
||||
<div class="p-3 border bg-light">Custom column padding</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="p-3 border bg-light">Custom column padding</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="p-3 border bg-light">Custom column padding</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="p-3 border bg-light">Custom column padding</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Horizontal & vertical gutters
|
||||
|
||||
`.g-*` classes can be used to control the horizontal gutter widths, for the following example we use a smaller gutter width, so there won't be a need to add the `.overflow-hidden` wrapper class.
|
||||
|
||||
{{< example >}}
|
||||
<div class="container text-center">
|
||||
<div class="row g-2">
|
||||
<div class="col-6">
|
||||
<div class="p-3 border bg-light">Custom column padding</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="p-3 border bg-light">Custom column padding</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="p-3 border bg-light">Custom column padding</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="p-3 border bg-light">Custom column padding</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Row columns gutters
|
||||
|
||||
Gutter classes can also be added to [row columns]({{< docsref "/layout/grid#row-columns" >}}). In the following example, we use responsive row columns and responsive gutter classes.
|
||||
|
||||
{{< example >}}
|
||||
<div class="container text-center">
|
||||
<div class="row row-cols-2 row-cols-lg-5 g-2 g-lg-3">
|
||||
<div class="col">
|
||||
<div class="p-3 border bg-light">Row column</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="p-3 border bg-light">Row column</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="p-3 border bg-light">Row column</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="p-3 border bg-light">Row column</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="p-3 border bg-light">Row column</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="p-3 border bg-light">Row column</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="p-3 border bg-light">Row column</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="p-3 border bg-light">Row column</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="p-3 border bg-light">Row column</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="p-3 border bg-light">Row column</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## No gutters
|
||||
|
||||
The gutters between columns in our predefined grid classes can be removed with `.g-0`. This removes the negative `margin`s from `.row` and the horizontal `padding` from all immediate children columns.
|
||||
|
||||
**Need an edge-to-edge design?** Drop the parent `.container` or `.container-fluid` and add `.mx-0` to the `.row` to prevent overflow.
|
||||
|
||||
In practice, here's how it looks. Note you can continue to use this with all other predefined grid classes (including column widths, responsive tiers, reorders, and more).
|
||||
|
||||
{{< example class="bd-example-row" >}}
|
||||
<div class="row g-0 text-center">
|
||||
<div class="col-sm-6 col-md-8">.col-sm-6 .col-md-8</div>
|
||||
<div class="col-6 col-md-4">.col-6 .col-md-4</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Change the gutters
|
||||
|
||||
Classes are built from the `$gutters` Sass map which is inherited from the `$spacers` Sass map.
|
||||
|
||||
```scss
|
||||
$grid-gutter-width: 1.5rem;
|
||||
$gutters: (
|
||||
0: 0,
|
||||
1: $spacer * .25,
|
||||
2: $spacer * .5,
|
||||
3: $spacer,
|
||||
4: $spacer * 1.5,
|
||||
5: $spacer * 3,
|
||||
);
|
||||
```
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Utilities for layout
|
||||
description: For faster mobile-friendly and responsive development, Bootstrap includes dozens of utility classes for showing, hiding, aligning, and spacing content.
|
||||
group: layout
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Changing `display`
|
||||
|
||||
Use our [display utilities]({{< docsref "/utilities/display" >}}) for responsively toggling common values of the `display` property. Mix it with our grid system, content, or components to show or hide them across specific viewports.
|
||||
|
||||
## Flexbox options
|
||||
|
||||
Bootstrap is built with flexbox, but not every element's `display` has been changed to `display: flex` as this would add many unnecessary overrides and unexpectedly change key browser behaviors. Most of [our components]({{< docsref "/components/alerts" >}}) are built with flexbox enabled.
|
||||
|
||||
Should you need to add `display: flex` to an element, do so with `.d-flex` or one of the responsive variants (e.g., `.d-sm-flex`). You'll need this class or `display` value to allow the use of our extra [flexbox utilities]({{< docsref "/utilities/flex" >}}) for sizing, alignment, spacing, and more.
|
||||
|
||||
## Margin and padding
|
||||
|
||||
Use the `margin` and `padding` [spacing utilities]({{< docsref "/utilities/spacing" >}}) to control how elements and components are spaced and sized. Bootstrap includes a six-level scale for spacing utilities, based on a `1rem` value default `$spacer` variable. Choose values for all viewports (e.g., `.me-3` for `margin-right: 1rem` in LTR), or pick responsive variants to target specific viewports (e.g., `.me-md-3` for `margin-right: 1rem` —in LTR— starting at the `md` breakpoint).
|
||||
|
||||
## Toggle `visibility`
|
||||
|
||||
When toggling `display` isn't needed, you can toggle the `visibility` of an element with our [visibility utilities]({{< docsref "/utilities/visibility" >}}). Invisible elements will still affect the layout of the page, but are visually hidden from visitors.
|
||||
|
|
@ -1,504 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Migrating to v5
|
||||
description: Track and review changes to the Bootstrap source files, documentation, and components to help you migrate from v4 to v5.
|
||||
group: migration
|
||||
aliases: "/migration/"
|
||||
toc: true
|
||||
---
|
||||
|
||||
## v5.2.0
|
||||
|
||||
<hr class="mb-4">
|
||||
|
||||
### Refreshed design
|
||||
|
||||
Bootstrap v5.2.0 features a subtle design update for a handful of components and properties across the project, **most notably through refined `border-radius` values on buttons and form controls**. Our documentation also has been updated with a new homepage, simpler docs layout that no longer collapses sections of the sidebar, and more prominent examples of [Bootstrap Icons](https://icons.getbootstrap.com).
|
||||
|
||||
### More CSS variables
|
||||
|
||||
**We've updated all our components to use CSS variables.** While Sass still underpins everything, each component has been updated to include CSS variables on the component base classes (e.g., `.btn`), allowing for more real-time customization of Bootstrap. In subsequent releases, we'll continue to expand our use of CSS variables into our layout, forms, helpers, and utilities. Read more about CSS variables in each component on their respective documentation pages.
|
||||
|
||||
Our CSS variable usage will be somewhat incomplete until Bootstrap 6. While we'd love to fully implement these across the board, they do run the risk of causing breaking changes. For example, setting `$alert-border-width: var(--bs-border-width)` in our source code breaks potential Sass in your own code if you were doing `$alert-border-width * 2` for some reason.
|
||||
|
||||
As such, wherever possible, we will continue to push towards more CSS variables, but please recognize our implementation may be slightly limited in v5.
|
||||
|
||||
### New `_maps.scss`
|
||||
|
||||
**Bootstrap v5.2.0 introduced a new Sass file with `_maps.scss`.** It pulls out several Sass maps from `_variables.scss` to fix an issue where updates to an original map were not applied to secondary maps that extend them. For example, updates to `$theme-colors` were not being applied to other theme maps that relied on `$theme-colors`, breaking key customization workflows. In short, Sass has a limitation where once a default variable or map has been _used_, it cannot be updated. _There's a similar shortcoming with CSS variables when they're used to compose other CSS variables._
|
||||
|
||||
This is why variable customizations in Bootstrap have to come after `@import "functions"`, but before `@import "variables"` and the rest of our import stack. The same applies to Sass maps—you must override the defaults before they get used. The following maps have been moved to the new `_maps.scss`:
|
||||
|
||||
- `$theme-colors-rgb`
|
||||
- `$utilities-colors`
|
||||
- `$utilities-text`
|
||||
- `$utilities-text-colors`
|
||||
- `$utilities-bg`
|
||||
- `$utilities-bg-colors`
|
||||
- `$negative-spacers`
|
||||
- `$gutters`
|
||||
|
||||
Your custom Bootstrap CSS builds should now look something like this with a separate maps import.
|
||||
|
||||
```diff
|
||||
// Functions come first
|
||||
@import "functions";
|
||||
|
||||
// Optional variable overrides here
|
||||
+ $custom-color: #df711b;
|
||||
+ $custom-theme-colors: (
|
||||
+ "custom": $custom-color
|
||||
+ );
|
||||
|
||||
// Variables come next
|
||||
@import "variables";
|
||||
|
||||
+ // Optional Sass map overrides here
|
||||
+ $theme-colors: map-merge($theme-colors, $custom-theme-colors);
|
||||
+
|
||||
+ // Followed by our default maps
|
||||
+ @import "maps";
|
||||
+
|
||||
// Rest of our imports
|
||||
@import "mixins";
|
||||
@import "utilities";
|
||||
@import "root";
|
||||
@import "reboot";
|
||||
// etc
|
||||
```
|
||||
|
||||
### New utilities
|
||||
|
||||
- Expanded [`font-weight` utilities]({{< docsref "/utilities/text#font-weight-and-italics" >}}) to include `.fw-semibold` for semibold fonts.
|
||||
- Expanded [`border-radius` utilities]({{< docsref "/utilities/borders#sizes" >}}) to include two new sizes, `.rounded-4` and `.rounded-5`, for more options.
|
||||
|
||||
### Additional changes
|
||||
|
||||
- **Introduced new `$enable-container-classes` option. —** Now when opting into the experimental CSS Grid layout, `.container-*` classes will still be compiled, unless this option is set to `false`. Containers also now keep their gutter values.
|
||||
|
||||
- **Offcanvas component now has [responsive variations]({{< docsref "/components/offcanvas#responsive" >}}).** The original `.offcanvas` class remains unchanged—it hides content across all viewports. To make it responsive, change that `.offcanvas` class to any `.offcanvas-{sm|md|lg|xl|xxl}` class.
|
||||
|
||||
- **Thicker table dividers are now opt-in. —** We've removed the thicker and more difficult to override border between table groups and moved it to an optional class you can apply, `.table-group-divider`. [See the table docs for an example.]({{< docsref "/content/tables#table-group-dividers" >}})
|
||||
|
||||
- **[Scrollspy has been rewritten](https://github.com/twbs/bootstrap/pull/33421) to use the Intersection Observer API**, which means you no longer need relative parent wrappers, deprecates `offset` config, and more. Look for your Scrollspy implementations to be more accurate and consistent in their nav highlighting.
|
||||
|
||||
- **Popovers and tooltips now use CSS variables.** Some CSS variables have been updated from their Sass counterparts to reduce the number of variables. As a result, three variables have been deprecated in this release: `$popover-arrow-color`, `$popover-arrow-outer-color`, and `$tooltip-arrow-color`.
|
||||
|
||||
- **Added new `.text-bg-{color}` helpers.** Instead of setting individual `.text-*` and `.bg-*` utilities, you can now use [the `.text-bg-*` helpers]({{< docsref "helpers/color-background" >}}) to set a `background-color` with contrasting foreground `color`.
|
||||
|
||||
- Added `.form-check-reverse` modifier to flip the order of labels and associated checkboxes/radios.
|
||||
|
||||
- Added [striped columns]({{< docsref "/content/tables#striped-columns" >}}) support to tables via the new `.table-striped-columns` class.
|
||||
|
||||
For a complete list of changes, [see the v5.2.0 project on GitHub](https://github.com/twbs/bootstrap/projects/32).
|
||||
|
||||
## v5.1.0
|
||||
|
||||
<hr class="mb-4">
|
||||
|
||||
- **Added experimental support for [CSS Grid layout]({{< docsref "/layout/css-grid" >}}). —** This is a work in progress, and is not yet ready for production use, but you can opt into the new feature via Sass. To enable it, disable the default grid, by setting `$enable-grid-classes: false` and enable the CSS Grid by setting `$enable-cssgrid: true`.
|
||||
|
||||
- **Updated navbars to support offcanvas. —** Add [offcanvas drawers in any navbar]({{< docsref "/components/navbar#offcanvas" >}}) with the responsive `.navbar-expand-*` classes and some offcanvas markup.
|
||||
|
||||
- **Added new [placeholder component]({{< docsref "/components/placeholders/" >}}). —** Our newest component, a way to provide temporary blocks in lieu of real content to help indicate that something is still loading in your site or app.
|
||||
|
||||
- **Collapse plugin now supports [horizontal collapsing]({{< docsref "/components/collapse#horizontal" >}}). —** Add `.collapse-horizontal` to your `.collapse` to collapse the `width` instead of the `height`. Avoid browser repainting by setting a `min-height` or `height`.
|
||||
|
||||
- **Added new stack and vertical rule helpers. —** Quickly apply multiple flexbox properties to quickly create custom layouts with [stacks]({{< docsref "/helpers/stacks/" >}}). Choose from horizontal (`.hstack`) and vertical (`.vstack`) stacks. Add vertical dividers similar to `<hr>` elements with the [new `.vr` helpers]({{< docsref "/helpers/vertical-rule/" >}}).
|
||||
|
||||
- **Added new global `:root` CSS variables. —** Added several new CSS variables to the `:root` level for controlling `<body>` styles. More are in the works, including across our utilities and components, but for now read up [CSS variables in the Customize section]({{< docsref "/customize/css-variables/" >}}).
|
||||
|
||||
- **Overhauled color and background utilities to use CSS variables, and added new [text opacity]({{< docsref "/utilities/text#opacity" >}}) and [background opacity]({{< docsref "/utilities/background#opacity" >}}) utilities. —** `.text-*` and `.bg-*` utilities are now built with CSS variables and `rgba()` color values, allowing you to easily customize any utility with new opacity utilities.
|
||||
|
||||
- **Added new snippet examples based to show how to customize our components. —** Pull ready to use customized components and other common design patterns with our new [Snippets examples]({{< docsref "/examples#snippets" >}}). Includes [footers]({{< docsref "/examples/footers/" >}}), [dropdowns]({{< docsref "/examples/dropdowns/" >}}), [list groups]({{< docsref "/examples/list-groups/" >}}), and [modals]({{< docsref "/examples/modals/" >}}).
|
||||
|
||||
- **Removed unused positioning styles from popovers and tooltips** as these are handled solely by Popper. `$tooltip-margin` has been deprecated and set to `null` in the process.
|
||||
|
||||
Want more information? [Read the v5.1.0 blog post.](https://blog.getbootstrap.com/2021/08/04/bootstrap-5-1-0/)
|
||||
|
||||
<hr class="my-5">
|
||||
|
||||
{{< callout info >}}
|
||||
**Hey there!** Changes to our first major release of Bootstrap 5, v5.0.0, are documented below. They don't reflect the additional changes shown above.
|
||||
{{< /callout >}}
|
||||
|
||||
## Dependencies
|
||||
|
||||
- Dropped jQuery.
|
||||
- Upgraded from Popper v1.x to Popper v2.x.
|
||||
- Replaced Libsass with Dart Sass as our Sass compiler given Libsass was deprecated.
|
||||
- Migrated from Jekyll to Hugo for building our documentation
|
||||
|
||||
## Browser support
|
||||
|
||||
- Dropped Internet Explorer 10 and 11
|
||||
- Dropped Microsoft Edge < 16 (Legacy Edge)
|
||||
- Dropped Firefox < 60
|
||||
- Dropped Safari < 12
|
||||
- Dropped iOS Safari < 12
|
||||
- Dropped Chrome < 60
|
||||
|
||||
<hr class="my-5">
|
||||
|
||||
## Documentation changes
|
||||
|
||||
- Redesigned homepage, docs layout, and footer.
|
||||
- Added [new Parcel guide]({{< docsref "/getting-started/parcel" >}}).
|
||||
- Added [new Customize section]({{< docsref "/customize/overview" >}}), replacing [v4's Theming page](https://getbootstrap.com/docs/4.6/getting-started/theming/), with new details on Sass, global configuration options, color schemes, CSS variables, and more.
|
||||
- Reorganized all form documentation into [new Forms section]({{< docsref "/forms/overview" >}}), breaking apart the content into more focused pages.
|
||||
- Similarly, updated [the Layout section]({{< docsref "/layout/breakpoints" >}}), to flesh out grid content more clearly.
|
||||
- Renamed "Navs" component page to "Navs & Tabs".
|
||||
- Renamed "Checks" page to "Checks & radios".
|
||||
- Redesigned the navbar and added a new subnav to make it easier to get around our sites and docs versions.
|
||||
- Added new keyboard shortcut for the search field: <kbd>Ctrl + /</kbd>.
|
||||
|
||||
## Sass
|
||||
|
||||
- We've ditched the default Sass map merges to make it easier to remove redundant values. Keep in mind you now have to define all values in the Sass maps like `$theme-colors`. Check out how to deal with [Sass maps]({{< docsref "/customize/sass#maps-and-loops" >}}).
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Renamed `color-yiq()` function and related variables to `color-contrast()` as it's no longer related to YIQ color space. [See #30168.](https://github.com/twbs/bootstrap/pull/30168/)
|
||||
- `$yiq-contrasted-threshold` is renamed to `$min-contrast-ratio`.
|
||||
- `$yiq-text-dark` and `$yiq-text-light` are respectively renamed to `$color-contrast-dark` and `$color-contrast-light`.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Media query mixins parameters have changed for a more logical approach.
|
||||
- `media-breakpoint-down()` uses the breakpoint itself instead of the next breakpoint (e.g., `media-breakpoint-down(lg)` instead of `media-breakpoint-down(md)` targets viewports smaller than `lg`).
|
||||
- Similarly, the second parameter in `media-breakpoint-between()` also uses the breakpoint itself instead of the next breakpoint (e.g., `media-between(sm, lg)` instead of `media-breakpoint-between(sm, md)` targets viewports between `sm` and `lg`).
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Removed print styles and `$enable-print-styles` variable. Print display classes are still around. [See #28339](https://github.com/twbs/bootstrap/pull/28339).
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Dropped `color()`, `theme-color()`, and `gray()` functions in favor of variables. [See #29083](https://github.com/twbs/bootstrap/pull/29083).
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Renamed `theme-color-level()` function to `color-level()` and now accepts any color you want instead of only `$theme-color` colors. [See #29083](https://github.com/twbs/bootstrap/pull/29083) **Watch out:** `color-level()` was later on dropped in `v5.0.0-alpha3`.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Renamed `$enable-prefers-reduced-motion-media-query` and `$enable-pointer-cursor-for-buttons` to `$enable-reduced-motion` and `$enable-button-pointers` for brevity.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Removed the `bg-gradient-variant()` mixin. Use the `.bg-gradient` class to add gradients to elements instead of the generated `.bg-gradient-*` classes.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> **Removed previously deprecated mixins:**
|
||||
- `hover`, `hover-focus`, `plain-hover-focus`, and `hover-focus-active`
|
||||
- `float()`
|
||||
- `form-control-mixin()`
|
||||
- `nav-divider()`
|
||||
- `retina-img()`
|
||||
- `text-hide()` (also dropped the associated utility class, `.text-hide`)
|
||||
- `visibility()`
|
||||
- `form-control-focus()`
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Renamed `scale-color()` function to `shift-color()` to avoid collision with Sass's own color scaling function.
|
||||
|
||||
- `box-shadow` mixins now allow `null` values and drop `none` from multiple arguments. [See #30394](https://github.com/twbs/bootstrap/pull/30394).
|
||||
|
||||
- The `border-radius()` mixin now has a default value.
|
||||
|
||||
## Color system
|
||||
|
||||
- The color system which worked with `color-level()` and `$theme-color-interval` was removed in favor of a new color system. All `lighten()` and `darken()` functions in our codebase are replaced by `tint-color()` and `shade-color()`. These functions will mix the color with either white or black instead of changing its lightness by a fixed amount. The `shift-color()` will either tint or shade a color depending on whether its weight parameter is positive or negative. [See #30622](https://github.com/twbs/bootstrap/pull/30622) for more details.
|
||||
|
||||
- Added new tints and shades for every color, providing nine separate colors for each base color, as new Sass variables.
|
||||
|
||||
- Improved color contrast. Bumped color contrast ratio from 3:1 to 4.5:1 and updated blue, green, cyan, and pink colors to ensure WCAG 2.1 AA contrast. Also changed our color contrast color from `$gray-900` to `$black`.
|
||||
|
||||
- To support our color system, we've added new custom `tint-color()` and `shade-color()` functions to mix our colors appropriately.
|
||||
|
||||
## Grid updates
|
||||
|
||||
- **New breakpoint!** Added new `xxl` breakpoint for `1400px` and up. No changes to all other breakpoints.
|
||||
|
||||
- **Improved gutters.** Gutters are now set in rems, and are narrower than v4 (`1.5rem`, or about `24px`, down from `30px`). This aligns our grid system's gutters with our spacing utilities.
|
||||
- Added new [gutter class]({{< docsref "/layout/gutters" >}}) (`.g-*`, `.gx-*`, and `.gy-*`) to control horizontal/vertical gutters, horizontal gutters, and vertical gutters.
|
||||
- <span class="badge bg-danger">Breaking</span> Renamed `.no-gutters` to `.g-0` to match new gutter utilities.
|
||||
|
||||
- Columns no longer have `position: relative` applied, so you may have to add `.position-relative` to some elements to restore that behavior.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Dropped several `.order-*` classes that often went unused. We now only provide `.order-1` to `.order-5` out of the box.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Dropped the `.media` component as it can be easily replicated with utilities. [See #28265](https://github.com/twbs/bootstrap/pull/28265) and the [flex utilities page for an example]({{< docsref "/utilities/flex#media-object" >}}).
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> `bootstrap-grid.css` now only applies `box-sizing: border-box` to the column instead of resetting the global box-sizing. This way, our grid styles can be used in more places without interference.
|
||||
|
||||
- `$enable-grid-classes` no longer disables the generation of container classes anymore. [See #29146.](https://github.com/twbs/bootstrap/pull/29146)
|
||||
|
||||
- Updated the `make-col` mixin to default to equal columns without a specified size.
|
||||
|
||||
## Content, Reboot, etc
|
||||
|
||||
- **[RFS]({{< docsref "/getting-started/rfs" >}}) is now enabled by default.** Headings using the `font-size()` mixin will automatically adjust their `font-size` to scale with the viewport. _This feature was previously opt-in with v4._
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Overhauled our display typography to replace our `$display-*` variables and with a `$display-font-sizes` Sass map. Also removed the individual `$display-*-weight` variables for a single `$display-font-weight` and adjusted `font-size`s.
|
||||
|
||||
- Added two new `.display-*` heading sizes, `.display-5` and `.display-6`.
|
||||
|
||||
- **Links are underlined by default** (not just on hover), unless they're part of specific components.
|
||||
|
||||
- **Redesigned tables** to refresh their styles and rebuild them with CSS variables for more control over styling.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Nested tables do not inherit styles anymore.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> `.thead-light` and `.thead-dark` are dropped in favor of the `.table-*` variant classes which can be used for all table elements (`thead`, `tbody`, `tfoot`, `tr`, `th` and `td`).
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> The `table-row-variant()` mixin is renamed to `table-variant()` and accepts only 2 parameters: `$color` (color name) and `$value` (color code). The border color and accent colors are automatically calculated based on the table factor variables.
|
||||
|
||||
- Split table cell padding variables into `-y` and `-x`.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Dropped `.pre-scrollable` class. [See #29135](https://github.com/twbs/bootstrap/pull/29135)
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> `.text-*` utilities do not add hover and focus states to links anymore. `.link-*` helper classes can be used instead. [See #29267](https://github.com/twbs/bootstrap/pull/29267)
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Dropped `.text-justify` class. [See #29793](https://github.com/twbs/bootstrap/pull/29793)
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> ~~`<hr>` elements now use `height` instead of `border` to better support the `size` attribute. This also enables use of padding utilities to create thicker dividers (e.g., `<hr class="py-1">`).~~
|
||||
|
||||
- Reset default horizontal `padding-left` on `<ul>` and `<ol>` elements from browser default `40px` to `2rem`.
|
||||
|
||||
- Added `$enable-smooth-scroll`, which applies `scroll-behavior: smooth` globally—except for users asking for reduced motion through `prefers-reduced-motion` media query. [See #31877](https://github.com/twbs/bootstrap/pull/31877)
|
||||
|
||||
## RTL
|
||||
|
||||
- Horizontal direction specific variables, utilities, and mixins have all been renamed to use logical properties like those found in flexbox layouts—e.g., `start` and `end` in lieu of `left` and `right`.
|
||||
|
||||
## Forms
|
||||
|
||||
- **Added new floating forms!** We've promoted the Floating labels example to fully supported form components. [See the new Floating labels page.]({{< docsref "/forms/floating-labels" >}})
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> **Consolidated native and custom form elements.** Checkboxes, radios, selects, and other inputs that had native and custom classes in v4 have been consolidated. Now nearly all our form elements are entirely custom, most without the need for custom HTML.
|
||||
- `.custom-control.custom-checkbox` is now `.form-check`.
|
||||
- `.custom-control.custom-custom-radio` is now `.form-check`.
|
||||
- `.custom-control.custom-switch` is now `.form-check.form-switch`.
|
||||
- `.custom-select` is now `.form-select`.
|
||||
- `.custom-file` and `.form-file` have been replaced by custom styles on top of `.form-control`.
|
||||
- `.custom-range` is now `.form-range`.
|
||||
- Dropped native `.form-control-file` and `.form-control-range`.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Dropped `.input-group-append` and `.input-group-prepend`. You can now just add buttons and `.input-group-text` as direct children of the input groups.
|
||||
|
||||
- The longstanding [Missing border radius on input group with validation feedback bug](https://github.com/twbs/bootstrap/issues/25110) is finally fixed by adding an additional `.has-validation` class to input groups with validation.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> **Dropped form-specific layout classes for our grid system.** Use our grid and utilities instead of `.form-group`, `.form-row`, or `.form-inline`.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Form labels now require `.form-label`.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> `.form-text` no longer sets `display`, allowing you to create inline or block help text as you wish just by changing the HTML element.
|
||||
|
||||
- Form controls no longer used fixed `height` when possible, instead deferring to `min-height` to improve customization and compatibility with other components.
|
||||
|
||||
- Validation icons are no longer applied to `<select>`s with `multiple`.
|
||||
|
||||
- Rearranged source Sass files under `scss/forms/`, including input group styles.
|
||||
|
||||
<hr class="my-5">
|
||||
|
||||
## Components
|
||||
|
||||
- Unified `padding` values for alerts, breadcrumbs, cards, dropdowns, list groups, modals, popovers, and tooltips to be based on our `$spacer` variable. [See #30564](https://github.com/twbs/bootstrap/pull/30564).
|
||||
|
||||
### Accordion
|
||||
|
||||
- Added [new accordion component]({{< docsref "/components/accordion" >}}).
|
||||
|
||||
### Alerts
|
||||
|
||||
- Alerts now have [examples with icons]({{< docsref "/components/alerts#icons" >}}).
|
||||
|
||||
- Removed custom styles for `<hr>`s in each alert since they already use `currentColor`.
|
||||
|
||||
### Badges
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Dropped all `.badge-*` color classes for background utilities (e.g., use `.bg-primary` instead of `.badge-primary`).
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Dropped `.badge-pill`—use the `.rounded-pill` utility instead.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Removed hover and focus styles for `<a>` and `<button>` elements.
|
||||
|
||||
- Increased default padding for badges from `.25em`/`.5em` to `.35em`/`.65em`.
|
||||
|
||||
### Breadcrumbs
|
||||
|
||||
- Simplified the default appearance of breadcrumbs by removing `padding`, `background-color`, and `border-radius`.
|
||||
|
||||
- Added new CSS custom property `--bs-breadcrumb-divider` for easy customization without needing to recompile CSS.
|
||||
|
||||
### Buttons
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> **[Toggle buttons]({{< docsref "/forms/checks-radios#toggle-buttons" >}}), with checkboxes or radios, no longer require JavaScript and have new markup.** We no longer require a wrapping element, add `.btn-check` to the `<input>`, and pair it with any `.btn` classes on the `<label>`. [See #30650](https://github.com/twbs/bootstrap/pull/30650). _The docs for this has moved from our Buttons page to the new Forms section._
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> **Dropped `.btn-block` for utilities.** Instead of using `.btn-block` on the `.btn`, wrap your buttons with `.d-grid` and a `.gap-*` utility to space them as needed. Switch to responsive classes for even more control over them. [Read the docs for some examples.]({{< docsref "/components/buttons#block-buttons" >}})
|
||||
|
||||
- Updated our `button-variant()` and `button-outline-variant()` mixins to support additional parameters.
|
||||
|
||||
- Updated buttons to ensure increased contrast on hover and active states.
|
||||
|
||||
- Disabled buttons now have `pointer-events: none;`.
|
||||
|
||||
### Card
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Dropped `.card-deck` in favor of our grid. Wrap your cards in column classes and add a parent `.row-cols-*` container to recreate card decks (but with more control over responsive alignment).
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Dropped `.card-columns` in favor of Masonry. [See #28922](https://github.com/twbs/bootstrap/pull/28922).
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Replaced the `.card` based accordion with a [new Accordion component]({{< docsref "/components/accordion" >}}).
|
||||
|
||||
### Carousel
|
||||
|
||||
- Added new [`.carousel-dark` variant]({{< docsref "/components/carousel#dark-variant" >}}) for dark text, controls, and indicators (great for lighter backgrounds).
|
||||
|
||||
- Replaced chevron icons for carousel controls with new SVGs from [Bootstrap Icons]({{< param "icons" >}}).
|
||||
|
||||
### Close button
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Renamed `.close` to `.btn-close` for a less generic name.
|
||||
|
||||
- Close buttons now use a `background-image` (embedded SVG) instead of a `×` in the HTML, allowing for easier customization without the need to touch your markup.
|
||||
|
||||
- Added new `.btn-close-white` variant that uses `filter: invert(1)` to enable higher contrast dismiss icons against darker backgrounds.
|
||||
|
||||
### Collapse
|
||||
|
||||
- Removed scroll anchoring for accordions.
|
||||
|
||||
### Dropdowns
|
||||
|
||||
- Added new `.dropdown-menu-dark` variant and associated variables for on-demand dark dropdowns.
|
||||
|
||||
- Added new variable for `$dropdown-padding-x`.
|
||||
|
||||
- Darkened the dropdown divider for improved contrast.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> All the events for the dropdown are now triggered on the dropdown toggle button and then bubbled up to the parent element.
|
||||
|
||||
- Dropdown menus now have a `data-bs-popper="static"` attribute set when the positioning of the dropdown is static, or dropdown is in the navbar. This is added by our JavaScript and helps us use custom position styles without interfering with Popper's positioning.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Dropped `flip` option for dropdown plugin in favor of native Popper configuration. You can now disable the flipping behavior by passing an empty array for [`fallbackPlacements`](https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements) option in [flip](https://popper.js.org/docs/v2/modifiers/flip/) modifier.
|
||||
|
||||
- Dropdown menus can now be clickable with a new `autoClose` option to handle the [auto close behavior]({{< docsref "/components/dropdowns#auto-close-behavior" >}}). You can use this option to accept the click inside or outside the dropdown menu to make it interactive.
|
||||
|
||||
- Dropdowns now support `.dropdown-item`s wrapped in `<li>`s.
|
||||
|
||||
### Jumbotron
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Dropped the jumbotron component as it can be replicated with utilities. [See our new Jumbotron example for a demo.]({{< docsref "/examples/jumbotron" >}})
|
||||
|
||||
### List group
|
||||
|
||||
- Added new [`.list-group-numbered` modifier]({{< docsref "/components/list-group#numbered" >}}) to list groups.
|
||||
|
||||
### Navs and tabs
|
||||
|
||||
- Added new `null` variables for `font-size`, `font-weight`, `color`, and `:hover` `color` to the `.nav-link` class.
|
||||
|
||||
### Navbars
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Navbars now require a container within (to drastically simplify spacing requirements and CSS required).
|
||||
- <span class="badge bg-danger">Breaking</span> The `.active` class can no longer be applied to `.nav-item`s, it must be applied directly on `.nav-link`s.
|
||||
|
||||
### Offcanvas
|
||||
|
||||
- Added the new [offcanvas component]({{< docsref "/components/offcanvas" >}}).
|
||||
|
||||
### Pagination
|
||||
|
||||
- Pagination links now have customizable `margin-left` that are dynamically rounded on all corners when separated from one another.
|
||||
|
||||
- Added `transition`s to pagination links.
|
||||
|
||||
### Popovers
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Renamed `.arrow` to `.popover-arrow` in our default popover template.
|
||||
|
||||
- Renamed `whiteList` option to `allowList`.
|
||||
|
||||
### Spinners
|
||||
|
||||
- Spinners now honor `prefers-reduced-motion: reduce` by slowing down animations. [See #31882](https://github.com/twbs/bootstrap/pull/31882).
|
||||
|
||||
- Improved spinner vertical alignment.
|
||||
|
||||
### Toasts
|
||||
|
||||
- Toasts can now be [positioned]({{< docsref "/components/toasts#placement" >}}) in a `.toast-container` with the help of [positioning utilities]({{< docsref "/utilities/position" >}}).
|
||||
|
||||
- Changed default toast duration to 5 seconds.
|
||||
|
||||
- Removed `overflow: hidden` from toasts and replaced with proper `border-radius`s with `calc()` functions.
|
||||
|
||||
### Tooltips
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Renamed `.arrow` to `.tooltip-arrow` in our default tooltip template.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> The default value for the `fallbackPlacements` is changed to `['top', 'right', 'bottom', 'left']` for better placement of popper elements.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Renamed `whiteList` option to `allowList`.
|
||||
|
||||
## Utilities
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Renamed several utilities to use logical property names instead of directional names with the addition of RTL support:
|
||||
- Renamed `.left-*` and `.right-*` to `.start-*` and `.end-*`.
|
||||
- Renamed `.float-left` and `.float-right` to `.float-start` and `.float-end`.
|
||||
- Renamed `.border-left` and `.border-right` to `.border-start` and `.border-end`.
|
||||
- Renamed `.rounded-left` and `.rounded-right` to `.rounded-start` and `.rounded-end`.
|
||||
- Renamed `.ml-*` and `.mr-*` to `.ms-*` and `.me-*`.
|
||||
- Renamed `.pl-*` and `.pr-*` to `.ps-*` and `.pe-*`.
|
||||
- Renamed `.text-left` and `.text-right` to `.text-start` and `.text-end`.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Disabled negative margins by default.
|
||||
|
||||
- Added new `.bg-body` class for quickly setting the `<body>`'s background to additional elements.
|
||||
|
||||
- Added new [position utilities]({{< docsref "/utilities/position#arrange-elements" >}}) for `top`, `right`, `bottom`, and `left`. Values include `0`, `50%`, and `100%` for each property.
|
||||
|
||||
- Added new `.translate-middle-x` & `.translate-middle-y` utilities to horizontally or vertically center absolute/fixed positioned elements.
|
||||
|
||||
- Added new [`border-width` utilities]({{< docsref "/utilities/borders#border-width" >}}).
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Renamed `.text-monospace` to `.font-monospace`.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Removed `.text-hide` as it's an antiquated method for hiding text that shouldn't be used anymore.
|
||||
|
||||
- Added `.fs-*` utilities for `font-size` utilities (with RFS enabled). These use the same scale as HTML's default headings (1-6, large to small), and can be modified via Sass map.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Renamed `.font-weight-*` utilities as `.fw-*` for brevity and consistency.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Renamed `.font-style-*` utilities as `.fst-*` for brevity and consistency.
|
||||
|
||||
- Added `.d-grid` to display utilities and new `gap` utilities (`.gap`) for CSS Grid and flexbox layouts.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Removed `.rounded-sm` and `rounded-lg`, and introduced a new scale of classes, `.rounded-0` to `.rounded-3`. [See #31687](https://github.com/twbs/bootstrap/pull/31687).
|
||||
|
||||
- Added new `line-height` utilities: `.lh-1`, `.lh-sm`, `.lh-base` and `.lh-lg`. See [here]({{< docsref "/utilities/text#line-height" >}}).
|
||||
|
||||
- Moved the `.d-none` utility in our CSS to give it more weight over other display utilities.
|
||||
|
||||
- Extended the `.visually-hidden-focusable` helper to also work on containers, using `:focus-within`.
|
||||
|
||||
## Helpers
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> **Responsive embed helpers have been renamed to [ratio helpers]({{< docsref "/helpers/ratio" >}})** with new class names and improved behaviors, as well as a helpful CSS variable.
|
||||
- Classes have been renamed to change `by` to `x` in the aspect ratio. For example, `.ratio-16by9` is now `.ratio-16x9`.
|
||||
- We've dropped the `.embed-responsive-item` and element group selector in favor of a simpler `.ratio > *` selector. No more class is needed, and the ratio helper now works with any HTML element.
|
||||
- The `$embed-responsive-aspect-ratios` Sass map has been renamed to `$aspect-ratios` and its values have been simplified to include the class name and the percentage as the `key: value` pair.
|
||||
- CSS variables are now generated and included for each value in the Sass map. Modify the `--bs-aspect-ratio` variable on the `.ratio` to create any [custom aspect ratio]({{< docsref "/helpers/ratio#custom-ratios" >}}).
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> **"Screen reader" classes are now ["visually hidden" classes]({{< docsref "/helpers/visually-hidden" >}}).**
|
||||
- Changed the Sass file from `scss/helpers/_screenreaders.scss` to `scss/helpers/_visually-hidden.scss`
|
||||
- Renamed `.sr-only` and `.sr-only-focusable` to `.visually-hidden` and `.visually-hidden-focusable`
|
||||
- Renamed `sr-only()` and `sr-only-focusable()` mixins to `visually-hidden()` and `visually-hidden-focusable()`.
|
||||
|
||||
- `bootstrap-utilities.css` now also includes our helpers. Helpers don't need to be imported in custom builds anymore.
|
||||
|
||||
## JavaScript
|
||||
|
||||
- **Dropped jQuery dependency** and rewrote plugins to be in regular JavaScript.
|
||||
|
||||
- <span class="badge bg-danger">Breaking</span> Data attributes for all JavaScript plugins are now namespaced to help distinguish Bootstrap functionality from third parties and your own code. For example, we use `data-bs-toggle` instead of `data-toggle`.
|
||||
|
||||
- **All plugins can now accept a CSS selector as the first argument.** You can either pass a DOM element or any valid CSS selector to create a new instance of the plugin:
|
||||
|
||||
```js
|
||||
const modal = new bootstrap.Modal('#myModal')
|
||||
const dropdown = new bootstrap.Dropdown('[data-bs-toggle="dropdown"]')
|
||||
```
|
||||
|
||||
- `popperConfig` can be passed as a function that accepts the Bootstrap's default Popper config as an argument, so that you can merge this default configuration in your way. **Applies to dropdowns, popovers, and tooltips.**
|
||||
|
||||
- The default value for the `fallbackPlacements` is changed to `['top', 'right', 'bottom', 'left']` for better placement of Popper elements. **Applies to dropdowns, popovers, and tooltips.**
|
||||
|
||||
- Removed underscore from public static methods like `_getInstance()` → `getInstance()`.
|
||||
|
|
@ -1,124 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Background
|
||||
description: Convey meaning through `background-color` and add decoration with gradients.
|
||||
group: utilities
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Background color
|
||||
|
||||
Similar to the contextual text color classes, set the background of an element to any contextual class. Background utilities **do not set `color`**, so in some cases you'll want to use `.text-*` [color utilities]({{< docsref "/utilities/colors" >}}).
|
||||
|
||||
{{< example >}}
|
||||
{{< colors.inline >}}
|
||||
{{- range (index $.Site.Data "theme-colors") }}
|
||||
<div class="p-3 mb-2 bg-{{ .name }}{{ if .contrast_color }} text-{{ .contrast_color }}{{ else }} text-white{{ end }}">.bg-{{ .name }}</div>
|
||||
{{- end -}}
|
||||
{{< /colors.inline >}}
|
||||
<div class="p-3 mb-2 bg-body text-dark">.bg-body</div>
|
||||
<div class="p-3 mb-2 bg-white text-dark">.bg-white</div>
|
||||
<div class="p-3 mb-2 bg-transparent text-dark">.bg-transparent</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Background gradient
|
||||
|
||||
By adding a `.bg-gradient` class, a linear gradient is added as background image to the backgrounds. This gradient starts with a semi-transparent white which fades out to the bottom.
|
||||
|
||||
Do you need a gradient in your custom CSS? Just add `background-image: var(--bs-gradient);`.
|
||||
|
||||
{{< markdown >}}
|
||||
{{< colors.inline >}}
|
||||
{{- range (index $.Site.Data "theme-colors") }}
|
||||
<div class="p-3 mb-2 bg-{{ .name }} bg-gradient{{ with .contrast_color }} text-{{ . }}{{ else }} text-white{{ end }}">.bg-{{ .name }}.bg-gradient</div>
|
||||
{{- end -}}
|
||||
{{< /colors.inline >}}
|
||||
{{< /markdown >}}
|
||||
|
||||
## Opacity
|
||||
|
||||
{{< added-in "5.1.0" >}}
|
||||
|
||||
As of v5.1.0, `background-color` utilities are generated with Sass using CSS variables. This allows for real-time color changes without compilation and dynamic alpha transparency changes.
|
||||
|
||||
### How it works
|
||||
|
||||
Consider our default `.bg-success` utility.
|
||||
|
||||
```css
|
||||
.bg-success {
|
||||
--bs-bg-opacity: 1;
|
||||
background-color: rgba(var(--bs-success-rgb), var(--bs-bg-opacity)) !important;
|
||||
}
|
||||
```
|
||||
|
||||
We use an RGB version of our `--bs-success` (with the value of `25, 135, 84`) CSS variable and attached a second CSS variable, `--bs-bg-opacity`, for the alpha transparency (with a default value `1` thanks to a local CSS variable). That means anytime you use `.bg-success` now, your computed `color` value is `rgba(25, 135, 84, 1)`. The local CSS variable inside each `.bg-*` class avoids inheritance issues so nested instances of the utilities don't automatically have a modified alpha transparency.
|
||||
|
||||
### Example
|
||||
|
||||
To change that opacity, override `--bs-bg-opacity` via custom styles or inline styles.
|
||||
|
||||
{{< example >}}
|
||||
<div class="bg-success p-2 text-white">This is default success background</div>
|
||||
<div class="bg-success p-2" style="--bs-bg-opacity: .5;">This is 50% opacity success background</div>
|
||||
{{< /example >}}
|
||||
|
||||
Or, choose from any of the `.bg-opacity` utilities:
|
||||
|
||||
{{< example >}}
|
||||
<div class="bg-success p-2 text-white">This is default success background</div>
|
||||
<div class="bg-success p-2 text-white bg-opacity-75">This is 75% opacity success background</div>
|
||||
<div class="bg-success p-2 text-dark bg-opacity-50">This is 50% opacity success background</div>
|
||||
<div class="bg-success p-2 text-dark bg-opacity-25">This is 25% opacity success background</div>
|
||||
<div class="bg-success p-2 text-dark bg-opacity-10">This is 10% opacity success background</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Sass
|
||||
|
||||
In addition to the following Sass functionality, consider reading about our included [CSS custom properties]({{< docsref "/customize/css-variables" >}}) (aka CSS variables) for colors and more.
|
||||
|
||||
### Variables
|
||||
|
||||
Most `background-color` utilities are generated by our theme colors, reassigned from our generic color palette variables.
|
||||
|
||||
{{< scss-docs name="color-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
{{< scss-docs name="theme-color-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
{{< scss-docs name="variable-gradient" file="scss/_variables.scss" >}}
|
||||
|
||||
Grayscale colors are also available, but only a subset are used to generate any utilities.
|
||||
|
||||
{{< scss-docs name="gray-color-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
### Map
|
||||
|
||||
Theme colors are then put into a Sass map so we can loop over them to generate our utilities, component modifiers, and more.
|
||||
|
||||
{{< scss-docs name="theme-colors-map" file="scss/_variables.scss" >}}
|
||||
|
||||
Grayscale colors are also available as a Sass map. **This map is not used to generate any utilities.**
|
||||
|
||||
{{< scss-docs name="gray-colors-map" file="scss/_variables.scss" >}}
|
||||
|
||||
RGB colors are generated from a separate Sass map:
|
||||
|
||||
{{< scss-docs name="theme-colors-rgb" file="scss/_maps.scss" >}}
|
||||
|
||||
And background color opacities build on that with their own map that's consumed by the utilities API:
|
||||
|
||||
{{< scss-docs name="utilities-bg-colors" file="scss/_maps.scss" >}}
|
||||
|
||||
### Mixins
|
||||
|
||||
**No mixins are used to generate our background utilities**, but we do have some additional mixins for other situations where you'd like to create your own gradients.
|
||||
|
||||
{{< scss-docs name="gradient-bg-mixin" file="scss/mixins/_gradients.scss" >}}
|
||||
|
||||
{{< scss-docs name="gradient-mixins" file="scss/mixins/_gradients.scss" >}}
|
||||
|
||||
### Utilities API
|
||||
|
||||
Background utilities are declared in our utilities API in `scss/_utilities.scss`. [Learn how to use the utilities API.]({{< docsref "/utilities/api#using-the-api" >}})
|
||||
|
||||
{{< scss-docs name="utils-bg-color" file="scss/_utilities.scss" >}}
|
||||
|
|
@ -1,166 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Borders
|
||||
description: Use border utilities to quickly style the border and border-radius of an element. Great for images, buttons, or any other element.
|
||||
group: utilities
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Border
|
||||
|
||||
Use border utilities to add or remove an element's borders. Choose from all borders or one at a time.
|
||||
|
||||
### Additive
|
||||
|
||||
Add borders to custom elements:
|
||||
|
||||
{{< example class="bd-example-border-utils" >}}
|
||||
<span class="border"></span>
|
||||
<span class="border-top"></span>
|
||||
<span class="border-end"></span>
|
||||
<span class="border-bottom"></span>
|
||||
<span class="border-start"></span>
|
||||
{{< /example >}}
|
||||
|
||||
### Subtractive
|
||||
|
||||
Or remove borders:
|
||||
|
||||
{{< example class="bd-example-border-utils" >}}
|
||||
<span class="border border-0"></span>
|
||||
<span class="border border-top-0"></span>
|
||||
<span class="border border-end-0"></span>
|
||||
<span class="border border-bottom-0"></span>
|
||||
<span class="border border-start-0"></span>
|
||||
{{< /example >}}
|
||||
|
||||
## Color
|
||||
|
||||
Change the border color using utilities built on our theme colors.
|
||||
|
||||
{{< example class="bd-example-border-utils" >}}
|
||||
{{< border.inline >}}
|
||||
{{- range (index $.Site.Data "theme-colors") }}
|
||||
<span class="border border-{{ .name }}"></span>
|
||||
{{- end -}}
|
||||
{{< /border.inline >}}
|
||||
<span class="border border-white"></span>
|
||||
{{< /example >}}
|
||||
|
||||
Or modify the default `border-color` of a component:
|
||||
|
||||
{{< example >}}
|
||||
<div class="mb-4">
|
||||
<label for="exampleFormControlInput1" class="form-label">Email address</label>
|
||||
<input type="email" class="form-control border-success" id="exampleFormControlInput1" placeholder="name@example.com">
|
||||
</div>
|
||||
|
||||
<div class="h4 pb-2 mb-4 text-danger border-bottom border-danger">
|
||||
Dangerous heading
|
||||
</div>
|
||||
|
||||
<div class="p-3 bg-info bg-opacity-10 border border-info border-start-0 rounded-end">
|
||||
Changing border color and width
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Opacity
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
Bootstrap `border-{color}` utilities are generated with Sass using CSS variables. This allows for real-time color changes without compilation and dynamic alpha transparency changes.
|
||||
|
||||
### How it works
|
||||
|
||||
Consider our default `.border-success` utility.
|
||||
|
||||
```css
|
||||
.border-success {
|
||||
--bs-border-opacity: 1;
|
||||
border-color: rgba(var(--bs-success-rgb), var(--bs-border-opacity)) !important;
|
||||
}
|
||||
```
|
||||
|
||||
We use an RGB version of our `--bs-success` (with the value of `25, 135, 84`) CSS variable and attached a second CSS variable, `--bs-border-opacity`, for the alpha transparency (with a default value `1` thanks to a local CSS variable). That means anytime you use `.border-success` now, your computed `color` value is `rgba(25, 135, 84, 1)`. The local CSS variable inside each `.border-*` class avoids inheritance issues so nested instances of the utilities don't automatically have a modified alpha transparency.
|
||||
|
||||
### Example
|
||||
|
||||
To change that opacity, override `--bs-border-opacity` via custom styles or inline styles.
|
||||
|
||||
{{< example >}}
|
||||
<div class="border border-success p-2 mb-2">This is default success border</div>
|
||||
<div class="border border-success p-2" style="--bs-border-opacity: .5;">This is 50% opacity success border</div>
|
||||
{{< /example >}}
|
||||
|
||||
Or, choose from any of the `.border-opacity` utilities:
|
||||
|
||||
{{< example >}}
|
||||
<div class="border border-success p-2 mb-2">This is default success border</div>
|
||||
<div class="border border-success p-2 mb-2 border-opacity-75">This is 75% opacity success border</div>
|
||||
<div class="border border-success p-2 mb-2 border-opacity-50">This is 50% opacity success border</div>
|
||||
<div class="border border-success p-2 mb-2 border-opacity-25">This is 25% opacity success border</div>
|
||||
<div class="border border-success p-2 border-opacity-10">This is 10% opacity success border</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Width
|
||||
|
||||
{{< example class="bd-example-border-utils" >}}
|
||||
<span class="border border-1"></span>
|
||||
<span class="border border-2"></span>
|
||||
<span class="border border-3"></span>
|
||||
<span class="border border-4"></span>
|
||||
<span class="border border-5"></span>
|
||||
{{< /example >}}
|
||||
|
||||
## Radius
|
||||
|
||||
Add classes to an element to easily round its corners.
|
||||
|
||||
{{< example class="bd-example-rounded-utils" >}}
|
||||
{{< placeholder width="75" height="75" class="rounded" title="Example rounded image" >}}
|
||||
{{< placeholder width="75" height="75" class="rounded-top" title="Example top rounded image" >}}
|
||||
{{< placeholder width="75" height="75" class="rounded-end" title="Example right rounded image" >}}
|
||||
{{< placeholder width="75" height="75" class="rounded-bottom" title="Example bottom rounded image" >}}
|
||||
{{< placeholder width="75" height="75" class="rounded-start" title="Example left rounded image" >}}
|
||||
{{< placeholder width="75" height="75" class="rounded-circle" title="Completely round image" >}}
|
||||
{{< placeholder width="150" height="75" class="rounded-pill" title="Rounded pill image" >}}
|
||||
{{< /example >}}
|
||||
|
||||
### Sizes
|
||||
|
||||
Use the scaling classes for larger or smaller rounded corners. Sizes range from `0` to `5`, and can be configured by modifying the utilities API.
|
||||
|
||||
{{< example class="bd-example-rounded-utils" >}}
|
||||
{{< placeholder width="75" height="75" class="rounded-0" title="Example non-rounded image" >}}
|
||||
{{< placeholder width="75" height="75" class="rounded-1" title="Example small rounded image" >}}
|
||||
{{< placeholder width="75" height="75" class="rounded-2" title="Example default rounded image" >}}
|
||||
{{< placeholder width="75" height="75" class="rounded-3" title="Example large rounded image" >}}
|
||||
{{< placeholder width="75" height="75" class="rounded-4" title="Example larger rounded image" >}}
|
||||
{{< placeholder width="75" height="75" class="rounded-5" title="Example extra large rounded image" >}}
|
||||
{{< /example >}}
|
||||
|
||||
## CSS
|
||||
|
||||
### Variables
|
||||
|
||||
{{< added-in "5.2.0" >}}
|
||||
|
||||
{{< scss-docs name="root-border-var" file="scss/_root.scss" >}}
|
||||
|
||||
### Sass variables
|
||||
|
||||
{{< scss-docs name="border-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
{{< scss-docs name="border-radius-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
### Sass mixins
|
||||
|
||||
{{< scss-docs name="border-radius-mixins" file="scss/mixins/_border-radius.scss" >}}
|
||||
|
||||
### Utilities API
|
||||
|
||||
Border utilities are declared in our utilities API in `scss/_utilities.scss`. [Learn how to use the utilities API.]({{< docsref "/utilities/api#using-the-api" >}})
|
||||
|
||||
{{< scss-docs name="utils-borders" file="scss/_utilities.scss" >}}
|
||||
|
||||
{{< scss-docs name="utils-border-radius" file="scss/_utilities.scss" >}}
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Colors
|
||||
description: Convey meaning through `color` with a handful of color utility classes. Includes support for styling links with hover states, too.
|
||||
group: utilities
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Colors
|
||||
|
||||
Colorize text with color utilities. If you want to colorize links, you can use the [`.link-*` helper classes]({{< docsref "/helpers/colored-links" >}}) which have `:hover` and `:focus` states.
|
||||
|
||||
{{< example >}}
|
||||
{{< colors.inline >}}
|
||||
{{- range (index $.Site.Data "theme-colors") }}
|
||||
<p class="text-{{ .name }}{{ with .contrast_color }} bg-{{ . }}{{ end }}">.text-{{ .name }}</p>
|
||||
{{- end -}}
|
||||
{{< /colors.inline >}}
|
||||
<p class="text-body">.text-body</p>
|
||||
<p class="text-muted">.text-muted</p>
|
||||
<p class="text-white bg-dark">.text-white</p>
|
||||
<p class="text-black-50">.text-black-50</p>
|
||||
<p class="text-white-50 bg-dark">.text-white-50</p>
|
||||
{{< /example >}}
|
||||
|
||||
{{< callout warning >}}
|
||||
**Deprecation:** With the addition of `.text-opacity-*` utilities and CSS variables for text utilities, `.text-black-50` and `.text-white-50` are deprecated as of v5.1.0. They'll be removed in v6.0.0.
|
||||
{{< /callout >}}
|
||||
|
||||
{{< callout info >}}
|
||||
{{< partial "callout-warning-color-assistive-technologies.md" >}}
|
||||
{{< /callout >}}
|
||||
|
||||
## Opacity
|
||||
|
||||
{{< added-in "5.1.0" >}}
|
||||
|
||||
As of v5.1.0, text color utilities are generated with Sass using CSS variables. This allows for real-time color changes without compilation and dynamic alpha transparency changes.
|
||||
|
||||
### How it works
|
||||
|
||||
Consider our default `.text-primary` utility.
|
||||
|
||||
```css
|
||||
.text-primary {
|
||||
--bs-text-opacity: 1;
|
||||
color: rgba(var(--bs-primary-rgb), var(--bs-text-opacity)) !important;
|
||||
}
|
||||
```
|
||||
|
||||
We use an RGB version of our `--bs-primary` (with the value of `13, 110, 253`) CSS variable and attached a second CSS variable, `--bs-text-opacity`, for the alpha transparency (with a default value `1` thanks to a local CSS variable). That means anytime you use `.text-primary` now, your computed `color` value is `rgba(13, 110, 253, 1)`. The local CSS variable inside each `.text-*` class avoids inheritance issues so nested instances of the utilities don't automatically have a modified alpha transparency.
|
||||
|
||||
### Example
|
||||
|
||||
To change that opacity, override `--bs-text-opacity` via custom styles or inline styles.
|
||||
|
||||
{{< example >}}
|
||||
<div class="text-primary">This is default primary text</div>
|
||||
<div class="text-primary" style="--bs-text-opacity: .5;">This is 50% opacity primary text</div>
|
||||
{{< /example >}}
|
||||
|
||||
Or, choose from any of the `.text-opacity` utilities:
|
||||
|
||||
{{< example >}}
|
||||
<div class="text-primary">This is default primary text</div>
|
||||
<div class="text-primary text-opacity-75">This is 75% opacity primary text</div>
|
||||
<div class="text-primary text-opacity-50">This is 50% opacity primary text</div>
|
||||
<div class="text-primary text-opacity-25">This is 25% opacity primary text</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Specificity
|
||||
|
||||
Sometimes contextual classes cannot be applied due to the specificity of another selector. In some cases, a sufficient workaround is to wrap your element's content in a `<div>` or more semantic element with the desired class.
|
||||
|
||||
## Sass
|
||||
|
||||
In addition to the following Sass functionality, consider reading about our included [CSS custom properties]({{< docsref "/customize/css-variables" >}}) (aka CSS variables) for colors and more.
|
||||
|
||||
### Variables
|
||||
|
||||
Most `color` utilities are generated by our theme colors, reassigned from our generic color palette variables.
|
||||
|
||||
{{< scss-docs name="color-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
{{< scss-docs name="theme-color-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
Grayscale colors are also available, but only a subset are used to generate any utilities.
|
||||
|
||||
{{< scss-docs name="gray-color-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
### Map
|
||||
|
||||
Theme colors are then put into a Sass map so we can loop over them to generate our utilities, component modifiers, and more.
|
||||
|
||||
{{< scss-docs name="theme-colors-map" file="scss/_variables.scss" >}}
|
||||
|
||||
Grayscale colors are also available as a Sass map. **This map is not used to generate any utilities.**
|
||||
|
||||
{{< scss-docs name="gray-colors-map" file="scss/_variables.scss" >}}
|
||||
|
||||
RGB colors are generated from a separate Sass map:
|
||||
|
||||
{{< scss-docs name="theme-colors-rgb" file="scss/_maps.scss" >}}
|
||||
|
||||
And color opacities build on that with their own map that's consumed by the utilities API:
|
||||
|
||||
{{< scss-docs name="utilities-text-colors" file="scss/_maps.scss" >}}
|
||||
|
||||
### Utilities API
|
||||
|
||||
Color utilities are declared in our utilities API in `scss/_utilities.scss`. [Learn how to use the utilities API.]({{< docsref "/utilities/api#using-the-api" >}})
|
||||
|
||||
{{< scss-docs name="utils-color" file="scss/_utilities.scss" >}}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Float
|
||||
description: Toggle floats on any element, across any breakpoint, using our responsive float utilities.
|
||||
group: utilities
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
These utility classes float an element to the left or right, or disable floating, based on the current viewport size using the [CSS `float` property](https://developer.mozilla.org/en-US/docs/Web/CSS/float). `!important` is included to avoid specificity issues. These use the same viewport breakpoints as our grid system. Please be aware float utilities have no effect on flex items.
|
||||
|
||||
{{< example >}}
|
||||
<div class="float-start">Float start on all viewport sizes</div><br>
|
||||
<div class="float-end">Float end on all viewport sizes</div><br>
|
||||
<div class="float-none">Don't float on all viewport sizes</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Responsive
|
||||
|
||||
Responsive variations also exist for each `float` value.
|
||||
|
||||
{{< example >}}
|
||||
<div class="float-sm-start">Float start on viewports sized SM (small) or wider</div><br>
|
||||
<div class="float-md-start">Float start on viewports sized MD (medium) or wider</div><br>
|
||||
<div class="float-lg-start">Float start on viewports sized LG (large) or wider</div><br>
|
||||
<div class="float-xl-start">Float start on viewports sized XL (extra-large) or wider</div><br>
|
||||
{{< /example >}}
|
||||
|
||||
Here are all the support classes:
|
||||
|
||||
{{< markdown >}}
|
||||
{{< float.inline >}}
|
||||
{{- range $.Site.Data.breakpoints }}
|
||||
- `.float{{ .abbr }}-start`
|
||||
- `.float{{ .abbr }}-end`
|
||||
- `.float{{ .abbr }}-none`
|
||||
{{- end -}}
|
||||
{{< /float.inline >}}
|
||||
{{< /markdown >}}
|
||||
|
||||
## Sass
|
||||
|
||||
### Utilities API
|
||||
|
||||
Float utilities are declared in our utilities API in `scss/_utilities.scss`. [Learn how to use the utilities API.]({{< docsref "/utilities/api#using-the-api" >}})
|
||||
|
||||
{{< scss-docs name="utils-float" file="scss/_utilities.scss" >}}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Overflow
|
||||
description: Use these shorthand utilities for quickly configuring how content overflows an element.
|
||||
group: utilities
|
||||
---
|
||||
|
||||
Adjust the `overflow` property on the fly with four default values and classes. These classes are not responsive by default.
|
||||
|
||||
<div class="bd-example d-md-flex">
|
||||
<div class="overflow-auto p-3 mb-3 mb-md-0 me-md-3 bg-light" style="max-width: 260px; max-height: 100px;">
|
||||
This is an example of using <code>.overflow-auto</code> on an element with set width and height dimensions. By design, this content will vertically scroll.
|
||||
</div>
|
||||
<div class="overflow-hidden p-3 mb-3 mb-md-0 me-md-3 bg-light" style="max-width: 260px; max-height: 100px;">
|
||||
This is an example of using <code>.overflow-hidden</code> on an element with set width and height dimensions.
|
||||
</div>
|
||||
<div class="overflow-visible p-3 mb-3 mb-md-0 me-md-3 bg-light" style="max-width: 260px; max-height: 100px;">
|
||||
This is an example of using <code>.overflow-visible</code> on an element with set width and height dimensions.
|
||||
</div>
|
||||
<div class="overflow-scroll p-3 bg-light" style="max-width: 260px; max-height: 100px;">
|
||||
This is an example of using <code>.overflow-scroll</code> on an element with set width and height dimensions.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
```html
|
||||
<div class="overflow-auto">...</div>
|
||||
<div class="overflow-hidden">...</div>
|
||||
<div class="overflow-visible">...</div>
|
||||
<div class="overflow-scroll">...</div>
|
||||
```
|
||||
|
||||
Using Sass variables, you may customize the overflow utilities by changing the `$overflows` variable in `_variables.scss`.
|
||||
|
||||
## Sass
|
||||
|
||||
### Utilities API
|
||||
|
||||
Overflow utilities are declared in our utilities API in `scss/_utilities.scss`. [Learn how to use the utilities API.]({{< docsref "/utilities/api#using-the-api" >}})
|
||||
|
||||
{{< scss-docs name="utils-overflow" file="scss/_utilities.scss" >}}
|
||||
|
|
@ -1,130 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Position
|
||||
description: Use these shorthand utilities for quickly configuring the position of an element.
|
||||
group: utilities
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Position values
|
||||
|
||||
Quick positioning classes are available, though they are not responsive.
|
||||
|
||||
```html
|
||||
<div class="position-static">...</div>
|
||||
<div class="position-relative">...</div>
|
||||
<div class="position-absolute">...</div>
|
||||
<div class="position-fixed">...</div>
|
||||
<div class="position-sticky">...</div>
|
||||
```
|
||||
|
||||
## Arrange elements
|
||||
|
||||
Arrange elements easily with the edge positioning utilities. The format is `{property}-{position}`.
|
||||
|
||||
Where *property* is one of:
|
||||
|
||||
- `top` - for the vertical `top` position
|
||||
- `start` - for the horizontal `left` position (in LTR)
|
||||
- `bottom` - for the vertical `bottom` position
|
||||
- `end` - for the horizontal `right` position (in LTR)
|
||||
|
||||
Where *position* is one of:
|
||||
|
||||
- `0` - for `0` edge position
|
||||
- `50` - for `50%` edge position
|
||||
- `100` - for `100%` edge position
|
||||
|
||||
(You can add more position values by adding entries to the `$position-values` Sass map variable.)
|
||||
|
||||
{{< example class="bd-example-position-utils" >}}
|
||||
<div class="position-relative">
|
||||
<div class="position-absolute top-0 start-0"></div>
|
||||
<div class="position-absolute top-0 end-0"></div>
|
||||
<div class="position-absolute top-50 start-50"></div>
|
||||
<div class="position-absolute bottom-50 end-50"></div>
|
||||
<div class="position-absolute bottom-0 start-0"></div>
|
||||
<div class="position-absolute bottom-0 end-0"></div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Center elements
|
||||
|
||||
In addition, you can also center the elements with the transform utility class `.translate-middle`.
|
||||
|
||||
This class applies the transformations `translateX(-50%)` and `translateY(-50%)` to the element which, in combination with the edge positioning utilities, allows you to absolute center an element.
|
||||
|
||||
{{< example class="bd-example-position-utils" >}}
|
||||
<div class="position-relative">
|
||||
<div class="position-absolute top-0 start-0 translate-middle"></div>
|
||||
<div class="position-absolute top-0 start-50 translate-middle"></div>
|
||||
<div class="position-absolute top-0 start-100 translate-middle"></div>
|
||||
<div class="position-absolute top-50 start-0 translate-middle"></div>
|
||||
<div class="position-absolute top-50 start-50 translate-middle"></div>
|
||||
<div class="position-absolute top-50 start-100 translate-middle"></div>
|
||||
<div class="position-absolute top-100 start-0 translate-middle"></div>
|
||||
<div class="position-absolute top-100 start-50 translate-middle"></div>
|
||||
<div class="position-absolute top-100 start-100 translate-middle"></div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
By adding `.translate-middle-x` or `.translate-middle-y` classes, elements can be positioned only in horizontal or vertical direction.
|
||||
|
||||
{{< example class="bd-example-position-utils" >}}
|
||||
<div class="position-relative">
|
||||
<div class="position-absolute top-0 start-0"></div>
|
||||
<div class="position-absolute top-0 start-50 translate-middle-x"></div>
|
||||
<div class="position-absolute top-0 end-0"></div>
|
||||
<div class="position-absolute top-50 start-0 translate-middle-y"></div>
|
||||
<div class="position-absolute top-50 start-50 translate-middle"></div>
|
||||
<div class="position-absolute top-50 end-0 translate-middle-y"></div>
|
||||
<div class="position-absolute bottom-0 start-0"></div>
|
||||
<div class="position-absolute bottom-0 start-50 translate-middle-x"></div>
|
||||
<div class="position-absolute bottom-0 end-0"></div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Examples
|
||||
|
||||
Here are some real life examples of these classes:
|
||||
|
||||
{{< example class="bd-example-position-examples d-flex justify-content-around" >}}
|
||||
<button type="button" class="btn btn-primary position-relative">
|
||||
Mails <span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-secondary">+99 <span class="visually-hidden">unread messages</span></span>
|
||||
</button>
|
||||
|
||||
<button type="button" class="btn btn-dark position-relative">
|
||||
Marker <svg width="1em" height="1em" viewBox="0 0 16 16" class="position-absolute top-100 start-50 translate-middle mt-1" fill="#212529" xmlns="http://www.w3.org/2000/svg"><path d="M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z"/></svg>
|
||||
</button>
|
||||
|
||||
<button type="button" class="btn btn-primary position-relative">
|
||||
Alerts <span class="position-absolute top-0 start-100 translate-middle badge border border-light rounded-circle bg-danger p-2"><span class="visually-hidden">unread messages</span></span>
|
||||
</button>
|
||||
{{< /example >}}
|
||||
|
||||
You can use these classes with existing components to create new ones. Remember that you can extend its functionality by adding entries to the `$position-values` variable.
|
||||
|
||||
{{< example class="bd-example-position-examples" >}}
|
||||
<div class="position-relative m-4">
|
||||
<div class="progress" style="height: 1px;">
|
||||
<div class="progress-bar" role="progressbar" aria-label="Progress" style="width: 50%;" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<button type="button" class="position-absolute top-0 start-0 translate-middle btn btn-sm btn-primary rounded-pill" style="width: 2rem; height:2rem;">1</button>
|
||||
<button type="button" class="position-absolute top-0 start-50 translate-middle btn btn-sm btn-primary rounded-pill" style="width: 2rem; height:2rem;">2</button>
|
||||
<button type="button" class="position-absolute top-0 start-100 translate-middle btn btn-sm btn-secondary rounded-pill" style="width: 2rem; height:2rem;">3</button>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Sass
|
||||
|
||||
### Maps
|
||||
|
||||
Default position utility values are declared in a Sass map, then used to generate our utilities.
|
||||
|
||||
{{< scss-docs name="position-map" file="scss/_variables.scss" >}}
|
||||
|
||||
### Utilities API
|
||||
|
||||
Position utilities are declared in our utilities API in `scss/_utilities.scss`. [Learn how to use the utilities API.]({{< docsref "/utilities/api#using-the-api" >}})
|
||||
|
||||
{{< scss-docs name="utils-position" file="scss/_utilities.scss" >}}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Shadows
|
||||
description: Add or remove shadows to elements with box-shadow utilities.
|
||||
group: utilities
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Examples
|
||||
|
||||
While shadows on components are disabled by default in Bootstrap and can be enabled via `$enable-shadows`, you can also quickly add or remove a shadow with our `box-shadow` utility classes. Includes support for `.shadow-none` and three default sizes (which have associated variables to match).
|
||||
|
||||
{{< example >}}
|
||||
<div class="shadow-none p-3 mb-5 bg-light rounded">No shadow</div>
|
||||
<div class="shadow-sm p-3 mb-5 bg-body rounded">Small shadow</div>
|
||||
<div class="shadow p-3 mb-5 bg-body rounded">Regular shadow</div>
|
||||
<div class="shadow-lg p-3 mb-5 bg-body rounded">Larger shadow</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Sass
|
||||
|
||||
### Variables
|
||||
|
||||
{{< scss-docs name="box-shadow-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
### Utilities API
|
||||
|
||||
Shadow utilities are declared in our utilities API in `scss/_utilities.scss`. [Learn how to use the utilities API.]({{< docsref "/utilities/api#using-the-api" >}})
|
||||
|
||||
{{< scss-docs name="utils-shadow" file="scss/_utilities.scss" >}}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Sizing
|
||||
description: Easily make an element as wide or as tall with our width and height utilities.
|
||||
group: utilities
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Relative to the parent
|
||||
|
||||
Width and height utilities are generated from the utility API in `_utilities.scss`. Includes support for `25%`, `50%`, `75%`, `100%`, and `auto` by default. Modify those values as you need to generate different utilities here.
|
||||
|
||||
{{< example >}}
|
||||
<div class="w-25 p-3" style="background-color: #eee;">Width 25%</div>
|
||||
<div class="w-50 p-3" style="background-color: #eee;">Width 50%</div>
|
||||
<div class="w-75 p-3" style="background-color: #eee;">Width 75%</div>
|
||||
<div class="w-100 p-3" style="background-color: #eee;">Width 100%</div>
|
||||
<div class="w-auto p-3" style="background-color: #eee;">Width auto</div>
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<div style="height: 100px; background-color: rgba(255,0,0,0.1);">
|
||||
<div class="h-25 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 25%</div>
|
||||
<div class="h-50 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 50%</div>
|
||||
<div class="h-75 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 75%</div>
|
||||
<div class="h-100 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 100%</div>
|
||||
<div class="h-auto d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height auto</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
You can also use `max-width: 100%;` and `max-height: 100%;` utilities as needed.
|
||||
|
||||
{{< example >}}
|
||||
{{< placeholder width="100%" height="100" class="mw-100" text="Max-width 100%" >}}
|
||||
{{< /example >}}
|
||||
|
||||
{{< example >}}
|
||||
<div style="height: 100px; background-color: rgba(255,0,0,.1);">
|
||||
<div class="mh-100" style="width: 100px; height: 200px; background-color: rgba(0,0,255,.1);">Max-height 100%</div>
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Relative to the viewport
|
||||
|
||||
You can also use utilities to set the width and height relative to the viewport.
|
||||
|
||||
```html
|
||||
<div class="min-vw-100">Min-width 100vw</div>
|
||||
<div class="min-vh-100">Min-height 100vh</div>
|
||||
<div class="vw-100">Width 100vw</div>
|
||||
<div class="vh-100">Height 100vh</div>
|
||||
```
|
||||
|
||||
## Sass
|
||||
|
||||
### Utilities API
|
||||
|
||||
Sizing utilities are declared in our utilities API in `scss/_utilities.scss`. [Learn how to use the utilities API.]({{< docsref "/utilities/api#using-the-api" >}})
|
||||
|
||||
{{< scss-docs name="utils-sizing" file="scss/_utilities.scss" >}}
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
---
|
||||
layout: docs
|
||||
title: Text
|
||||
description: Documentation and examples for common text utilities to control alignment, wrapping, weight, and more.
|
||||
group: utilities
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Text alignment
|
||||
|
||||
Easily realign text to components with text alignment classes. For start, end, and center alignment, responsive classes are available that use the same viewport width breakpoints as the grid system.
|
||||
|
||||
{{< example >}}
|
||||
<p class="text-start">Start aligned text on all viewport sizes.</p>
|
||||
<p class="text-center">Center aligned text on all viewport sizes.</p>
|
||||
<p class="text-end">End aligned text on all viewport sizes.</p>
|
||||
|
||||
<p class="text-sm-start">Start aligned text on viewports sized SM (small) or wider.</p>
|
||||
<p class="text-md-start">Start aligned text on viewports sized MD (medium) or wider.</p>
|
||||
<p class="text-lg-start">Start aligned text on viewports sized LG (large) or wider.</p>
|
||||
<p class="text-xl-start">Start aligned text on viewports sized XL (extra-large) or wider.</p>
|
||||
{{< /example >}}
|
||||
|
||||
{{< callout info >}}
|
||||
Note that we don't provide utility classes for justified text. While, aesthetically, justified text might look more appealing, it does make word-spacing more random and therefore harder to read.
|
||||
{{< /callout >}}
|
||||
|
||||
## Text wrapping and overflow
|
||||
|
||||
Wrap text with a `.text-wrap` class.
|
||||
|
||||
{{< example >}}
|
||||
<div class="badge bg-primary text-wrap" style="width: 6rem;">
|
||||
This text should wrap.
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
Prevent text from wrapping with a `.text-nowrap` class.
|
||||
|
||||
{{< example >}}
|
||||
<div class="text-nowrap bg-light border" style="width: 8rem;">
|
||||
This text should overflow the parent.
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
## Word break
|
||||
|
||||
Prevent long strings of text from breaking your components' layout by using `.text-break` to set `word-wrap: break-word` and `word-break: break-word`. We use `word-wrap` instead of the more common `overflow-wrap` for wider browser support, and add the deprecated `word-break: break-word` to avoid issues with flex containers.
|
||||
|
||||
{{< example >}}
|
||||
<p class="text-break">mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm</p>
|
||||
{{< /example >}}
|
||||
|
||||
{{< callout warning >}}
|
||||
Note that [breaking words isn't possible in Arabic](https://rtlstyling.com/posts/rtl-styling#3.-line-break), which is the most used RTL language. Therefore `.text-break` is removed from our RTL compiled CSS.
|
||||
{{< /callout >}}
|
||||
|
||||
## Text transform
|
||||
|
||||
Transform text in components with text capitalization classes.
|
||||
|
||||
{{< example >}}
|
||||
<p class="text-lowercase">Lowercased text.</p>
|
||||
<p class="text-uppercase">Uppercased text.</p>
|
||||
<p class="text-capitalize">CapiTaliZed text.</p>
|
||||
{{< /example >}}
|
||||
|
||||
Note how `.text-capitalize` only changes the first letter of each word, leaving the case of any other letters unaffected.
|
||||
|
||||
## Font size
|
||||
|
||||
Quickly change the `font-size` of text. While our heading classes (e.g., `.h1`–`.h6`) apply `font-size`, `font-weight`, and `line-height`, these utilities _only_ apply `font-size`. Sizing for these utilities matches HTML's heading elements, so as the number increases, their size decreases.
|
||||
|
||||
{{< example >}}
|
||||
<p class="fs-1">.fs-1 text</p>
|
||||
<p class="fs-2">.fs-2 text</p>
|
||||
<p class="fs-3">.fs-3 text</p>
|
||||
<p class="fs-4">.fs-4 text</p>
|
||||
<p class="fs-5">.fs-5 text</p>
|
||||
<p class="fs-6">.fs-6 text</p>
|
||||
{{< /example >}}
|
||||
|
||||
Customize your available `font-size`s by modifying the `$font-sizes` Sass map.
|
||||
|
||||
## Font weight and italics
|
||||
|
||||
Quickly change the `font-weight` or `font-style` of text with these utilities. `font-style` utilities are abbreviated as `.fst-*` and `font-weight` utilities are abbreviated as `.fw-*`.
|
||||
|
||||
{{< example >}}
|
||||
<p class="fw-bold">Bold text.</p>
|
||||
<p class="fw-bolder">Bolder weight text (relative to the parent element).</p>
|
||||
<p class="fw-semibold">Semibold weight text.</p>
|
||||
<p class="fw-normal">Normal weight text.</p>
|
||||
<p class="fw-light">Light weight text.</p>
|
||||
<p class="fw-lighter">Lighter weight text (relative to the parent element).</p>
|
||||
<p class="fst-italic">Italic text.</p>
|
||||
<p class="fst-normal">Text with normal font style</p>
|
||||
{{< /example >}}
|
||||
|
||||
## Line height
|
||||
|
||||
Change the line height with `.lh-*` utilities.
|
||||
|
||||
{{< example >}}
|
||||
<p class="lh-1">This is a long paragraph written to show how the line-height of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.</p>
|
||||
<p class="lh-sm">This is a long paragraph written to show how the line-height of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.</p>
|
||||
<p class="lh-base">This is a long paragraph written to show how the line-height of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.</p>
|
||||
<p class="lh-lg">This is a long paragraph written to show how the line-height of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.</p>
|
||||
{{< /example >}}
|
||||
|
||||
## Monospace
|
||||
|
||||
Change a selection to our monospace font stack with `.font-monospace`.
|
||||
|
||||
{{< example >}}
|
||||
<p class="font-monospace">This is in monospace</p>
|
||||
{{< /example >}}
|
||||
|
||||
## Reset color
|
||||
|
||||
Reset a text or link's color with `.text-reset`, so that it inherits the color from its parent.
|
||||
|
||||
{{< example >}}
|
||||
<p class="text-muted">
|
||||
Muted text with a <a href="#" class="text-reset">reset link</a>.
|
||||
</p>
|
||||
{{< /example >}}
|
||||
|
||||
## Text decoration
|
||||
|
||||
Decorate text in components with text decoration classes.
|
||||
|
||||
{{< example >}}
|
||||
<p class="text-decoration-underline">This text has a line underneath it.</p>
|
||||
<p class="text-decoration-line-through">This text has a line going through it.</p>
|
||||
<a href="#" class="text-decoration-none">This link has its text decoration removed</a>
|
||||
{{< /example >}}
|
||||
|
||||
## Sass
|
||||
|
||||
### Variables
|
||||
|
||||
{{< scss-docs name="font-variables" file="scss/_variables.scss" >}}
|
||||
|
||||
### Maps
|
||||
|
||||
Font-size utilities are generated from this map, in combination with our utilities API.
|
||||
|
||||
{{< scss-docs name="font-sizes" file="scss/_variables.scss" >}}
|
||||
|
||||
### Utilities API
|
||||
|
||||
Font and text utilities are declared in our utilities API in `scss/_utilities.scss`. [Learn how to use the utilities API.]({{< docsref "/utilities/api#using-the-api" >}})
|
||||
|
||||
{{< scss-docs name="utils-text" file="scss/_utilities.scss" >}}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
layout: redirect
|
||||
sitemap_exclude: true
|
||||
redirect: "/docs/5.2/getting-started/introduction/"
|
||||
---
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
---
|
||||
title: Versions
|
||||
description: An appendix of hosted documentation for nearly every release of Bootstrap, from v1 through v5.
|
||||
---
|
||||
|
||||
{{< list-versions.inline >}}
|
||||
<div class="row">
|
||||
{{- range $release := sort (index $.Site.Data "docs-versions") "group" "desc" }}
|
||||
<div class="col-md-6 col-lg-4 col-xl mb-4">
|
||||
<h2>{{ $release.group }}</h2>
|
||||
<p>{{ $release.description }}</p>
|
||||
{{- $versions := sort $release.versions "v" "desc" -}}
|
||||
{{- range $i, $version := $versions }}
|
||||
{{- $len := len $versions -}}
|
||||
{{ if (eq $i 0) }}<div class="list-group">{{ end }}
|
||||
<a class="list-group-item list-group-item-action py-2 text-primary{{ if (eq $version.v $.Site.Params.docs_version) }} d-flex justify-content-between align-items-center{{ end }}" href="{{ $release.baseurl }}/{{ $version.v }}/">
|
||||
{{ $version.v }}
|
||||
{{ if (eq $version.v $.Site.Params.docs_version) -}}
|
||||
<span class="badge bg-primary">Latest</span>
|
||||
{{- end }}
|
||||
</a>
|
||||
{{ if (eq (add $i 1) $len) }}</div>{{ end }}
|
||||
{{ end -}}
|
||||
</div>
|
||||
{{ end -}}
|
||||
</div>
|
||||
{{< /list-versions.inline >}}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
- breakpoint: xs
|
||||
abbr: ""
|
||||
abbr: ''
|
||||
name: X-Small
|
||||
min-width: 0px
|
||||
container: ""
|
||||
container: ''
|
||||
|
||||
- breakpoint: sm
|
||||
abbr: -sm
|
||||
|
|
|
|||
|
|
@ -1,26 +1,26 @@
|
|||
- name: blue
|
||||
hex: "#0d6efd"
|
||||
hex: '#0d6efd'
|
||||
- name: indigo
|
||||
hex: "#6610f2"
|
||||
hex: '#6610f2'
|
||||
- name: purple
|
||||
hex: "#6f42c1"
|
||||
hex: '#6f42c1'
|
||||
- name: pink
|
||||
hex: "#d63384"
|
||||
hex: '#d63384'
|
||||
- name: red
|
||||
hex: "#dc3545"
|
||||
hex: '#dc3545'
|
||||
- name: orange
|
||||
hex: "#fd7e14"
|
||||
hex: '#fd7e14'
|
||||
- name: yellow
|
||||
hex: "#ffc107"
|
||||
hex: '#ffc107'
|
||||
- name: green
|
||||
hex: "#198754"
|
||||
hex: '#198754'
|
||||
- name: teal
|
||||
hex: "#20c997"
|
||||
hex: '#20c997'
|
||||
- name: cyan
|
||||
hex: "#0dcaf0"
|
||||
hex: '#0dcaf0'
|
||||
- name: white
|
||||
hex: "#fff"
|
||||
hex: '#fff'
|
||||
- name: gray
|
||||
hex: "#6c757d"
|
||||
hex: '#6c757d'
|
||||
- name: gray-dark
|
||||
hex: "#343a40"
|
||||
hex: '#343a40'
|
||||
|
|
|
|||
|
|
@ -10,18 +10,21 @@
|
|||
- name: GeoSot
|
||||
user: geosot
|
||||
|
||||
- name: Patrick H. Lauke
|
||||
user: patrickhlauke
|
||||
|
||||
- name: Julien Déramond
|
||||
user: julien-deramond
|
||||
|
||||
- name: Gaël Poupard
|
||||
user: ffoodd
|
||||
|
||||
- name: Rohit Sharma
|
||||
user: rohit2sharma95
|
||||
|
||||
- name: alpadev
|
||||
user: alpadev
|
||||
|
||||
- name: Gaël Poupard
|
||||
user: ffoodd
|
||||
|
||||
- name: Patrick H. Lauke
|
||||
user: patrickhlauke
|
||||
|
||||
- name: Martijn Cuppens
|
||||
user: martijncuppens
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue