diff options
Diffstat (limited to 'site')
56 files changed, 871 insertions, 568 deletions
diff --git a/site/assets/js/snippets.js b/site/assets/js/snippets.js index 4a9a9dc8f6..66ef949f74 100644 --- a/site/assets/js/snippets.js +++ b/site/assets/js/snippets.js @@ -1,5 +1,7 @@ -// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT -// IT'S ALL JUST JUNK FOR OUR DOCS! +// NOTICE!!! Initially embedded in our docs this JavaScript +// file contains elements that can help you create reproducible +// use cases in StackBlitz for instance. +// In a real project please adapt this content to your needs. // ++++++++++++++++++++++++++++++++++++++++++ /*! @@ -15,18 +17,28 @@ (() => { 'use strict' - // Tooltip and popover demos - // Tooltip and popover demos + // -------- + // Tooltips + // -------- + // Instanciate all tooltips in a docs or StackBlitz page document.querySelectorAll('[data-bs-toggle="tooltip"]') .forEach(tooltip => { new bootstrap.Tooltip(tooltip) }) + // -------- + // Popovers + // -------- + // Instanciate all popovers in a docs or StackBlitz page document.querySelectorAll('[data-bs-toggle="popover"]') .forEach(popover => { new bootstrap.Popover(popover) }) + // ------------------------------- + // Toasts + // ------------------------------- + // Used by 'Placement' example in docs or StackBlitz const toastPlacement = document.getElementById('toastPlacement') if (toastPlacement) { document.getElementById('selectToastPlacement').addEventListener('change', function () { @@ -38,6 +50,7 @@ }) } + // Instanciate all toasts in a docs page only document.querySelectorAll('.bd-example .toast') .forEach(toastNode => { const toast = new bootstrap.Toast(toastNode, { @@ -47,6 +60,7 @@ toast.show() }) + // Instanciate all toasts in a docs page only const toastTrigger = document.getElementById('liveToastBtn') const toastLiveExample = document.getElementById('liveToast') if (toastTrigger) { @@ -57,6 +71,10 @@ }) } + // ------------------------------- + // Alerts + // ------------------------------- + // Used in 'Show live toast' example in docs or StackBlitz const alertPlaceholder = document.getElementById('liveAlertPlaceholder') const alertTrigger = document.getElementById('liveAlertBtn') @@ -78,13 +96,19 @@ }) } - // Indeterminate checkbox example + // ------------------------------- + // Checks & Radios + // ------------------------------- + // Indeterminate checkbox example in docs and StackBlitz document.querySelectorAll('.bd-example-indeterminate [type="checkbox"]') .forEach(checkbox => { checkbox.indeterminate = true }) - // Disable empty links in docs examples + // ------------------------------- + // Links + // ------------------------------- + // Disable empty links in docs examples only document.querySelectorAll('.bd-content [href="#"]') .forEach(link => { link.addEventListener('click', event => { @@ -92,7 +116,10 @@ }) }) - // Modal relatedTarget demo + // ------------------------------- + // Modal + // ------------------------------- + // Modal 'Varying modal content' example in docs and StackBlitz const exampleModal = document.getElementById('exampleModal') if (exampleModal) { exampleModal.addEventListener('show.bs.modal', event => { @@ -110,11 +137,16 @@ }) } - // Offcanvas demo - const myOffcanvas = document.querySelector('.bd-example-offcanvas #offcanvas') + // ------------------------------- + // Offcanvas + // ------------------------------- + // 'Offcanvas components' example in docs only + const myOffcanvas = document.querySelectorAll('.bd-example-offcanvas .offcanvas') if (myOffcanvas) { - myOffcanvas.addEventListener('show.bs.offcanvas', event => { - event.preventDefault() - }, false) + myOffcanvas.forEach(offcanvas => { + offcanvas.addEventListener('show.bs.offcanvas', event => { + event.preventDefault() + }, false) + }) } })() diff --git a/site/assets/js/vendor/clipboard.min.js b/site/assets/js/vendor/clipboard.min.js index 95f55d7b0c..1103f811ed 100644 --- a/site/assets/js/vendor/clipboard.min.js +++ b/site/assets/js/vendor/clipboard.min.js @@ -1,7 +1,7 @@ /*! - * clipboard.js v2.0.8 + * clipboard.js v2.0.11 * https://clipboardjs.com/ * * Licensed MIT © Zeno Rocha */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ClipboardJS=e():t.ClipboardJS=e()}(this,function(){return n={134:function(t,e,n){"use strict";n.d(e,{default:function(){return r}});var e=n(279),i=n.n(e),e=n(370),a=n.n(e),e=n(817),o=n.n(e);function c(t){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function u(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var l=function(){function e(t){!function(t){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this.resolveOptions(t),this.initSelection()}var t,n,r;return t=e,(n=[{key:"resolveOptions",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};this.action=t.action,this.container=t.container,this.emitter=t.emitter,this.target=t.target,this.text=t.text,this.trigger=t.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"createFakeElement",value:function(){var t="rtl"===document.documentElement.getAttribute("dir");this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[t?"right":"left"]="-9999px";t=window.pageYOffset||document.documentElement.scrollTop;return this.fakeElem.style.top="".concat(t,"px"),this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.fakeElem}},{key:"selectFake",value:function(){var t=this,e=this.createFakeElement();this.fakeHandlerCallback=function(){return t.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.container.appendChild(e),this.selectedText=o()(e),this.copyText(),this.removeFake()}},{key:"removeFake",value:function(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=o()(this.target),this.copyText()}},{key:"copyText",value:function(){var e;try{e=document.execCommand(this.action)}catch(t){e=!1}this.handleResult(e)}},{key:"handleResult",value:function(t){this.emitter.emit(t?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.trigger&&this.trigger.focus(),document.activeElement.blur(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=t,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(t){if(void 0!==t){if(!t||"object"!==c(t)||1!==t.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&t.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(t.hasAttribute("readonly")||t.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=t}},get:function(){return this._target}}])&&u(t.prototype,n),r&&u(t,r),e}();function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function f(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function h(t,e){return(h=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function d(n){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=p(n);return t=r?(t=p(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),e=this,!(t=t)||"object"!==s(t)&&"function"!=typeof t?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}}function p(t){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function y(t,e){t="data-clipboard-".concat(t);if(e.hasAttribute(t))return e.getAttribute(t)}var r=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&h(t,e)}(o,i());var t,e,n,r=d(o);function o(t,e){var n;return function(t){if(!(t instanceof o))throw new TypeError("Cannot call a class as a function")}(this),(n=r.call(this)).resolveOptions(e),n.listenClick(t),n}return t=o,n=[{key:"isSupported",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:["copy","cut"],t="string"==typeof t?[t]:t,e=!!document.queryCommandSupported;return t.forEach(function(t){e=e&&!!document.queryCommandSupported(t)}),e}}],(e=[{key:"resolveOptions",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof t.action?t.action:this.defaultAction,this.target="function"==typeof t.target?t.target:this.defaultTarget,this.text="function"==typeof t.text?t.text:this.defaultText,this.container="object"===s(t.container)?t.container:document.body}},{key:"listenClick",value:function(t){var e=this;this.listener=a()(t,"click",function(t){return e.onClick(t)})}},{key:"onClick",value:function(t){t=t.delegateTarget||t.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new l({action:this.action(t),target:this.target(t),text:this.text(t),container:this.container,trigger:t,emitter:this})}},{key:"defaultAction",value:function(t){return y("action",t)}},{key:"defaultTarget",value:function(t){t=y("target",t);if(t)return document.querySelector(t)}},{key:"defaultText",value:function(t){return y("text",t)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}])&&f(t.prototype,e),n&&f(t,n),o}()},828:function(t){var e;"undefined"==typeof Element||Element.prototype.matches||((e=Element.prototype).matches=e.matchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector||e.webkitMatchesSelector),t.exports=function(t,e){for(;t&&9!==t.nodeType;){if("function"==typeof t.matches&&t.matches(e))return t;t=t.parentNode}}},438:function(t,e,n){var a=n(828);function i(t,e,n,r,o){var i=function(e,n,t,r){return function(t){t.delegateTarget=a(t.target,n),t.delegateTarget&&r.call(e,t)}}.apply(this,arguments);return t.addEventListener(n,i,o),{destroy:function(){t.removeEventListener(n,i,o)}}}t.exports=function(t,e,n,r,o){return"function"==typeof t.addEventListener?i.apply(null,arguments):"function"==typeof n?i.bind(null,document).apply(null,arguments):("string"==typeof t&&(t=document.querySelectorAll(t)),Array.prototype.map.call(t,function(t){return i(t,e,n,r,o)}))}},879:function(t,n){n.node=function(t){return void 0!==t&&t instanceof HTMLElement&&1===t.nodeType},n.nodeList=function(t){var e=Object.prototype.toString.call(t);return void 0!==t&&("[object NodeList]"===e||"[object HTMLCollection]"===e)&&"length"in t&&(0===t.length||n.node(t[0]))},n.string=function(t){return"string"==typeof t||t instanceof String},n.fn=function(t){return"[object Function]"===Object.prototype.toString.call(t)}},370:function(t,e,n){var l=n(879),s=n(438);t.exports=function(t,e,n){if(!t&&!e&&!n)throw new Error("Missing required arguments");if(!l.string(e))throw new TypeError("Second argument must be a String");if(!l.fn(n))throw new TypeError("Third argument must be a Function");if(l.node(t))return c=e,u=n,(a=t).addEventListener(c,u),{destroy:function(){a.removeEventListener(c,u)}};if(l.nodeList(t))return r=t,o=e,i=n,Array.prototype.forEach.call(r,function(t){t.addEventListener(o,i)}),{destroy:function(){Array.prototype.forEach.call(r,function(t){t.removeEventListener(o,i)})}};if(l.string(t))return t=t,e=e,n=n,s(document.body,t,e,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList");var r,o,i,a,c,u}},817:function(t){t.exports=function(t){var e,n="SELECT"===t.nodeName?(t.focus(),t.value):"INPUT"===t.nodeName||"TEXTAREA"===t.nodeName?((e=t.hasAttribute("readonly"))||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),e||t.removeAttribute("readonly"),t.value):(t.hasAttribute("contenteditable")&&t.focus(),n=window.getSelection(),(e=document.createRange()).selectNodeContents(t),n.removeAllRanges(),n.addRange(e),n.toString());return n}},279:function(t){function e(){}e.prototype={on:function(t,e,n){var r=this.e||(this.e={});return(r[t]||(r[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){var r=this;function o(){r.off(t,o),e.apply(n,arguments)}return o._=e,this.on(t,o,n)},emit:function(t){for(var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),r=0,o=n.length;r<o;r++)n[r].fn.apply(n[r].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),r=n[t],o=[];if(r&&e)for(var i=0,a=r.length;i<a;i++)r[i].fn!==e&&r[i].fn._!==e&&o.push(r[i]);return o.length?n[t]=o:delete n[t],this}},t.exports=e,t.exports.TinyEmitter=e}},o={},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,{a:e}),e},r.d=function(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r(134).default;function r(t){if(o[t])return o[t].exports;var e=o[t]={exports:{}};return n[t](e,e.exports,r),e.exports}var n,o});
\ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ClipboardJS=e():t.ClipboardJS=e()}(this,function(){return n={686:function(t,e,n){"use strict";n.d(e,{default:function(){return b}});var e=n(279),i=n.n(e),e=n(370),u=n.n(e),e=n(817),r=n.n(e);function c(t){try{return document.execCommand(t)}catch(t){return}}var a=function(t){t=r()(t);return c("cut"),t};function o(t,e){var n,o,t=(n=t,o="rtl"===document.documentElement.getAttribute("dir"),(t=document.createElement("textarea")).style.fontSize="12pt",t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px",o=window.pageYOffset||document.documentElement.scrollTop,t.style.top="".concat(o,"px"),t.setAttribute("readonly",""),t.value=n,t);return e.container.appendChild(t),e=r()(t),c("copy"),t.remove(),e}var f=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{container:document.body},n="";return"string"==typeof t?n=o(t,e):t instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(null==t?void 0:t.type)?n=o(t.value,e):(n=r()(t),c("copy")),n};function l(t){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var s=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=t.action,n=void 0===e?"copy":e,o=t.container,e=t.target,t=t.text;if("copy"!==n&&"cut"!==n)throw new Error('Invalid "action" value, use either "copy" or "cut"');if(void 0!==e){if(!e||"object"!==l(e)||1!==e.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===n&&e.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===n&&(e.hasAttribute("readonly")||e.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes')}return t?f(t,{container:o}):e?"cut"===n?a(e):f(e,{container:o}):void 0};function p(t){return(p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function d(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function y(t,e){return(y=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function h(n){var o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=v(n);return t=o?(t=v(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),e=this,!(t=t)||"object"!==p(t)&&"function"!=typeof t?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e):t}}function v(t){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function m(t,e){t="data-clipboard-".concat(t);if(e.hasAttribute(t))return e.getAttribute(t)}var b=function(){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&y(t,e)}(r,i());var t,e,n,o=h(r);function r(t,e){var n;return function(t){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this),(n=o.call(this)).resolveOptions(e),n.listenClick(t),n}return t=r,n=[{key:"copy",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{container:document.body};return f(t,e)}},{key:"cut",value:function(t){return a(t)}},{key:"isSupported",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:["copy","cut"],t="string"==typeof t?[t]:t,e=!!document.queryCommandSupported;return t.forEach(function(t){e=e&&!!document.queryCommandSupported(t)}),e}}],(e=[{key:"resolveOptions",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof t.action?t.action:this.defaultAction,this.target="function"==typeof t.target?t.target:this.defaultTarget,this.text="function"==typeof t.text?t.text:this.defaultText,this.container="object"===p(t.container)?t.container:document.body}},{key:"listenClick",value:function(t){var e=this;this.listener=u()(t,"click",function(t){return e.onClick(t)})}},{key:"onClick",value:function(t){var e=t.delegateTarget||t.currentTarget,n=this.action(e)||"copy",t=s({action:n,container:this.container,target:this.target(e),text:this.text(e)});this.emit(t?"success":"error",{action:n,text:t,trigger:e,clearSelection:function(){e&&e.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(t){return m("action",t)}},{key:"defaultTarget",value:function(t){t=m("target",t);if(t)return document.querySelector(t)}},{key:"defaultText",value:function(t){return m("text",t)}},{key:"destroy",value:function(){this.listener.destroy()}}])&&d(t.prototype,e),n&&d(t,n),r}()},828:function(t){var e;"undefined"==typeof Element||Element.prototype.matches||((e=Element.prototype).matches=e.matchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector||e.webkitMatchesSelector),t.exports=function(t,e){for(;t&&9!==t.nodeType;){if("function"==typeof t.matches&&t.matches(e))return t;t=t.parentNode}}},438:function(t,e,n){var u=n(828);function i(t,e,n,o,r){var i=function(e,n,t,o){return function(t){t.delegateTarget=u(t.target,n),t.delegateTarget&&o.call(e,t)}}.apply(this,arguments);return t.addEventListener(n,i,r),{destroy:function(){t.removeEventListener(n,i,r)}}}t.exports=function(t,e,n,o,r){return"function"==typeof t.addEventListener?i.apply(null,arguments):"function"==typeof n?i.bind(null,document).apply(null,arguments):("string"==typeof t&&(t=document.querySelectorAll(t)),Array.prototype.map.call(t,function(t){return i(t,e,n,o,r)}))}},879:function(t,n){n.node=function(t){return void 0!==t&&t instanceof HTMLElement&&1===t.nodeType},n.nodeList=function(t){var e=Object.prototype.toString.call(t);return void 0!==t&&("[object NodeList]"===e||"[object HTMLCollection]"===e)&&"length"in t&&(0===t.length||n.node(t[0]))},n.string=function(t){return"string"==typeof t||t instanceof String},n.fn=function(t){return"[object Function]"===Object.prototype.toString.call(t)}},370:function(t,e,n){var f=n(879),l=n(438);t.exports=function(t,e,n){if(!t&&!e&&!n)throw new Error("Missing required arguments");if(!f.string(e))throw new TypeError("Second argument must be a String");if(!f.fn(n))throw new TypeError("Third argument must be a Function");if(f.node(t))return c=e,a=n,(u=t).addEventListener(c,a),{destroy:function(){u.removeEventListener(c,a)}};if(f.nodeList(t))return o=t,r=e,i=n,Array.prototype.forEach.call(o,function(t){t.addEventListener(r,i)}),{destroy:function(){Array.prototype.forEach.call(o,function(t){t.removeEventListener(r,i)})}};if(f.string(t))return t=t,e=e,n=n,l(document.body,t,e,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList");var o,r,i,u,c,a}},817:function(t){t.exports=function(t){var e,n="SELECT"===t.nodeName?(t.focus(),t.value):"INPUT"===t.nodeName||"TEXTAREA"===t.nodeName?((e=t.hasAttribute("readonly"))||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),e||t.removeAttribute("readonly"),t.value):(t.hasAttribute("contenteditable")&&t.focus(),n=window.getSelection(),(e=document.createRange()).selectNodeContents(t),n.removeAllRanges(),n.addRange(e),n.toString());return n}},279:function(t){function e(){}e.prototype={on:function(t,e,n){var o=this.e||(this.e={});return(o[t]||(o[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){var o=this;function r(){o.off(t,r),e.apply(n,arguments)}return r._=e,this.on(t,r,n)},emit:function(t){for(var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),o=0,r=n.length;o<r;o++)n[o].fn.apply(n[o].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),o=n[t],r=[];if(o&&e)for(var i=0,u=o.length;i<u;i++)o[i].fn!==e&&o[i].fn._!==e&&r.push(o[i]);return r.length?n[t]=r:delete n[t],this}},t.exports=e,t.exports.TinyEmitter=e}},r={},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,{a:e}),e},o.d=function(t,e){for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o(686).default;function o(t){if(r[t])return r[t].exports;var e=r[t]={exports:{}};return n[t](e,e.exports,o),e.exports}var n,r});
\ No newline at end of file diff --git a/site/assets/scss/_algolia.scss b/site/assets/scss/_algolia.scss deleted file mode 100644 index ab22ad9a7e..0000000000 --- a/site/assets/scss/_algolia.scss +++ /dev/null @@ -1,96 +0,0 @@ -// Docsearch theming - -// stylelint-disable selector-class-pattern - -.algolia-autocomplete { - width: 100%; -} - -.ds-dropdown-menu { - width: 100%; - padding: $dropdown-padding-y 0; - margin: $dropdown-spacer 0 0; - @include font-size(.875rem); - background-color: $dropdown-bg; - background-clip: padding-box; - border: $dropdown-border-width solid $dropdown-border-color; - @include border-radius($dropdown-border-radius); - box-shadow: $dropdown-box-shadow; - - @include media-breakpoint-up(md) { - width: 500px; - margin-top: .5rem; - margin-left: -110px; - } -} - -.algolia-docsearch-suggestion--category-header { - padding: .125rem 1rem; - font-weight: 600; - color: $bd-violet; - - :not(.algolia-docsearch-suggestion__main) > & { - display: none; - } - - .ds-suggestion:not(:first-child) & { - padding-top: .75rem; - margin-top: .75rem; - border-top: 1px solid rgba(0, 0, 0, .1); - } -} - -.algolia-docsearch-suggestion--content { - padding: .25rem 1rem; - - .ds-cursor & { - background-color: rgba($bd-purple-light, .2); - } -} - -.algolia-docsearch-suggestion { - display: block; - text-decoration: none; -} - -.algolia-docsearch-suggestion--subcategory-column { - display: none; -} - -.algolia-docsearch-suggestion--subcategory-inline { - display: inline; - color: $gray-700; - - &::after { - padding: 0 .25rem; - content: "/"; - } -} - -.algolia-docsearch-suggestion--title { - display: inline; - font-weight: 500; - color: $gray-800; -} - -.algolia-docsearch-suggestion--text { - color: $gray-800; - @include font-size(.75rem); -} - -.algolia-docsearch-suggestion--highlight { - color: $purple; - background-color: rgba($purple, .1); -} - -.algolia-docsearch-footer { - padding: .5rem 1rem 0; - margin-top: .625rem; - @include font-size(.75rem); - color: $gray-600; - border-top: 1px solid rgba(0, 0, 0, .1); -} - -.algolia-docsearch-footer--logo { - color: inherit; -} diff --git a/site/assets/scss/_search.scss b/site/assets/scss/_search.scss index 49e34e8ee0..24c0e2dc8a 100644 --- a/site/assets/scss/_search.scss +++ b/site/assets/scss/_search.scss @@ -23,7 +23,7 @@ --docsearch-muted-color: #{$text-muted}; --docsearch-hit-shadow: none; - z-index: 1030; + z-index: 2000; // Make sure to be over all components showcased in the documentation @include media-breakpoint-up(lg) { padding-top: 4rem; diff --git a/site/assets/scss/docs.scss b/site/assets/scss/docs.scss index f1390e2fae..5214934611 100644 --- a/site/assets/scss/docs.scss +++ b/site/assets/scss/docs.scss @@ -57,4 +57,3 @@ $enable-cssgrid: true; // stylelint-disable-line scss/dollar-variable-default // Load docs dependencies @import "syntax"; @import "anchor"; -@import "algolia"; diff --git a/site/content/docs/5.2/components/alerts.md b/site/content/docs/5.2/components/alerts.md index 12cad35881..8837ed46cd 100644 --- a/site/content/docs/5.2/components/alerts.md +++ b/site/content/docs/5.2/components/alerts.md @@ -27,7 +27,7 @@ Alerts are available for any length of text, as well as an optional close button 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 >}} +{{< example stackblitz_add_js="true" >}} <div id="liveAlertPlaceholder"></div> <button type="button" class="btn btn-primary" id="liveAlertBtn">Show live alert</button> {{< /example >}} diff --git a/site/content/docs/5.2/components/breadcrumb.md b/site/content/docs/5.2/components/breadcrumb.md index 05df37a0aa..0012f97481 100644 --- a/site/content/docs/5.2/components/breadcrumb.md +++ b/site/content/docs/5.2/components/breadcrumb.md @@ -94,7 +94,7 @@ $breadcrumb-divider: none; Since breadcrumbs provide a navigation, it's a good idea to add a meaningful label such as `aria-label="breadcrumb"` to describe the type of navigation provided in the `<nav>` element, as well as applying an `aria-current="page"` to the last item of the set to indicate that it represents the current page. -For more information, see the [WAI-ARIA Authoring Practices for the breadcrumb pattern](https://www.w3.org/TR/wai-aria-practices/#breadcrumb). +For more information, see the [ARIA Authoring Practices Guide breadcrumb pattern](https://www.w3.org/WAI/ARIA/apg/patterns/breadcrumb/). ## CSS diff --git a/site/content/docs/5.2/components/button-group.md b/site/content/docs/5.2/components/button-group.md index 184ca4973a..8f7d2d6a9e 100644 --- a/site/content/docs/5.2/components/button-group.md +++ b/site/content/docs/5.2/components/button-group.md @@ -143,31 +143,25 @@ Feel free to mix input groups with button groups in your toolbars. Similar to th 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. -<div class="bd-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 >}} +<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> - -```html -<div class="btn-group btn-group-lg" role="group" aria-label="...">...</div> -<div class="btn-group" role="group" aria-label="...">...</div> -<div class="btn-group btn-group-sm" role="group" aria-label="...">...</div> -``` +<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 @@ -179,10 +173,10 @@ Place a `.btn-group` within another `.btn-group` when you want dropdown menus mi <button type="button" class="btn btn-primary">2</button> <div class="btn-group" role="group"> - <button id="btnGroupDrop1" type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"> + <button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </button> - <ul class="dropdown-menu" aria-labelledby="btnGroupDrop1"> + <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> @@ -194,75 +188,69 @@ Place a `.btn-group` within another `.btn-group` when you want dropdown menus mi Make a set of buttons appear vertically stacked rather than horizontally. **Split button dropdowns are not supported here.** -<div class="bd-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 >}} +<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 >}} -<div class="bd-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 id="btnGroupVerticalDrop1" type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"> - Dropdown - </button> - <ul class="dropdown-menu" aria-labelledby="btnGroupVerticalDrop1"> - <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 id="btnGroupVerticalDrop2" type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"> - Dropdown - </button> - <ul class="dropdown-menu" aria-labelledby="btnGroupVerticalDrop2"> - <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 id="btnGroupVerticalDrop3" type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"> - Dropdown - </button> - <ul class="dropdown-menu" aria-labelledby="btnGroupVerticalDrop3"> - <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 id="btnGroupVerticalDrop4" type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"> - Dropdown - </button> - <ul class="dropdown-menu" aria-labelledby="btnGroupVerticalDrop4"> - <li><a class="dropdown-item" href="#">Dropdown link</a></li> - <li><a class="dropdown-item" href="#">Dropdown link</a></li> - </ul> - </div> +{{< 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> -</div> - -<div class="bd-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> + <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 >}} -```html -<div class="btn-group-vertical"> - ... +{{< 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 >}} diff --git a/site/content/docs/5.2/components/carousel.md b/site/content/docs/5.2/components/carousel.md index b2894ab129..fee28995bc 100644 --- a/site/content/docs/5.2/components/carousel.md +++ b/site/content/docs/5.2/components/carousel.md @@ -208,10 +208,10 @@ Add `data-bs-interval=""` to a `.carousel-item` to change the amount of time to ### 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 and has `data-bs-interval="false"` so it doesn't autoplay. +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" data-bs-interval="false"> +<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" >}} @@ -314,7 +314,7 @@ const carousel = new bootstrap.Carousel('#myCarousel') {{< bs-table >}} | Name | Type | Default | Description | | --- | --- | --- | --- | -| `interval` | number | `5000` | The amount of time to delay between automatically cycling an item. If `false`, carousel will not automatically cycle. | +| `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. | diff --git a/site/content/docs/5.2/components/collapse.md b/site/content/docs/5.2/components/collapse.md index 3c89327c2d..cc7c429ad2 100644 --- a/site/content/docs/5.2/components/collapse.md +++ b/site/content/docs/5.2/components/collapse.md @@ -98,7 +98,7 @@ Be sure to add `aria-expanded` to the control element. This attribute explicitly 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 [WAI-ARIA Authoring Practices 1.1 accordion pattern](https://www.w3.org/TR/wai-aria-practices-1.1/#accordion) - you will need to include these yourself with custom JavaScript. +Note that Bootstrap's current implementation does not cover the various *optional* keyboard interactions described in the [ARIA Authoring Practices Guide accordion pattern](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/) - you will need to include these yourself with custom JavaScript. ## Sass diff --git a/site/content/docs/5.2/components/dropdowns.md b/site/content/docs/5.2/components/dropdowns.md index d3edd2efb5..f7746e372a 100644 --- a/site/content/docs/5.2/components/dropdowns.md +++ b/site/content/docs/5.2/components/dropdowns.md @@ -14,7 +14,7 @@ Dropdowns are built on a third party library, [Popper](https://popper.js.org/), ## Accessibility -The [<abbr title="Web Accessibility Initiative">WAI</abbr> <abbr title="Accessible Rich Internet Applications">ARIA</abbr>](https://www.w3.org/TR/wai-aria/) standard defines an actual [`role="menu"` widget](https://www.w3.org/WAI/PF/aria/roles#menu), but this is specific to application-like menus which trigger actions or functions. <abbr title="Accessible Rich Internet Applications">ARIA</abbr> menus can only contain menu items, checkbox menu items, radio button menu items, radio button groups, and sub-menus. +The [<abbr title="Web Accessibility Initiative">WAI</abbr> <abbr title="Accessible Rich Internet Applications">ARIA</abbr>](https://www.w3.org/TR/wai-aria/) standard defines an actual [`role="menu"` widget](https://www.w3.org/TR/wai-aria/#menu), but this is specific to application-like menus which trigger actions or functions. <abbr title="Accessible Rich Internet Applications">ARIA</abbr> menus can only contain menu items, checkbox menu items, radio button menu items, radio button groups, and sub-menus. Bootstrap's dropdowns, on the other hand, are designed to be generic and applicable to a variety of situations and markup structures. For instance, it is possible to create dropdowns that contain additional inputs and form controls, such as search fields or login forms. For this reason, Bootstrap does not expect (nor automatically add) any of the `role` and `aria-` attributes required for true <abbr title="Accessible Rich Internet Applications">ARIA</abbr> menus. Authors will have to include these more specific attributes themselves. @@ -30,10 +30,10 @@ Any single `.btn` can be turned into a dropdown toggle with some markup changes. {{< example >}} <div class="dropdown"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown button </button> - <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1"> + <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> @@ -45,11 +45,11 @@ And with `<a>` elements: {{< example >}} <div class="dropdown"> - <a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false"> + <a class="btn btn-secondary dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown link </a> - <ul class="dropdown-menu" aria-labelledby="dropdownMenuLink"> + <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> @@ -353,10 +353,10 @@ Opt into darker dropdowns to match a dark navbar or custom style by adding `.dro {{< example >}} <div class="dropdown"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton2" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown button </button> - <ul class="dropdown-menu dropdown-menu-dark" aria-labelledby="dropdownMenuButton2"> + <ul class="dropdown-menu dropdown-menu-dark"> <li><a class="dropdown-item active" 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> @@ -378,10 +378,10 @@ And putting it to use in a navbar: <div class="collapse navbar-collapse" id="navbarNavDarkDropdown"> <ul class="navbar-nav"> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="navbarDarkDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false"> + <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" aria-labelledby="navbarDarkDropdownMenuLink"> + <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><a class="dropdown-item" href="#">Something else here</a></li> @@ -406,10 +406,10 @@ Make the dropdown menu centered below the toggle with `.dropdown-center` on the {{< example >}} <div class="dropdown-center"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownCenterBtn" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Centered dropdown </button> - <ul class="dropdown-menu" aria-labelledby="dropdownCenterBtn"> + <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Action two</a></li> <li><a class="dropdown-item" href="#">Action three</a></li> @@ -482,10 +482,10 @@ Make the dropup menu centered above the toggle with `.dropup-center` on the pare {{< example >}} <div class="dropup-center dropup"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="dropupCenterBtn" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Centered dropup </button> - <ul class="dropdown-menu" aria-labelledby="dropupCenterBtn"> + <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Action two</a></li> <li><a class="dropdown-item" href="#">Action three</a></li> @@ -617,10 +617,10 @@ You can use `<a>` or `<button>` elements as dropdown items. {{< example >}} <div class="dropdown"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </button> - <ul class="dropdown-menu" aria-labelledby="dropdownMenu2"> + <ul class="dropdown-menu"> <li><button class="dropdown-item" type="button">Action</button></li> <li><button class="dropdown-item" type="button">Another action</button></li> <li><button class="dropdown-item" type="button">Something else here</button></li> @@ -728,10 +728,10 @@ Taking most of the options shown above, here's a small kitchen sink demo of vari {{< example >}} <div class="btn-group"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </button> - <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton"> + <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Menu item</a></li> <li><a class="dropdown-item" href="#">Menu item</a></li> <li><a class="dropdown-item" href="#">Menu item</a></li> @@ -913,10 +913,10 @@ Use `data-bs-offset` or `data-bs-reference` to change the location of the dropdo {{< example >}} <div class="d-flex"> <div class="dropdown me-1"> - <button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuOffset" data-bs-toggle="dropdown" aria-expanded="false" data-bs-offset="10,20"> + <button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false" data-bs-offset="10,20"> Offset </button> - <ul class="dropdown-menu" aria-labelledby="dropdownMenuOffset"> + <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> @@ -924,10 +924,10 @@ Use `data-bs-offset` or `data-bs-reference` to change the location of the dropdo </div> <div class="btn-group"> <button type="button" class="btn btn-secondary">Reference</button> - <button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" id="dropdownMenuReference" data-bs-toggle="dropdown" aria-expanded="false" data-bs-reference="parent"> + <button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false" data-bs-reference="parent"> <span class="visually-hidden">Toggle Dropdown</span> </button> - <ul class="dropdown-menu" aria-labelledby="dropdownMenuReference"> + <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> @@ -944,10 +944,10 @@ By default, the dropdown menu is closed when clicking inside or outside the drop {{< example >}} <div class="btn-group"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="defaultDropdown" data-bs-toggle="dropdown" data-bs-auto-close="true" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" data-bs-auto-close="true" aria-expanded="false"> Default dropdown </button> - <ul class="dropdown-menu" aria-labelledby="defaultDropdown"> + <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Menu item</a></li> <li><a class="dropdown-item" href="#">Menu item</a></li> <li><a class="dropdown-item" href="#">Menu item</a></li> @@ -955,10 +955,10 @@ By default, the dropdown menu is closed when clicking inside or outside the drop </div> <div class="btn-group"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuClickableOutside" data-bs-toggle="dropdown" data-bs-auto-close="inside" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" data-bs-auto-close="inside" aria-expanded="false"> Clickable outside </button> - <ul class="dropdown-menu" aria-labelledby="dropdownMenuClickableOutside"> + <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Menu item</a></li> <li><a class="dropdown-item" href="#">Menu item</a></li> <li><a class="dropdown-item" href="#">Menu item</a></li> @@ -966,10 +966,10 @@ By default, the dropdown menu is closed when clicking inside or outside the drop </div> <div class="btn-group"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuClickableInside" data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false"> Clickable inside </button> - <ul class="dropdown-menu" aria-labelledby="dropdownMenuClickableInside"> + <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Menu item</a></li> <li><a class="dropdown-item" href="#">Menu item</a></li> <li><a class="dropdown-item" href="#">Menu item</a></li> @@ -977,10 +977,10 @@ By default, the dropdown menu is closed when clicking inside or outside the drop </div> <div class="btn-group"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuClickable" data-bs-toggle="dropdown" data-bs-auto-close="false" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" data-bs-auto-close="false" aria-expanded="false"> Manual close </button> - <ul class="dropdown-menu" aria-labelledby="dropdownMenuClickable"> + <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Menu item</a></li> <li><a class="dropdown-item" href="#">Menu item</a></li> <li><a class="dropdown-item" href="#">Menu item</a></li> @@ -1036,10 +1036,10 @@ Add `data-bs-toggle="dropdown"` to a link or button to toggle a dropdown. ```html <div class="dropdown"> - <button id="dLabel" type="button" data-bs-toggle="dropdown" aria-expanded="false"> + <button type="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown trigger </button> - <ul class="dropdown-menu" aria-labelledby="dLabel"> + <ul class="dropdown-menu"> ... </ul> </div> diff --git a/site/content/docs/5.2/components/list-group.md b/site/content/docs/5.2/components/list-group.md index 349823a589..d9b2ea200f 100644 --- a/site/content/docs/5.2/components/list-group.md +++ b/site/content/docs/5.2/components/list-group.md @@ -247,53 +247,54 @@ Place Bootstrap's checkboxes and radios within list group items and customize as {{< example >}} <ul class="list-group"> <li class="list-group-item"> - <input class="form-check-input me-1" type="checkbox" value="" aria-label="..."> - First checkbox + <input class="form-check-input me-1" type="checkbox" value="" id="firstCheckbox"> + <label class="form-check-label" for="firstCheckbox">First checkbox</label> </li> <li class="list-group-item"> - <input class="form-check-input me-1" type="checkbox" value="" aria-label="..."> - Second checkbox + <input class="form-check-input me-1" type="checkbox" value="" id="secondCheckbox"> + <label class="form-check-label" for="secondCheckbox">Second checkbox</label> </li> <li class="list-group-item"> - <input class="form-check-input me-1" type="checkbox" value="" aria-label="..."> - Third checkbox + <input class="form-check-input me-1" type="checkbox" value="" id="thirdCheckbox"> + <label class="form-check-label" for="thirdCheckbox">Third checkbox</label> </li> +</ul> +{{< /example >}} + +{{< example >}} +<ul class="list-group"> <li class="list-group-item"> - <input class="form-check-input me-1" type="checkbox" value="" aria-label="..."> - Fourth checkbox + <input class="form-check-input me-1" type="radio" name="listGroupRadio" value="" id="firstRadio" checked> + <label class="form-check-label" for="firstRadio">First radio</label> </li> <li class="list-group-item"> - <input class="form-check-input me-1" type="checkbox" value="" aria-label="..."> - Fifth checkbox + <input class="form-check-input me-1" type="radio" name="listGroupRadio" value="" id="secondRadio"> + <label class="form-check-label" for="secondRadio">Second radio</label> + </li> + <li class="list-group-item"> + <input class="form-check-input me-1" type="radio" name="listGroupRadio" value="" id="thirdRadio"> + <label class="form-check-label" for="thirdRadio">Third radio</label> </li> </ul> {{< /example >}} -And if you want `<label>`s as the `.list-group-item` for large hit areas, you can do that, too. +You can use `.stretched-link` on `<label>`s to make the whole list group item clickable. {{< example >}} -<div class="list-group"> - <label class="list-group-item"> - <input class="form-check-input me-1" type="checkbox" value=""> - First checkbox - </label> - <label class="list-group-item"> - <input class="form-check-input me-1" type="checkbox" value=""> - Second checkbox - </label> - <label class="list-group-item"> - <input class="form-check-input me-1" type="checkbox" value=""> - Third checkbox - </label> - <label class="list-group-item"> - <input class="form-check-input me-1" type="checkbox" value=""> - Fourth checkbox - </label> - <label class="list-group-item"> - <input class="form-check-input me-1" type="checkbox" value=""> - Fifth checkbox - </label> -</div> +<ul class="list-group"> + <li class="list-group-item"> + <input class="form-check-input me-1" type="checkbox" value="" id="firstCheckboxStretched"> + <label class="form-check-label stretched-link" for="firstCheckboxStretched">First checkbox</label> + </li> + <li class="list-group-item"> + <input class="form-check-input me-1" type="checkbox" value="" id="secondCheckboxStretched"> + <label class="form-check-label stretched-link" for="secondCheckboxStretched">Second checkbox</label> + </li> + <li class="list-group-item"> + <input class="form-check-input me-1" type="checkbox" value="" id="thirdCheckboxStretched"> + <label class="form-check-label stretched-link" for="thirdCheckboxStretched">Third checkbox</label> + </li> +</ul> {{< /example >}} ## CSS diff --git a/site/content/docs/5.2/components/modal.md b/site/content/docs/5.2/components/modal.md index 87c0687424..373078e593 100644 --- a/site/content/docs/5.2/components/modal.md +++ b/site/content/docs/5.2/components/modal.md @@ -444,7 +444,7 @@ Have a bunch of buttons that all trigger the same modal with slightly different Below is a live demo followed by example HTML and JavaScript. For more information, [read the modal events docs](#events) for details on `relatedTarget`. -{{< example >}} +{{< example stackblitz_add_js="true" >}} <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal" data-bs-whatever="@mdo">Open modal for @mdo</button> <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal" data-bs-whatever="@fat">Open modal for @fat</button> <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal" data-bs-whatever="@getbootstrap">Open modal for @getbootstrap</button> @@ -807,7 +807,7 @@ Activate a modal without writing JavaScript. Set `data-bs-toggle="modal"` on a c {{% js-dismiss "modal" %}} {{< callout warning >}} -While both ways to dismiss a modal are supported, keep in mind that dismissing from outside a modal does not match [the WAI-ARIA modal dialog design pattern](https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal). Do this at your own risk. +While both ways to dismiss a modal are supported, keep in mind that dismissing from outside a modal 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 diff --git a/site/content/docs/5.2/components/navbar.md b/site/content/docs/5.2/components/navbar.md index 392531160d..a1d671a427 100644 --- a/site/content/docs/5.2/components/navbar.md +++ b/site/content/docs/5.2/components/navbar.md @@ -52,10 +52,10 @@ Here's an example of all the sub-components included in a responsive light-theme <a class="nav-link" href="#">Link</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> + <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </a> - <ul class="dropdown-menu" aria-labelledby="navbarDropdown"> + <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> @@ -207,10 +207,10 @@ You can also use dropdowns in your navbar. Dropdown menus require a wrapping ele <a class="nav-link" href="#">Pricing</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false"> + <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown link </a> - <ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> + <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> @@ -523,10 +523,10 @@ Here's an example navbar using `.navbar-nav-scroll` with `style="--bs-scroll-hei <a class="nav-link" href="#">Link</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="navbarScrollingDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> + <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Link </a> - <ul class="dropdown-menu" aria-labelledby="navbarScrollingDropdown"> + <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> @@ -670,7 +670,7 @@ When you do this, we recommend including additional JavaScript to move the focus ### Offcanvas -Transform your expanding and collapsing navbar into an offcanvas drawer with the offcanvas plugin. We extend both the offcanvas default styles and use our `.navbar-expand-*` classes to create a dynamic and flexible navigation sidebar. +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. @@ -695,10 +695,10 @@ In the example below, to create an offcanvas navbar that is always collapsed acr <a class="nav-link" href="#">Link</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="offcanvasNavbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> + <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </a> - <ul class="dropdown-menu" aria-labelledby="offcanvasNavbarDropdown"> + <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> <li> @@ -732,6 +732,52 @@ To create an offcanvas navbar that expands into a normal navbar at a specific br </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" 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 diff --git a/site/content/docs/5.2/components/navs-tabs.md b/site/content/docs/5.2/components/navs-tabs.md index 978a702c42..0c6aa422a6 100644 --- a/site/content/docs/5.2/components/navs-tabs.md +++ b/site/content/docs/5.2/components/navs-tabs.md @@ -246,7 +246,7 @@ If you need responsive nav variations, consider using a series of [flexbox utili If you're using navs to provide a navigation bar, be sure to add a `role="navigation"` to the most logical parent container of the `<ul>`, or wrap a `<nav>` element around the whole navigation. Do not add the role to the `<ul>` itself, as this would prevent it from being announced as an actual list by assistive technologies. -Note that navigation bars, even if visually styled as tabs with the `.nav-tabs` class, should **not** be given `role="tablist"`, `role="tab"` or `role="tabpanel"` attributes. These are only appropriate for dynamic tabbed interfaces, as described in the [<abbr title="Web Accessibility Initiative">WAI</abbr> <abbr title="Accessible Rich Internet Applications">ARIA</abbr> Authoring Practices](https://www.w3.org/TR/wai-aria-practices/#tabpanel). See [JavaScript behavior](#javascript-behavior) for dynamic tabbed interfaces in this section for an example. The `aria-current` attribute is not necessary on dynamic tabbed interfaces since our JavaScript handles the selected state by adding `aria-selected="true"` on the active tab. +Note that navigation bars, even if visually styled as tabs with the `.nav-tabs` class, should **not** be given `role="tablist"`, `role="tab"` or `role="tabpanel"` attributes. These are only appropriate for dynamic tabbed interfaces, as described in the [ARIA Authoring Practices Guide tabs pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tabpanel/). See [JavaScript behavior](#javascript-behavior) for dynamic tabbed interfaces in this section for an example. The `aria-current` attribute is not necessary on dynamic tabbed interfaces since our JavaScript handles the selected state by adding `aria-selected="true"` on the active tab. ## Using dropdowns @@ -538,9 +538,9 @@ And with vertical pills. Ideally, for vertical tabs, you should also add `aria-o ### Accessibility -Dynamic tabbed interfaces, as described in the [<abbr title="Web Accessibility Initiative">WAI</abbr> <abbr title="Accessible Rich Internet Applications">ARIA</abbr> Authoring Practices 1.2](https://www.w3.org/TR/wai-aria-practices-1.2/#tabpanel), require `role="tablist"`, `role="tab"`, `role="tabpanel"`, and additional `aria-` attributes in order to convey their structure, functionality, and current state to users of assistive technologies (such as screen readers). As a best practice, we recommend using `<button>` elements for the tabs, as these are controls that trigger a dynamic change, rather than links that navigate to a new page or location. +Dynamic tabbed interfaces, as described in the [ARIA Authoring Practices Guide tabs pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tabpanel/), require `role="tablist"`, `role="tab"`, `role="tabpanel"`, and additional `aria-` attributes in order to convey their structure, functionality, and current state to users of assistive technologies (such as screen readers). As a best practice, we recommend using `<button>` elements for the tabs, as these are controls that trigger a dynamic change, rather than links that navigate to a new page or location. -In line with the ARIA Authoring Practices pattern, only the currently active tab receives keyboard focus. When the JavaScript plugin is initialized, it will set `tabindex="-1"` on all inactive tab controls. Once the currently active tab has focus, the cursor keys activate the previous/next tab, with the plugin changing the [roving `tabindex`](https://www.w3.org/TR/wai-aria-practices-1.2/#kbd_roving_tabindex) accordingly. However, note that the JavaScript plugin does not distinguish between horizontal and vertical tab lists when it comes to cursor key interactions: regardless of the tab list's orientation, both the up *and* left cursor go to the previous tab, and down *and* right cursor go to the next tab. +In line with the ARIA Authoring Practices pattern, only the currently active tab receives keyboard focus. When the JavaScript plugin is initialized, it will set `tabindex="-1"` on all inactive tab controls. Once the currently active tab has focus, the cursor keys activate the previous/next tab, with the plugin changing the [roving `tabindex`](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/) accordingly. However, note that the JavaScript plugin does not distinguish between horizontal and vertical tab lists when it comes to cursor key interactions: regardless of the tab list's orientation, both the up *and* left cursor go to the previous tab, and down *and* right cursor go to the next tab. {{< callout warning >}} In general, to facilitate keyboard navigation, it's recommended to make the tab panels themselves focusable as well, unless the first element containing meaningful content inside the tab panel is already focusable. The JavaScript plugin does not try to handle this aspect—where appropriate, you'll need to explicitly make your tab panels focusable by adding `tabindex="0"` in your markup. diff --git a/site/content/docs/5.2/components/offcanvas.md b/site/content/docs/5.2/components/offcanvas.md index 9b05a03070..d3c59c40f4 100644 --- a/site/content/docs/5.2/components/offcanvas.md +++ b/site/content/docs/5.2/components/offcanvas.md @@ -66,10 +66,10 @@ You can use a link with the `href` attribute, or a button with the `data-bs-targ 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" id="dropdownMenuButton" data-bs-toggle="dropdown"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown"> Dropdown button </button> - <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton"> + <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> @@ -79,6 +79,22 @@ You can use a link with the `href` attribute, or a button with the `data-bs-targ </div> {{< /example >}} +### Dark offcanvas + +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 >}} + ### 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. @@ -263,7 +279,7 @@ Add `data-bs-toggle="offcanvas"` and a `data-bs-target` or `href` to the element {{% 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 WAI-ARIA modal dialog design pattern](https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal). Do this at your own risk. +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 diff --git a/site/content/docs/5.2/components/popovers.md b/site/content/docs/5.2/components/popovers.md index a96e0fb530..b035ece229 100644 --- a/site/content/docs/5.2/components/popovers.md +++ b/site/content/docs/5.2/components/popovers.md @@ -44,17 +44,21 @@ const popoverList = [...popoverTriggerList].map(popoverTriggerEl => new bootstra ### Live demo -We use JavaScript similar to the snippet above to render the following live popover. Titles are set via `title` attribute and body content is set via `data-bs-content`. +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`. -{{< example >}} -<button type="button" class="btn btn-lg btn-danger" data-bs-toggle="popover" title="Popover title" data-bs-content="And here's some amazing content. It's very engaging. Right?">Click to toggle popover</button> +{{< 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 >}} +{{< 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> @@ -87,11 +91,11 @@ You can customize the appearance of popovers using [CSS variables](#variables). {{< scss-docs name="custom-popovers" file="site/assets/scss/_component-examples.scss" >}} -{{< example class="custom-popover-demo" >}} +{{< 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" - title="Custom popover" + data-bs-title="Custom popover" data-bs-content="This popover is themed via CSS variables."> Custom popover </button> @@ -107,8 +111,8 @@ Use the `focus` trigger to dismiss popovers on the user's next click of a differ 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 >}} -<a tabindex="0" class="btn btn-lg btn-danger" role="button" data-bs-toggle="popover" data-bs-trigger="focus" title="Dismissible popover" data-bs-content="And here's some amazing content. It's very engaging. Right?">Dismissible popover</a> +{{< 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 @@ -123,7 +127,7 @@ Elements with the `disabled` attribute aren't interactive, meaning users cannot 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 >}} +{{< 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> diff --git a/site/content/docs/5.2/components/toasts.md b/site/content/docs/5.2/components/toasts.md index 5591a0bc96..e718d30697 100644 --- a/site/content/docs/5.2/components/toasts.md +++ b/site/content/docs/5.2/components/toasts.md @@ -197,7 +197,7 @@ Building on the above example, you can create different toast color schemes with 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 >}} +{{< example stackblitz_add_js="true" >}} <form> <div class="mb-3"> <label for="selectToastPlacement">Toast placement</label> diff --git a/site/content/docs/5.2/components/tooltips.md b/site/content/docs/5.2/components/tooltips.md index e28c368601..e007de641c 100644 --- a/site/content/docs/5.2/components/tooltips.md +++ b/site/content/docs/5.2/components/tooltips.md @@ -45,11 +45,15 @@ const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstra Hover over the links below to see tooltips: -{{< example class="tooltip-demo" >}} -<p class="muted">Placeholder text to demonstrate some <a href="#" data-bs-toggle="tooltip" title="Default tooltip">inline links</a> with tooltips. This is now just filler, no killer. Content placed here just to mimic the presence of <a href="#" data-bs-toggle="tooltip" title="Another tooltip">real text</a>. And all that just to give you an idea of how tooltips would look when used in real-world situations. So hopefully you've now seen how <a href="#" data-bs-toggle="tooltip" title="Another one here too">these tooltips on links</a> can work in practice, once you use them on <a href="#" data-bs-toggle="tooltip" title="The last tip!">your own</a> site or project. +{{< example class="tooltip-demo" stackblitz_add_js="true" >}} +<p class="muted">Placeholder text to demonstrate some <a href="#" data-bs-toggle="tooltip" data-bs-title="Default tooltip">inline links</a> with tooltips. This is now just filler, no killer. Content placed here just to mimic the presence of <a href="#" data-bs-toggle="tooltip" data-bs-title="Another tooltip">real text</a>. And all that just to give you an idea of how tooltips would look when used in real-world situations. So hopefully you've now seen how <a href="#" data-bs-toggle="tooltip" data-bs-title="Another one here too">these tooltips on links</a> can work in practice, once you use them on <a href="#" data-bs-toggle="tooltip" data-bs-title="The last tip!">your own</a> site or project. </p> {{< /example >}} +{{< callout warning >}} +{{< partial "callout-warning-data-bs-title-vs-title.md" >}} +{{< /callout >}} + ### Custom tooltips {{< added-in "5.2.0" >}} @@ -59,11 +63,11 @@ You can customize the appearance of tooltips using [CSS variables](#variables). {{< scss-docs name="custom-tooltip" file="site/assets/scss/_component-examples.scss" >}} -{{< example class="tooltip-demo" >}} +{{< example class="tooltip-demo" stackblitz_add_js="true" >}} <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-custom-class="custom-tooltip" - title="This top tooltip is themed via CSS variables."> + data-bs-title="This top tooltip is themed via CSS variables."> Custom tooltip </button> {{< /example >}} @@ -74,25 +78,25 @@ Hover over the buttons below to see the four tooltips directions: top, right, bo <div class="bd-example tooltip-demo"> <div class="bd-example-tooltips"> - <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top" title="Tooltip on top">Tooltip on top</button> - <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="right" title="Tooltip on right">Tooltip on right</button> - <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Tooltip on bottom">Tooltip on bottom</button> - <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="left" title="Tooltip on left">Tooltip on left</button> - <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-html="true" title="<em>Tooltip</em> <u>with</u> <b>HTML</b>">Tooltip with HTML</button> + <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="Tooltip on top">Tooltip on top</button> + <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="right" data-bs-title="Tooltip on right">Tooltip on right</button> + <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-title="Tooltip on bottom">Tooltip on bottom</button> + <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="left" data-bs-title="Tooltip on left">Tooltip on left</button> + <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-html="true" data-bs-title="<em>Tooltip</em> <u>with</u> <b>HTML</b>">Tooltip with HTML</button> </div> </div> ```html -<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top" title="Tooltip on top"> +<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-title="Tooltip on top"> Tooltip on top </button> -<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="right" title="Tooltip on right"> +<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="right" data-bs-title="Tooltip on right"> Tooltip on right </button> -<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Tooltip on bottom"> +<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-title="Tooltip on bottom"> Tooltip on bottom </button> -<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="left" title="Tooltip on left"> +<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="left" data-bs-title="Tooltip on left"> Tooltip on left </button> ``` @@ -100,7 +104,7 @@ Hover over the buttons below to see the four tooltips directions: top, right, bo And with custom HTML added: ```html -<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-html="true" title="<em>Tooltip</em> <u>with</u> <b>HTML</b>"> +<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-html="true" data-bs-title="<em>Tooltip</em> <u>with</u> <b>HTML</b>"> Tooltip with HTML </button> ``` @@ -108,7 +112,7 @@ And with custom HTML added: With an SVG: <div class="bd-example tooltip-demo"> - <a href="#" class="d-inline-block" data-bs-toggle="tooltip" title="Default tooltip"> + <a href="#" class="d-inline-block" data-bs-toggle="tooltip" data-bs-title="Default tooltip"> <svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 100 100"> <rect width="100%" height="100%" fill="#563d7c"/> <circle cx="50" cy="50" r="30" fill="#007bff"/> @@ -165,7 +169,7 @@ You should only add tooltips to HTML elements that are traditionally keyboard-fo ```html <!-- HTML to write --> -<a href="#" data-bs-toggle="tooltip" title="Some tooltip text!">Hover over me</a> +<a href="#" data-bs-toggle="tooltip" data-bs-title="Some tooltip text!">Hover over me</a> <!-- Generated markup by the plugin --> <div class="tooltip bs-tooltip-top" role="tooltip"> @@ -182,7 +186,7 @@ Elements with the `disabled` attribute aren't interactive, meaning users cannot <div class="tooltip-demo"> {{< example >}} -<span class="d-inline-block" tabindex="0" data-bs-toggle="tooltip" title="Disabled tooltip"> +<span class="d-inline-block" tabindex="0" data-bs-toggle="tooltip" data-bs-title="Disabled tooltip"> <button class="btn btn-primary" type="button" disabled>Disabled button</button> </span> {{< /example >}} diff --git a/site/content/docs/5.2/content/reboot.md b/site/content/docs/5.2/content/reboot.md index 4a1521cd00..911155af25 100644 --- a/site/content/docs/5.2/content/reboot.md +++ b/site/content/docs/5.2/content/reboot.md @@ -106,8 +106,8 @@ The `<hr>` element has been simplified. Similar to browser defaults, `<hr>`s are <hr> </div> -<hr class="text-danger border-2 opacity-50"> -<hr class="border-primary border-3 opacity-75"> +<hr class="border border-danger border-2 opacity-50"> +<hr class="border border-primary border-3 opacity-75"> {{< /example >}} ## Lists diff --git a/site/content/docs/5.2/customize/optimize.md b/site/content/docs/5.2/customize/optimize.md index b5e8de7ee2..e618ce23a0 100644 --- a/site/content/docs/5.2/customize/optimize.md +++ b/site/content/docs/5.2/customize/optimize.md @@ -19,7 +19,7 @@ If you're not using a component, comment it out or delete it entirely. For examp Bootstrap's JavaScript includes every component in our primary dist files (`bootstrap.js` and `bootstrap.min.js`), and even our primary dependency (Popper) with our bundle files (`bootstrap.bundle.js` and `bootstrap.bundle.min.js`). While you're customizing via Sass, be sure to remove related JavaScript. -For instance, assuming you're using your own JavaScript bundler like Webpack or Rollup, you'd only import the JavaScript you plan on using. In the example below, we show how to just include our modal JavaScript: +For instance, assuming you're using your own JavaScript bundler like Webpack, Parcel, or Vite, you'd only import the JavaScript you plan on using. In the example below, we show how to just include our modal JavaScript: <!-- eslint-skip --> ```js @@ -77,7 +77,7 @@ Whenever possible, be sure to compress all the code you serve to your visitors. While minifying and using compression might seem like enough, making your files non-blocking ones is also a big step in making your site well-optimized and fast enough. -If you are using a [Lighthouse](https://developers.google.com/web/tools/lighthouse/) plugin in Google Chrome, you may have stumbled over FCP. [The First Contentful Paint](https://web.dev/fcp/) metric measures the time from when the page starts loading to when any part of the page's content is rendered on the screen. +If you are using a [Lighthouse](https://developer.chrome.com/docs/lighthouse/overview/) plugin in Google Chrome, you may have stumbled over FCP. [The First Contentful Paint](https://web.dev/fcp/) metric measures the time from when the page starts loading to when any part of the page's content is rendered on the screen. You can improve FCP by deferring non-critical JavaScript or CSS. What does that mean? Simply, JavaScript or stylesheets that don't need to be present on the first paint of your page should be marked with `async` or `defer` attributes. diff --git a/site/content/docs/5.2/customize/sass.md b/site/content/docs/5.2/customize/sass.md index a80004e1bb..6215d1032d 100644 --- a/site/content/docs/5.2/customize/sass.md +++ b/site/content/docs/5.2/customize/sass.md @@ -215,9 +215,9 @@ In practice, you'd call the function and pass in the color and weight parameters ### Color contrast -In order to meet [WCAG 2.0 accessibility standards for color contrast](https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html), authors **must** provide [a contrast ratio of at least 4.5:1](https://www.w3.org/WAI/WCAG20/quickref/20160105/Overview.php#visual-audio-contrast-contrast), with very few exceptions. +In order to meet the [Web Content Accessibility Guidelines (WCAG)](https://www.w3.org/TR/WCAG/) contrast requirements, authors **must** provide a minimum [text color contrast of 4.5:1](https://www.w3.org/TR/WCAG/#contrast-minimum) and a minimum [non-text color contrast of 3:1](https://www.w3.org/TR/WCAG/#non-text-contrast), with very few exceptions. -An additional function we include in Bootstrap is the color contrast function, `color-contrast`. It utilizes the [WCAG 2.0 algorithm](https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests) for calculating contrast thresholds based on [relative luminance](https://www.w3.org/WAI/GL/wiki/Relative_luminance) in a `sRGB` color space to automatically return a light (`#fff`), dark (`#212529`) or black (`#000`) contrast color based on the specified base color. This function is especially useful for mixins or loops where you're generating multiple classes. +To help with this, we included the `color-contrast` function in Bootstrap. It uses the [WCAG contrast ratio algorithm](https://www.w3.org/TR/WCAG/#dfn-contrast-ratio) for calculating contrast thresholds based on [relative luminance](https://www.w3.org/TR/WCAG/#dfn-relative-luminance) in an `sRGB` color space to automatically return a light (`#fff`), dark (`#212529`) or black (`#000`) contrast color based on the specified base color. This function is especially useful for mixins or loops where you're generating multiple classes. For example, to generate color swatches from our `$theme-colors` map: diff --git a/site/content/docs/5.2/examples/cheatsheet-rtl/index.html b/site/content/docs/5.2/examples/cheatsheet-rtl/index.html index 2a1db691cf..093554ebda 100644 --- a/site/content/docs/5.2/examples/cheatsheet-rtl/index.html +++ b/site/content/docs/5.2/examples/cheatsheet-rtl/index.html @@ -913,10 +913,10 @@ direction: rtl {{< example show_markup="false" >}} <div class="btn-group w-100 align-items-center justify-content-between flex-wrap"> <div class="dropdown"> - <button class="btn btn-secondary btn-sm dropdown-toggle" type="button" id="dropdownMenuButtonSM" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary btn-sm dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> زر القائمة المنسدلة </button> - <ul class="dropdown-menu" aria-labelledby="dropdownMenuButtonSM"> + <ul class="dropdown-menu"> <li><h6 class="dropdown-header">عنوان القائمة المنسدلة</h6></li> <li><a class="dropdown-item" href="#">عمل</a></li> <li><a class="dropdown-item" href="#">عمل آخر</a></li> @@ -926,10 +926,10 @@ direction: rtl </ul> </div> <div class="dropdown"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> زر القائمة المنسدلة </button> - <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton"> + <ul class="dropdown-menu"> <li><h6 class="dropdown-header">عنوان القائمة المنسدلة</h6></li> <li><a class="dropdown-item" href="#">عمل</a></li> <li><a class="dropdown-item" href="#">عمل آخر</a></li> @@ -939,10 +939,10 @@ direction: rtl </ul> </div> <div class="dropdown"> - <button class="btn btn-secondary btn-lg dropdown-toggle" type="button" id="dropdownMenuButtonLG" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary btn-lg dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> زر القائمة المنسدلة </button> - <ul class="dropdown-menu" aria-labelledby="dropdownMenuButtonLG"> + <ul class="dropdown-menu"> <li><h6 class="dropdown-header">عنوان القائمة المنسدلة</h6></li> <li><a class="dropdown-item" href="#">عمل</a></li> <li><a class="dropdown-item" href="#">عمل آخر</a></li> @@ -1026,10 +1026,10 @@ direction: rtl {{< example show_markup="false" >}} <div class="btn-group w-100 align-items-center justify-content-between flex-wrap"> <div class="dropend"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="dropendMenuButton" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> زر القائمة المنسدلة لليسار </button> - <ul class="dropdown-menu" aria-labelledby="dropendMenuButton"> + <ul class="dropdown-menu"> <li><h6 class="dropdown-header">عنوان القائمة المنسدلة</h6></li> <li><a class="dropdown-item" href="#">عمل</a></li> <li><a class="dropdown-item" href="#">عمل آخر</a></li> @@ -1039,10 +1039,10 @@ direction: rtl </ul> </div> <div class="dropup"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="dropupMenuButton" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> زر القائمة المنسدلة للأعلى </button> - <ul class="dropdown-menu" aria-labelledby="dropupMenuButton"> + <ul class="dropdown-menu"> <li><h6 class="dropdown-header">عنوان القائمة المنسدلة</h6></li> <li><a class="dropdown-item" href="#">عمل</a></li> <li><a class="dropdown-item" href="#">عمل آخر</a></li> @@ -1052,10 +1052,10 @@ direction: rtl </ul> </div> <div class="dropstart"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="dropstartMenuButton" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> زر القائمة المنسدلة لليمين </button> - <ul class="dropdown-menu" aria-labelledby="dropstartMenuButton"> + <ul class="dropdown-menu"> <li><h6 class="dropdown-header">عنوان القائمة المنسدلة</h6></li> <li><a class="dropdown-item" href="#">عمل</a></li> <li><a class="dropdown-item" href="#">عمل آخر</a></li> @@ -1070,10 +1070,10 @@ direction: rtl {{< example show_markup="false" >}} <div class="btn-group"> <div class="dropdown"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownRightMenuButton" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> قائمة منسدلة بمحاذاة نهاية الزر </button> - <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="dropdownRightMenuButton"> + <ul class="dropdown-menu dropdown-menu-end"> <li><h6 class="dropdown-header">عنوان القائمة المنسدلة</h6></li> <li><a class="dropdown-item" href="#">عمل</a></li> <li><a class="dropdown-item" href="#">عمل آخر</a></li> @@ -1230,10 +1230,10 @@ direction: rtl <a class="nav-link" href="#">رابط</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> + <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"> قائمة منسدلة </a> - <ul class="dropdown-menu" aria-labelledby="navbarDropdown"> + <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">عمل</a></li> <li><a class="dropdown-item" href="#">عمل آخر</a></li> <li><hr class="dropdown-divider"></li> @@ -1269,10 +1269,10 @@ direction: rtl <a class="nav-link" href="#">رابط</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown2" role="button" data-bs-toggle="dropdown" aria-expanded="false"> + <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"> قائمة منسدلة </a> - <ul class="dropdown-menu" aria-labelledby="navbarDropdown2"> + <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">عمل</a></li> <li><a class="dropdown-item" href="#">عمل آخر</a></li> <li><hr class="dropdown-divider"></li> diff --git a/site/content/docs/5.2/examples/cheatsheet/index.html b/site/content/docs/5.2/examples/cheatsheet/index.html index afd66d4fa8..8bbd5dc261 100644 --- a/site/content/docs/5.2/examples/cheatsheet/index.html +++ b/site/content/docs/5.2/examples/cheatsheet/index.html @@ -912,10 +912,10 @@ body_class: "bg-light" {{< example show_markup="false" >}} <div class="btn-group w-100 align-items-center justify-content-between flex-wrap"> <div class="dropdown"> - <button class="btn btn-secondary btn-sm dropdown-toggle" type="button" id="dropdownMenuButtonSM" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary btn-sm dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown button </button> - <ul class="dropdown-menu" aria-labelledby="dropdownMenuButtonSM"> + <ul class="dropdown-menu"> <li><h6 class="dropdown-header">Dropdown header</h6></li> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> @@ -925,10 +925,10 @@ body_class: "bg-light" </ul> </div> <div class="dropdown"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown button </button> - <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton"> + <ul class="dropdown-menu"> <li><h6 class="dropdown-header">Dropdown header</h6></li> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> @@ -938,10 +938,10 @@ body_class: "bg-light" </ul> </div> <div class="dropdown"> - <button class="btn btn-secondary btn-lg dropdown-toggle" type="button" id="dropdownMenuButtonLG" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary btn-lg dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown button </button> - <ul class="dropdown-menu" aria-labelledby="dropdownMenuButtonLG"> + <ul class="dropdown-menu"> <li><h6 class="dropdown-header">Dropdown header</h6></li> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> @@ -1025,10 +1025,10 @@ body_class: "bg-light" {{< example show_markup="false" >}} <div class="btn-group w-100 align-items-center justify-content-between flex-wrap"> <div class="dropend"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="dropendMenuButton" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropend button </button> - <ul class="dropdown-menu" aria-labelledby="dropendMenuButton"> + <ul class="dropdown-menu"> <li><h6 class="dropdown-header">Dropdown header</h6></li> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> @@ -1038,10 +1038,10 @@ body_class: "bg-light" </ul> </div> <div class="dropup"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="dropupMenuButton" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropup button </button> - <ul class="dropdown-menu" aria-labelledby="dropupMenuButton"> + <ul class="dropdown-menu"> <li><h6 class="dropdown-header">Dropdown header</h6></li> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> @@ -1051,10 +1051,10 @@ body_class: "bg-light" </ul> </div> <div class="dropstart"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="dropstartMenuButton" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropstart button </button> - <ul class="dropdown-menu" aria-labelledby="dropstartMenuButton"> + <ul class="dropdown-menu"> <li><h6 class="dropdown-header">Dropdown header</h6></li> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> @@ -1069,10 +1069,10 @@ body_class: "bg-light" {{< example show_markup="false" >}} <div class="btn-group"> <div class="dropdown"> - <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownRightMenuButton" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> End-aligned menu </button> - <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="dropdownRightMenuButton"> + <ul class="dropdown-menu dropdown-menu-end"> <li><h6 class="dropdown-header">Dropdown header</h6></li> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> @@ -1229,10 +1229,10 @@ body_class: "bg-light" <a class="nav-link" href="#">Link</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> + <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </a> - <ul class="dropdown-menu" aria-labelledby="navbarDropdown"> + <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> @@ -1268,10 +1268,10 @@ body_class: "bg-light" <a class="nav-link" href="#">Link</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown2" role="button" data-bs-toggle="dropdown" aria-expanded="false"> + <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </a> - <ul class="dropdown-menu" aria-labelledby="navbarDropdown2"> + <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> diff --git a/site/content/docs/5.2/examples/dashboard-rtl/index.html b/site/content/docs/5.2/examples/dashboard-rtl/index.html index be8ef6a88c..bc41cc6043 100644 --- a/site/content/docs/5.2/examples/dashboard-rtl/index.html +++ b/site/content/docs/5.2/examples/dashboard-rtl/index.html @@ -28,7 +28,7 @@ extra_js: <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"> + <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="#"> diff --git a/site/content/docs/5.2/examples/dashboard/dashboard.css b/site/content/docs/5.2/examples/dashboard/dashboard.css index 4426da7fe0..ad12048e76 100644 --- a/site/content/docs/5.2/examples/dashboard/dashboard.css +++ b/site/content/docs/5.2/examples/dashboard/dashboard.css @@ -32,10 +32,7 @@ body { } .sidebar-sticky { - position: relative; - top: 0; height: calc(100vh - 48px); - padding-top: .5rem; overflow-x: hidden; overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */ } diff --git a/site/content/docs/5.2/examples/dashboard/dashboard.rtl.css b/site/content/docs/5.2/examples/dashboard/dashboard.rtl.css index a3f114f0ff..31ea3cc64e 100644 --- a/site/content/docs/5.2/examples/dashboard/dashboard.rtl.css +++ b/site/content/docs/5.2/examples/dashboard/dashboard.rtl.css @@ -28,10 +28,7 @@ body { } .sidebar-sticky { - position: relative; - top: 0; height: calc(100vh - 48px); - padding-top: .5rem; overflow-x: hidden; overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */ } diff --git a/site/content/docs/5.2/examples/dashboard/index.html b/site/content/docs/5.2/examples/dashboard/index.html index 7e08308992..b3b40c266c 100644 --- a/site/content/docs/5.2/examples/dashboard/index.html +++ b/site/content/docs/5.2/examples/dashboard/index.html @@ -27,7 +27,7 @@ extra_js: <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"> + <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="#"> diff --git a/site/content/docs/5.2/examples/headers/index.html b/site/content/docs/5.2/examples/headers/index.html index 5ef2eef163..b8fc8b27b8 100644 --- a/site/content/docs/5.2/examples/headers/index.html +++ b/site/content/docs/5.2/examples/headers/index.html @@ -137,10 +137,10 @@ body_class: "" </form> <div class="dropdown text-end"> - <a href="#" class="d-block link-dark text-decoration-none dropdown-toggle" id="dropdownUser1" data-bs-toggle="dropdown" aria-expanded="false"> + <a href="#" class="d-block link-dark text-decoration-none dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"> <img src="https://github.com/mdo.png" alt="mdo" width="32" height="32" class="rounded-circle"> </a> - <ul class="dropdown-menu text-small" aria-labelledby="dropdownUser1"> + <ul class="dropdown-menu text-small"> <li><a class="dropdown-item" href="#">New project...</a></li> <li><a class="dropdown-item" href="#">Settings</a></li> <li><a class="dropdown-item" href="#">Profile</a></li> @@ -157,10 +157,10 @@ body_class: "" <header class="py-3 mb-3 border-bottom"> <div class="container-fluid d-grid gap-3 align-items-center" style="grid-template-columns: 1fr 2fr;"> <div class="dropdown"> - <a href="#" class="d-flex align-items-center col-lg-4 mb-2 mb-lg-0 link-dark text-decoration-none dropdown-toggle" id="dropdownNavLink" data-bs-toggle="dropdown" aria-expanded="false"> + <a href="#" class="d-flex align-items-center col-lg-4 mb-2 mb-lg-0 link-dark text-decoration-none dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"> <svg class="bi me-2" width="40" height="32"><use xlink:href="#bootstrap"/></svg> </a> - <ul class="dropdown-menu text-small shadow" aria-labelledby="dropdownNavLink"> + <ul class="dropdown-menu text-small shadow"> <li><a class="dropdown-item active" href="#" aria-current="page">Overview</a></li> <li><a class="dropdown-item" href="#">Inventory</a></li> <li><a class="dropdown-item" href="#">Customers</a></li> @@ -177,10 +177,10 @@ body_class: "" </form> <div class="flex-shrink-0 dropdown"> - <a href="#" class="d-block link-dark text-decoration-none dropdown-toggle" id="dropdownUser2" data-bs-toggle="dropdown" aria-expanded="false"> + <a href="#" class="d-block link-dark text-decoration-none dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"> <img src="https://github.com/mdo.png" alt="mdo" width="32" height="32" class="rounded-circle"> </a> - <ul class="dropdown-menu text-small shadow" aria-labelledby="dropdownUser2"> + <ul class="dropdown-menu text-small shadow"> <li><a class="dropdown-item" href="#">New project...</a></li> <li><a class="dropdown-item" href="#">Settings</a></li> <li><a class="dropdown-item" href="#">Profile</a></li> diff --git a/site/content/docs/5.2/examples/navbar-bottom/index.html b/site/content/docs/5.2/examples/navbar-bottom/index.html index 1a6399975f..c0e859ad0c 100644 --- a/site/content/docs/5.2/examples/navbar-bottom/index.html +++ b/site/content/docs/5.2/examples/navbar-bottom/index.html @@ -28,8 +28,8 @@ title: Bottom navbar example <a class="nav-link disabled">Disabled</a> </li> <li class="nav-item dropup"> - <a class="nav-link dropdown-toggle" href="#" id="dropdown10" data-bs-toggle="dropdown" aria-expanded="false">Dropup</a> - <ul class="dropdown-menu" aria-labelledby="dropdown10"> + <a class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown" aria-expanded="false">Dropup</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> diff --git a/site/content/docs/5.2/examples/navbars-offcanvas/index.html b/site/content/docs/5.2/examples/navbars-offcanvas/index.html index b08ed63391..9099dc93ac 100644 --- a/site/content/docs/5.2/examples/navbars-offcanvas/index.html +++ b/site/content/docs/5.2/examples/navbars-offcanvas/index.html @@ -26,10 +26,10 @@ extra_css: <a class="nav-link" href="#">Link</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="offcanvasNavbarDarkDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> + <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </a> - <ul class="dropdown-menu" aria-labelledby="offcanvasNavbarDarkDropdown"> + <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> <li> @@ -68,10 +68,10 @@ extra_css: <a class="nav-link" href="#">Link</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="offcanvasNavbarLightDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> + <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </a> - <ul class="dropdown-menu" aria-labelledby="offcanvasNavbarLightDropdown"> + <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> <li> @@ -110,10 +110,10 @@ extra_css: <a class="nav-link" href="#">Link</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="offcanvasNavbarLgDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> + <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </a> - <ul class="dropdown-menu" aria-labelledby="offcanvasNavbarLgDropdown"> + <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> <li> diff --git a/site/content/docs/5.2/examples/navbars/index.html b/site/content/docs/5.2/examples/navbars/index.html index f0a49c1d40..cc90b8ce09 100644 --- a/site/content/docs/5.2/examples/navbars/index.html +++ b/site/content/docs/5.2/examples/navbars/index.html @@ -25,8 +25,8 @@ extra_css: <a class="nav-link disabled">Disabled</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="dropdown01" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</a> - <ul class="dropdown-menu" aria-labelledby="dropdown01"> + <a class="nav-link dropdown-toggle" href="#" 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><a class="dropdown-item" href="#">Something else here</a></li> @@ -82,8 +82,8 @@ extra_css: <a class="nav-link disabled">Disabled</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="dropdown03" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</a> - <ul class="dropdown-menu" aria-labelledby="dropdown03"> + <a class="nav-link dropdown-toggle" href="#" 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><a class="dropdown-item" href="#">Something else here</a></li> @@ -116,8 +116,8 @@ extra_css: <a class="nav-link disabled">Disabled</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="dropdown04" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</a> - <ul class="dropdown-menu" aria-labelledby="dropdown04"> + <a class="nav-link dropdown-toggle" href="#" 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><a class="dropdown-item" href="#">Something else here</a></li> @@ -150,8 +150,8 @@ extra_css: <a class="nav-link disabled">Disabled</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="dropdown05" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</a> - <ul class="dropdown-menu" aria-labelledby="dropdown05"> + <a class="nav-link dropdown-toggle" href="#" 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><a class="dropdown-item" href="#">Something else here</a></li> @@ -184,8 +184,8 @@ extra_css: <a class="nav-link disabled">Disabled</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="dropdown06" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</a> - <ul class="dropdown-menu" aria-labelledby="dropdown06"> + <a class="nav-link dropdown-toggle" href="#" 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><a class="dropdown-item" href="#">Something else here</a></li> @@ -218,8 +218,8 @@ extra_css: <a class="nav-link disabled">Disabled</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="dropdownXxl" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</a> - <ul class="dropdown-menu" aria-labelledby="dropdownXxl"> + <a class="nav-link dropdown-toggle" href="#" 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><a class="dropdown-item" href="#">Something else here</a></li> @@ -252,8 +252,8 @@ extra_css: <a class="nav-link disabled">Disabled</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="dropdown07" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</a> - <ul class="dropdown-menu" aria-labelledby="dropdown07"> + <a class="nav-link dropdown-toggle" href="#" 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><a class="dropdown-item" href="#">Something else here</a></li> @@ -286,8 +286,8 @@ extra_css: <a class="nav-link disabled">Disabled</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="dropdown07XL" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</a> - <ul class="dropdown-menu" aria-labelledby="dropdown07XL"> + <a class="nav-link dropdown-toggle" href="#" 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><a class="dropdown-item" href="#">Something else here</a></li> @@ -323,8 +323,8 @@ extra_css: <a class="nav-link disabled">Disabled</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="dropdown08" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</a> - <ul class="dropdown-menu" aria-labelledby="dropdown08"> + <a class="nav-link dropdown-toggle" href="#" 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><a class="dropdown-item" href="#">Something else here</a></li> @@ -355,8 +355,8 @@ extra_css: <a class="nav-link disabled">Disabled</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="dropdown09" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</a> - <ul class="dropdown-menu" aria-labelledby="dropdown09"> + <a class="nav-link dropdown-toggle" href="#" 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><a class="dropdown-item" href="#">Something else here</a></li> @@ -388,8 +388,8 @@ extra_css: <a class="nav-link disabled">Disabled</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="dropdown10" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</a> - <ul class="dropdown-menu" aria-labelledby="dropdown10"> + <a class="nav-link dropdown-toggle" href="#" 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><a class="dropdown-item" href="#">Something else here</a></li> diff --git a/site/content/docs/5.2/examples/offcanvas-navbar/index.html b/site/content/docs/5.2/examples/offcanvas-navbar/index.html index 667e73bb44..81c9bb4bbe 100644 --- a/site/content/docs/5.2/examples/offcanvas-navbar/index.html +++ b/site/content/docs/5.2/examples/offcanvas-navbar/index.html @@ -31,8 +31,8 @@ aliases: "/docs/5.2/examples/offcanvas/" <a class="nav-link" href="#">Switch account</a> </li> <li class="nav-item dropdown"> - <a class="nav-link dropdown-toggle" href="#" id="dropdown01" data-bs-toggle="dropdown" aria-expanded="false">Settings</a> - <ul class="dropdown-menu" aria-labelledby="dropdown01"> + <a class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown" aria-expanded="false">Settings</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> diff --git a/site/content/docs/5.2/examples/sidebars/index.html b/site/content/docs/5.2/examples/sidebars/index.html index 33a80e1f8a..48889faccb 100644 --- a/site/content/docs/5.2/examples/sidebars/index.html +++ b/site/content/docs/5.2/examples/sidebars/index.html @@ -110,11 +110,11 @@ body_class: "" </ul> <hr> <div class="dropdown"> - <a href="#" class="d-flex align-items-center text-white text-decoration-none dropdown-toggle" id="dropdownUser1" data-bs-toggle="dropdown" aria-expanded="false"> + <a href="#" class="d-flex align-items-center text-white text-decoration-none dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"> <img src="https://github.com/mdo.png" alt="" width="32" height="32" class="rounded-circle me-2"> <strong>mdo</strong> </a> - <ul class="dropdown-menu dropdown-menu-dark text-small shadow" aria-labelledby="dropdownUser1"> + <ul class="dropdown-menu dropdown-menu-dark text-small shadow"> <li><a class="dropdown-item" href="#">New project...</a></li> <li><a class="dropdown-item" href="#">Settings</a></li> <li><a class="dropdown-item" href="#">Profile</a></li> @@ -166,11 +166,11 @@ body_class: "" </ul> <hr> <div class="dropdown"> - <a href="#" class="d-flex align-items-center link-dark text-decoration-none dropdown-toggle" id="dropdownUser2" data-bs-toggle="dropdown" aria-expanded="false"> + <a href="#" class="d-flex align-items-center link-dark text-decoration-none dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"> <img src="https://github.com/mdo.png" alt="" width="32" height="32" class="rounded-circle me-2"> <strong>mdo</strong> </a> - <ul class="dropdown-menu text-small shadow" aria-labelledby="dropdownUser2"> + <ul class="dropdown-menu text-small shadow"> <li><a class="dropdown-item" href="#">New project...</a></li> <li><a class="dropdown-item" href="#">Settings</a></li> <li><a class="dropdown-item" href="#">Profile</a></li> @@ -215,10 +215,10 @@ body_class: "" </li> </ul> <div class="dropdown border-top"> - <a href="#" class="d-flex align-items-center justify-content-center p-3 link-dark text-decoration-none dropdown-toggle" id="dropdownUser3" data-bs-toggle="dropdown" aria-expanded="false"> + <a href="#" class="d-flex align-items-center justify-content-center p-3 link-dark text-decoration-none dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"> <img src="https://github.com/mdo.png" alt="mdo" width="24" height="24" class="rounded-circle"> </a> - <ul class="dropdown-menu text-small shadow" aria-labelledby="dropdownUser3"> + <ul class="dropdown-menu text-small shadow"> <li><a class="dropdown-item" href="#">New project...</a></li> <li><a class="dropdown-item" href="#">Settings</a></li> <li><a class="dropdown-item" href="#">Profile</a></li> diff --git a/site/content/docs/5.2/examples/starter-template/index.html b/site/content/docs/5.2/examples/starter-template/index.html index e1eda9e304..a16984ab9b 100644 --- a/site/content/docs/5.2/examples/starter-template/index.html +++ b/site/content/docs/5.2/examples/starter-template/index.html @@ -40,6 +40,7 @@ extra_css: <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> diff --git a/site/content/docs/5.2/forms/checks-radios.md b/site/content/docs/5.2/forms/checks-radios.md index 812e7c198e..5c7ab52616 100644 --- a/site/content/docs/5.2/forms/checks-radios.md +++ b/site/content/docs/5.2/forms/checks-radios.md @@ -36,7 +36,7 @@ Our checks use custom Bootstrap icons to indicate checked or indeterminate state 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">}} +{{< 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"> diff --git a/site/content/docs/5.2/forms/form-control.md b/site/content/docs/5.2/forms/form-control.md index 046004d7c0..4d6972d1df 100644 --- a/site/content/docs/5.2/forms/form-control.md +++ b/site/content/docs/5.2/forms/form-control.md @@ -31,7 +31,7 @@ Set heights using classes like `.form-control-lg` and `.form-control-sm`. ## Disabled -Add the `disabled` boolean attribute on an input to give it a grayed out appearance and remove pointer events. +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> @@ -40,7 +40,7 @@ Add the `disabled` boolean attribute on an input to give it a grayed out appeara ## Readonly -Add the `readonly` boolean attribute on an input to prevent modification of the input's value. +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> @@ -48,7 +48,7 @@ Add the `readonly` boolean attribute on an input to prevent modification of the ## Readonly plain text -If you want to have `<input readonly>` elements in your form styled as plain text, use the `.form-control-plaintext` class to remove the default form field styling and preserve the correct margin and padding. +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"> diff --git a/site/content/docs/5.2/getting-started/javascript.md b/site/content/docs/5.2/getting-started/javascript.md index 0b79ef8912..fa157e006c 100644 --- a/site/content/docs/5.2/getting-started/javascript.md +++ b/site/content/docs/5.2/getting-started/javascript.md @@ -10,7 +10,7 @@ toc: true Plugins can be included individually (using Bootstrap's individual `js/dist/*.js`), or all at once using `bootstrap.js` or the minified `bootstrap.min.js` (don't include both). -If you use a bundler (Webpack, Rollup...), you can use `/js/dist/*.js` files which are UMD ready. +If you use a bundler (Webpack, Parcel, Vite...), you can use `/js/dist/*.js` files which are UMD ready. ## Usage with JavaScript frameworks @@ -19,7 +19,7 @@ While the Bootstrap CSS can be used with any framework, **the Bootstrap JavaScri A better alternative for those using this type of frameworks is to use a framework-specific package **instead of** the Bootstrap JavaScript. Here are some of the most popular options: - React: [React Bootstrap](https://react-bootstrap.github.io/) -- Vue: [BootstrapVue](https://bootstrap-vue.org/) +- Vue: [BootstrapVue](https://bootstrap-vue.org/) (currently only supports Vue 2 and Bootstrap 4) - Angular: [ng-bootstrap](https://ng-bootstrap.github.io/) ## Using Bootstrap as a module @@ -89,22 +89,19 @@ To fix this, you can use an `importmap` to resolve the arbitrary module names to Some plugins and CSS components depend on other plugins. If you include plugins individually, make sure to check for these dependencies in the docs. -Our dropdowns, popovers and tooltips also depend on [Popper](https://popper.js.org/). - -## Still want to use jQuery? It's possible! - -Bootstrap 5 is designed to be used without jQuery, but it's still possible to use our components with jQuery. **If Bootstrap detects `jQuery` in the `window` object** it'll add all of our components in jQuery's plugin system; this means you'll be able to do `$('[data-bs-toggle="tooltip"]').tooltip()` to enable tooltips. The same goes for our other components. +Our dropdowns, popovers, and tooltips also depend on [Popper](https://popper.js.org/). ## Data attributes Nearly all Bootstrap plugins can be enabled and configured through HTML alone with data attributes (our preferred way of using JavaScript functionality). Be sure to **only use one set of data attributes on a single element** (e.g., you cannot trigger a tooltip and modal from the same button.) -{{< callout warning >}} +{{< markdown >}} +{{< partial "js-data-attributes.md" >}} +{{< /markdown >}} + ## Selectors -Currently to query DOM elements we use the native methods `querySelector` and `querySelectorAll` for performance reasons, so you have to use [valid selectors](https://www.w3.org/TR/CSS21/syndata.html#value-def-identifier). -If you use special selectors, for example: `collapse:Example` be sure to escape them. -{{< /callout >}} +We use the native `querySelector` and `querySelectorAll` methods to query DOM elements for performance reasons, so you must use [valid selectors](https://www.w3.org/TR/CSS21/syndata.html#value-def-identifier). If you use special selectors like `collapse:Example`, be sure to escape them. ## Events @@ -113,7 +110,7 @@ Bootstrap provides custom events for most plugins' unique actions. Generally, th All infinitive events provide [`preventDefault()`](https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault) functionality. This provides the ability to stop the execution of an action before it starts. Returning false from an event handler will also automatically call `preventDefault()`. ```js -const myModal = document.getElementById('myModal') +const myModal = document.querySelector('#myModal') myModal.addEventListener('show.bs.modal', event => { if (!data) { @@ -122,58 +119,62 @@ myModal.addEventListener('show.bs.modal', event => { }) ``` -{{< callout warning >}} -## jQuery events +## Programmatic API -Bootstrap will detect jQuery if `jQuery` is present in the `window` object and there is no `data-bs-no-jquery` attribute set on `<body>`. If jQuery is found, Bootstrap will emit events thanks to jQuery's event system. So if you want to listen to Bootstrap's events, you'll have to use the jQuery methods (`.on`, `.one`) instead of `addEventListener`. +All constructors accept an optional options object or nothing (which initiates a plugin with its default behavior): ```js -$('#myTab a').on('shown.bs.tab', () => { - // do something... -}) -``` -{{< /callout >}} +const myModalEl = document.querySelector('#myModal') -## Programmatic API +const modal = new bootstrap.Modal(myModalEl) // initialized with defaults -All constructors accept an optional options object or nothing (which initiates a plugin with its default behavior): +const configObject = { keyboard: false } +const modal1 = new bootstrap.Modal(myModalEl, configObject) // initialized with no keyboard +``` + +If you'd like to get a particular plugin instance, each plugin exposes a `getInstance` method. For example, to retrieve an instance directly from an element: ```js -const myModalEl = document.getElementById('myModal') +bootstrap.Popover.getInstance(myPopoverEl) +``` -const modal = new bootstrap.Modal(myModalEl) // initialized with defaults -const modal1 = new bootstrap.Modal(myModalEl, { keyboard: false }) // initialized with no keyboard +This method will return `null` if an instance is not initiated over the requested element. + +Alternatively, `getOrCreateInstance` can be used to get the instance associated with a DOM element, or create a new one in case it wasn't initialized. + +```js +bootstrap.Popover.getOrCreateInstance(myPopoverEl, configObject) ``` -If you'd like to get a particular plugin instance, each plugin exposes a `getInstance` method. In order to retrieve it directly from an element, do this: `bootstrap.Popover.getInstance(myPopoverEl)`. +In case an instance wasn't initialized, it may accept and use an optional configuration object as second argument. ### CSS selectors in constructors -You can also use a CSS selector as the first argument instead of a DOM element to initialize the plugin. Currently the element for the plugin is found by the `querySelector` method since our plugins support a single element only. +In addition to the `getInstance` and `getOrCreateInstance` methods, all plugin constructors can accept a DOM element or a valid [CSS selector](#selectors) as the first argument. Plugin elements are found with the `querySelector` method since our plugins only support a single element. ```js const modal = new bootstrap.Modal('#myModal') const dropdown = new bootstrap.Dropdown('[data-bs-toggle="dropdown"]') +const offcanvas = bootstrap.Offcanvas.getInstance('#myOffcanvas') +const alert = bootstrap.Alert.getOrCreateInstance('#myAlert') ``` ### Asynchronous functions and transitions -All programmatic API methods are **asynchronous** and return to the caller once the transition is started but **before it ends**. - -In order to execute an action once the transition is complete, you can listen to the corresponding event. +All programmatic API methods are **asynchronous** and return to the caller once the transition is started, but **before it ends**. In order to execute an action once the transition is complete, you can listen to the corresponding event. ```js -const myCollapseEl = document.getElementById('myCollapse') +const myCollapseEl = document.querySelector('#myCollapse') myCollapseEl.addEventListener('shown.bs.collapse', event => { // Action to execute once the collapsible area is expanded }) ``` -In addition a method call on a **transitioning component will be ignored**. +In addition, a method call on a **transitioning component will be ignored**. ```js -const myCarouselEl = document.getElementById('myCarousel') +const myCarouselEl = document.querySelector('#myCarousel') const carousel = bootstrap.Carousel.getInstance(myCarouselEl) // Retrieve a Carousel instance myCarouselEl.addEventListener('slid.bs.carousel', event => { @@ -184,41 +185,46 @@ carousel.to('1') // Will start sliding to the slide 1 and returns to the caller carousel.to('2') // !! Will be ignored, as the transition to the slide 1 is not finished !! ``` -### Default settings +#### `dispose` method -You can change the default settings for a plugin by modifying the plugin's `Constructor.Default` object: +While it may seem correct to use the `dispose` method immediately after `hide()`, it will lead to incorrect results. Here's an example of the problem use: ```js -// changes default for the modal plugin's `keyboard` option to false -bootstrap.Modal.Default.keyboard = false -``` - -## No conflict (only if you use jQuery) - -Sometimes it is necessary to use Bootstrap plugins with other UI frameworks. In these circumstances, namespace collisions can occasionally occur. If this happens, you may call `.noConflict` on the plugin you wish to revert the value of. +const myModal = document.querySelector('#myModal') +myModal.hide() // it is asynchronous -```js -const bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value -$.fn.bootstrapBtn = bootstrapButton // give $().bootstrapBtn the Bootstrap functionality +myModal.addEventListener('shown.bs.hidden', event => { + myModal.dispose() +}) ``` -## Version numbers +### Default settings -The version of each of Bootstrap's plugins can be accessed via the `VERSION` property of the plugin's constructor. For example, for the tooltip plugin: +You can change the default settings for a plugin by modifying the plugin's `Constructor.Default` object: ```js -bootstrap.Tooltip.VERSION // => "{{< param current_version >}}" +// changes default for the modal plugin's `keyboard` option to false +bootstrap.Modal.Default.keyboard = false ``` -## No special fallbacks when JavaScript is disabled +## Methods and properties -Bootstrap's plugins don't fall back particularly gracefully when JavaScript is disabled. If you care about the user experience in this case, use [`<noscript>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript) to explain the situation (and how to re-enable JavaScript) to your users, and/or add your own custom fallbacks. +Every Bootstrap plugin exposes the following methods and static properties. -{{< callout warning >}} -##### Third-party libraries +{{< bs-table "table" >}} +| Method | Description | +| --- | --- | +| `dispose` | Destroys an element's modal. (Removes stored data on the DOM element) | +| `getInstance` | *Static* method which allows you to get the modal instance associated with a DOM element. | +| `getOrCreateInstance` | *Static* method which allows you to get the modal instance associated with a DOM element, or create a new one in case it wasn't initialized. | +{{< /bs-table >}} -**Bootstrap does not officially support third-party JavaScript libraries** like Prototype or jQuery UI. Despite `.noConflict` and namespaced events, there may be compatibility problems that you need to fix on your own. -{{< /callout >}} +{{< bs-table "table" >}} +| Static property | Description | +| --- | --- | +| `NAME` | Returns the plugin name. (Example: `bootstrap.Tooltip.NAME`) | +| `VERSION` | The version of each of Bootstrap's plugins can be accessed via the `VERSION` property of the plugin's constructor (Example: `bootstrap.Tooltip.VERSION`) | +{{< /bs-table >}} ## Sanitizer @@ -283,10 +289,49 @@ myDefaultAllowList['*'].push(myCustomRegex) If you want to bypass our sanitizer because you prefer to use a dedicated library, for example [DOMPurify](https://www.npmjs.com/package/dompurify), you should do the following: ```js -const yourTooltipEl = document.getElementById('yourTooltip') +const yourTooltipEl = document.querySelector('#yourTooltip') const tooltip = new bootstrap.Tooltip(yourTooltipEl, { sanitizeFn(content) { return DOMPurify.sanitize(content) } }) ``` + +## Optionally using jQuery + +**You don't need jQuery in Bootstrap 5**, but it's still possible to use our components with jQuery. If Bootstrap detects `jQuery` in the `window` object, it'll add all of our components in jQuery's plugin system. This allows you to do the following: + +```js +$('[data-bs-toggle="tooltip"]').tooltip() // to enable tooltips, with default configuration + +$('[data-bs-toggle="tooltip"]').tooltip({ boundary: 'clippingParents', customClass: 'myClass' }) // to initialize tooltips with given configuration + +$('#myTooltip').tooltip('show') // to trigger `show` method +``` + +The same goes for our other components. + +### No conflict + +Sometimes it is necessary to use Bootstrap plugins with other UI frameworks. In these circumstances, namespace collisions can occasionally occur. If this happens, you may call `.noConflict` on the plugin you wish to revert the value of. + +```js +const bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value +$.fn.bootstrapBtn = bootstrapButton // give $().bootstrapBtn the Bootstrap functionality +``` + +Bootstrap does not officially support third-party JavaScript libraries like Prototype or jQuery UI. Despite `.noConflict` and namespaced events, there may be compatibility problems that you need to fix on your own. + +### jQuery events + +Bootstrap will detect jQuery if `jQuery` is present in the `window` object and there is no `data-bs-no-jquery` attribute set on `<body>`. If jQuery is found, Bootstrap will emit events thanks to jQuery's event system. So if you want to listen to Bootstrap's events, you'll have to use the jQuery methods (`.on`, `.one`) instead of `addEventListener`. + +```js +$('#myTab a').on('shown.bs.tab', () => { + // do something... +}) +``` + +## Disabled JavaScript + +Bootstrap's plugins have no special fallback when JavaScript is disabled. If you care about the user experience in this case, use [`<noscript>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript) to explain the situation (and how to re-enable JavaScript) to your users, and/or add your own custom fallbacks. diff --git a/site/content/docs/5.2/getting-started/vite.md b/site/content/docs/5.2/getting-started/vite.md new file mode 100644 index 0000000000..ca0b61925e --- /dev/null +++ b/site/content/docs/5.2/getting-started/vite.md @@ -0,0 +1,197 @@ +--- +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 +--- + +<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 were 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 [checkout 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 >}} diff --git a/site/content/docs/5.2/getting-started/webpack.md b/site/content/docs/5.2/getting-started/webpack.md index 015ea4efc8..e45df81e5d 100644 --- a/site/content/docs/5.2/getting-started/webpack.md +++ b/site/content/docs/5.2/getting-started/webpack.md @@ -93,7 +93,7 @@ With dependencies installed and our project folder ready for us to start coding, } ``` -2. **Next we create 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. +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> @@ -142,7 +142,7 @@ In the next and final section to this guide, we'll setup the Webpack loaders and 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. **Setup 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. +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') diff --git a/site/content/docs/5.2/layout/grid.md b/site/content/docs/5.2/layout/grid.md index 765b7eb603..9d147239fe 100644 --- a/site/content/docs/5.2/layout/grid.md +++ b/site/content/docs/5.2/layout/grid.md @@ -63,77 +63,79 @@ Bootstrap's grid system can adapt across all six default breakpoints, and any br 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: -<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 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 diff --git a/site/content/docs/5.2/migration.md b/site/content/docs/5.2/migration.md index 9750e4e77a..dbeb8f60c8 100644 --- a/site/content/docs/5.2/migration.md +++ b/site/content/docs/5.2/migration.md @@ -388,6 +388,7 @@ Want more information? [Read the v5.1.0 blog post.](https://blog.getbootstrap.co ### 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 diff --git a/site/content/docs/5.2/utilities/api.md b/site/content/docs/5.2/utilities/api.md index ef6d9ac1eb..81017ee8eb 100644 --- a/site/content/docs/5.2/utilities/api.md +++ b/site/content/docs/5.2/utilities/api.md @@ -392,7 +392,6 @@ New utilities can be added to the default `$utilities` map with a `map-merge`. M @import "bootstrap/scss/maps"; @import "bootstrap/scss/mixins"; @import "bootstrap/scss/utilities"; -@import "bootstrap/scss/utilities/api"; $utilities: map-merge( $utilities, @@ -405,6 +404,8 @@ $utilities: map-merge( ) ) ); + +@import "bootstrap/scss/utilities/api"; ``` ### Modify utilities @@ -417,7 +418,6 @@ Modify existing utilities in the default `$utilities` map with `map-get` and `ma @import "bootstrap/scss/maps"; @import "bootstrap/scss/mixins"; @import "bootstrap/scss/utilities"; -@import "bootstrap/scss/utilities/api"; $utilities: map-merge( $utilities, @@ -433,6 +433,8 @@ $utilities: map-merge( ), ) ); + +@import "bootstrap/scss/utilities/api"; ``` #### Enable responsive @@ -445,7 +447,6 @@ You can enable responsive classes for an existing set of utilities that are not @import "bootstrap/scss/maps"; @import "bootstrap/scss/mixins"; @import "bootstrap/scss/utilities"; -@import "bootstrap/scss/utilities/api"; $utilities: map-merge( $utilities, ( @@ -455,6 +456,8 @@ $utilities: map-merge( ), ) ); + +@import "bootstrap/scss/utilities/api"; ``` This will now generate responsive variations of `.border` and `.border-0` for each breakpoint. Your generated CSS will look like this: @@ -499,7 +502,6 @@ Missing v4 utilities, or used to another naming convention? The utilities API ca @import "bootstrap/scss/maps"; @import "bootstrap/scss/mixins"; @import "bootstrap/scss/utilities"; -@import "bootstrap/scss/utilities/api"; $utilities: map-merge( $utilities, ( @@ -509,11 +511,13 @@ $utilities: map-merge( ), ) ); + +@import "bootstrap/scss/utilities/api"; ``` ### Remove utilities -Remove any of the default utilities by setting the group key to `null`. For example, to remove all our `width` utilities, create a `$utilities` `map-merge` and add `"width": null` within. +Remove any of the default utilities with the [`map-remove()` Sass function](https://sass-lang.com/documentation/modules/map#remove). ```scss @import "bootstrap/scss/functions"; @@ -521,7 +525,21 @@ Remove any of the default utilities by setting the group key to `null`. For exam @import "bootstrap/scss/maps"; @import "bootstrap/scss/mixins"; @import "bootstrap/scss/utilities"; + +// Remove multiple utilities with a comma-separated list +$utilities: map-remove($utilities, "width", "float"); + @import "bootstrap/scss/utilities/api"; +``` + +You can also use the [`map-merge()` Sass function](https://sass-lang.com/documentation/modules/map#merge) and set the group key to `null` to remove the utility. + +```scss +@import "bootstrap/scss/functions"; +@import "bootstrap/scss/variables"; +@import "bootstrap/scss/maps"; +@import "bootstrap/scss/mixins"; +@import "bootstrap/scss/utilities"; $utilities: map-merge( $utilities, @@ -529,6 +547,44 @@ $utilities: map-merge( "width": null ) ); + +@import "bootstrap/scss/utilities/api"; +``` + +### Add, remove, modify + +You can add, remove, and modify many utilities all at once with the [`map-merge()` Sass function](https://sass-lang.com/documentation/modules/map#merge). Here's how you can combine the previous examples into one larger map. + +```scss +@import "bootstrap/scss/functions"; +@import "bootstrap/scss/variables"; +@import "bootstrap/scss/maps"; +@import "bootstrap/scss/mixins"; +@import "bootstrap/scss/utilities"; + +$utilities: map-merge( + $utilities, + ( + // Remove the `width` utility + "width": null, + + // Make an existing utility responsive + "border": map-merge( + map-get($utilities, "border"), + ( responsive: true ), + ), + + // Add new utilities + "cursor": ( + property: cursor, + class: cursor, + responsive: true, + values: auto pointer grab, + ) + ) +); + +@import "bootstrap/scss/utilities/api"; ``` #### Remove utility in RTL diff --git a/site/data/sidebar.yml b/site/data/sidebar.yml index c63f29c6ee..2b7fddfd4f 100644 --- a/site/data/sidebar.yml +++ b/site/data/sidebar.yml @@ -12,6 +12,7 @@ - title: JavaScript - title: Webpack - title: Parcel + - title: Vite - title: Accessibility - title: RFS - title: RTL diff --git a/site/layouts/partials/callout-warning-data-bs-title-vs-title.md b/site/layouts/partials/callout-warning-data-bs-title-vs-title.md new file mode 100644 index 0000000000..e932f22ad9 --- /dev/null +++ b/site/layouts/partials/callout-warning-data-bs-title-vs-title.md @@ -0,0 +1 @@ +Feel free to use either `title` or `data-bs-title` in your HTML. When `title` is used, Popper will replace it automatically with `data-bs-title` when the element is rendered. diff --git a/site/layouts/partials/docs-versions.html b/site/layouts/partials/docs-versions.html index 54cf3a2e2a..2ebf4416d3 100644 --- a/site/layouts/partials/docs-versions.html +++ b/site/layouts/partials/docs-versions.html @@ -11,10 +11,10 @@ {{- end }} <li class="nav-item dropdown"> - <button class="btn btn-link nav-link py-2 px-0 px-lg-2 dropdown-toggle" id="bd-versions" data-bs-toggle="dropdown" aria-expanded="false" data-bs-display="static"> - <span class="d-lg-none">Bootstrap</span> v{{ .Site.Params.docs_version }} + <button class="btn btn-link nav-link py-2 px-0 px-lg-2 dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false" data-bs-display="static"> + <span class="d-lg-none" aria-hidden="true">Bootstrap</span><span class="visually-hidden">Bootstrap </span> v{{ .Site.Params.docs_version }} <span class="visually-hidden">(switch to other versions)</span> </button> - <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="bd-versions"> + <ul class="dropdown-menu dropdown-menu-end"> <li><h6 class="dropdown-header">v5 releases</h6></li> <li> <a class="dropdown-item current" aria-current="true" href="{{ if .IsHome }}/{{ else }}/docs/{{ .Site.Params.docs_version }}/{{ $versions_link }}{{ end }}"> diff --git a/site/layouts/partials/footer.html b/site/layouts/partials/footer.html index 2cd5fc2bc3..c7eb7e2178 100644 --- a/site/layouts/partials/footer.html +++ b/site/layouts/partials/footer.html @@ -30,6 +30,7 @@ <li class="mb-2"><a href="/docs/{{ .Site.Params.docs_version }}/examples/starter-template/">Starter template</a></li> <li class="mb-2"><a href="/docs/{{ .Site.Params.docs_version }}/getting-started/webpack/">Webpack</a></li> <li class="mb-2"><a href="/docs/{{ .Site.Params.docs_version }}/getting-started/parcel/">Parcel</a></li> + <li class="mb-2"><a href="/docs/{{ .Site.Params.docs_version }}/getting-started/vite/">Vite</a></li> </ul> </div> <div class="col-6 col-lg-2 mb-3"> diff --git a/site/layouts/partials/home/masthead-followup.html b/site/layouts/partials/home/masthead-followup.html index 8d4e9796f0..3dc8cb4823 100644 --- a/site/layouts/partials/home/masthead-followup.html +++ b/site/layouts/partials/home/masthead-followup.html @@ -243,10 +243,10 @@ $utilities: map-merge( <p>Why write more JavaScript when you can write HTML? Nearly all of Bootstrap's JavaScript plugins feature a first-class data API, allowing you to use JavaScript just by adding <code>data</code> attributes.</p> <div class="p-4 mb-3 border rounded-3"> <div class="dropdown"> - <button class="btn btn-primary dropdown-toggle" type="button" id="dropdown" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-primary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </button> - <ul class="dropdown-menu" aria-labelledby="dropdown"> + <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Dropdown item</a></li> <li><a class="dropdown-item" href="#">Dropdown item</a></li> <li><a class="dropdown-item" href="#">Dropdown item</a></li> @@ -255,10 +255,10 @@ $utilities: map-merge( </div> {{ highlight (printf `<div class="dropdown"> - <button class="btn btn-primary dropdown-toggle" type="button" id="dropdown" data-bs-toggle="dropdown" aria-expanded="false"> + <button class="btn btn-primary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </button> - <ul class="dropdown-menu" aria-labelledby="dropdown"> + <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Dropdown item</a></li> <li><a class="dropdown-item" href="#">Dropdown item</a></li> <li><a class="dropdown-item" href="#">Dropdown item</a></li> diff --git a/site/layouts/partials/home/masthead.html b/site/layouts/partials/home/masthead.html index ac35d43a3d..6a7356eddd 100644 --- a/site/layouts/partials/home/masthead.html +++ b/site/layouts/partials/home/masthead.html @@ -3,7 +3,7 @@ <div class="col-md-8 mx-auto text-center"> <a class="d-flex flex-column flex-lg-row justify-content-center align-items-center mb-4 text-dark lh-sm text-decoration-none" href="https://blog.getbootstrap.com/2022/05/13/bootstrap-5-2-0-beta/"> <strong class="d-sm-inline-block p-2 me-2 mb-2 mb-lg-0 rounded-3 masthead-notice">New in v5.2</strong> - <span class="text-muted">CSS variables, responsive offcanvas, new utilites, and more!</span> + <span class="text-muted">CSS variables, responsive offcanvas, new utilities, and more!</span> </a> <img src="/docs/{{ .Site.Params.docs_version }}/assets/brand/bootstrap-logo-shadow.png" width="200" height="165" alt="Bootstrap" class="d-block mx-auto mb-3"> <h1 class="mb-3 fw-semibold">Build fast, responsive sites with Bootstrap</h1> diff --git a/site/layouts/partials/js-data-attributes.md b/site/layouts/partials/js-data-attributes.md index c188652f06..e99ff7112c 100644 --- a/site/layouts/partials/js-data-attributes.md +++ b/site/layouts/partials/js-data-attributes.md @@ -1,3 +1,3 @@ -Options can be passed via data attributes or JavaScript. For data attributes, append the option name to `data-bs-`, as in `data-bs-animation=""`. Make sure to change the case type of the option name from camelCase to kebab-case when passing the options via data attributes. For example, use `data-bs-custom-class="beautifier"` instead of `data-bs-customClass="beautifier"`. +As options can be passed via data attributes or JavaScript, you can append an option name to `data-bs-`, as in `data-bs-animation="{value}"`. Make sure to change the case type of the option name from "_camelCase_" to "_kebab-case_" when passing the options via data attributes. For example, use `data-bs-custom-class="beautifier"` instead of `data-bs-customClass="beautifier"`. As of Bootstrap 5.2.0, all components support an **experimental** reserved data attribute `data-bs-config` that can house simple component configuration as a JSON string. When an element has `data-bs-config='{"delay":0, "title":123}'` and `data-bs-title="456"` attributes, the final `title` value will be `456` and the separate data attributes will override values given on `data-bs-config`. In addition, existing data attributes are able to house JSON values like `data-bs-delay='{"show":0,"hide":150}'`. diff --git a/site/layouts/partials/scripts.html b/site/layouts/partials/scripts.html index 56513c7ff8..3378a230e9 100644 --- a/site/layouts/partials/scripts.html +++ b/site/layouts/partials/scripts.html @@ -26,36 +26,43 @@ document.querySelectorAll('.btn-edit').forEach(btn => { btn.addEventListener('click', event => { const htmlSnippet = event.target.closest('.bd-code-snippet').querySelector('.bd-example').innerHTML - StackBlitzSDK.openBootstrapSnippet(htmlSnippet) + + // Get extra classes for this example + const classes = Array.from(event.target.closest('.bd-code-snippet').querySelector('.bd-example').classList).join(' ') + + const jsSnippet = event.target.closest('.bd-code-snippet').querySelector('.btn-edit').getAttribute('data-sb-js-snippet') + StackBlitzSDK.openBootstrapSnippet(htmlSnippet, jsSnippet, classes) }) }) - StackBlitzSDK.openBootstrapSnippet = snippet => { + StackBlitzSDK.openBootstrapSnippet = (htmlSnippet, jsSnippet, classes) => { const markup = `<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="{{ .Site.Params.cdn.css }}" rel="stylesheet"> + <link href="https://getbootstrap.com/docs/{{ .Site.Params.docs_version }}/assets/css/docs.css" rel="stylesheet"> <title>Bootstrap Example</title> + <${'script'} src="{{ .Site.Params.cdn.js_bundle }}"></${'script'}> </head> - <body> + <body class="p-3 m-0 border-0 ${classes}"> <!-- Example Code --> -${snippet.replace(/^/gm, ' ')} +${htmlSnippet.replace(/^/gm, ' ')} <!-- End Example Code --> - - <${'script'} src="{{ .Site.Params.cdn.js_bundle }}"></${'script'}> </body> </html>` + const jsSnippetContent = jsSnippet ? '{{ os.ReadFile "site/assets/js/snippets.js" }}' : null const project = { files: { - 'index.html': markup + 'index.html': markup, + 'index.js': jsSnippetContent }, title: 'Bootstrap Example', description: `Official example from ${window.location.href}`, - template: 'html', + template: jsSnippet ? 'javascript' : 'html', tags: ['bootstrap'] } diff --git a/site/layouts/shortcodes/example.html b/site/layouts/shortcodes/example.html index 9bfa2c906c..3cbbd9fca9 100644 --- a/site/layouts/shortcodes/example.html +++ b/site/layouts/shortcodes/example.html @@ -4,15 +4,18 @@ `args` are all optional and can be one of the following: * id: the `div`'s id - default: "" * class: any extra class(es) to be added to the `div` - default: "" - * show_preview: if the preview should be output in the HTML - default: `true` + * lang: language used to display the code - default: "html" * show_markup: if the markup should be output in the HTML - default: `true` + * show_preview: if the preview should be output in the HTML - default: `true` + * stackblitz_add_js: if extra JS snippet shoud le added to StackBlitz - default: `false` */ -}} {{- $id := .Get "id" -}} {{- $class := .Get "class" -}} {{- $lang := .Get "lang" | default "html" -}} -{{- $show_preview := .Get "show_preview" | default true -}} +{{- $stackblitz_add_js := .Get "stackblitz_add_js" | default false -}} {{- $show_markup := .Get "show_markup" | default true -}} +{{- $show_preview := .Get "show_preview" | default true -}} {{- $input := .Inner -}} <div class="bd-example-snippet bd-code-snippet"> @@ -27,7 +30,7 @@ <div class="d-flex align-items-center highlight-toolbar bg-light ps-3 pe-2 py-1"> <small class="font-monospace text-muted text-uppercase">{{- $lang -}}</small> <div class="d-flex ms-auto"> - <button type="button" class="btn-edit text-nowrap" title="Try it on StackBlitz"> + <button type="button" class="btn-edit text-nowrap"{{ with $stackblitz_add_js }} data-sb-js-snippet="{{ $stackblitz_add_js }}"{{ end }} title="Try it on StackBlitz"> <svg class="bi" role="img" aria-label="Try it"><use xlink:href="#lightning-charge-fill"/></svg> </button> <button type="button" class="btn-clipboard mt-0 me-0" title="Copy to clipboard"> diff --git a/site/static/docs/5.2/assets/img/guides/bootstrap-vite.png b/site/static/docs/5.2/assets/img/guides/bootstrap-vite.png Binary files differnew file mode 100644 index 0000000000..a290110e7d --- /dev/null +++ b/site/static/docs/5.2/assets/img/guides/bootstrap-vite.png diff --git a/site/static/docs/5.2/assets/img/guides/bootstrap-vite@2x.png b/site/static/docs/5.2/assets/img/guides/bootstrap-vite@2x.png Binary files differnew file mode 100644 index 0000000000..5fe40c526d --- /dev/null +++ b/site/static/docs/5.2/assets/img/guides/bootstrap-vite@2x.png diff --git a/site/static/docs/5.2/assets/img/guides/vite-dev-server-bootstrap.png b/site/static/docs/5.2/assets/img/guides/vite-dev-server-bootstrap.png Binary files differnew file mode 100644 index 0000000000..0c3741bd6d --- /dev/null +++ b/site/static/docs/5.2/assets/img/guides/vite-dev-server-bootstrap.png diff --git a/site/static/docs/5.2/assets/img/guides/vite-dev-server.png b/site/static/docs/5.2/assets/img/guides/vite-dev-server.png Binary files differnew file mode 100644 index 0000000000..e29729c23c --- /dev/null +++ b/site/static/docs/5.2/assets/img/guides/vite-dev-server.png |