Private or compiled

Plugins can be included individually (using Bootstrap'southward private *.js files), or all at once (using bootstrap.js or the minified bootstrap.min.js).

Using the compiled JavaScript

Both bootstrap.js and bootstrap.min.js contain all plugins in a single file. Include merely one.

Plugin dependencies

Some plugins and CSS components depend on other plugins. If you lot include plugins individually, brand certain to check for these dependencies in the docs. Also note that all plugins depend on jQuery (this means jQuery must be included earlier the plugin files). Consult our bower.json to see which versions of jQuery are supported.

Data attributes

You can apply all Bootstrap plugins purely through the markup API without writing a unmarried line of JavaScript. This is Bootstrap's excellent API and should exist your starting time consideration when using a plugin.

That said, in some situations it may be desirable to plough this functionality off. Therefore, we also provide the ability to disable the data attribute API by unbinding all events on the document namespaced with data-api. This looks like this:

                              $                (                certificate                ).                off                (                '.data-api'                )                          

Alternatively, to target a specific plugin, just include the plugin's name as a namespace along with the data-api namespace like this:

                              $                (                document                ).                off                (                '.alert.data-api'                )                          

Only one plugin per element via information attributes

Don't use data attributes from multiple plugins on the same element. For example, a button cannot both have a tooltip and toggle a modal. To accomplish this, apply a wrapping element.

Programmatic API

We as well believe you should exist able to use all Bootstrap plugins purely through the JavaScript API. All public APIs are unmarried, chainable methods, and return the drove acted upon.

                              $                (                '.btn.danger'                ).                button                (                'toggle'                ).                addClass                (                'fat'                )                          

All methods should accept an optional options object, a string which targets a particular method, or nothing (which initiates a plugin with default behavior):

                              $                (                '#myModal'                ).                modal                ()                // initialized with defaults                $                (                '#myModal'                ).                modal                ({                keyboard                :                false                })                // initialized with no keyboard                $                (                '#myModal'                ).                modal                (                'evidence'                )                // initializes and invokes evidence immediately                          

Each plugin also exposes its raw constructor on a Constructor property: $.fn.popover.Constructor. If you'd like to get a particular plugin instance, retrieve it directly from an chemical element: $('[rel="popover"]').information('popover').

Default settings

You tin alter the default settings for a plugin by modifying the plugin's Constructor.DEFAULTS object:

                              $                .                fn                .                modal                .                Constructor                .                DEFAULTS                .                keyboard                =                false                // changes default for the modal plugin's `keyboard` option to simulated                          

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 yous wish to revert the value of.

                              var                bootstrapButton                =                $                .                fn                .                button                .                noConflict                ()                // return $.fn.button to previously assigned value                $                .                fn                .                bootstrapBtn                =                bootstrapButton                // give $().bootstrapBtn the Bootstrap functionality                          

Events

Bootstrap provides custom events for about plugins' unique deportment. Generally, these come in an infinitive and past participle form - where the infinitive (ex. show) is triggered at the showtime of an consequence, and its past participle form (ex. shown) is triggered on the completion of an activeness.

Equally of 3.0.0, all Bootstrap events are namespaced.

All infinitive events provide preventDefault functionality. This provides the power to stop the execution of an activity before it starts.

                              $                (                '#myModal'                ).                on                (                'show.bs.modal'                ,                function                (                eastward                )                {                if                (                !                data                )                return                eastward                .                preventDefault                ()                // stops modal from beingness shown                })                          

Version numbers

The version of each of Bootstrap's jQuery plugins tin can be accessed via the VERSION property of the plugin'southward constructor. For example, for the tooltip plugin:

                              $                .                fn                .                tooltip                .                Constructor                .                VERSION                // => "three.3.7"                          

No special fallbacks when JavaScript is disabled

Bootstrap'southward plugins don't fall dorsum particularly gracefully when JavaScript is disabled. If you care well-nigh the user experience in this example, utilize <noscript> to explain the state of affairs (and how to re-enable JavaScript) to your users, and/or add your own custom fallbacks.

Third-party libraries

Bootstrap does not officially support third-party JavaScript libraries like Prototype or jQuery UI. Despite .noConflict and namespaced events, in that location may be compatibility bug that you need to set up on your ain.

About transitions

For simple transition effects, include transition.js one time alongside the other JS files. If you're using the compiled (or minified) bootstrap.js, there is no need to include this—it'south already there.

What's within

Transition.js is a basic helper for transitionEnd events as well equally a CSS transition emulator. It'due south used by the other plugins to cheque for CSS transition support and to catch hanging transitions.

Disabling transitions

Transitions can be globally disabled using the following JavaScript snippet, which must come after transition.js (or bootstrap.js or bootstrap.min.js, as the case may be) has loaded:

                              $                .                back up                .                transition                =                false                          

Modals are streamlined, but flexible, dialog prompts with the minimum required functionality and smart defaults.

Multiple open modals not supported

Be sure not to open a modal while another is still visible. Showing more than ane modal at a time requires custom code.

Modal markup placement

Always endeavor to identify a modal's HTML code in a pinnacle-level position in your document to avoid other components affecting the modal's appearance and/or functionality.

Due to how HTML5 defines its semantics, the autofocus HTML attribute has no issue in Bootstrap modals. To attain the same issue, use some custom JavaScript:

                              $                (                '#myModal'                ).                on                (                'shown.bs.modal'                ,                role                ()                {                $                (                '#myInput'                ).                focus                ()                })                          

Examples

Static example

A rendered modal with header, body, and prepare of actions in the footer.

                              <div                grade=                "modal fade"                tabindex=                "-one"                role=                "dialog"                >                <div                grade=                "modal-dialog"                role=                "document"                >                <div                form=                "modal-content"                >                <div                grade=                "modal-header"                >                <button                type=                "button"                grade=                "shut"                data-dismiss=                "modal"                aria-label=                "Close"                ><bridge                aria-subconscious=                "truthful"                >                &times;                </span></button>                <h4                grade=                "modal-championship"                >Modal title</h4>                </div>                <div                class=                "modal-body"                >                <p>One fine body&hellip;                </p>                </div>                <div                course=                "modal-footer"                >                <button                type=                "button"                class=                "btn btn-default"                data-dismiss=                "modal"                >Close</button>                <button                type=                "button"                class=                "btn btn-principal"                >Save changes</push>                </div>                </div>                <!-- /.modal-content -->                </div>                <!-- /.modal-dialog -->                </div>                <!-- /.modal -->                          

Live demo

Toggle a modal via JavaScript past clicking the push button below. It will slide downwardly and fade in from the summit of the page.

                              <!-- Button trigger modal -->                <button                type=                "button"                grade=                "btn btn-principal btn-lg"                data-toggle=                "modal"                data-target=                "#myModal"                >                Launch demo modal                </button>                <!-- Modal -->                <div                class=                "modal fade"                id=                "myModal"                tabindex=                "-1"                office=                "dialog"                aria-labelledby=                "myModalLabel"                >                <div                class=                "modal-dialog"                role=                "document"                >                <div                class=                "modal-content"                >                <div                class=                "modal-header"                >                <push button                type=                "button"                class=                "close"                information-dismiss=                "modal"                aria-label=                "Close"                ><span                aria-subconscious=                "true"                >                &times;                </span></button>                <h4                form=                "modal-title"                id=                "myModalLabel"                >Modal title</h4>                </div>                <div                class=                "modal-body"                >                ...                </div>                <div                class=                "modal-footer"                >                <button                blazon=                "button"                class=                "btn btn-default"                data-dismiss=                "modal"                >Close</button>                <push                type=                "button"                class=                "btn btn-main"                >Save changes</button>                </div>                </div>                </div>                </div>                          

Brand modals accessible

Be sure to add role="dialog" and aria-labelledby="...", referencing the modal title, to .modal, and part="document" to the .modal-dialog itself.

Additionally, you may requite a description of your modal dialog with aria-describedby on .modal.

Embedding YouTube videos

Embedding YouTube videos in modals requires additional JavaScript not in Bootstrap to automatically finish playback and more. See this helpful Stack Overflow postal service for more information.

Optional sizes

Modals have ii optional sizes, bachelor via modifier classes to be placed on a .modal-dialog.

                              <!-- Large modal -->                <button                blazon=                "push"                class=                "btn btn-primary"                data-toggle=                "modal"                information-target=                ".bs-example-modal-lg"                >Large modal</button>                <div                class=                "modal fade bs-instance-modal-lg"                tabindex=                "-ane"                part=                "dialog"                aria-labelledby=                "myLargeModalLabel"                >                <div                form=                "modal-dialog modal-lg"                role=                "document"                >                <div                class=                "modal-content"                >                ...                </div>                </div>                </div>                <!-- Small modal -->                <button                type=                "button"                class=                "btn btn-main"                data-toggle=                "modal"                data-target=                ".bs-example-modal-sm"                >Small modal</button>                <div                class=                "modal fade bs-instance-modal-sm"                tabindex=                "-1"                role=                "dialog"                aria-labelledby=                "mySmallModalLabel"                >                <div                form=                "modal-dialog modal-sm"                function=                "document"                >                <div                class=                "modal-content"                >                ...                </div>                </div>                </div>                          

Remove animation

For modals that but appear rather than fade in to view, remove the .fade grade from your modal markup.

                              <div                class=                "modal"                tabindex=                "-1"                role=                "dialog"                aria-labelledby=                "..."                >                ...                </div>                          

Using the grid organization

To take advantage of the Bootstrap grid system within a modal, merely nest .rows within the .modal-body and then employ the normal grid arrangement classes.

                              <div                class=                "modal fade"                tabindex=                "-i"                part=                "dialog"                aria-labelledby=                "gridSystemModalLabel"                >                <div                course=                "modal-dialog"                role=                "document"                >                <div                class=                "modal-content"                >                <div                class=                "modal-header"                >                <button                blazon=                "push"                class=                "close"                data-dismiss=                "modal"                aria-label=                "Close"                ><bridge                aria-hidden=                "truthful"                >                &times;                </span></button>                <h4                grade=                "modal-title"                id=                "gridSystemModalLabel"                >Modal title</h4>                </div>                <div                grade=                "modal-torso"                >                <div                class=                "row"                >                <div                class=                "col-md-4"                >.col-md-4</div>                <div                class=                "col-md-four col-doctor-offset-4"                >.col-md-four .col-medico-start-four</div>                </div>                <div                class=                "row"                >                <div                form=                "col-md-three col-md-start-3"                >.col-md-iii .col-dr.-offset-three</div>                <div                class=                "col-md-2 col-md-get-go-4"                >.col-md-ii .col-md-showtime-iv</div>                </div>                <div                class=                "row"                >                <div                course=                "col-md-6 col-md-kickoff-3"                >.col-md-6 .col-medico-offset-three</div>                </div>                <div                class=                "row"                >                <div                form=                "col-sm-nine"                >                Level 1: .col-sm-ix                <div                form=                "row"                >                <div                class=                "col-xs-8 col-sm-6"                >                Level two: .col-xs-8 .col-sm-6                </div>                <div                class=                "col-xs-iv col-sm-vi"                >                Level 2: .col-xs-four .col-sm-6                </div>                </div>                </div>                </div>                </div>                <div                class=                "modal-footer"                >                <button                blazon=                "push button"                grade=                "btn btn-default"                information-dismiss=                "modal"                >Close</button>                <push button                type=                "push button"                grade=                "btn btn-primary"                >Save changes</button>                </div>                </div>                <!-- /.modal-content -->                </div>                <!-- /.modal-dialog -->                </div>                <!-- /.modal -->                          

Accept a bunch of buttons that all trigger the same modal, but with slightly different contents? Use event.relatedTarget and HTML information-* attributes (possibly via jQuery) to vary the contents of the modal depending on which button was clicked. Meet the Modal Events docs for details on relatedTarget,

                              <button                type=                "button"                class=                "btn btn-primary"                information-toggle=                "modal"                data-target=                "#exampleModal"                information-whatever=                "@mdo"                >Open modal for @mdo</button>                <button                type=                "button"                course=                "btn btn-primary"                information-toggle=                "modal"                information-target=                "#exampleModal"                data-whatever=                "@fat"                >Open up modal for @fatty</button>                <push button                type=                "push button"                class=                "btn btn-chief"                information-toggle=                "modal"                data-target=                "#exampleModal"                data-whatever=                "@getbootstrap"                >Open up modal for @getbootstrap</button>                ...more than buttons...                <div                class=                "modal fade"                id=                "exampleModal"                tabindex=                "-1"                role=                "dialog"                aria-labelledby=                "exampleModalLabel"                >                <div                class=                "modal-dialog"                role=                "document"                >                <div                class=                "modal-content"                >                <div                course=                "modal-header"                >                <button                type=                "button"                course=                "close"                data-dismiss=                "modal"                aria-label=                "Close"                ><span                aria-subconscious=                "truthful"                >                &times;                </span></button>                <h4                course=                "modal-title"                id=                "exampleModalLabel"                >New message</h4>                </div>                <div                class=                "modal-body"                >                <form>                <div                form=                "course-group"                >                <label                for=                "recipient-name"                class=                "control-characterization"                >Recipient:</label>                <input                blazon=                "text"                class=                "grade-control"                id=                "recipient-proper noun"                >                </div>                <div                form=                "form-group"                >                <label                for=                "message-text"                class=                "command-characterization"                >Message:</label>                <textarea                form=                "class-command"                id=                "message-text"                ></textarea>                </div>                </form>                </div>                <div                grade=                "modal-footer"                >                <button                blazon=                "button"                course=                "btn btn-default"                information-dismiss=                "modal"                >Close</button>                <push button                type=                "push button"                grade=                "btn btn-primary"                >Send bulletin</button>                </div>                </div>                </div>                </div>                          
                              $                (                '#exampleModal'                ).                on                (                'show.bs.modal'                ,                office                (                event                )                {                var                button                =                $                (                event                .                relatedTarget                )                // Button that triggered the modal                var                recipient                =                button                .                data                (                'whatsoever'                )                // Excerpt info from data-* attributes                // If necessary, you could initiate an AJAX request here (and and then do the updating in a callback).                // Update the modal's content. Nosotros'll use jQuery here, but you could use a information bounden library or other methods instead.                var                modal                =                $                (                this                )                modal                .                find                (                '.modal-title'                ).                text                (                'New bulletin to '                +                recipient                )                modal                .                notice                (                '.modal-body input'                ).                val                (                recipient                )                })                          

Usage

The modal plugin toggles your hidden content on demand, via data attributes or JavaScript. Information technology as well adds .modal-open to the <torso> to override default scrolling beliefs and generates a .modal-backdrop to provide a click area for dismissing shown modals when clicking exterior the modal.

Via data attributes

Activate a modal without writing JavaScript. Fix data-toggle="modal" on a controller element, like a push, forth with a data-target="#foo" or href="#foo" to target a specific modal to toggle.

                              <button                type=                "button"                data-toggle=                "modal"                information-target=                "#myModal"                >Launch modal</button>                          

Via JavaScript

Call a modal with id myModal with a single line of JavaScript:

                              $                (                '#myModal'                ).                modal                (                options                )                          

Options

Options tin can be passed via data attributes or JavaScript. For information attributes, append the option name to data-, every bit in data-backdrop="".

Proper name type default description
properties boolean or the string 'static' true Includes a modal-backdrop element. Alternatively, specify static for a properties which doesn't close the modal on click.
keyboard boolean truthful Closes the modal when escape key is pressed
testify boolean true Shows the modal when initialized.
remote path false

This option is deprecated since v3.3.0 and has been removed in v4. Nosotros recommend instead using client-side templating or a information bounden framework, or calling jQuery.load yourself.

If a remote URL is provided, content will be loaded one time via jQuery's load method and injected into the .modal-content div. If you're using the data-api, you may alternatively apply the href attribute to specify the remote source. An example of this is shown below:

                                                  <a                          information-toggle=                          "modal"                          href=                          "remote.html"                          data-target=                          "#modal"                          >Click me</a>                                              

Methods

.modal(options)

Activates your content as a modal. Accepts an optional options object.

                              $                (                '#myModal'                ).                modal                ({                keyboard                :                imitation                })                          

.modal('toggle')

Manually toggles a modal. Returns to the caller earlier the modal has really been shown or hidden (i.east. before the shown.bs.modal or hidden.bs.modal event occurs).

                              $                (                '#myModal'                ).                modal                (                'toggle'                )                          

.modal('bear witness')

Manually opens a modal. Returns to the caller before the modal has really been shown (i.e. earlier the shown.bs.modal event occurs).

                              $                (                '#myModal'                ).                modal                (                'prove'                )                          

.modal('hibernate')

Manually hides a modal. Returns to the caller before the modal has actually been hidden (i.eastward. before the hidden.bs.modal event occurs).

                              $                (                '#myModal'                ).                modal                (                'hibernate'                )                          

.modal('handleUpdate')

Readjusts the modal'southward positioning to counter a scrollbar in example one should announced, which would brand the modal spring to the left.

Only needed when the height of the modal changes while it is open.

                              $                (                '#myModal'                ).                modal                (                'handleUpdate'                )                          

Events

Bootstrap'south modal grade exposes a few events for hooking into modal functionality.

All modal events are fired at the modal itself (i.e. at the <div class="modal">).

Event Type Description
prove.bs.modal This event fires immediately when the bear witness instance method is called. If caused by a click, the clicked chemical element is available as the relatedTarget holding of the upshot.
shown.bs.modal This event is fired when the modal has been made visible to the user (will expect for CSS transitions to complete). If caused by a click, the clicked element is available every bit the relatedTarget property of the event.
hide.bs.modal This event is fired immediately when the hide instance method has been called.
hidden.bs.modal This issue is fired when the modal has finished existence hidden from the user (volition expect for CSS transitions to consummate).
loaded.bs.modal This result is fired when the modal has loaded content using the remote selection.
                              $                (                '#myModal'                ).                on                (                'subconscious.bs.modal'                ,                function                (                e                )                {                // do something...                })                          

Add together dropdown menus to nearly annihilation with this simple plugin, including the navbar, tabs, and pills.

Within a navbar

Inside pills

Via data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) past toggling the .open grade on the parent list item.

On mobile devices, opening a dropdown adds a .dropdown-backdrop equally a tap area for endmost dropdown menus when tapping outside the carte du jour, a requirement for proper iOS support. This means that switching from an open dropdown menu to a unlike dropdown menu requires an extra tap on mobile.

Note: The data-toggle="dropdown" aspect is relied on for endmost dropdown menus at an application level, so information technology's a skillful thought to always apply it.

Via data attributes

Add data-toggle="dropdown" to a link or button to toggle a dropdown.

                              <div                class=                "dropdown"                >                <button                id=                "dLabel"                type=                "button"                information-toggle=                "dropdown"                aria-haspopup=                "truthful"                aria-expanded=                "false"                >                Dropdown trigger                <span                class=                "caret"                ></span>                </button>                <ul                class=                "dropdown-menu"                aria-labelledby=                "dLabel"                >                ...                </ul>                </div>                          

To keep URLs intact with link buttons, use the data-target aspect instead of href="#".

                              <div                class=                "dropdown"                >                <a                id=                "dLabel"                data-target=                "#"                href=                "http://example.com/"                data-toggle=                "dropdown"                function=                "push button"                aria-haspopup=                "true"                aria-expanded=                "false"                >                Dropdown trigger                <span                class=                "caret"                ></span>                </a>                <ul                class=                "dropdown-bill of fare"                aria-labelledby=                "dLabel"                >                ...                </ul>                </div>                          

Via JavaScript

Phone call the dropdowns via JavaScript:

                              $                (                '.dropdown-toggle'                ).                dropdown                ()                          

information-toggle="dropdown" still required

Regardless of whether you call your dropdown via JavaScript or instead use the data-api, data-toggle="dropdown" is always required to exist present on the dropdown's trigger chemical element.

None

$().dropdown('toggle')

Toggles the dropdown menu of a given navbar or tabbed navigation.

All dropdown events are fired at the .dropdown-menu's parent element.

All dropdown events take a relatedTarget property, whose value is the toggling ballast chemical element.

Result Type Description
bear witness.bs.dropdown This event fires immediately when the show instance method is called.
shown.bs.dropdown This event is fired when the dropdown has been made visible to the user (will expect for CSS transitions, to complete).
hide.bs.dropdown This issue is fired immediately when the hide instance method has been called.
hidden.bs.dropdown This issue is fired when the dropdown has finished being subconscious from the user (will wait for CSS transitions, to complete).
                              $                (                '#myDropdown'                ).                on                (                'show.bs.dropdown'                ,                role                ()                {                // do something…                })                          

The ScrollSpy plugin is for automatically updating nav targets based on ringlet position. Gyre the area below the navbar and watch the active class change. The dropdown sub items will be highlighted also.

Requires relative positioning

No matter the implementation method, scrollspy requires the use of position: relative; on the element you're spying on. In most cases this is the <trunk>. When scrollspying on elements other than the <body>, exist sure to have a height set and overflow-y: scroll; applied.

Via information attributes

To hands add together scrollspy behavior to your topbar navigation, add data-spy="gyre" to the chemical element you want to spy on (most typically this would be the <body>). Then add the data-target aspect with the ID or course of the parent element of any Bootstrap .nav component.

                              body                {                position                :                relative                ;                }                          
                              <body                data-spy=                "scroll"                information-target=                "#navbar-case"                >                ...                <div                id=                "navbar-case"                >                <ul                form=                "nav nav-tabs"                role=                "tablist"                >                ...                </ul>                </div>                ...                </trunk>                          

Via JavaScript

Later on calculation position: relative; in your CSS, call the scrollspy via JavaScript:

                              $                (                'body'                ).                scrollspy                ({                target                :                '#navbar-instance'                })                          

Methods

.scrollspy('refresh')

When using scrollspy in conjunction with adding or removing of elements from the DOM, you lot'll need to call the refresh method like and then:

                              $                (                '[data-spy="scroll"]'                ).                each                (                role                ()                {                var                $spy                =                $                (                this                ).                scrollspy                (                'refresh'                )                })                          

Options

Options tin can exist passed via data attributes or JavaScript. For data attributes, append the choice proper name to information-, every bit in data-outset="".

Name blazon default clarification
offset number 10 Pixels to starting time from top when calculating position of scroll.

Events

Event Type Clarification
activate.bs.scrollspy This event fires whenever a new item becomes activated by the scrollspy.
                              $                (                '#myScrollspy'                ).                on                (                'activate.bs.scrollspy'                ,                function                ()                {                // do something…                })                          

Instance tabs

Add quick, dynamic tab functionality to transition through panes of local content, even via dropdown menus. Nested tabs are not supported.

Raw denim y'all probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth main cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.

Food truck fixie locavore, accusamus mcsweeney'due south marfa nulla single-origin java squid. Exercitation +1 labore velit, blog sartorial PBR leggings adjacent level wes anderson artisan four loko farm-to-table craft beer twee. Qui photograph berth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco advertisement vinyl cillum PBR. Human nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.

Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney'due south organic lomo retro fanny pack lo-fi farm-to-tabular array readymade. Messenger purse gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid eight-bit cred pitchfork. Williamsburg banh mi whatsoever gluten-gratuitous, carles pitchfork biodiesel fixie etsy retro mlkshk vice weblog. Scenester cred yous probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.

Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out master cleanse gluten-complimentary squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche loftier life repeat park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi earlier they sold out farm-to-table VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh craft beer marfa ethical. Wolf salvia freegan, sartorial keffiyeh echo park vegan.

Usage

Enable tabbable tabs via JavaScript (each tab needs to be activated individually):

                              $                (                '#myTabs a'                ).                click                (                function                (                due east                )                {                e                .                preventDefault                ()                $                (                this                ).                tab                (                'bear witness'                )                })                          

Y'all can activate individual tabs in several means:

                              $                (                '#myTabs a[href="#profile"]'                ).                tab                (                'show'                )                // Select tab by name                $                (                '#myTabs a:first'                ).                tab                (                'bear witness'                )                // Select first tab                $                (                '#myTabs a:last'                ).                tab                (                'show'                )                // Select concluding tab                $                (                '#myTabs li:eq(2) a'                ).                tab                (                'show'                )                // Select 3rd tab (0-indexed)                          

Markup

Yous can actuate a tab or pill navigation without writing whatever JavaScript by merely specifying data-toggle="tab" or data-toggle="pill" on an chemical element. Adding the nav and nav-tabs classes to the tab ul will use the Bootstrap tab styling, while adding the nav and nav-pills classes will apply pill styling.

                              <div>                <!-- Nav tabs -->                <ul                class=                "nav nav-tabs"                part=                "tablist"                >                <li                office=                "presentation"                grade=                "active"                ><a                href=                "#home"                aria-controls=                "dwelling house"                part=                "tab"                information-toggle=                "tab"                >Home</a></li>                <li                office=                "presentation"                ><a                href=                "#profile"                aria-controls=                "profile"                role=                "tab"                data-toggle=                "tab"                >Profile</a></li>                <li                part=                "presentation"                ><a                href=                "#messages"                aria-controls=                "letters"                role=                "tab"                data-toggle=                "tab"                >Messages</a></li>                <li                function=                "presentation"                ><a                href=                "#settings"                aria-controls=                "settings"                office=                "tab"                data-toggle=                "tab"                >Settings</a></li>                </ul>                <!-- Tab panes -->                <div                class=                "tab-content"                >                <div                role=                "tabpanel"                class=                "tab-pane active"                id=                "dwelling"                >...</div>                <div                office=                "tabpanel"                class=                "tab-pane"                id=                "contour"                >...</div>                <div                function=                "tabpanel"                class=                "tab-pane"                id=                "messages"                >...</div>                <div                role=                "tabpanel"                class=                "tab-pane"                id=                "settings"                >...</div>                </div>                </div>                          

Fade result

To make tabs fade in, add together .fade to each .tab-pane. The outset tab pane must likewise have .in to make the initial content visible.

                              <div                class=                "tab-content"                >                <div                function=                "tabpanel"                class=                "tab-pane fade in active"                id=                "home"                >...</div>                <div                role=                "tabpanel"                class=                "tab-pane fade"                id=                "contour"                >...</div>                <div                office=                "tabpanel"                class=                "tab-pane fade"                id=                "letters"                >...</div>                <div                role=                "tabpanel"                class=                "tab-pane fade"                id=                "settings"                >...</div>                </div>                          

Methods

$().tab

Activates a tab element and content container. Tab should have either a data-target or an href targeting a container node in the DOM. In the above examples, the tabs are the <a>s with data-toggle="tab" attributes.

.tab('show')

Selects the given tab and shows its associated content. Whatever other tab that was previously selected becomes unselected and its associated content is hidden. Returns to the caller before the tab pane has actually been shown (i.e. before the shown.bs.tab event occurs).

                              $                (                '#someTab'                ).                tab                (                'evidence'                )                          

Events

When showing a new tab, the events fire in the following order:

  1. hide.bs.tab (on the electric current active tab)
  2. bear witness.bs.tab (on the to-be-shown tab)
  3. hidden.bs.tab (on the previous active tab, the same 1 as for the hibernate.bs.tab issue)
  4. shown.bs.tab (on the newly-active just-shown tab, the aforementioned 1 as for the prove.bs.tab result)

If no tab was already active, then the hibernate.bs.tab and hidden.bs.tab events volition non exist fired.

Event Type Description
show.bs.tab This effect fires on tab evidence, but before the new tab has been shown. Use consequence.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively.
shown.bs.tab This event fires on tab evidence after a tab has been shown. Use event.target and outcome.relatedTarget to target the active tab and the previous agile tab (if available) respectively.
hibernate.bs.tab This event fires when a new tab is to be shown (and thus the previous active tab is to exist hidden). Employ result.target and event.relatedTarget to target the current active tab and the new soonhoped-for-active tab, respectively.
hidden.bs.tab This issue fires afterward a new tab is shown (and thus the previous active tab is hidden). Apply result.target and outcome.relatedTarget to target the previous agile tab and the new active tab, respectively.
                              $                (                'a[information-toggle="tab"]'                ).                on                (                'shown.bs.tab'                ,                function                (                due east                )                {                e                .                target                // newly activated tab                due east                .                relatedTarget                // previous active tab                })                          

Inspired by the excellent jQuery.tipsy plugin written by Jason Frame; Tooltips are an updated version, which don't rely on images, use CSS3 for animations, and data-attributes for local title storage.

Tooltips with zero-length titles are never displayed.

Hover over the links beneath to run into tooltips:

Tight pants side by side level keffiyeh you lot probably oasis't heard of them. Photo booth beard raw denim letterpress vegan messenger pocketbook stumptown. Farm-to-table seitan, mcsweeney'south fixie sustainable quinoa 8-scrap american apparel have a terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A really ironic artisan whatever keytar, scenester subcontract-to-table banksy Austin twitter handle freegan cred raw denim single-origin coffee viral.

Static tooltip

Four options are bachelor: top, right, lesser, and left aligned.

Four directions

                              <button                type=                "button"                course=                "btn btn-default"                data-toggle=                "tooltip"                data-placement=                "left"                title=                "Tooltip on left"                >Tooltip on left</button>                <button                type=                "button"                grade=                "btn btn-default"                data-toggle=                "tooltip"                information-placement=                "acme"                title=                "Tooltip on top"                >Tooltip on superlative</button>                <button                blazon=                "push"                class=                "btn btn-default"                data-toggle=                "tooltip"                information-placement=                "bottom"                championship=                "Tooltip on bottom"                >Tooltip on bottom</button>                <button                type=                "button"                course=                "btn btn-default"                data-toggle=                "tooltip"                information-placement=                "right"                title=                "Tooltip on right"                >Tooltip on right</button>                          

The tooltip plugin generates content and markup on need, and by default places tooltips later on their trigger element.

Trigger the tooltip via JavaScript:

                              $                (                '#instance'                ).                tooltip                (                options                )                          

Markup

The required markup for a tooltip is simply a data attribute and championship on the HTML chemical element you wish to have a tooltip. The generated markup of a tooltip is rather simple, though it does crave a position (past default, set to top past the plugin).

                              <!-- HTML to write -->                <a                href=                "#"                data-toggle=                "tooltip"                title=                "Some tooltip text!"                >Hover over me</a>                <!-- Generated markup past the plugin -->                <div                form=                "tooltip top"                role=                "tooltip"                >                <div                class=                "tooltip-arrow"                ></div>                <div                class=                "tooltip-inner"                >                Some tooltip text!                </div>                </div>                          

Options

Options can be passed via information attributes or JavaScript. For data attributes, suspend the option name to data-, as in data-animation="".

Proper noun Type Default Clarification
animation boolean true Apply a CSS fade transition to the tooltip
container cord | false false

Appends the tooltip to a specific element. Example: container: 'torso'. This choice is especially useful in that information technology allows you to position the tooltip in the flow of the document well-nigh the triggering element - which volition prevent the tooltip from floating abroad from the triggering chemical element during a window resize.

filibuster number | object 0

Delay showing and hiding the tooltip (ms) - does not employ to manual trigger blazon

If a number is supplied, delay is applied to both hibernate/show

Object construction is: filibuster: { "testify": 500, "hide": 100 }

html boolean false Insert HTML into the tooltip. If false, jQuery'due south text method will be used to insert content into the DOM. Use text if y'all're worried about XSS attacks.
placement cord | function 'superlative'

How to position the tooltip - top | bottom | left | right | motorcar.
When "auto" is specified, it will dynamically reorient the tooltip. For example, if placement is "auto left", the tooltip will display to the left when possible, otherwise it will display correct.

When a part is used to determine the placement, it is chosen with the tooltip DOM node as its first argument and the triggering element DOM node as its second. The this context is prepare to the tooltip case.

selector string false If a selector is provided, tooltip objects will be delegated to the specified targets. In practice, this is used to enable dynamic HTML content to have tooltips added. Run into this and an informative example.
template string '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div course="tooltip-inner"></div></div>'

Base HTML to use when creating the tooltip.

The tooltip's title will be injected into the .tooltip-inner.

.tooltip-pointer will become the tooltip's arrow.

The outermost wrapper chemical element should have the .tooltip class.

title string | office ''

Default championship value if title attribute isn't present.

If a function is given, information technology will be called with its this reference set to the chemical element that the tooltip is attached to.

trigger string 'hover focus' How tooltip is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space. manual cannot be combined with any other trigger.
viewport string | object | role { selector: 'body', padding: 0 }

Keeps the tooltip within the bounds of this chemical element. Example: viewport: '#viewport' or { "selector": "#viewport", "padding": 0 }

If a function is given, it is called with the triggering element DOM node as its simply argument. The this context is gear up to the tooltip example.

Methods

$().tooltip(options)

Attaches a tooltip handler to an element collection.

.tooltip('show')

Reveals an element'due south tooltip. Returns to the caller before the tooltip has actually been shown (i.e. before the shown.bs.tooltip consequence occurs). This is considered a "manual" triggering of the tooltip. Tooltips with zero-length titles are never displayed.

                              $                (                '#element'                ).                tooltip                (                'show'                )                          

.tooltip('hide')

Hides an element'southward tooltip. Returns to the caller before the tooltip has actually been hidden (i.eastward. earlier the subconscious.bs.tooltip upshot occurs). This is considered a "transmission" triggering of the tooltip.

                              $                (                '#element'                ).                tooltip                (                'hide'                )                          

.tooltip('toggle')

Toggles an element'south tooltip. Returns to the caller before the tooltip has really been shown or hidden (i.e. before the shown.bs.tooltip or hidden.bs.tooltip consequence occurs). This is considered a "manual" triggering of the tooltip.

                              $                (                '#element'                ).                tooltip                (                'toggle'                )                          

.tooltip('destroy')

Hides and destroys an element's tooltip. Tooltips that use delegation (which are created using the selector option) cannot be individually destroyed on descendant trigger elements.

                              $                (                '#element'                ).                tooltip                (                'destroy'                )                          

Events

Effect Type Description
show.bs.tooltip This event fires immediately when the bear witness instance method is called.
shown.bs.tooltip This event is fired when the tooltip has been made visible to the user (will wait for CSS transitions to complete).
hide.bs.tooltip This upshot is fired immediately when the hibernate example method has been called.
subconscious.bs.tooltip This event is fired when the tooltip has finished existence hidden from the user (will wait for CSS transitions to consummate).
inserted.bs.tooltip This event is fired subsequently the evidence.bs.tooltip event when the tooltip template has been added to the DOM.
                              $                (                '#myTooltip'                ).                on                (                'subconscious.bs.tooltip'                ,                function                ()                {                // do something…                })                          

Add small overlays of content, similar those on the iPad, to any chemical element for housing secondary information.

Popovers whose both title and content are aught-length are never displayed.

Opt-in functionality

For functioning reasons, the Tooltip and Popover data-apis are opt-in, meaning you must initialize them yourself.

One manner to initialize all popovers on a page would exist to select them by their information-toggle attribute:

                                  $                  (                  part                  ()                  {                  $                  (                  '[data-toggle="popover"]'                  ).                  popover                  ()                  })                              

Popovers in button groups, input groups, and tables require special setting

When using popovers on elements within a .btn-group or an .input-group, or on table-related elements (<td>, <th>, <tr>, <thead>, <tbody>, <tfoot>), you'll have to specify the option container: 'body' (documented beneath) to avoid unwanted side effects (such as the chemical element growing wider and/or losing its rounded corners when the popover is triggered).

Popovers on disabled elements crave wrapper elements

To add together a popover to a disabled or .disabled chemical element, put the chemical element inside of a <div> and utilize the popover to that <div> instead.

Multiple-line links

Sometimes y'all want to add a popover to a hyperlink that wraps multiple lines. The default behavior of the popover plugin is to center it horizontally and vertically. Add white-space: nowrap; to your anchors to avoid this.

Examples

Static popover

Four options are bachelor: summit, right, bottom, and left aligned.

Popover top

Sed posuere consectetur est at lobortis. Aenean european union leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

Popover right

Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

Popover lesser

Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

Popover left

Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

Live demo

                              <push button                type=                "button"                form=                "btn btn-lg btn-danger"                data-toggle=                "popover"                title=                "Popover title"                information-content=                "And here's some amazing content. Information technology's very engaging. Right?"                >Click to toggle popover</button>                          

Four directions

                              <button                type=                "button"                form=                "btn btn-default"                data-container=                "trunk"                information-toggle=                "popover"                data-placement=                "left"                data-content=                "Vivamus sagittis lacus vel augue laoreet rutrum faucibus."                >                Popover on left                </button>                <button                type=                "button"                class=                "btn btn-default"                data-container=                "body"                data-toggle=                "popover"                data-placement=                "top"                data-content=                "Vivamus sagittis lacus vel augue laoreet rutrum faucibus."                >                Popover on pinnacle                </button>                <button                type=                "button"                class=                "btn btn-default"                information-container=                "body"                information-toggle=                "popover"                data-placement=                "bottom"                data-content=                "Vivamus sagittis lacus vel augue laoreet rutrum faucibus."                >                Popover on bottom                </button>                <button                type=                "button"                class=                "btn btn-default"                information-container=                "body"                data-toggle=                "popover"                information-placement=                "right"                information-content=                "Vivamus sagittis lacus vel augue laoreet rutrum faucibus."                >                Popover on correct                </button>                          

Dismiss on next click

Employ the focus trigger to dismiss popovers on the next click that the user makes.

Specific markup required for dismiss-on-next-click

For proper cross-browser and cross-platform beliefs, you must use the <a> tag, not the <button> tag, and you as well must include the office="button" and tabindex attributes.

                              <a                tabindex=                "0"                class=                "btn btn-lg btn-danger"                function=                "button"                data-toggle=                "popover"                information-trigger=                "focus"                title=                "Dismissible popover"                data-content=                "And here's some amazing content. It's very engaging. Right?"                >Dismissible popover</a>                          

Usage

Enable popovers via JavaScript:

                              $                (                '#example'                ).                popover                (                options                )                          

Options

Options tin can exist passed via information attributes or JavaScript. For data attributes, suspend the option name to data-, equally in data-animation="".

Proper name Type Default Description
blitheness boolean true Employ a CSS fade transition to the popover
container string | fake false

Appends the popover to a specific element. Case: container: 'body'. This choice is particularly useful in that information technology allows y'all to position the popover in the flow of the certificate nearly the triggering element - which will preclude the popover from floating abroad from the triggering element during a window resize.

content string | function ''

Default content value if information-content attribute isn't present.

If a role is given, it volition be chosen with its this reference ready to the element that the popover is attached to.

filibuster number | object 0

Filibuster showing and hiding the popover (ms) - does not utilise to manual trigger blazon

If a number is supplied, delay is practical to both hide/bear witness

Object structure is: delay: { "prove": 500, "hide": 100 }

html boolean faux Insert HTML into the popover. If false, jQuery's text method will be used to insert content into the DOM. Employ text if you're worried about XSS attacks.
placement cord | office 'correct'

How to position the popover - tiptop | bottom | left | correct | auto.
When "auto" is specified, it will dynamically reorient the popover. For example, if placement is "machine left", the popover will brandish to the left when possible, otherwise information technology will display right.

When a function is used to decide the placement, information technology is called with the popover DOM node equally its commencement statement and the triggering element DOM node every bit its 2d. The this context is set to the popover instance.

selector cord false If a selector is provided, popover objects will be delegated to the specified targets. In exercise, this is used to enable dynamic HTML content to have popovers added. Run into this and an informative example.
template string '<div class="popover" role="tooltip"><div class="arrow"></div><h3 grade="popover-championship"></h3><div course="popover-content"></div></div>'

Base HTML to employ when creating the popover.

The popover's championship will be injected into the .popover-title.

The popover'southward content volition be injected into the .popover-content.

.arrow will become the popover'southward arrow.

The outermost wrapper element should take the .popover grade.

title string | function ''

Default title value if title aspect isn't nowadays.

If a office is given, it will be chosen with its this reference set to the element that the popover is attached to.

trigger string 'click' How popover is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space. manual cannot exist combined with whatever other trigger.
viewport string | object | function { selector: 'torso', padding: 0 }

Keeps the popover within the bounds of this element. Case: viewport: '#viewport' or { "selector": "#viewport", "padding": 0 }

If a part is given, it is called with the triggering chemical element DOM node equally its simply statement. The this context is set to the popover instance.

Data attributes for individual popovers

Options for individual popovers can alternatively be specified through the utilize of data attributes, as explained higher up.

Methods

$().popover(options)

Initializes popovers for an element drove.

.popover('show')

Reveals an element's popover. Returns to the caller before the popover has actually been shown (i.e. before the shown.bs.popover issue occurs). This is considered a "transmission" triggering of the popover. Popovers whose both title and content are nil-length are never displayed.

                              $                (                '#element'                ).                popover                (                'prove'                )                          

.popover('hide')

Hides an element's popover. Returns to the caller earlier the popover has actually been hidden (i.e. before the hidden.bs.popover event occurs). This is considered a "manual" triggering of the popover.

                              $                (                '#chemical element'                ).                popover                (                'hide'                )                          

.popover('toggle')

Toggles an chemical element'southward popover. Returns to the caller before the popover has actually been shown or hidden (i.e. before the shown.bs.popover or hidden.bs.popover effect occurs). This is considered a "manual" triggering of the popover.

                              $                (                '#element'                ).                popover                (                'toggle'                )                          

.popover('destroy')

Hides and destroys an chemical element's popover. Popovers that use delegation (which are created using the selector option) cannot be individually destroyed on descendant trigger elements.

                              $                (                '#chemical element'                ).                popover                (                'destroy'                )                          

Events

Effect Blazon Description
testify.bs.popover This event fires immediately when the testify case method is called.
shown.bs.popover This effect is fired when the popover has been made visible to the user (will expect for CSS transitions to complete).
hide.bs.popover This event is fired immediately when the hide instance method has been called.
hidden.bs.popover This event is fired when the popover has finished beingness hidden from the user (will wait for CSS transitions to consummate).
inserted.bs.popover This event is fired after the show.bs.popover upshot when the popover template has been added to the DOM.
                              $                (                '#myPopover'                ).                on                (                'hidden.bs.popover'                ,                role                ()                {                // do something…                })                          

Instance alerts

Add together dismiss functionality to all alert letters with this plugin.

When using a .shut push, information technology must be the first child of the .alert-dismissible and no text content may come up earlier it in the markup.

Usage

Just add data-dismiss="alert" to your shut push button to automatically requite an alert close functionality. Endmost an alert removes information technology from the DOM.

                              <button                blazon=                "button"                class=                "shut"                data-dismiss=                "alert"                aria-label=                "Close"                >                <span                aria-hidden=                "true"                >                &times;                </span>                </button>                          

To accept your alerts use animation when closing, make sure they take the .fade and .in classes already applied to them.

Methods

$().alert()

Makes an alert listen for click events on descendant elements which take the data-dismiss="warning" attribute. (Non necessary when using the data-api's motorcar-initialization.)

$().warning('close')

Closes an alarm past removing it from the DOM. If the .fade and .in classes are present on the element, the alert will fade out earlier it is removed.

Events

Bootstrap's alert plugin exposes a few events for hooking into warning functionality.

Event Blazon Description
close.bs.alert This outcome fires immediately when the close case method is chosen.
closed.bs.alert This upshot is fired when the alert has been airtight (will wait for CSS transitions to complete).
                              $                (                '#myAlert'                ).                on                (                'closed.bs.alert'                ,                part                ()                {                // practise something…                })                          

Do more with buttons. Control push states or create groups of buttons for more components like toolbars.

Stateful

Add data-loading-text="Loading..." to utilise a loading land on a button.

This characteristic is deprecated since v3.3.5 and has been removed in v4.

Use whichever land you similar!

For the sake of this demonstration, nosotros are using data-loading-text and $().button('loading'), but that's non the simply country you tin can utilize. See more than on this beneath in the $().button(cord) documentation.

                              <button                blazon=                "button"                id=                "myButton"                data-loading-text=                "Loading..."                class=                "btn btn-primary"                autocomplete=                "off"                >                Loading state                </push button>                <script>                $                (                '#myButton'                ).                on                (                'click'                ,                role                ()                {                var                $btn                =                $                (                this                ).                button                (                'loading'                )                // business organisation logic...                $btn                .                button                (                'reset'                )                })                </script>                          

Single toggle

Add together information-toggle="push" to activate toggling on a single push button.

Pre-toggled buttons need .active and aria-pressed="truthful"

For pre-toggled buttons, yous must add the .active form and the aria-pressed="true" attribute to the button yourself.

                              <button                blazon=                "button"                class=                "btn btn-primary"                data-toggle=                "button"                aria-pressed=                "false"                autocomplete=                "off"                >                Single toggle                </button>                          

Checkbox / Radio

Add data-toggle="buttons" to a .btn-group containing checkbox or radio inputs to enable toggling in their corresponding styles.

Preselected options need .active

For preselected options, y'all must add the .active class to the input's label yourself.

Visual checked country only updated on click

If the checked state of a checkbox button is updated without firing a click result on the push (e.m. via <input blazon="reset"> or via setting the checked property of the input), you will need to toggle the .active form on the input's label yourself.

                              <div                course=                "btn-group"                data-toggle=                "buttons"                >                <label                class=                "btn btn-primary active"                >                <input                type=                "checkbox"                autocomplete=                "off"                checked                >                Checkbox ane (pre-checked)                </label>                <characterization                form=                "btn btn-primary"                >                <input                type=                "checkbox"                autocomplete=                "off"                >                Checkbox 2                </label>                <characterization                class=                "btn btn-primary"                >                <input                type=                "checkbox"                autocomplete=                "off"                >                Checkbox 3                </label>                </div>                          

                              <div                form=                "btn-group"                data-toggle=                "buttons"                >                <label                class=                "btn btn-main active"                >                <input                blazon=                "radio"                proper noun=                "options"                id=                "option1"                autocomplete=                "off"                checked                >                Radio 1 (preselected)                </label>                <label                form=                "btn btn-primary"                >                <input                type=                "radio"                name=                "options"                id=                "option2"                autocomplete=                "off"                >                Radio ii                </label>                <label                grade=                "btn btn-chief"                >                <input                type=                "radio"                proper name=                "options"                id=                "option3"                autocomplete=                "off"                >                Radio three                </label>                </div>                          

Methods

$().button('toggle')

Toggles push state. Gives the button the appearance that it has been activated.

$().push('reset')

Resets button country - swaps text to original text. This method is asynchronous and returns before the resetting has actually completed.

$().button(string)

Swaps text to whatever data defined text land.

                              <push                type=                "button"                id=                "myStateButton"                data-complete-text=                "finished!"                class=                "btn btn-chief"                autocomplete=                "off"                >                ...                </button>                <script>                $                (                '#myStateButton'                ).                on                (                'click'                ,                role                ()                {                $                (                this                ).                button                (                'complete'                )                // push text will exist "finished!"                })                </script>                          

Flexible plugin that utilizes a scattering of classes for easy toggle behavior.

Plugin dependency

Plummet requires the transitions plugin to be included in your version of Bootstrap.

Instance

Click the buttons below to show and hide another element via form changes:

  • .collapse hides content
  • .collapsing is applied during transitions
  • .collapse.in shows content

You lot can use a link with the href attribute, or a button with the data-target attribute. In both cases, the data-toggle="collapse" is required.

Link with href

Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.

                              <a                class=                "btn btn-main"                role=                "push button"                data-toggle=                "collapse"                href=                "#collapseExample"                aria-expanded=                "false"                aria-controls=                "collapseExample"                >                Link with href                </a>                <button                class=                "btn btn-primary"                blazon=                "button"                information-toggle=                "collapse"                information-target=                "#collapseExample"                aria-expanded=                "false"                aria-controls=                "collapseExample"                >                Button with information-target                </button>                <div                class=                "plummet"                id=                "collapseExample"                >                <div                grade=                "well"                >                ...                </div>                </div>                          

Accordion example

Extend the default plummet beliefs to create an squeeze box with the panel component.

Collapsible Group Item #1

Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, not cupidatat skateboard dolor brunch. Nutrient truck quinoa nesciunt laborum eiusmod. Brunch iii wolf moon tempor, sunt aliqua put a bird on information technology squid unmarried-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, arts and crafts beer labore wes anderson cred nesciunt sapiente ea proident. Advertising vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim artful synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.

Collapsible Group Item #2

Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson advertizement squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Nutrient truck quinoa nesciunt laborum eiusmod. Brunch three wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer subcontract-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.

Collapsible Group Item #3

Anim pariatur cliche reprehenderit, enim eiusmod loftier life accusamus terry richardson advert squid. iii wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin java nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Advert vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim artful synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.

                              <div                form=                "console-group"                id=                "piano accordion"                function=                "tablist"                aria-multiselectable=                "true"                >                <div                class=                "panel console-default"                >                <div                class=                "panel-heading"                role=                "tab"                id=                "headingOne"                >                <h4                course=                "panel-title"                >                <a                role=                "push"                data-toggle=                "collapse"                information-parent=                "#accordion"                href=                "#collapseOne"                aria-expanded=                "true"                aria-controls=                "collapseOne"                >                Collapsible Group Item #1                </a>                </h4>                </div>                <div                id=                "collapseOne"                class=                "panel-collapse collapse in"                role=                "tabpanel"                aria-labelledby=                "headingOne"                >                <div                course=                "panel-trunk"                >                Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson advertizement squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch iii wolf moon tempor, sunt aliqua put a bird on it squid single-origin java nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt y'all probably haven't heard of them accusamus labore sustainable VHS.                </div>                </div>                </div>                <div                grade=                "panel panel-default"                >                <div                class=                "console-heading"                role=                "tab"                id=                "headingTwo"                >                <h4                course=                "panel-title"                >                <a                class=                "collapsed"                role=                "button"                data-toggle=                "collapse"                data-parent=                "#squeeze box"                href=                "#collapseTwo"                aria-expanded=                "simulated"                aria-controls=                "collapseTwo"                >                Collapsible Group Item #2                </a>                </h4>                </div>                <div                id=                "collapseTwo"                grade=                "panel-plummet collapse"                role=                "tabpanel"                aria-labelledby=                "headingTwo"                >                <div                class=                "panel-body"                >                Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, not cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Advert vegan excepteur butcher vice lomo. Leggings occaecat arts and crafts beer farm-to-table, raw denim artful synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.                </div>                </div>                </div>                <div                grade=                "panel console-default"                >                <div                class=                "panel-heading"                function=                "tab"                id=                "headingThree"                >                <h4                class=                "panel-title"                >                <a                class=                "collapsed"                role=                "button"                information-toggle=                "plummet"                data-parent=                "#accordion"                href=                "#collapseThree"                aria-expanded=                "false"                aria-controls=                "collapseThree"                >                Collapsible Grouping Particular #iii                </a>                </h4>                </div>                <div                id=                "collapseThree"                class=                "panel-collapse collapse"                role=                "tabpanel"                aria-labelledby=                "headingThree"                >                <div                class=                "panel-body"                >                Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson advert squid. three wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.                </div>                </div>                </div>                </div>                          

It'southward also possible to swap out .panel-bodysouthward with .list-groups.

Collapsible listing grouping

  • Bootply
  • One itmus ac facilin
  • Second eros

Make expand/collapse controls accessible

Be sure to add aria-expanded to the control chemical element. This attribute explicitly defines the electric current land of the collapsible chemical element to screen readers and similar assistive technologies. If the collapsible chemical element is airtight by default, it should take a value of aria-expanded="false". If you lot've set the collapsible chemical element to be open by default using the in class, fix aria-expanded="true" on the control instead. The plugin volition automatically toggle this attribute based on whether or not the collapsible element has been opened or airtight.

Additionally, if your control element is targeting a single collapsible element – i.e. the information-target attribute is pointing to an id selector – you may add an additional aria-controls aspect to the control element, containing the id of the collapsible element. Modern screen readers and similar assistive technologies brand use of this attribute to provide users with additional shortcuts to navigate straight to the collapsible element itself.

Usage

The plummet plugin utilizes a few classes to handle the heavy lifting:

  • .plummet hides the content
  • .collapse.in shows the content
  • .collapsing is added when the transition starts, and removed when it finishes

These classes can be found in component-animations.less.

Via data attributes

Simply add information-toggle="collapse" and a data-target to the element to automatically assign control of a collapsible chemical element. The information-target attribute accepts a CSS selector to employ the collapse to. Be sure to add the form collapse to the collapsible chemical element. If you'd like it to default open, add the additional class in.

To add accordion-like group management to a collapsible control, add the data aspect data-parent="#selector". Refer to the demo to see this in action.

Via JavaScript

Enable manually with:

                              $                (                '.plummet'                ).                collapse                ()                          

Options

Options tin be passed via data attributes or JavaScript. For data attributes, append the selection name to information-, as in information-parent="".

Name type default description
parent selector false If a selector is provided, so all collapsible elements under the specified parent volition be closed when this collapsible item is shown. (like to traditional squeeze box beliefs - this is dependent on the panel form)
toggle boolean truthful Toggles the collapsible chemical element on invocation

Methods

.plummet(options)

Activates your content as a collapsible element. Accepts an optional options object.

                              $                (                '#myCollapsible'                ).                collapse                ({                toggle                :                false                })                          

.collapse('toggle')

Toggles a collapsible element to shown or subconscious. Returns to the caller before the collapsible element has actually been shown or hidden (i.e. before the shown.bs.collapse or hidden.bs.collapse event occurs).

.collapse('show')

Shows a collapsible element. Returns to the caller before the collapsible chemical element has actually been shown (i.e. earlier the shown.bs.collapse result occurs).

.plummet('hide')

Hides a collapsible element. Returns to the caller before the collapsible element has actually been subconscious (i.e. before the subconscious.bs.plummet event occurs).

Events

Bootstrap's collapse class exposes a few events for hooking into collapse functionality.

Event Type Description
show.bs.collapse This event fires immediately when the show instance method is chosen.
shown.bs.collapse This event is fired when a plummet element has been made visible to the user (will await for CSS transitions to complete).
hide.bs.collapse This event is fired immediately when the hide method has been called.
hidden.bs.collapse This event is fired when a collapse element has been hidden from the user (will look for CSS transitions to consummate).
                              $                (                '#myCollapsible'                ).                on                (                'hidden.bs.collapse'                ,                function                ()                {                // do something…                })                          

A slideshow component for cycling through elements, like a carousel. Nested carousels are non supported.

                              <div                id=                "carousel-example-generic"                class=                "carousel slide"                data-ride=                "carousel"                >                <!-- Indicators -->                <ol                class=                "carousel-indicators"                >                <li                information-target=                "#carousel-example-generic"                data-slide-to=                "0"                class=                "active"                ></li>                <li                data-target=                "#carousel-example-generic"                data-slide-to=                "one"                ></li>                <li                data-target=                "#carousel-example-generic"                information-slide-to=                "2"                ></li>                </ol>                <!-- Wrapper for slides -->                <div                form=                "carousel-inner"                office=                "listbox"                >                <div                form=                "item active"                >                <img                src=                "..."                alt=                "..."                >                <div                class=                "carousel-caption"                >                ...                </div>                </div>                <div                class=                "item"                >                <img                src=                "..."                alt=                "..."                >                <div                class=                "carousel-caption"                >                ...                </div>                </div>                ...                </div>                <!-- Controls -->                <a                class=                "left carousel-control"                href=                "#carousel-example-generic"                part=                "button"                information-slide=                "prev"                >                <span                class=                "glyphicon glyphicon-chevron-left"                aria-subconscious=                "true"                ></span>                <span                class=                "sr-only"                >Previous</span>                </a>                <a                form=                "right carousel-control"                href=                "#carousel-example-generic"                role=                "push"                data-slide=                "next"                >                <span                class=                "glyphicon glyphicon-chevron-correct"                aria-hidden=                "truthful"                ></span>                <bridge                form=                "sr-simply"                >Next</span>                </a>                </div>                          

Optional captions

Add together captions to your slides easily with the .carousel-caption element within any .item. Identify only most whatever optional HTML inside there and information technology will exist automatically aligned and formatted.

                              <div                class=                "item"                >                <img                src=                "..."                alt=                "..."                >                <div                class=                "carousel-caption"                >                <h3>...</h3>                <p>...</p>                </div>                </div>                          

Multiple carousels

Carousels require the use of an id on the outermost container (the .carousel) for carousel controls to office properly. When calculation multiple carousels, or when irresolute a carousel's id, exist sure to update the relevant controls.

Via data attributes

Employ data attributes to easily control the position of the carousel. data-slide accepts the keywords prev or next, which alters the slide position relative to its current position. Alternatively, use data-slide-to to pass a raw slide index to the carousel information-slide-to="2", which shifts the slide position to a detail index beginning with 0.

The information-ride="carousel" attribute is used to marking a carousel as animating starting at page load. Information technology cannot be used in combination with (redundant and unnecessary) explicit JavaScript initialization of the aforementioned carousel.

Via JavaScript

Call carousel manually with:

                              $                (                '.carousel'                ).                carousel                ()                          

Options tin can be passed via data attributes or JavaScript. For data attributes, append the selection name to data-, every bit in data-interval="".

Name type default description
interval number 5000 The amount of time to delay between automatically cycling an item. If faux, carousel volition not automatically cycle.
pause string | aught "hover" If prepare to "hover", pauses the cycling of the carousel on mouseenter and resumes the cycling of the carousel on mouseleave. If prepare to cypher, hovering over the carousel won't break it.
wrap boolean true Whether the carousel should cycle continuously or have hard stops.
keyboard boolean true Whether the carousel should react to keyboard events.

.carousel(options)

Initializes the carousel with an optional options object and starts cycling through items.

                              $                (                '.carousel'                ).                carousel                ({                interval                :                2000                })                          

.carousel('cycle')

Cycles through the carousel items from left to correct.

.carousel('interruption')

Stops the carousel from cycling through items.

.carousel(number)

Cycles the carousel to a particular frame (0 based, similar to an array).

.carousel('prev')

Cycles to the previous particular.

.carousel('side by side')

Cycles to the next item.

Bootstrap'south carousel class exposes two events for hooking into carousel functionality.

Both events have the following additional properties:

  • direction: The direction in which the carousel is sliding (either "left" or "correct").
  • relatedTarget: The DOM element that is existence slid into place as the active item.

All carousel events are fired at the carousel itself (i.e. at the <div class="carousel">).

Event Type Description
slide.bs.carousel This event fires immediately when the slide case method is invoked.
slid.bs.carousel This effect is fired when the carousel has completed its slide transition.
                              $                (                '#myCarousel'                ).                on                (                'slide.bs.carousel'                ,                function                ()                {                // do something…                })                          

Example

The affix plugin toggles position: fixed; on and off, emulating the effect constitute with position: gummy;. The subnavigation on the right is a live demo of the affix plugin.


Usage

Use the affix plugin via data attributes or manually with your own JavaScript. In both situations, you must provide CSS for the positioning and width of your affixed content.

Note: Do not use the affix plugin on an element contained in a relatively positioned element, such as a pulled or pushed column, due to a Safari rendering bug.

Positioning via CSS

The affix plugin toggles betwixt three classes, each representing a item state: .affix, .braze-top, and .affix-bottom. You must provide the styles, with the exception of position: fixed; on .braze, for these classes yourself (independent of this plugin) to handle the actual positions.

Hither'southward how the affix plugin works:

  1. To start, the plugin adds .affix-pinnacle to indicate the element is in its top-virtually position. At this point no CSS positioning is required.
  2. Scrolling past the chemical element y'all want affixed should trigger the actual affixing. This is where .braze replaces .braze-superlative and sets position: fixed; (provided past Bootstrap's CSS).
  3. If a lesser offset is defined, scrolling past it should replace .affix with .affix-bottom. Since offsets are optional, setting ane requires you to set the appropriate CSS. In this example, add position: accented; when necessary. The plugin uses the data attribute or JavaScript option to decide where to position the element from there.

Follow the above steps to set your CSS for either of the usage options below.

Via data attributes

To easily add affix beliefs to any element, but add together data-spy="braze" to the element you want to spy on. Use offsets to define when to toggle the pinning of an element.

                              <div                data-spy=                "affix"                data-offset-top=                "60"                data-get-go-bottom=                "200"                >                ...                </div>                          

Via JavaScript

Phone call the affix plugin via JavaScript:

                              $                (                '#myAffix'                ).                affix                ({                get-go                :                {                superlative                :                100                ,                bottom                :                function                ()                {                return                (                this                .                lesser                =                $                (                '.footer'                ).                outerHeight                (                truthful                ))                }                }                })                          

Options

Options tin be passed via data attributes or JavaScript. For data attributes, append the option proper name to information-, as in information-kickoff-top="200".

Name type default description
offset number | part | object 10 Pixels to offset from screen when calculating position of coil. If a single number is provided, the offset volition be applied in both top and lesser directions. To provide a unique, bottom and top first just provide an object start: { top: x } or commencement: { top: ten, lesser: v }. Use a function when you lot demand to dynamically calculate an get-go.
target selector | node | jQuery element the window object Specifies the target chemical element of the affix.

Methods

.affix(options)

Activates your content every bit affixed content. Accepts an optional options object.

                              $                (                '#myAffix'                ).                braze                ({                get-go                :                15                })                          

.braze('checkPosition')

Recalculates the land of the affix based on the dimensions, position, and roll position of the relevant elements. The .braze, .affix-peak, and .braze-bottom classes are added to or removed from the affixed content according to the new country. This method needs to be called whenever the dimensions of the affixed content or the target element are inverse, to ensure correct positioning of the affixed content.

                              $                (                '#myAffix'                ).                affix                (                'checkPosition'                )                          

Events

Bootstrap's affix plugin exposes a few events for hooking into affix functionality.

Event Type Description
affix.bs.affix This effect fires immediately before the element has been affixed.
affixed.bs.affix This event is fired afterward the element has been affixed.
braze-top.bs.affix This upshot fires immediately earlier the element has been affixed-top.
affixed-top.bs.affix This event is fired after the chemical element has been affixed-top.
braze-bottom.bs.braze This event fires immediately before the element has been affixed-lesser.
affixed-bottom.bs.braze This event is fired after the element has been affixed-bottom.