Individual or compiled

Plugins tin can be included individually (using Bootstrap's individual *.js files), or all at one time (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 only one.

Plugin dependencies

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

Data attributes

You can use all Bootstrap plugins purely through the markup API without writing a single line of JavaScript. This is Bootstrap's kickoff-class API and should be your outset consideration when using a plugin.

That said, in some situations it may exist desirable to turn this functionality off. Therefore, we likewise provide the power to disable the data attribute API past 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'                )                          

Just one plugin per element via information attributes

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

Programmatic API

Nosotros also 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 collection acted upon.

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

All methods should take an optional options object, a cord 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                (                'testify'                )                // initializes and invokes evidence immediately                          

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

Default settings

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

                              $                .                fn                .                modal                .                Constructor                .                DEFAULTS                .                keyboard                =                imitation                // changes default for the modal plugin's `keyboard` selection to imitation                          

No conflict

Sometimes it is necessary to utilize Bootstrap plugins with other UI frameworks. In these circumstances, namespace collisions tin occasionally occur. If this happens, you lot may call .noConflict on the plugin you wish to revert the value of.

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

Events

Bootstrap provides custom events for virtually plugins' unique actions. By and large, these come up in an infinitive and past participle form - where the infinitive (ex. testify) is triggered at the start of an outcome, and its past participle form (ex. shown) is triggered on the completion of an action.

As of 3.0.0, all Bootstrap events are namespaced.

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

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

Version numbers

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

                              $                .                fn                .                tooltip                .                Constructor                .                VERSION                // => "3.3.7"                          

No special fallbacks when JavaScript is disabled

Bootstrap's plugins don't fall back specially gracefully when JavaScript is disabled. If you lot care about the user experience in this case, use <noscript> to explain the state of affairs (and how to re-enable JavaScript) to your users, and/or add your ain custom fallbacks.

Third-party libraries

Bootstrap does not officially support tertiary-party JavaScript libraries like Prototype or jQuery UI. Despite .noConflict and namespaced events, there may exist compatibility issues that you need to fix on your ain.

About transitions

For elementary transition effects, include transition.js once 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 in that location.

What's inside

Transition.js is a basic helper for transitionEnd events as well as a CSS transition emulator. It's used by the other plugins to check 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:

                              $                .                support                .                transition                =                false                          

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

Multiple open modals not supported

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

Modal markup placement

Ever try to place a modal'southward HTML code in a superlative-level position in your certificate to avert other components affecting the modal's appearance and/or functionality.

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

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

Examples

Static example

A rendered modal with header, torso, and fix of actions in the footer.

                              <div                class=                "modal fade"                tabindex=                "-ane"                role=                "dialog"                >                <div                form=                "modal-dialog"                role=                "certificate"                >                <div                class=                "modal-content"                >                <div                class=                "modal-header"                >                <button                blazon=                "button"                class=                "shut"                data-dismiss=                "modal"                aria-label=                "Close"                ><span                aria-hidden=                "true"                >                &times;                </span></push button>                <h4                course=                "modal-title"                >Modal title</h4>                </div>                <div                class=                "modal-body"                >                <p>One fine body&hellip;                </p>                </div>                <div                course=                "modal-footer"                >                <button                type=                "button"                form=                "btn btn-default"                data-dismiss=                "modal"                >Shut</button>                <push                type=                "push button"                class=                "btn btn-principal"                >Relieve changes</push>                </div>                </div>                <!-- /.modal-content -->                </div>                <!-- /.modal-dialog -->                </div>                <!-- /.modal -->                          

Live demo

Toggle a modal via JavaScript by clicking the button beneath. Information technology will slide downwardly and fade in from the pinnacle of the folio.

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

Make modals attainable

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

Additionally, you may give 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 cease playback and more than. Meet this helpful Stack Overflow post for more information.

Optional sizes

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

                              <!-- Big modal -->                <button                type=                "button"                class=                "btn btn-primary"                data-toggle=                "modal"                data-target=                ".bs-example-modal-lg"                >Big modal</button>                <div                class=                "modal fade bs-example-modal-lg"                tabindex=                "-i"                role=                "dialog"                aria-labelledby=                "myLargeModalLabel"                >                <div                class=                "modal-dialog modal-lg"                role=                "document"                >                <div                class=                "modal-content"                >                ...                </div>                </div>                </div>                <!-- Small modal -->                <button                type=                "button"                class=                "btn btn-primary"                data-toggle=                "modal"                data-target=                ".bs-example-modal-sm"                >Small modal</push button>                <div                class=                "modal fade bs-instance-modal-sm"                tabindex=                "-1"                part=                "dialog"                aria-labelledby=                "mySmallModalLabel"                >                <div                grade=                "modal-dialog modal-sm"                function=                "certificate"                >                <div                class=                "modal-content"                >                ...                </div>                </div>                </div>                          

Remove animation

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

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

Using the grid organisation

To accept advantage of the Bootstrap filigree system within a modal, just nest .rows inside the .modal-torso and so employ the normal filigree system classes.

                              <div                class=                "modal fade"                tabindex=                "-1"                role=                "dialog"                aria-labelledby=                "gridSystemModalLabel"                >                <div                class=                "modal-dialog"                function=                "certificate"                >                <div                class=                "modal-content"                >                <div                class=                "modal-header"                >                <button                type=                "push"                class=                "close"                data-dismiss=                "modal"                aria-characterization=                "Close"                ><span                aria-hidden=                "true"                >                &times;                </span></button>                <h4                class=                "modal-title"                id=                "gridSystemModalLabel"                >Modal championship</h4>                </div>                <div                class=                "modal-torso"                >                <div                class=                "row"                >                <div                course=                "col-md-iv"                >.col-md-4</div>                <div                class=                "col-md-4 col-md-offset-4"                >.col-md-4 .col-md-get-go-4</div>                </div>                <div                class=                "row"                >                <div                class=                "col-md-3 col-md-starting time-iii"                >.col-dr.-3 .col-md-commencement-iii</div>                <div                form=                "col-doc-two col-md-offset-4"                >.col-physician-2 .col-md-offset-4</div>                </div>                <div                class=                "row"                >                <div                course=                "col-physician-6 col-md-get-go-iii"                >.col-md-6 .col-md-offset-three</div>                </div>                <div                class=                "row"                >                <div                form=                "col-sm-ix"                >                Level 1: .col-sm-nine                <div                course=                "row"                >                <div                class=                "col-xs-8 col-sm-6"                >                Level two: .col-xs-8 .col-sm-6                </div>                <div                class=                "col-xs-4 col-sm-vi"                >                Level 2: .col-xs-4 .col-sm-6                </div>                </div>                </div>                </div>                </div>                <div                course=                "modal-footer"                >                <button                type=                "button"                class=                "btn btn-default"                information-dismiss=                "modal"                >Close</button>                <push button                type=                "button"                class=                "btn btn-primary"                >Relieve changes</button>                </div>                </div>                <!-- /.modal-content -->                </div>                <!-- /.modal-dialog -->                </div>                <!-- /.modal -->                          

Have a bunch of buttons that all trigger the aforementioned modal, just with slightly unlike contents? Use consequence.relatedTarget and HTML data-* attributes (maybe via jQuery) to vary the contents of the modal depending on which push button was clicked. See the Modal Events docs for details on relatedTarget,

                              <button                blazon=                "button"                class=                "btn btn-principal"                information-toggle=                "modal"                data-target=                "#exampleModal"                information-any=                "@mdo"                >Open modal for @mdo</push>                <button                type=                "button"                grade=                "btn btn-primary"                data-toggle=                "modal"                data-target=                "#exampleModal"                data-whatever=                "@fat"                >Open modal for @fat</button>                <push                type=                "push"                class=                "btn btn-chief"                data-toggle=                "modal"                data-target=                "#exampleModal"                information-whatever=                "@getbootstrap"                >Open modal for @getbootstrap</button>                ...more buttons...                <div                course=                "modal fade"                id=                "exampleModal"                tabindex=                "-i"                role=                "dialog"                aria-labelledby=                "exampleModalLabel"                >                <div                class=                "modal-dialog"                role=                "document"                >                <div                class=                "modal-content"                >                <div                course=                "modal-header"                >                <push                blazon=                "push button"                grade=                "close"                information-dismiss=                "modal"                aria-characterization=                "Shut"                ><span                aria-hidden=                "true"                >                &times;                </span></button>                <h4                class=                "modal-title"                id=                "exampleModalLabel"                >New message</h4>                </div>                <div                class=                "modal-trunk"                >                <form>                <div                course=                "form-group"                >                <characterization                for=                "recipient-proper noun"                class=                "control-label"                >Recipient:</label>                <input                type=                "text"                class=                "form-command"                id=                "recipient-name"                >                </div>                <div                class=                "form-group"                >                <label                for=                "message-text"                class=                "control-label"                >Message:</label>                <textarea                form=                "form-control"                id=                "message-text"                ></textarea>                </div>                </course>                </div>                <div                course=                "modal-footer"                >                <push                type=                "button"                class=                "btn btn-default"                data-dismiss=                "modal"                >Close</push>                <push button                blazon=                "button"                class=                "btn btn-principal"                >Send message</push button>                </div>                </div>                </div>                </div>                          
                              $                (                '#exampleModal'                ).                on                (                'testify.bs.modal'                ,                function                (                event                )                {                var                button                =                $                (                event                .                relatedTarget                )                // Button that triggered the modal                var                recipient                =                button                .                information                (                'whatever'                )                // Extract info from data-* attributes                // If necessary, you could initiate an AJAX request here (and and then practice the updating in a callback).                // Update the modal'south content. Nosotros'll utilize jQuery here, only you could employ a information binding library or other methods instead.                var                modal                =                $                (                this                )                modal                .                find                (                '.modal-title'                ).                text                (                'New message to '                +                recipient                )                modal                .                observe                (                '.modal-body input'                ).                val                (                recipient                )                })                          

Usage

The modal plugin toggles your hidden content on demand, via information attributes or JavaScript. It also 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 outside the modal.

Via data attributes

Activate a modal without writing JavaScript. Set up data-toggle="modal" on a controller chemical element, like a push button, along with a data-target="#foo" or href="#foo" to target a specific modal to toggle.

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

Via JavaScript

Phone call a modal with id myModal with a unmarried line of JavaScript:

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

Options

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

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

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

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

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

Methods

.modal(options)

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

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

.modal('toggle')

Manually toggles a modal. Returns to the caller before the modal has actually been shown or hidden (i.e. before the shown.bs.modal or subconscious.bs.modal effect occurs).

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

.modal('show')

Manually opens a modal. Returns to the caller before the modal has actually been shown (i.due east. before 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.e. before the hidden.bs.modal event occurs).

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

.modal('handleUpdate')

Readjusts the modal's positioning to counter a scrollbar in example 1 should announced, which would make the modal jump to the left.

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

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

Events

Bootstrap's modal course exposes a few events for hooking into modal functionality.

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

Event Type Description
show.bs.modal This result fires immediately when the testify instance method is called. If caused by a click, the clicked element is available as the relatedTarget belongings of the issue.
shown.bs.modal This event is fired when the modal has been made visible to the user (will look for CSS transitions to complete). If caused by a click, the clicked element is available as the relatedTarget belongings of the event.
hibernate.bs.modal This event is fired immediately when the hide example method has been called.
hidden.bs.modal This event is fired when the modal has finished beingness hidden from the user (volition expect for CSS transitions to complete).
loaded.bs.modal This event is fired when the modal has loaded content using the remote option.
                              $                (                '#myModal'                ).                on                (                'hidden.bs.modal'                ,                function                (                e                )                {                // practise something...                })                          

Add dropdown menus to near anything with this elementary plugin, including the navbar, tabs, and pills.

Within a navbar

Within pills

Via data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) past toggling the .open class on the parent listing particular.

On mobile devices, opening a dropdown adds a .dropdown-properties equally a tap area for closing dropdown menus when borer outside the carte, a requirement for proper iOS back up. This means that switching from an open dropdown menu to a different dropdown menu requires an extra tap on mobile.

Note: The data-toggle="dropdown" attribute is relied on for closing dropdown menus at an application level, then it'south a good idea to e'er use it.

Via data attributes

Add information-toggle="dropdown" to a link or push to toggle a dropdown.

                              <div                class=                "dropdown"                >                <push                id=                "dLabel"                type=                "push button"                data-toggle=                "dropdown"                aria-haspopup=                "true"                aria-expanded=                "simulated"                >                Dropdown trigger                <span                grade=                "caret"                ></span>                </button>                <ul                class=                "dropdown-menu"                aria-labelledby=                "dLabel"                >                ...                </ul>                </div>                          

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

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

Via JavaScript

Call the dropdowns via JavaScript:

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

information-toggle="dropdown" even so required

Regardless of whether you phone call your dropdown via JavaScript or instead use the information-api, data-toggle="dropdown" is always required to be nowadays on the dropdown'south 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-bill of fare's parent element.

All dropdown events have a relatedTarget property, whose value is the toggling anchor element.

Consequence Blazon Description
prove.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 wait for CSS transitions, to complete).
hide.bs.dropdown This consequence is fired immediately when the hide instance method has been called.
hidden.bs.dropdown This upshot is fired when the dropdown has finished beingness hidden from the user (will wait for CSS transitions, to complete).
                              $                (                '#myDropdown'                ).                on                (                'testify.bs.dropdown'                ,                function                ()                {                // do something…                })                          

The ScrollSpy plugin is for automatically updating nav targets based on coil position. Curlicue the area beneath the navbar and lookout the active class modify. The dropdown sub items volition be highlighted equally well.

Requires relative positioning

No matter the implementation method, scrollspy requires the utilise of position: relative; on the element you're spying on. In most cases this is the <trunk>. When scrollspying on elements other than the <torso>, be sure to have a acme set up and overflow-y: scroll; practical.

Via data attributes

To easily add scrollspy behavior to your topbar navigation, add data-spy="scroll" to the chemical element yous want to spy on (most typically this would be the <torso>). And so add the data-target aspect with the ID or grade of the parent element of any Bootstrap .nav component.

                              body                {                position                :                relative                ;                }                          
                              <torso                data-spy=                "curlicue"                data-target=                "#navbar-example"                >                ...                <div                id=                "navbar-instance"                >                <ul                class=                "nav nav-tabs"                role=                "tablist"                >                ...                </ul>                </div>                ...                </body>                          

Via JavaScript

After adding position: relative; in your CSS, call the scrollspy via JavaScript:

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

Methods

.scrollspy('refresh')

When using scrollspy in conjunction with adding or removing of elements from the DOM, yous'll need to telephone call the refresh method like so:

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

Options

Options tin exist passed via data attributes or JavaScript. For information attributes, append the option proper name to data-, equally in data-offset="".

Name type default description
offset number x Pixels to get-go from pinnacle when calculating position of curlicue.

Events

Issue Type Description
actuate.bs.scrollspy This event fires whenever a new item becomes activated by the scrollspy.
                              $                (                '#myScrollspy'                ).                on                (                'actuate.bs.scrollspy'                ,                part                ()                {                // do something…                })                          

Instance tabs

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

Raw denim you 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's marfa nulla single-origin coffee squid. Exercitation +i labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-tabular array craft beer twee. Qui photo berth letterpress, commodo enim arts and crafts beer mlkshk aliquip jean shorts ullamco advertizement vinyl cillum PBR. Human being nostrud organic, assumenda labore artful magna delectus mollit. Keytar helvetica VHS salvia twelvemonth, 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. Fine art political 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's 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 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-gratis, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably oasis't heard of them, vinyl arts and crafts beer web log stumptown. Pitchfork sustainable tofu synth chambray yr.

Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out primary cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out farm-to-table VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh arts and crafts 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                (                e                )                {                e                .                preventDefault                ()                $                (                this                ).                tab                (                'testify'                )                })                          

Y'all tin activate individual tabs in several means:

                              $                (                '#myTabs a[href="#profile"]'                ).                tab                (                'evidence'                )                // Select tab by proper name                $                (                '#myTabs a:first'                ).                tab                (                'testify'                )                // Select first tab                $                (                '#myTabs a:final'                ).                tab                (                'evidence'                )                // Select last tab                $                (                '#myTabs li:eq(2) a'                ).                tab                (                'bear witness'                )                // Select third tab (0-indexed)                          

Markup

Yous tin activate a tab or pill navigation without writing any JavaScript by but specifying data-toggle="tab" or data-toggle="pill" on an element. Adding the nav and nav-tabs classes to the tab ul volition apply the Bootstrap tab styling, while adding the nav and nav-pills classes will use pill styling.

                              <div>                <!-- Nav tabs -->                <ul                class=                "nav nav-tabs"                role=                "tablist"                >                <li                role=                "presentation"                class=                "active"                ><a                href=                "#home"                aria-controls=                "home"                role=                "tab"                data-toggle=                "tab"                >Home</a></li>                <li                role=                "presentation"                ><a                href=                "#profile"                aria-controls=                "contour"                function=                "tab"                data-toggle=                "tab"                >Profile</a></li>                <li                role=                "presentation"                ><a                href=                "#messages"                aria-controls=                "messages"                role=                "tab"                data-toggle=                "tab"                >Messages</a></li>                <li                role=                "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 agile"                id=                "home"                >...</div>                <div                function=                "tabpanel"                class=                "tab-pane"                id=                "profile"                >...</div>                <div                role=                "tabpanel"                course=                "tab-pane"                id=                "messages"                >...</div>                <div                role=                "tabpanel"                class=                "tab-pane"                id=                "settings"                >...</div>                </div>                </div>                          

Fade issue

To brand tabs fade in, add together .fade to each .tab-pane. The starting time tab pane must too have .in to brand the initial content visible.

                              <div                class=                "tab-content"                >                <div                role=                "tabpanel"                course=                "tab-pane fade in agile"                id=                "home"                >...</div>                <div                role=                "tabpanel"                class=                "tab-pane fade"                id=                "profile"                >...</div>                <div                role=                "tabpanel"                class=                "tab-pane fade"                id=                "messages"                >...</div>                <div                office=                "tabpanel"                class=                "tab-pane fade"                id=                "settings"                >...</div>                </div>                          

Methods

$().tab

Activates a tab element and content container. Tab should accept either a information-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. Any 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.east. before the shown.bs.tab issue occurs).

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

Events

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

  1. hide.bs.tab (on the current active tab)
  2. show.bs.tab (on the to-be-shown tab)
  3. hidden.bs.tab (on the previous active tab, the same ane as for the hide.bs.tab event)
  4. shown.bs.tab (on the newly-active but-shown tab, the aforementioned one as for the prove.bs.tab event)

If no tab was already active, then the hide.bs.tab and hidden.bs.tab events volition not be fired.

Result Type Description
show.bs.tab This upshot fires on tab show, only before the new tab has been shown. Apply result.target and event.relatedTarget to target the active tab and the previous active tab (if bachelor) respectively.
shown.bs.tab This event fires on tab show afterwards a tab has been shown. Utilise event.target and effect.relatedTarget to target the agile tab and the previous agile tab (if available) respectively.
hibernate.bs.tab This issue fires when a new tab is to be shown (and thus the previous active tab is to exist subconscious). Employ outcome.target and event.relatedTarget to target the current active tab and the new presently-to-be-active tab, respectively.
subconscious.bs.tab This event fires after a new tab is shown (and thus the previous active tab is hidden). Use event.target and effect.relatedTarget to target the previous active tab and the new active tab, respectively.
                              $                (                'a[data-toggle="tab"]'                ).                on                (                'shown.bs.tab'                ,                function                (                e                )                {                e                .                target                // newly activated tab                e                .                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 championship storage.

Tooltips with zero-length titles are never displayed.

Hover over the links beneath to see tooltips:

Tight pants next level keffiyeh you probably haven't heard of them. Photo berth beard raw denim letterpress vegan messenger bag stumptown. Subcontract-to-table seitan, mcsweeney's fixie sustainable quinoa 8-scrap american apparel have a terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, 4 loko mcsweeney's cleanse vegan chambray. A really ironic artisan any keytar, scenester farm-to-table banksy Austin twitter handle freegan cred raw denim single-origin coffee viral.

Static tooltip

Four options are available: top, correct, lesser, and left aligned.

4 directions

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

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

Trigger the tooltip via JavaScript:

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

Markup

The required markup for a tooltip is only a data attribute and championship on the HTML element you wish to take a tooltip. The generated markup of a tooltip is rather simple, though it does require a position (by default, set to top by the plugin).

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

Options

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

Name Type Default Description
blitheness boolean true Use a CSS fade transition to the tooltip
container cord | simulated false

Appends the tooltip to a specific element. Example: container: 'body'. This selection is especially useful in that information technology allows yous to position the tooltip in the catamenia of the certificate well-nigh the triggering element - which will forestall the tooltip from floating away from the triggering element during a window resize.

delay number | object 0

Delay showing and hiding the tooltip (ms) - does not apply to transmission trigger blazon

If a number is supplied, delay is applied to both hide/testify

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

html boolean false Insert HTML into the tooltip. If false, jQuery's text method will exist used to insert content into the DOM. Use text if you lot're worried about XSS attacks.
placement cord | function 'top'

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

When a office is used to decide the placement, it is called with the tooltip DOM node every bit its beginning statement and the triggering element DOM node as its second. The this context is set to the tooltip example.

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 take tooltips added. See this and an informative instance.
template string '<div course="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'

Base HTML to utilize when creating the tooltip.

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

.tooltip-arrow volition become the tooltip'south arrow.

The outermost wrapper element should take the .tooltip class.

title cord | function ''

Default title value if title aspect isn't present.

If a function is given, it will be called with its this reference gear up to the element that the tooltip is attached to.

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

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

If a part is given, it is chosen with the triggering element DOM node as its only statement. The this context is set to the tooltip instance.

Methods

$().tooltip(options)

Attaches a tooltip handler to an element drove.

.tooltip('testify')

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

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

.tooltip('hide')

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

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

.tooltip('toggle')

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

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

.tooltip('destroy')

Hides and destroys an chemical 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

Event 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 hide example method has been called.
hidden.bs.tooltip This upshot is fired when the tooltip has finished existence hidden from the user (will expect for CSS transitions to complete).
inserted.bs.tooltip This result is fired afterward the show.bs.tooltip event when the tooltip template has been added to the DOM.
                              $                (                '#myTooltip'                ).                on                (                'subconscious.bs.tooltip'                ,                role                ()                {                // practice something…                })                          

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

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

Opt-in functionality

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

1 mode to initialize all popovers on a page would exist to select them past their data-toggle attribute:

                                  $                  (                  office                  ()                  {                  $                  (                  '[information-toggle="popover"]'                  ).                  popover                  ()                  })                              

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

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

Popovers on disabled elements require wrapper elements

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

Multiple-line links

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

Examples

Static popover

Four options are available: acme, right, lesser, and left aligned.

Popover top

Sed posuere consectetur est at lobortis. Aenean eu 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 bottom

Sed posuere consectetur est at lobortis. Aenean european union 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.

Alive demo

                              <push                type=                "button"                class=                "btn btn-lg btn-danger"                information-toggle=                "popover"                championship=                "Popover title"                data-content=                "And here's some astonishing content. It'southward very engaging. Right?"                >Click to toggle popover</button>                          

Iv directions

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

Dismiss on next click

Apply 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 cantankerous-platform beliefs, y'all must utilize the <a> tag, not the <push> tag, and you too must include the function="push button" and tabindex attributes.

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

Usage

Enable popovers via JavaScript:

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

Options

Options can be passed via data attributes or JavaScript. For data attributes, suspend the selection proper noun to data-, as in data-animation="".

Name Blazon Default Description
animation boolean truthful Use a CSS fade transition to the popover
container cord | imitation false

Appends the popover to a specific chemical element. Case: container: 'body'. This option is specially useful in that it allows you to position the popover in the menstruum of the document most the triggering element - which will forbid the popover from floating away from the triggering element during a window resize.

content string | function ''

Default content value if data-content aspect isn't present.

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

delay number | object 0

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

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

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

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

How to position the popover - top | bottom | left | right | auto.
When "automobile" is specified, it will dynamically reorient the popover. For instance, if placement is "auto left", the popover volition display to the left when possible, otherwise it will brandish right.

When a part is used to determine the placement, it is called with the popover DOM node as its start statement and the triggering chemical element DOM node as its second. The this context is prepare to the popover case.

selector string imitation If a selector is provided, popover objects will exist delegated to the specified targets. In practice, this is used to enable dynamic HTML content to have popovers added. Meet this and an informative example.
template cord '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div grade="popover-content"></div></div>'

Base of operations HTML to use when creating the popover.

The popover's title volition be injected into the .popover-title.

The popover's content will exist injected into the .popover-content.

.arrow volition go the popover's arrow.

The outermost wrapper chemical element should take the .popover class.

title string | function ''

Default title value if championship attribute isn't present.

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

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

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

If a office is given, it is chosen with the triggering element DOM node as its only argument. The this context is ready to the popover example.

Data attributes for individual popovers

Options for private popovers can alternatively be specified through the use of information attributes, every bit explained above.

Methods

$().popover(options)

Initializes popovers for an element collection.

.popover('show')

Reveals an element'south popover. Returns to the caller earlier the popover has actually been shown (i.east. before the shown.bs.popover event occurs). This is considered a "manual" triggering of the popover. Popovers whose both title and content are zero-length are never displayed.

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

.popover('hide')

Hides an element'due south popover. Returns to the caller before the popover has actually been subconscious (i.east. 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'south popover. Returns to the caller before the popover has actually been shown or hidden (i.e. before the shown.bs.popover or hidden.bs.popover event occurs). This is considered a "manual" triggering of the popover.

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

.popover('destroy')

Hides and destroys an element'south popover. Popovers that utilize delegation (which are created using the selector pick) cannot exist individually destroyed on descendant trigger elements.

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

Events

Event Type Clarification
show.bs.popover This event fires immediately when the bear witness instance method is called.
shown.bs.popover This effect is fired when the popover has been made visible to the user (will wait 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 expect for CSS transitions to complete).
inserted.bs.popover This upshot is fired afterwards the testify.bs.popover consequence when the popover template has been added to the DOM.
                              $                (                '#myPopover'                ).                on                (                'hidden.bs.popover'                ,                function                ()                {                // practise something…                })                          

Example alerts

Add dismiss functionality to all alert letters with this plugin.

When using a .shut button, it must be the first child of the .alarm-dismissible and no text content may come before it in the markup.

Usage

Just add information-dismiss="alert" to your close button to automatically requite an warning shut functionality. Closing an alert removes it from the DOM.

                              <button                type=                "button"                class=                "close"                data-dismiss=                "alarm"                aria-characterization=                "Shut"                >                <span                aria-hidden=                "true"                >                &times;                </span>                </push button>                          

To have your alerts employ blitheness when closing, make sure they have the .fade and .in classes already applied to them.

Methods

$().alert()

Makes an alarm listen for click events on descendant elements which accept the data-dismiss="alert" aspect. (Not necessary when using the information-api's auto-initialization.)

$().alert('shut')

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

Events

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

Event Type Clarification
close.bs.alert This event fires immediately when the shut example method is called.
closed.bs.alert This issue is fired when the alert has been closed (volition look for CSS transitions to complete).
                              $                (                '#myAlert'                ).                on                (                'closed.bs.warning'                ,                function                ()                {                // exercise something…                })                          

Do more than with buttons. Command button states or create groups of buttons for more components like toolbars.

Stateful

Add together data-loading-text="Loading..." to utilize a loading country on a button.

This feature is deprecated since v3.3.v and has been removed in v4.

Use whichever country you like!

For the sake of this sit-in, we are using information-loading-text and $().button('loading'), but that's not the only country you lot tin can utilize. See more on this beneath in the $().button(string) documentation.

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

Single toggle

Add information-toggle="push" to actuate toggling on a unmarried button.

Pre-toggled buttons demand .active and aria-pressed="true"

For pre-toggled buttons, you must add the .agile class and the aria-pressed="true" aspect to the push button yourself.

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

Checkbox / Radio

Add together 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, you lot must add the .active course 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 issue on the button (east.g. via <input type="reset"> or via setting the checked property of the input), you volition demand to toggle the .agile class on the input's label yourself.

                              <div                class=                "btn-group"                data-toggle=                "buttons"                >                <label                class=                "btn btn-chief agile"                >                <input                type=                "checkbox"                autocomplete=                "off"                checked                >                Checkbox 1 (pre-checked)                </label>                <label                grade=                "btn btn-primary"                >                <input                type=                "checkbox"                autocomplete=                "off"                >                Checkbox 2                </label>                <characterization                grade=                "btn btn-primary"                >                <input                type=                "checkbox"                autocomplete=                "off"                >                Checkbox 3                </characterization>                </div>                          

                              <div                class=                "btn-group"                data-toggle=                "buttons"                >                <label                course=                "btn btn-primary agile"                >                <input                type=                "radio"                proper noun=                "options"                id=                "option1"                autocomplete=                "off"                checked                >                Radio i (preselected)                </characterization>                <label                class=                "btn btn-master"                >                <input                type=                "radio"                proper noun=                "options"                id=                "option2"                autocomplete=                "off"                >                Radio 2                </label>                <label                class=                "btn btn-principal"                >                <input                type=                "radio"                name=                "options"                id=                "option3"                autocomplete=                "off"                >                Radio iii                </characterization>                </div>                          

Methods

$().button('toggle')

Toggles button land. Gives the button the appearance that it has been activated.

$().button('reset')

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

$().push button(string)

Swaps text to any data divers text state.

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

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

Plugin dependency

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

Example

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

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

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

Link with href

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

                              <a                course=                "btn btn-master"                role=                "push"                data-toggle=                "collapse"                href=                "#collapseExample"                aria-expanded=                "false"                aria-controls=                "collapseExample"                >                Link with href                </a>                <button                form=                "btn btn-chief"                type=                "push button"                information-toggle=                "plummet"                data-target=                "#collapseExample"                aria-expanded=                "simulated"                aria-controls=                "collapseExample"                >                Button with data-target                </button>                <div                course=                "collapse"                id=                "collapseExample"                >                <div                form=                "well"                >                ...                </div>                </div>                          

Accordion instance

Extend the default collapse behavior to create an accordion with the console component.

Collapsible Group Item #1

Anim pariatur platitude 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 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 farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.

Collapsible Group Item #2

Anim pariatur platitude reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 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 unmarried-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 artful synth nesciunt yous 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, not cupidatat skateboard dolor brunch. Nutrient truck quinoa nesciunt laborum eiusmod. Brunch iii wolf moon tempor, sunt aliqua put a bird on it squid unmarried-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Advertisement 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.

                              <div                class=                "console-group"                id=                "accordion"                role=                "tablist"                aria-multiselectable=                "true"                >                <div                course=                "panel panel-default"                >                <div                class=                "panel-heading"                role=                "tab"                id=                "headingOne"                >                <h4                class=                "panel-title"                >                <a                role=                "button"                data-toggle=                "plummet"                information-parent=                "#squeeze box"                href=                "#collapseOne"                aria-expanded=                "true"                aria-controls=                "collapseOne"                >                Collapsible Group Item #1                </a>                </h4>                </div>                <div                id=                "collapseOne"                course=                "panel-collapse collapse in"                role=                "tabpanel"                aria-labelledby=                "headingOne"                >                <div                grade=                "panel-body"                >                Anim pariatur cliche reprehenderit, enim eiusmod loftier life accusamus terry richardson advertising squid. 3 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 artful synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.                </div>                </div>                </div>                <div                course=                "console panel-default"                >                <div                class=                "panel-heading"                office=                "tab"                id=                "headingTwo"                >                <h4                class=                "panel-title"                >                <a                grade=                "collapsed"                role=                "button"                information-toggle=                "collapse"                information-parent=                "#accordion"                href=                "#collapseTwo"                aria-expanded=                "simulated"                aria-controls=                "collapseTwo"                >                Collapsible Grouping Item #2                </a>                </h4>                </div>                <div                id=                "collapseTwo"                course=                "console-collapse collapse"                function=                "tabpanel"                aria-labelledby=                "headingTwo"                >                <div                grade=                "panel-body"                >                Anim pariatur cliche reprehenderit, enim eiusmod loftier life accusamus terry richardson ad squid. 3 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 arts and crafts beer farm-to-table, raw denim aesthetic synth nesciunt you lot probably haven't heard of them accusamus labore sustainable VHS.                </div>                </div>                </div>                <div                grade=                "panel panel-default"                >                <div                form=                "panel-heading"                role=                "tab"                id=                "headingThree"                >                <h4                class=                "panel-title"                >                <a                class=                "collapsed"                office=                "button"                data-toggle=                "collapse"                data-parent=                "#accordion"                href=                "#collapseThree"                aria-expanded=                "false"                aria-controls=                "collapseThree"                >                Collapsible Group Item #3                </a>                </h4>                </div>                <div                id=                "collapseThree"                grade=                "console-collapse plummet"                function=                "tabpanel"                aria-labelledby=                "headingThree"                >                <div                class=                "panel-body"                >                Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad 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 coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Advertising 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>                          

It's too possible to swap out .panel-bodys with .listing-groups.

Collapsible list group

  • Bootply
  • One itmus air-conditioning facilin
  • 2nd eros

Make expand/collapse controls accessible

Be sure to add aria-expanded to the control chemical element. This attribute explicitly defines the current state of the collapsible element to screen readers and like assistive technologies. If the collapsible element is airtight by default, it should have a value of aria-expanded="false". If y'all've set the collapsible element to be open by default using the in class, set 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 closed.

Additionally, if your command element is targeting a unmarried collapsible element – i.e. the data-target attribute is pointing to an id selector – y'all may add an additional aria-controls aspect to the control chemical element, containing the id of the collapsible chemical element. Modernistic screen readers and similar assistive technologies make use of this attribute to provide users with additional shortcuts to navigate directly to the collapsible element itself.

Usage

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

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

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

Via data attributes

Just add data-toggle="collapse" and a data-target to the element to automatically assign control of a collapsible element. The data-target attribute accepts a CSS selector to apply the plummet to. Be certain to add the grade plummet to the collapsible element. If you'd like it to default open, add the additional class in.

To add squeeze box-like group management to a collapsible command, add together the information attribute data-parent="#selector". Refer to the demo to run into this in action.

Via JavaScript

Enable manually with:

                              $                (                '.plummet'                ).                plummet                ()                          

Options

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

Name type default description
parent selector false If a selector is provided, then all collapsible elements under the specified parent will be airtight when this collapsible item is shown. (similar to traditional accordion behavior - this is dependent on the console class)
toggle boolean true Toggles the collapsible element on invocation

Methods

.collapse(options)

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

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

.collapse('toggle')

Toggles a collapsible chemical element to shown or hidden. Returns to the caller earlier the collapsible element has actually been shown or subconscious (i.eastward. before the shown.bs.plummet or hidden.bs.collapse result occurs).

.collapse('bear witness')

Shows a collapsible element. Returns to the caller before the collapsible element has really been shown (i.eastward. before the shown.bs.collapse event occurs).

.collapse('hide')

Hides a collapsible element. Returns to the caller before the collapsible element has actually been hidden (i.e. before the hidden.bs.collapse effect occurs).

Events

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

Upshot Type Description
testify.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 fabricated visible to the user (will await for CSS transitions to complete).
hibernate.bs.collapse This event is fired immediately when the hide method has been called.
hidden.bs.collapse This event is fired when a collapse chemical element has been hidden from the user (volition wait for CSS transitions to complete).
                              $                (                '#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                course=                "carousel-indicators"                >                <li                data-target=                "#carousel-case-generic"                information-slide-to=                "0"                class=                "active"                ></li>                <li                data-target=                "#carousel-example-generic"                information-slide-to=                "one"                ></li>                <li                information-target=                "#carousel-example-generic"                data-slide-to=                "2"                ></li>                </ol>                <!-- Wrapper for slides -->                <div                class=                "carousel-inner"                role=                "listbox"                >                <div                form=                "particular active"                >                <img                src=                "..."                alt=                "..."                >                <div                class=                "carousel-caption"                >                ...                </div>                </div>                <div                course=                "item"                >                <img                src=                "..."                alt=                "..."                >                <div                course=                "carousel-caption"                >                ...                </div>                </div>                ...                </div>                <!-- Controls -->                <a                course=                "left carousel-control"                href=                "#carousel-example-generic"                role=                "button"                information-slide=                "prev"                >                <span                form=                "glyphicon glyphicon-chevron-left"                aria-hidden=                "true"                ></bridge>                <span                class=                "sr-simply"                >Previous</bridge>                </a>                <a                class=                "right carousel-control"                href=                "#carousel-example-generic"                part=                "button"                data-slide=                "next"                >                <span                class=                "glyphicon glyphicon-chevron-right"                aria-hidden=                "truthful"                ></span>                <bridge                grade=                "sr-merely"                >Next</bridge>                </a>                </div>                          

Optional captions

Add captions to your slides easily with the .carousel-caption element within whatever .item. Place just about any optional HTML within at that place and it will be 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 utilize of an id on the outermost container (the .carousel) for carousel controls to function properly. When adding multiple carousels, or when changing a carousel's id, be sure to update the relevant controls.

Via data attributes

Use information attributes to hands control the position of the carousel. information-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 item index beginning with 0.

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

Via JavaScript

Call carousel manually with:

                              $                (                '.carousel'                ).                carousel                ()                          

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

Proper noun type default description
interval number 5000 The amount of time to delay betwixt automatically cycling an item. If simulated, carousel will not automatically wheel.
pause string | null "hover" If fix to "hover", pauses the cycling of the carousel on mouseenter and resumes the cycling of the carousel on mouseleave. If ready to null, hovering over the carousel won't pause it.
wrap boolean true Whether the carousel should wheel continuously or accept 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 right.

.carousel('pause')

Stops the carousel from cycling through items.

.carousel(number)

Cycles the carousel to a item frame (0 based, like to an array).

.carousel('prev')

Cycles to the previous item.

.carousel('side by side')

Cycles to the side by side item.

Bootstrap'southward carousel grade exposes two events for hooking into carousel functionality.

Both events take the following boosted properties:

  • direction: The direction in which the carousel is sliding (either "left" or "right").
  • relatedTarget: The DOM element that is existence slid into identify as the agile 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 instance method is invoked.
slid.bs.carousel This result is fired when the carousel has completed its slide transition.
                              $                (                '#myCarousel'                ).                on                (                'slide.bs.carousel'                ,                function                ()                {                // practise something…                })                          

Example

The braze plugin toggles position: fixed; on and off, emulating the consequence found with position: sticky;. 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 chemical element independent in a relatively positioned element, such equally a pulled or pushed column, due to a Safari rendering bug.

Positioning via CSS

The affix plugin toggles betwixt three classes, each representing a particular land: .braze, .affix-top, and .braze-bottom. Y'all must provide the styles, with the exception of position: fixed; on .affix, for these classes yourself (independent of this plugin) to handle the bodily positions.

Hither'due south how the affix plugin works:

  1. To beginning, the plugin adds .affix-meridian to betoken the element is in its top-nigh position. At this point no CSS positioning is required.
  2. Scrolling past the chemical element you want affixed should trigger the actual affixing. This is where .affix replaces .affix-top and sets position: fixed; (provided by Bootstrap's CSS).
  3. If a bottom offset is defined, scrolling past information technology should replace .affix with .braze-bottom. Since offsets are optional, setting 1 requires you to set the advisable CSS. In this case, add together position: accented; when necessary. The plugin uses the data aspect or JavaScript option to determine where to position the element from there.

Follow the to a higher place steps to prepare your CSS for either of the usage options below.

Via information attributes

To easily add affix behavior to whatsoever chemical element, but add data-spy="affix" to the element you want to spy on. Utilise offsets to ascertain when to toggle the pinning of an chemical element.

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

Via JavaScript

Phone call the braze plugin via JavaScript:

                              $                (                '#myAffix'                ).                braze                ({                commencement                :                {                top                :                100                ,                lesser                :                function                ()                {                render                (                this                .                bottom                =                $                (                '.footer'                ).                outerHeight                (                true                ))                }                }                })                          

Options

Options can be passed via data attributes or JavaScript. For data attributes, suspend the pick name to information-, as in information-offset-top="200".

Proper name blazon default description
kickoff number | function | object 10 Pixels to offset from screen when calculating position of gyre. If a unmarried number is provided, the first will be applied in both peak and bottom directions. To provide a unique, bottom and height start just provide an object offset: { meridian: 10 } or kickoff: { meridian: 10, bottom: 5 }. Use a function when you demand to dynamically calculate an offset.
target selector | node | jQuery element the window object Specifies the target element of the affix.

Methods

.affix(options)

Activates your content as affixed content. Accepts an optional options object.

                              $                (                '#myAffix'                ).                braze                ({                outset                :                15                })                          

.affix('checkPosition')

Recalculates the country of the affix based on the dimensions, position, and scroll position of the relevant elements. The .affix, .affix-acme, and .affix-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 changed, to ensure correct positioning of the affixed content.

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

Events

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

Event Blazon Description
affix.bs.affix This effect fires immediately before the chemical element has been affixed.
affixed.bs.braze This event is fired after the element has been affixed.
affix-meridian.bs.affix This upshot fires immediately before the chemical element has been affixed-peak.
affixed-top.bs.affix This consequence is fired later on the element has been affixed-meridian.
affix-bottom.bs.braze This event fires immediately before the element has been affixed-bottom.
affixed-bottom.bs.braze This upshot is fired after the chemical element has been affixed-lesser.