From 48c64127b37be4a692a70cb7b38ed9744163582b Mon Sep 17 00:00:00 2001
From: Thomas Park Some plugins and CSS components depend on other plugins. If you include plugins individually, make sure to check for these dependencies in the docs. Also note that all plugins depend on jQuery (this means jQuery must be included before the plugin files). Some plugins and CSS components depend on other plugins. If you include plugins individually, make sure to check for these dependencies in the docs. Also note that all plugins depend on jQuery (this means jQuery must be included before the plugin files). Consult our Modals are streamlined, but flexible, dialog prompts with the minimum required functionality and smart defaults. Be sure not to open a modal while another is still visible. Showing more than one modal at a time requires custom code. There are some caveats regarding using modals on mobile devices. See our browser support docs for details. A rendered modal with header, body, and set of actions in the footer.
- Be sure to add Be sure to add Additionally, you may give a description of your modal dialog with The modal plugin toggles your hidden content on demand, via data attributes or JavaScript. It also adds Activate a modal without writing JavaScript. Set If a remote URL is provided, content will be loaded via jQuery's If a remote URL is provided, content will be loaded via jQuery's Via data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) by toggling the Add To easily add scrollspy behavior to your topbar navigation, add To easily add scrollspy behavior to your topbar navigation, add This plugin extends the tabbed navigation component to add tabbable areas. Enable tabbable tabs via JavaScript (each tab needs to be activated individually): You can activate a tab or pill navigation without writing any JavaScript by simply specifying You can activate a tab or pill navigation without writing any JavaScript by simply specifying To make tabs fade in, add To make tabs fade in, add Plugin dependencies
- bower.json
to see which versions of jQuery are supported.Data attributes
@@ -104,6 +104,15 @@ $('#myModal').on('show.bs.modal', function (e) {
Examples
Overlapping modals not supported
+ Mobile device caveats
+ Static example
Make modals accessible
- role="dialog"
to your primary modal div. In the example above, div#myModal
.
- Also, the aria-labelledby
attribute references your modal title. In this example, h4#myModalLabel
.
- Finally, aria-hidden="true"
tells assistive technologies to skip DOM elements.
- Additionally, you may give a description of your modal dialog. Use the aria-describedby
attribute in the modal's primary <div>
to point to this description (this is not shown in the above example).
- role="dialog"
to .modal
, aria-labelledby="myModalLabel"
attribute to reference the modal title, and aria-hidden="true"
to tell assistive technologies to skip the modal's DOM elements.aria-describedby
on .modal
.Usage
+ .model-open
to the <body>
to override default scrolling behavior and generates a .modal-backdrop
to provide a click area for dismissing shown modals when clicking outside the modal.Via data attributes
data-toggle="modal"
on a controller element, like a button, along with a data-target="#foo"
or href="#foo"
to target a specific modal to toggle.
@@ -273,10 +283,11 @@ $('#myModal').on('show.bs.modal', function (e) {
backdrop
- boolean
+ boolean or the string
'static'
true
Includes a modal-backdrop element. Alternatively, specify
static
for a backdrop which doesn't close the modal on click.remote
path
false
- load
method and injected into the root of the modal element. If you're using the data api, you may alternatively use the href
attribute to specify the remote source. An example of this is shown below:
@@ -443,6 +454,7 @@ $('#myModal').on('hidden.bs.modal', function () {
load
method and injected into the root of the modal element. If you're using the data-api, you may alternatively use the href
attribute to specify the remote source. An example of this is shown below:Usage
+ .open
class on the parent list item. When opened, the plugin also adds .dropdown-backdrop
as a click area for closing dropdown menus when clicking outside the menu.Via data attributes
data-toggle="dropdown"
to a link or button to toggle a dropdown.Usage
Via data attributes
- data-spy="scroll"
to the element you want to spy on (most typically this would be the <body>
. Then add the data-target
attribute with the ID or class of the parent element of any Bootstrap .nav
component.data-spy="scroll"
to the element you want to spy on (most typically this would be the <body>
). Then add the data-target
attribute with the ID or class of the parent element of any Bootstrap .nav
component.Extends tabbed navigation
+ Usage
Markup
- data-toggle="tab"
or data-toggle="pill"
on an element. Adding the nav
and nav-tabs
classes to the tab ul
will apply the Bootstrap tab styling.data-toggle="tab"
or data-toggle="pill"
on an element. Adding the nav
and nav-tabs
classes to the tab ul
will apply the Bootstrap tab styling, while adding the nav
and nav-pills
classes will apply pill styling..fade
to each .tab-pane
.Fade effect
+ .fade
to each .tab-pane
. The first tab pane must also have .in
to properly fade in initial content.Methods
$().tab
@@ -724,10 +761,10 @@ $('#myTab li:eq(2) a').tab('show') // Select third tab (0-indexed)
For performance reasons, the Tooltip and Popover data-apis are opt-in, meaning you must initialize them yourself.
+When using tooltips on elements within a .btn-group
or an .input-group
, you'll have to specify the option container: 'body'
(documented below) to avoid unwanted side effects (such as the element growing wider and/or losing its rounded corners when the tooltip is triggered).
To add a tooltip to a disabled
or .disabled
element, put the element inside of a <div>
and apply the tooltip to that <div>
instead.
The tooltip plugin generates content and markup on demand, and by default places tooltips after their trigger element.
Trigger the tooltip via JavaScript:
{% highlight js %} $('#example').tooltip(options) +{% endhighlight %} + +The generated markup of a tooltip is rather simple, though it does require a position (by default, set to top
by the plugin).
Popovers require the tooltip plugin to be included in your version of Bootstrap.
+For performance reasons, the Tooltip and Popover data-apis are opt-in, meaning you must initialize them yourself.
+When using popovers on elements within a .btn-group
or an .input-group
, you'll have to specify the option container: 'body'
(documented below) to avoid unwanted side effects (such as the element growing wider and/or losing its rounded corners when the popover is triggered).
To add a popover to a disabled
or .disabled
element, put the element inside of a <div>
and apply the popover to that <div>
instead.
Four options are available: top, right, bottom, and left aligned.
@@ -990,6 +1054,7 @@ $('#myTooltip').on('hidden.bs.tooltip', function () {Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Options for individual popovers can alternatively be specified through the use of data attributes, as explained above.
-For performance reasons, the Tooltip and Popover data-apis are opt in. If you would like to use them just specify a selector option.
-Initializes popovers for an element collection.
@@ -1191,12 +1253,13 @@ $('#myPopover').on('hidden.bs.popover', function () {Change this and that and try again. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.
- Take this action Or do this + +
Enable buttons via JavaScript:
{% highlight js %} -$('.nav-tabs').button() +$('.btn-group').button() {% endhighlight %}The collapse plugin utilizes a few classes to handle the heavy lifting:
+.collapse
hides the content.collapse.in
shows the content.collapsing
is added when the transition starts, and removed when it finishesThese classes can be found in component-animations.less
.
Just add data-toggle="collapse"
and a data-target
to element to automatically assign control of a collapsible element. The data-target
attribute accepts a CSS selector to apply the collapse to. Be sure to add the class collapse
to the collapsible element. If you'd like it to default open, add the additional class in
.
The slideshow below shows a generic plugin and component for cycling through elements like a carousel.