Private or compiled

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

Using the compiled JavaScript

Both bootstrap.js and bootstrap.min.js incorporate all plugins in a single file. Include just ane.

Plugin dependencies

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

Data attributes

You can use all Bootstrap plugins purely through the markup API without writing a unmarried line of JavaScript. This is Bootstrap'due south first-course API and should be your get-go consideration when using a plugin.

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

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

Alternatively, to target a specific plugin, just include the plugin's proper noun as a namespace along with the information-api namespace similar this:

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

Only one plugin per element via data attributes

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

Programmatic API

Nosotros also believe you should be able to employ all Bootstrap plugins purely through the JavaScript API. All public APIs are single, 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 item method, or naught (which initiates a plugin with default behavior):

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

Each plugin likewise exposes its raw constructor on a Constructor holding: $.fn.popover.Constructor. If you'd like to become a particular plugin instance, recall it directly from an element: $('[rel="popover"]').data('popover').

Default settings

Y'all tin change the default settings for a plugin by modifying the plugin's Constructor.DEFAULTS object:

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

No conflict

Sometimes it is necessary to use Bootstrap plugins with other UI frameworks. In these circumstances, namespace collisions can occasionally occur. If this happens, y'all may telephone call .noConflict on the plugin you wish to revert the value of.

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

Events

Bootstrap provides custom events for near plugins' unique actions. Generally, these come in an infinitive and past participle form - where the infinitive (ex. prove) is triggered at the start of an event, and its past participle form (ex. shown) is triggered on the completion of an action.

Equally of 3.0.0, all Bootstrap events are namespaced.

All infinitive events provide preventDefault functionality. This provides the ability to finish the execution of an action before it starts.

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

Version numbers

The version of each of Bootstrap'south jQuery plugins tin be accessed via the VERSION property of the plugin'due south constructor. For case, for the tooltip plugin:

                              $                .                fn                .                tooltip                .                Constructor                .                VERSION                // => "3.three.7"                          

No special fallbacks when JavaScript is disabled

Bootstrap'southward plugins don't autumn dorsum specially gracefully when JavaScript is disabled. If y'all intendance about the user experience in this example, utilize <noscript> to explain the state of affairs (and how to re-enable JavaScript) to your users, and/or add your own custom fallbacks.

Tertiary-party libraries

Bootstrap does non officially support third-party JavaScript libraries similar Epitome or jQuery UI. Despite .noConflict and namespaced events, there may exist compatibility problems that yous need to fix on your own.

About transitions

For unproblematic transition effects, include transition.js one time aslope the other JS files. If you lot're using the compiled (or minified) bootstrap.js, in that location is no demand to include this—it'south already there.

What's within

Transition.js is a bones helper for transitionEnd events also as a CSS transition emulator. It'southward 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 later transition.js (or bootstrap.js or bootstrap.min.js, as the case may be) has loaded:

                              $                .                support                .                transition                =                faux                          

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

Multiple open modals non supported

Exist sure not to open up a modal while another is yet visible. Showing more than i modal at a time requires custom code.

Modal markup placement

E'er attempt to place a modal's HTML lawmaking in a top-level position in your certificate to avoid other components affecting the modal's appearance and/or functionality.

Due to how HTML5 defines its semantics, the autofocus HTML aspect has no effect in Bootstrap modals. To achieve the same effect, employ some custom JavaScript:

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

Examples

Static example

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

                              <div                form=                "modal fade"                tabindex=                "-one"                role=                "dialog"                >                <div                form=                "modal-dialog"                role=                "document"                >                <div                class=                "modal-content"                >                <div                class=                "modal-header"                >                <button                blazon=                "button"                course=                "close"                information-dismiss=                "modal"                aria-label=                "Shut"                ><span                aria-subconscious=                "true"                >                &times;                </span></button>                <h4                course=                "modal-title"                >Modal championship</h4>                </div>                <div                class=                "modal-body"                >                <p>One fine body&hellip;                </p>                </div>                <div                class=                "modal-footer"                >                <button                type=                "button"                grade=                "btn btn-default"                data-dismiss=                "modal"                >Shut</button>                <button                type=                "button"                class=                "btn btn-primary"                >Save changes</button>                </div>                </div>                <!-- /.modal-content -->                </div>                <!-- /.modal-dialog -->                </div>                <!-- /.modal -->                          

Alive demo

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

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

Brand modals accessible

Be sure to add function="dialog" and aria-labelledby="...", referencing the modal championship, to .modal, and function="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. See this helpful Stack Overflow post for more information.

Optional sizes

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

                              <!-- Large modal -->                <push                type=                "push"                grade=                "btn btn-main"                information-toggle=                "modal"                information-target=                ".bs-example-modal-lg"                >Large modal</button>                <div                class=                "modal fade bs-instance-modal-lg"                tabindex=                "-1"                office=                "dialog"                aria-labelledby=                "myLargeModalLabel"                >                <div                class=                "modal-dialog modal-lg"                role=                "document"                >                <div                class=                "modal-content"                >                ...                </div>                </div>                </div>                <!-- Pocket-size modal -->                <button                type=                "push button"                class=                "btn btn-primary"                data-toggle=                "modal"                data-target=                ".bs-example-modal-sm"                >Pocket-sized modal</button>                <div                grade=                "modal fade bs-instance-modal-sm"                tabindex=                "-1"                office=                "dialog"                aria-labelledby=                "mySmallModalLabel"                >                <div                course=                "modal-dialog modal-sm"                office=                "document"                >                <div                grade=                "modal-content"                >                ...                </div>                </div>                </div>                          

Remove animation

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

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

Using the grid arrangement

To accept advantage of the Bootstrap grid system within a modal, but nest .rows inside the .modal-body and and then utilise the normal grid organisation classes.

                              <div                form=                "modal fade"                tabindex=                "-1"                role=                "dialog"                aria-labelledby=                "gridSystemModalLabel"                >                <div                class=                "modal-dialog"                role=                "document"                >                <div                class=                "modal-content"                >                <div                class=                "modal-header"                >                <button                type=                "push button"                class=                "shut"                information-dismiss=                "modal"                aria-label=                "Shut"                ><span                aria-hidden=                "true"                >                &times;                </span></button>                <h4                class=                "modal-title"                id=                "gridSystemModalLabel"                >Modal title</h4>                </div>                <div                class=                "modal-body"                >                <div                form=                "row"                >                <div                grade=                "col-md-four"                >.col-md-4</div>                <div                class=                "col-md-4 col-md-beginning-4"                >.col-physician-4 .col-md-commencement-4</div>                </div>                <div                class=                "row"                >                <div                form=                "col-md-3 col-md-offset-iii"                >.col-md-3 .col-md-offset-3</div>                <div                form=                "col-md-two col-md-offset-iv"                >.col-md-2 .col-dr.-offset-4</div>                </div>                <div                grade=                "row"                >                <div                course=                "col-dr.-6 col-doc-commencement-3"                >.col-dr.-6 .col-md-offset-3</div>                </div>                <div                class=                "row"                >                <div                class=                "col-sm-9"                >                Level 1: .col-sm-9                <div                class=                "row"                >                <div                course=                "col-xs-8 col-sm-6"                >                Level two: .col-xs-8 .col-sm-6                </div>                <div                class=                "col-xs-four col-sm-half dozen"                >                Level 2: .col-xs-four .col-sm-6                </div>                </div>                </div>                </div>                </div>                <div                class=                "modal-footer"                >                <button                type=                "button"                form=                "btn btn-default"                data-dismiss=                "modal"                >Close</button>                <button                type=                "button"                class=                "btn btn-chief"                >Relieve changes</button>                </div>                </div>                <!-- /.modal-content -->                </div>                <!-- /.modal-dialog -->                </div>                <!-- /.modal -->                          

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

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

Usage

The modal plugin toggles your subconscious content on demand, via information attributes or JavaScript. Information technology also adds .modal-open up to the <body> to override default scrolling behavior and generates a .modal-backdrop to provide a click expanse for dismissing shown modals when clicking outside the modal.

Via data attributes

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

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

Via JavaScript

Telephone call a modal with id myModal with a single line of JavaScript:

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

Options

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

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

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

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

                                                  <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                :                false                })                          

.modal('toggle')

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

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

.modal('bear witness')

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

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

.modal('hide')

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

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

.modal('handleUpdate')

Readjusts the modal's positioning to counter a scrollbar in case ane should announced, which would make the modal bound to the left.

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

                              $                (                '#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 class="modal">).

Event Type Description
show.bs.modal This event fires immediately when the show instance method is called. If caused by a click, the clicked element is bachelor as the relatedTarget property of the effect.
shown.bs.modal This result is fired when the modal has been made visible to the user (will expect for CSS transitions to complete). If caused by a click, the clicked element is available as the relatedTarget property of the event.
hibernate.bs.modal This event is fired immediately when the hibernate instance method has been called.
hidden.bs.modal This upshot is fired when the modal has finished existence hidden from the user (will wait for CSS transitions to consummate).
loaded.bs.modal This effect is fired when the modal has loaded content using the remote option.
                              $                (                '#myModal'                ).                on                (                'subconscious.bs.modal'                ,                role                (                e                )                {                // do something...                })                          

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

Within a navbar

Inside pills

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

On mobile devices, opening a dropdown adds a .dropdown-backdrop equally a tap area for closing dropdown menus when tapping outside the card, a requirement for proper iOS back up. This means that switching from an open dropdown bill of fare to a different dropdown carte du jour requires an extra tap on mobile.

Note: The data-toggle="dropdown" attribute is relied on for closing dropdown menus at an application level, and so information technology's a good idea to always use it.

Via information attributes

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

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

To proceed URLs intact with link buttons, use the information-target attribute instead of href="#".

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

Via JavaScript

Call the dropdowns via JavaScript:

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

data-toggle="dropdown" still required

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

None

$().dropdown('toggle')

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

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

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

Event Type Description
testify.bs.dropdown This upshot fires immediately when the show example method is chosen.
shown.bs.dropdown This event is fired when the dropdown has been made visible to the user (will wait for CSS transitions, to complete).
hibernate.bs.dropdown This event is fired immediately when the hide instance method has been chosen.
hidden.bs.dropdown This upshot is fired when the dropdown has finished being subconscious from the user (will wait for CSS transitions, to consummate).
                              $                (                '#myDropdown'                ).                on                (                'testify.bs.dropdown'                ,                function                ()                {                // do something…                })                          

The ScrollSpy plugin is for automatically updating nav targets based on scroll position. Whorl the expanse below the navbar and sentinel the active class alter. The dropdown sub items will exist highlighted likewise.

Requires relative positioning

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

Via information attributes

To easily add scrollspy behavior to your topbar navigation, add data-spy="whorl" to the chemical element you want to spy on (most typically this would be the <body>). And then add the information-target attribute with the ID or class of the parent element of whatever Bootstrap .nav component.

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

Via JavaScript

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

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

Methods

.scrollspy('refresh')

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

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

Options

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

Name type default description
offset number x Pixels to first from top when computing position of ringlet.

Events

Event Blazon Clarification
actuate.bs.scrollspy This event fires whenever a new item becomes activated by the scrollspy.
                              $                (                '#myScrollspy'                ).                on                (                'actuate.bs.scrollspy'                ,                office                ()                {                // practice something…                })                          

Example tabs

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

Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache platitude 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 clothes, butcher voluptate nisi qui.

Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin java squid. Exercitation +ane labore velit, blog sartorial PBR leggings side by side level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco advert vinyl cillum PBR. Homo nostrud organic, assumenda labore artful magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts bristles ut DIY upstanding culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.

Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-tabular array readymade. Messenger bag 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-gratuitous, carles pitchfork biodiesel fixie etsy retro mlkshk vice web log. Scenester cred y'all probably oasis't heard of them, vinyl craft 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 master cleanse gluten-costless squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life repeat 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                (                role                (                e                )                {                e                .                preventDefault                ()                $                (                this                ).                tab                (                'show'                )                })                          

You tin activate individual tabs in several ways:

                              $                (                '#myTabs a[href="#profile"]'                ).                tab                (                'show'                )                // Select tab past proper name                $                (                '#myTabs a:first'                ).                tab                (                'show'                )                // Select first tab                $                (                '#myTabs a:last'                ).                tab                (                'show'                )                // Select last tab                $                (                '#myTabs li:eq(2) a'                ).                tab                (                'show'                )                // Select third tab (0-indexed)                          

Markup

Y'all can activate a tab or pill navigation without writing any JavaScript by simply specifying data-toggle="tab" or information-toggle="pill" on an element. Calculation the nav and nav-tabs classes to the tab ul will utilize the Bootstrap tab styling, while calculation the nav and nav-pills classes will apply pill styling.

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

Fade effect

To brand tabs fade in, add .fade to each .tab-pane. The offset tab pane must also have .in to make the initial content visible.

                              <div                class=                "tab-content"                >                <div                role=                "tabpanel"                class=                "tab-pane fade in active"                id=                "dwelling"                >...</div>                <div                role=                "tabpanel"                class=                "tab-pane fade"                id=                "profile"                >...</div>                <div                function=                "tabpanel"                class=                "tab-pane fade"                id=                "messages"                >...</div>                <div                role=                "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 information-toggle="tab" attributes.

.tab('testify')

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

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

Events

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

  1. hide.bs.tab (on the electric current active tab)
  2. show.bs.tab (on the to-exist-shown tab)
  3. subconscious.bs.tab (on the previous active tab, the aforementioned one as for the hide.bs.tab event)
  4. shown.bs.tab (on the newly-agile but-shown tab, the same 1 equally for the show.bs.tab event)

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

Event Type Description
show.bs.tab This event fires on tab show, simply earlier the new tab has been shown. Use event.target and result.relatedTarget to target the active tab and the previous active tab (if available) respectively.
shown.bs.tab This event fires on tab show after a tab has been shown. Use outcome.target and event.relatedTarget to target the active tab and the previous agile tab (if available) respectively.
hide.bs.tab This event fires when a new tab is to be shown (and thus the previous active tab is to be hidden). Use consequence.target and event.relatedTarget to target the current active tab and the new soon-to-be-active tab, respectively.
subconscious.bs.tab This consequence fires after a new tab is shown (and thus the previous agile tab is subconscious). Apply event.target and event.relatedTarget to target the previous agile tab and the new agile tab, respectively.
                              $                (                'a[data-toggle="tab"]'                ).                on                (                'shown.bs.tab'                ,                function                (                e                )                {                e                .                target                // newly activated tab                due east                .                relatedTarget                // previous agile tab                })                          

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

Tooltips with zero-length titles are never displayed.

Hover over the links below to see tooltips:

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

Static tooltip

4 options are available: top, right, bottom, and left aligned.

4 directions

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

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

Trigger the tooltip via JavaScript:

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

Markup

The required markup for a tooltip is only a information attribute and title on the HTML element yous wish to have a tooltip. The generated markup of a tooltip is rather simple, though information technology does crave a position (past default, set to height by the plugin).

                              <!-- HTML to write -->                <a                href=                "#"                data-toggle=                "tooltip"                title=                "Some tooltip text!"                >Hover over me</a>                <!-- Generated markup by the plugin -->                <div                class=                "tooltip tiptop"                part=                "tooltip"                >                <div                form=                "tooltip-pointer"                ></div>                <div                class=                "tooltip-inner"                >                Some tooltip text!                </div>                </div>                          

Options

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

Proper name Type Default Description
animation boolean true Employ a CSS fade transition to the tooltip
container cord | false false

Appends the tooltip to a specific element. Case: container: 'torso'. This choice is specially useful in that it allows you to position the tooltip in the period of the document near the triggering element - which will forbid the tooltip from floating abroad from the triggering element during a window resize.

delay number | object 0

Delay showing and hiding the tooltip (ms) - does not apply to manual trigger type

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

Object structure is: filibuster: { "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're worried about XSS attacks.
placement string | function 'elevation'

How to position the tooltip - summit | bottom | left | correct | automobile.
When "automobile" is specified, it will dynamically reorient the tooltip. For instance, if placement is "car left", the tooltip will display to the left when possible, otherwise it volition display right.

When a function is used to make up one's mind the placement, it is called with the tooltip DOM node as its offset argument and the triggering element DOM node as its second. The this context is set to the tooltip instance.

selector cord false If a selector is provided, tooltip objects will be delegated to the specified targets. In exercise, this is used to enable dynamic HTML content to take tooltips added. Encounter this and an informative example.
template string '<div class="tooltip" part="tooltip"><div form="tooltip-arrow"></div><div form="tooltip-inner"></div></div>'

Base HTML to employ when creating the tooltip.

The tooltip's championship will exist injected into the .tooltip-inner.

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

The outermost wrapper element should take the .tooltip class.

championship string | office ''

Default championship value if title aspect isn't present.

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

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

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

If a function is given, information technology is called with the triggering chemical element DOM node equally its only argument. The this context is set to the tooltip instance.

Methods

$().tooltip(options)

Attaches a tooltip handler to an chemical element collection.

.tooltip('show')

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

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

.tooltip('hibernate')

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

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

.tooltip('toggle')

Toggles an chemical element's tooltip. Returns to the caller before the tooltip has actually been shown or hidden (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 selection) cannot exist individually destroyed on descendant trigger elements.

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

Events

Event Type Description
evidence.bs.tooltip This event fires immediately when the testify case method is called.
shown.bs.tooltip This event is fired when the tooltip has been made visible to the user (volition wait for CSS transitions to complete).
hide.bs.tooltip This event is fired immediately when the hide instance method has been called.
hidden.bs.tooltip This issue is fired when the tooltip has finished being subconscious from the user (will wait for CSS transitions to complete).
inserted.bs.tooltip This event is fired after the show.bs.tooltip upshot when the tooltip template has been added to the DOM.
                              $                (                '#myTooltip'                ).                on                (                'hidden.bs.tooltip'                ,                role                ()                {                // do something…                })                          

Add pocket-size overlays of content, like those on the iPad, to any element for housing secondary information.

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

Opt-in functionality

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

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

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

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

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

Popovers on disabled elements require wrapper elements

To add a popover to a disabled or .disabled element, put the element within of a <div> and apply 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 center it horizontally and vertically. Add white-space: nowrap; to your anchors to avoid this.

Examples

Static popover

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

Popover superlative

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 eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

Popover left

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

Live demo

                              <button                type=                "button"                grade=                "btn btn-lg btn-danger"                data-toggle=                "popover"                title=                "Popover title"                data-content=                "And hither's some amazing content. It's very engaging. Right?"                >Click to toggle popover</push>                          

Four directions

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

Dismiss on next click

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

Specific markup required for dismiss-on-next-click

For proper cantankerous-browser and cantankerous-platform behavior, you must use the <a> tag, not the <push button> tag, and you besides must include the role="button" and tabindex attributes.

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

Usage

Enable popovers via JavaScript:

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

Options

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

Name Blazon Default Description
blitheness boolean true Apply a CSS fade transition to the popover
container string | false false

Appends the popover to a specific element. Example: container: 'body'. This option is specially useful in that it allows you to position the popover in the flow of the document near the triggering element - which volition prevent the popover from floating abroad from the triggering element during a window resize.

content string | office ''

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

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

filibuster number | object 0

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

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

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

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

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

When a part is used to decide the placement, information technology is called with the popover DOM node as its beginning statement and the triggering element DOM node as its second. The this context is prepare to the popover instance.

selector cord false 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. See this and an informative case.
template string '<div class="popover" function="tooltip"><div grade="arrow"></div><h3 class="popover-title"></h3><div form="popover-content"></div></div>'

Base of operations HTML to use when creating the popover.

The popover'southward title will be injected into the .popover-title.

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

.arrow volition go the popover's arrow.

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

title string | function ''

Default championship value if title attribute isn't present.

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

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

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

If a function is given, it is called with the triggering element DOM node as its only argument. The this context is set to the popover case.

Data attributes for individual popovers

Options for individual popovers can alternatively be specified through the utilise of data attributes, as explained above.

Methods

$().popover(options)

Initializes popovers for an chemical element collection.

.popover('show')

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

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

.popover('hide')

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

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

.popover('toggle')

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

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

.popover('destroy')

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

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

Events

Upshot Blazon Description
show.bs.popover This outcome fires immediately when the show instance method is called.
shown.bs.popover This event is fired when the popover has been made visible to the user (will wait for CSS transitions to complete).
hide.bs.popover This issue is fired immediately when the hide instance method has been called.
hidden.bs.popover This event is fired when the popover has finished being hidden from the user (will look for CSS transitions to complete).
inserted.bs.popover This outcome is fired later on the show.bs.popover event 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 alarm letters with this plugin.

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

Usage

Simply add data-dismiss="alert" to your close push button to automatically give an alarm close functionality. Endmost an alert removes it from the DOM.

                              <button                blazon=                "button"                class=                "close"                information-dismiss=                "alert"                aria-label=                "Close"                >                <bridge                aria-hidden=                "truthful"                >                &times;                </span>                </button>                          

To have your alerts use animation when closing, brand certain they have the .fade and .in classes already applied to them.

Methods

$().alert()

Makes an alert listen for click events on descendant elements which have the information-dismiss="warning" aspect. (Not necessary when using the data-api'south 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 warning will fade out before it is removed.

Events

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

Event Type Clarification
close.bs.alert This event fires immediately when the shut instance method is called.
closed.bs.alert This event is fired when the alert has been closed (will await for CSS transitions to complete).
                              $                (                '#myAlert'                ).                on                (                'closed.bs.alarm'                ,                part                ()                {                // do something…                })                          

Do more with buttons. Command push states or create groups of buttons for more components similar toolbars.

Stateful

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

This feature is deprecated since v3.three.five and has been removed in v4.

Use whichever country you lot like!

For the sake of this demonstration, we are using data-loading-text and $().button('loading'), but that's not the only state you can employ. Run into more on this below in the $().button(string) documentation.

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

Single toggle

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

Pre-toggled buttons need .agile and aria-pressed="true"

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

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

Checkbox / Radio

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

Preselected options demand .active

For preselected options, you must add the .active class to the input'south label yourself.

Visual checked state only updated on click

If the checked state of a checkbox button is updated without firing a click result on the button (east.yard. via <input blazon="reset"> or via setting the checked holding of the input), you will demand to toggle the .active class on the input's label yourself.

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

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

Methods

$().button('toggle')

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

$().push button('reset')

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

$().button(string)

Swaps text to any data defined text state.

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

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

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 element via class changes:

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

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

Link with href

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

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

Squeeze box case

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

Collapsible Group Item #one

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

Collapsible Group Item #two

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

Collapsible Group Particular #3

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

                              <div                form=                "console-group"                id=                "accordion"                role=                "tablist"                aria-multiselectable=                "true"                >                <div                form=                "console panel-default"                >                <div                class=                "console-heading"                role=                "tab"                id=                "headingOne"                >                <h4                course=                "panel-title"                >                <a                part=                "push"                data-toggle=                "collapse"                information-parent=                "#accordion"                href=                "#collapseOne"                aria-expanded=                "true"                aria-controls=                "collapseOne"                >                Collapsible Grouping Particular #i                </a>                </h4>                </div>                <div                id=                "collapseOne"                course=                "console-collapse plummet in"                role=                "tabpanel"                aria-labelledby=                "headingOne"                >                <div                course=                "panel-body"                >                Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson advertizing squid. three wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on information technology 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 subcontract-to-table, raw denim aesthetic synth nesciunt yous probably haven't heard of them accusamus labore sustainable VHS.                </div>                </div>                </div>                <div                course=                "console panel-default"                >                <div                course=                "panel-heading"                part=                "tab"                id=                "headingTwo"                >                <h4                class=                "panel-championship"                >                <a                class=                "collapsed"                role=                "push button"                data-toggle=                "collapse"                data-parent=                "#accordion"                href=                "#collapseTwo"                aria-expanded=                "faux"                aria-controls=                "collapseTwo"                >                Collapsible Group Item #2                </a>                </h4>                </div>                <div                id=                "collapseTwo"                class=                "panel-collapse collapse"                part=                "tabpanel"                aria-labelledby=                "headingTwo"                >                <div                class=                "console-torso"                >                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 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. Advertisement vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.                </div>                </div>                </div>                <div                form=                "panel panel-default"                >                <div                class=                "console-heading"                role=                "tab"                id=                "headingThree"                >                <h4                class=                "panel-championship"                >                <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"                class=                "console-plummet collapse"                role=                "tabpanel"                aria-labelledby=                "headingThree"                >                <div                course=                "panel-body"                >                Anim pariatur cliché reprehenderit, enim eiusmod high life accusamus terry richardson advert squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch three wolf moon tempor, sunt aliqua put a bird on it squid unmarried-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, arts and crafts beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-tabular array, raw denim artful synth nesciunt y'all probably haven't heard of them accusamus labore sustainable VHS.                </div>                </div>                </div>                </div>                          

It'south as well possible to bandy out .console-torsos with .list-groupings.

Collapsible list group

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

Make aggrandize/collapse controls accessible

Exist sure to add together aria-expanded to the command element. This aspect explicitly defines the current state of the collapsible chemical element to screen readers and similar assistive technologies. If the collapsible element is airtight by default, it should have a value of aria-expanded="false". If you've set the collapsible element to be open past default using the in class, set aria-expanded="truthful" on the command instead. The plugin volition automatically toggle this aspect based on whether or not the collapsible element has been opened or airtight.

Additionally, if your control element is targeting a single collapsible chemical element – i.due east. the data-target attribute is pointing to an id selector – you may add an additional aria-controls attribute to the control element, containing the id of the collapsible chemical element. Mod screen readers and similar assistive technologies make use of this attribute to provide users with boosted 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
  • .plummet.in shows the content
  • .collapsing is added when the transition starts, and removed when it finishes

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

Via data attributes

Simply add data-toggle="collapse" and a data-target to the chemical element to automatically assign control of a collapsible chemical element. The data-target attribute accepts a CSS selector to apply the collapse to. Exist certain to add the class collapse to the collapsible element. If yous'd similar information technology to default open, add together the additional class in.

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

Via JavaScript

Enable manually with:

                              $                (                '.collapse'                ).                collapse                ()                          

Options

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

Proper name type default description
parent selector false If a selector is provided, then all collapsible elements under the specified parent will exist closed when this collapsible item is shown. (similar to traditional piano accordion beliefs - this is dependent on the panel grade)
toggle boolean truthful 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 element to shown or hidden. Returns to the caller before the collapsible element has really been shown or subconscious (i.e. before the shown.bs.plummet or hidden.bs.plummet outcome occurs).

.collapse('evidence')

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

.collapse('hibernate')

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

Events

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

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

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

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

Optional captions

Add captions to your slides easily with the .carousel-caption element within whatsoever .item. Place just about whatever optional HTML within there and information technology will exist automatically aligned and formatted.

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

Multiple carousels

Carousels crave the utilise of an id on the outermost container (the .carousel) for carousel controls to office properly. When adding multiple carousels, or when changing a carousel'southward id, be sure to update the relevant controls.

Via data attributes

Use data attributes to easily control the position of the carousel. data-slide accepts the keywords prev or next, which alters the slide position relative to its current position. Alternatively, use data-slide-to to laissez passer a raw slide index to the carousel information-slide-to="ii", which shifts the slide position to a item alphabetize beginning with 0.

The data-ride="carousel" attribute is used to mark a carousel as animating starting at folio 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 can be passed via information attributes or JavaScript. For data attributes, suspend the pick name to data-, as in information-interval="".

Name type default description
interval number 5000 The amount of fourth dimension to delay between automatically cycling an item. If false, carousel will not automatically cycle.
intermission cord | cipher "hover" If gear up to "hover", pauses the cycling of the carousel on mouseenter and resumes the cycling of the carousel on mouseleave. If set up to null, hovering over the carousel won't interruption it.
wrap boolean true Whether the carousel should bicycle continuously or have hard stops.
keyboard boolean true Whether the carousel should react to keyboard events.

.carousel(options)

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

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

.carousel('cycle')

Cycles through the carousel items from left to correct.

.carousel('pause')

Stops the carousel from cycling through items.

.carousel(number)

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

.carousel('prev')

Cycles to the previous particular.

.carousel('side by side')

Cycles to the next item.

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

Both events accept the following additional properties:

  • management: The direction in which the carousel is sliding (either "left" or "right").
  • relatedTarget: The DOM element that is beingness slid into identify as the active item.

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

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

Example

The affix plugin toggles position: fixed; on and off, emulating the effect plant with position: sticky;. The subnavigation on the correct is a live demo of the braze plugin.


Usage

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

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

Positioning via CSS

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

Here'south how the affix plugin works:

  1. To start, the plugin adds .braze-top to signal the element is in its top-most position. At this betoken no CSS positioning is required.
  2. Scrolling past the element you desire affixed should trigger the actual affixing. This is where .affix replaces .affix-top and sets position: stock-still; (provided by Bootstrap's CSS).
  3. If a bottom offset is defined, scrolling past it should supersede .braze with .affix-bottom. Since offsets are optional, setting i requires y'all to prepare the appropriate CSS. In this instance, add position: absolute; when necessary. The plugin uses the information attribute or JavaScript selection to decide where to position the element from there.

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

Via data attributes

To hands add affix behavior to any element, merely add information-spy="braze" to the chemical element you want to spy on. Use offsets to define when to toggle the pinning of an chemical element.

                              <div                data-spy=                "affix"                data-offset-top=                "threescore"                data-showtime-bottom=                "200"                >                ...                </div>                          

Via JavaScript

Call the affix plugin via JavaScript:

                              $                (                '#myAffix'                ).                affix                ({                offset                :                {                summit                :                100                ,                bottom                :                function                ()                {                return                (                this                .                lesser                =                $                (                '.footer'                ).                outerHeight                (                true                ))                }                }                })                          

Options

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

Name type default description
offset number | part | object 10 Pixels to offset from screen when calculating position of ringlet. If a unmarried number is provided, the outset will exist practical in both top and bottom directions. To provide a unique, lesser and top offset simply provide an object offset: { top: 10 } or offset: { top: 10, bottom: 5 }. Use a function when you need to dynamically summate an first.
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'                ).                affix                ({                offset                :                15                })                          

.affix('checkPosition')

Recalculates the state of the braze based on the dimensions, position, and curlicue position of the relevant elements. The .braze, .affix-summit, and .affix-lesser classes are added to or removed from the affixed content according to the new state. This method needs to exist called whenever the dimensions of the affixed content or the target element are changed, to ensure right positioning of the affixed content.

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

Events

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

Result Type Description
affix.bs.braze This event fires immediately before the element has been affixed.
affixed.bs.affix This event is fired afterwards the element has been affixed.
affix-top.bs.affix This consequence fires immediately before the element has been affixed-top.
affixed-acme.bs.braze This event is fired after the element has been affixed-top.
affix-bottom.bs.affix This consequence fires immediately before the element has been affixed-lesser.
affixed-bottom.bs.affix This outcome is fired afterwards the element has been affixed-bottom.