Before getting started with Bootstrap’s modal component, be sure to read the following as our menu options have recently changed. Show
Keep reading for demos and usage guidelines. ExamplesModal componentsBelow is a static modal example (meaning its 7 and 8 have been overridden). Included are the modal header, modal body (required for 9), and modal footer (optional). We ask that you include modal headers with dismiss actions whenever possible, or provide another explicit dismiss action.Modal body text goes here.
Live demoToggle a working modal demo by clicking the button below. It will slide down and fade in from the top of the page. Woohoo, you're reading this text in a modal!
Static backdropWhen backdrop is set to static, the modal will not close when clicking outside it. Click the button below to try it. I will not close if you click outside me. Don't even try to press escape key. Launch static backdrop modal
When modals become too long for the user’s viewport or device, they scroll independent of the page itself. Try the demo below to see what we mean. This is some placeholder content to show the scrolling behavior for modals. Instead of repeating the text the modal, we use an inline style set a minimum height, thereby extending the length of the overall modal and demonstrating the overflow scrolling. When content becomes longer than the height of the viewport, scrolling will move the modal as needed. You can also create a scrollable modal that allows scroll the modal body by adding 0 to 1.This is some placeholder content to show the scrolling behavior for modals. We use repeated line breaks to demonstrate how content can exceed minimum inner height, thereby showing inner scrolling. When content becomes longer than the prefedined max-height of modal, content will be cropped and scrollable within the modal. This content should appear at the bottom after you scroll.
Vertically centeredAdd 2 to 1 to vertically center the modal.This is a vertically centered modal. This is some placeholder content to show a vertically centered modal. We've added some extra copy here to show how vertically centering the modal works when combined with scrollable modals. We also use some repeated line breaks to quickly extend the height of the content, thereby triggering the scrolling. When content becomes longer than the prefedined max-height of modal, content will be cropped and scrollable within the modal. Just like that. Vertically centered modal Vertically centered scrollable modal
Tooltips and popovers can be placed within modals as needed. When modals are closed, any tooltips and popovers within are also automatically dismissed.
Using the gridUtilize the Bootstrap grid system within a modal by nesting 4 within the 5. Then, use the normal grid system classes as you would anywhere else.Level 1: .col-sm-9 Level 2: .col-8 .col-sm-6 Level 2: .col-4 .col-sm-6
Varying modal contentHave a bunch of buttons that all trigger the same modal with slightly different contents? Use 6 and HTML 7 attributes to vary the contents of the modal depending on which button was clicked.Below is a live demo followed by example HTML and JavaScript. For more information, for details on 8.Open modal for @mdo Open modal for @fat Open modal for @getbootstrap
Toggle between modalsToggle between multiple modals with some clever placement of the 9 and 0 attributes. For example, you could toggle a password reset modal from within an already open sign in modal. Please note multiple modals cannot be open at the same time—this method simply toggles between two separate modals.Show a second modal and hide this one with the button below. Hide this modal and show the first with the button below. 0Change animationThe 1 variable determines the transform state of 1 before the modal fade-in animation, the 3 variable determines the transform of 1 at the end of the modal fade-in animation.If you want for example a zoom-in animation, you can set 5.Remove animationFor modals that simply appear rather than fade in to view, remove the 6 class from your modal markup. 1Dynamic heightsIf the height of a modal changes while it is open, you should call 7 to readjust the modal’s position in case a scrollbar appears.AccessibilityBe sure to add 8, referencing the modal title, to 4. Additionally, you may give a description of your modal dialog with 0 on 4. Note that you don’t need to add 2 since we already add it via JavaScript.Embedding YouTube videosEmbedding YouTube videos in modals requires additional JavaScript not in Bootstrap to automatically stop playback and more. See this helpful Stack Overflow post for more information. Optional sizesModals have three optional sizes, available via modifier classes to be placed on a 1. These sizes kick in at certain breakpoints to avoid horizontal scrollbars on narrower viewports.SizeClassModal max-widthSmall 4 5DefaultNone 6Large 7 8Extra large 9 0Our default modal without modifier class constitutes the “medium” size modal. Extra large modal Large modal Small modal 2Fullscreen ModalAnother override is the option to pop up a modal that covers the user viewport, available via modifier classes that are placed on a 1.ClassAvailability 2Always 3Below 4 5Below 6 7Below 8 9Below 0 1Below 2Full screen Full screen below sm Full screen below md Full screen below lg Full screen below xl Full screen below xxl 3SassVariables 4Loopare generated via the 3 map and a loop in 4. 5UsageThe modal plugin toggles your hidden content on demand, via data attributes or JavaScript. It also overrides default scrolling behavior and generates a 5 to provide a click area for dismissing shown modals when clicking outside the modal.Via data attributesActivate a modal without writing JavaScript. Set 6 on a controller element, like a button, along with a 7 or 8 to target a specific modal to toggle. 6Via JavaScriptCreate a modal with a single line of JavaScript: 7OptionsOptions can be passed via data attributes or JavaScript. For data attributes, append the option name to 9, as in 0.NameTypeDefaultDescription 1boolean or the string 2 3Includes a modal-backdrop element. Alternatively, specify 4 for a backdrop which doesn't close the modal on click. 5boolean 3Closes the modal when escape key is pressed 7boolean 3Puts the focus on the modal when initialized.MethodsAsynchronous methods and transitionsAll API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started but before it ends. In addition, a method call on a transitioning component will be ignored. . Passing optionsActivates your content as a modal. Accepts an optional options 9. 8toggleManually toggles a modal. Returns to the caller before the modal has actually been shown or hidden (i.e. before the 0 or 1 event occurs).showManually opens a modal. Returns to the caller before the modal has actually been shown (i.e. before the 0 event occurs).Also, you can pass a DOM element as an argument that can be received in the modal events (as the 8 property). 9hideManually hides a modal. Returns to the caller before the modal has actually been hidden (i.e. before the 1 event occurs).handleUpdateManually readjust the modal’s position if the height of a modal changes while it is open (i.e. in case a scrollbar appears). disposeDestroys an element’s modal. (Removes stored data on the DOM element) getInstanceStatic method which allows you to get the modal instance associated with a DOM element 0getOrCreateInstanceStatic method which allows you to get the modal instance associated with a DOM element, or create a new one in case it wasn’t initialised 1EventsBootstrap’s modal class exposes a few events for hooking into modal functionality. All modal events are fired at the modal itself (i.e. at the |