Individual or compiled

Plugins can 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 contain all plugins in a single file. Include only ane.

Plugin dependencies

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

Data attributes

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

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

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

Alternatively, to target a specific plugin, simply include the plugin'southward name as a namespace along with the information-api namespace like this:

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

Only i plugin per element via information attributes

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

Programmatic API

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

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

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

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

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

Default settings

You can modify 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` selection to imitation                          

No conflict

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

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

Events

Bootstrap provides custom events for most plugins' unique actions. More often than not, these come up in an infinitive and past participle course - where the infinitive (ex. testify) is triggered at the offset of an consequence, and its by participle form (ex. shown) is triggered on the completion of an action.

As of iii.0.0, all Bootstrap events are namespaced.

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

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

Version numbers

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

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

No special fallbacks when JavaScript is disabled

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

Third-party libraries

Bootstrap does non officially support third-party JavaScript libraries similar Image or jQuery UI. Despite .noConflict and namespaced events, there may be compatibility problems that yous need to gear up on your ain.

About transitions

For simple transition furnishings, include transition.js once alongside the other JS files. If you're using the compiled (or minified) bootstrap.js, in that location is no need to include this—information technology's already there.

What's inside

Transition.js is a bones helper for transitionEnd events too as a CSS transition emulator. It'south used past the other plugins to check for CSS transition support and to grab hanging transitions.

Disabling transitions

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

                              $                .                support                .                transition                =                false                          

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

Multiple open modals non supported

Be sure non to open a modal while some other is still visible. Showing more than one modal at a fourth dimension requires custom code.

Modal markup placement

E'er endeavour to place a modal's HTML code in a superlative-level position in your document to avert other components affecting the modal'due south appearance and/or functionality.

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

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

Examples

Static case

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

                              <div                class=                "modal fade"                tabindex=                "-i"                role=                "dialog"                >                <div                class=                "modal-dialog"                role=                "document"                >                <div                class=                "modal-content"                >                <div                class=                "modal-header"                >                <button                type=                "button"                class=                "shut"                data-dismiss=                "modal"                aria-characterization=                "Close"                ><span                aria-hidden=                "true"                >                &times;                </span></button>                <h4                class=                "modal-championship"                >Modal title</h4>                </div>                <div                form=                "modal-trunk"                >                <p>Ane fine body&hellip;                </p>                </div>                <div                class=                "modal-footer"                >                <button                type=                "button"                grade=                "btn btn-default"                information-dismiss=                "modal"                >Close</button>                <push                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 by clicking the button beneath. Information technology volition slide downwards and fade in from the top of the page.

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

Make modals accessible

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

Additionally, yous may give a clarification 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 stop playback and more. See this helpful Stack Overflow post for more than information.

Optional sizes

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

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

Remove animation

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

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

Using the filigree system

To take reward of the Bootstrap grid system inside a modal, just nest .rowsouth within the .modal-body and so utilize the normal grid system classes.

                              <div                grade=                "modal fade"                tabindex=                "-1"                part=                "dialog"                aria-labelledby=                "gridSystemModalLabel"                >                <div                grade=                "modal-dialog"                role=                "certificate"                >                <div                class=                "modal-content"                >                <div                course=                "modal-header"                >                <button                type=                "button"                class=                "shut"                data-dismiss=                "modal"                aria-label=                "Close"                ><span                aria-subconscious=                "true"                >                &times;                </span></button>                <h4                class=                "modal-championship"                id=                "gridSystemModalLabel"                >Modal title</h4>                </div>                <div                grade=                "modal-torso"                >                <div                course=                "row"                >                <div                class=                "col-md-iv"                >.col-md-4</div>                <div                course=                "col-md-4 col-medico-get-go-4"                >.col-md-4 .col-physician-start-4</div>                </div>                <div                grade=                "row"                >                <div                course=                "col-dr.-3 col-physician-offset-3"                >.col-dr.-3 .col-physician-kickoff-3</div>                <div                class=                "col-doc-2 col-md-offset-4"                >.col-dr.-2 .col-doctor-starting time-4</div>                </div>                <div                class=                "row"                >                <div                class=                "col-md-six col-doctor-offset-3"                >.col-md-6 .col-physician-offset-3</div>                </div>                <div                class=                "row"                >                <div                form=                "col-sm-9"                >                Level one: .col-sm-9                <div                class=                "row"                >                <div                class=                "col-xs-8 col-sm-6"                >                Level 2: .col-xs-8 .col-sm-6                </div>                <div                grade=                "col-xs-four col-sm-6"                >                Level 2: .col-xs-4 .col-sm-6                </div>                </div>                </div>                </div>                </div>                <div                form=                "modal-footer"                >                <push                type=                "button"                class=                "btn btn-default"                information-dismiss=                "modal"                >Shut</button>                <button                type=                "button"                class=                "btn btn-primary"                >Save 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 different contents? Use upshot.relatedTarget and HTML data-* attributes (mayhap via jQuery) to vary the contents of the modal depending on which push was clicked. Encounter the Modal Events docs for details on relatedTarget,

                              <button                type=                "button"                class=                "btn btn-primary"                data-toggle=                "modal"                data-target=                "#exampleModal"                data-whatsoever=                "@mdo"                >Open modal for @mdo</push button>                <button                blazon=                "button"                class=                "btn btn-master"                data-toggle=                "modal"                data-target=                "#exampleModal"                information-any=                "@fat"                >Open up modal for @fat</push button>                <push                type=                "button"                form=                "btn btn-primary"                data-toggle=                "modal"                information-target=                "#exampleModal"                data-whatever=                "@getbootstrap"                >Open modal for @getbootstrap</button>                ...more buttons...                <div                class=                "modal fade"                id=                "exampleModal"                tabindex=                "-i"                role=                "dialog"                aria-labelledby=                "exampleModalLabel"                >                <div                class=                "modal-dialog"                role=                "document"                >                <div                class=                "modal-content"                >                <div                class=                "modal-header"                >                <button                type=                "button"                course=                "shut"                data-dismiss=                "modal"                aria-characterization=                "Close"                ><span                aria-hidden=                "true"                >                &times;                </bridge></push button>                <h4                course=                "modal-title"                id=                "exampleModalLabel"                >New bulletin</h4>                </div>                <div                form=                "modal-body"                >                <form>                <div                class=                "course-group"                >                <label                for=                "recipient-name"                class=                "control-label"                >Recipient:</label>                <input                blazon=                "text"                class=                "grade-command"                id=                "recipient-name"                >                </div>                <div                class=                "form-group"                >                <label                for=                "message-text"                class=                "control-label"                >Bulletin:</characterization>                <textarea                class=                "grade-control"                id=                "message-text"                ></textarea>                </div>                </form>                </div>                <div                class=                "modal-footer"                >                <push button                blazon=                "push"                class=                "btn btn-default"                data-dismiss=                "modal"                >Close</button>                <push                type=                "button"                class=                "btn btn-principal"                >Send message</button>                </div>                </div>                </div>                </div>                          
                              $                (                '#exampleModal'                ).                on                (                'evidence.bs.modal'                ,                office                (                issue                )                {                var                button                =                $                (                event                .                relatedTarget                )                // Push button that triggered the modal                var                recipient                =                push button                .                data                (                'whatever'                )                // Excerpt info from data-* attributes                // If necessary, you could initiate an AJAX asking here (and then do the updating in a callback).                // Update the modal'south content. Nosotros'll utilize jQuery here, but you could use a information bounden library or other methods instead.                var                modal                =                $                (                this                )                modal                .                find                (                '.modal-title'                ).                text                (                'New message to '                +                recipient                )                modal                .                discover                (                '.modal-torso input'                ).                val                (                recipient                )                })                          

Usage

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

Via information attributes

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

                              <button                type=                "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 exist passed via information attributes or JavaScript. For data attributes, append the option name to data-, equally in data-backdrop="".

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

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

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

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

Methods

.modal(options)

Activates your content as 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 hidden (i.e. before the shown.bs.modal or subconscious.bs.modal event occurs).

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

.modal('show')

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

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

.modal('hide')

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

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

.modal('handleUpdate')

Readjusts the modal's positioning to counter a scrollbar in case ane should appear, which would brand the modal jump to the left.

But needed when the superlative of the modal changes while it is open.

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

Events

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

All modal events are fired at the modal itself (i.due east. 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 available as the relatedTarget holding of the event.
shown.bs.modal This upshot is fired when the modal has been made visible to the user (will expect for CSS transitions to complete). If acquired past a click, the clicked element is available as the relatedTarget holding of the event.
hide.bs.modal This event is fired immediately when the hide instance method has been called.
hidden.bs.modal This event is fired when the modal has finished being hidden from the user (will wait for CSS transitions to complete).
loaded.bs.modal This event is fired when the modal has loaded content using the remote option.
                              $                (                '#myModal'                ).                on                (                'hidden.bs.modal'                ,                function                (                e                )                {                // do something...                })                          

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

Within a navbar

Within pills

Via data attributes or JavaScript, the dropdown plugin toggles subconscious content (dropdown menus) by toggling the .open class on the parent list item.

On mobile devices, opening a dropdown adds a .dropdown-backdrop equally a tap area for closing dropdown menus when tapping outside the carte du jour, a requirement for proper iOS support. This ways that switching from an open up dropdown card 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, then it'southward a good idea to ever use information technology.

Via data attributes

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

                              <div                class=                "dropdown"                >                <push                id=                "dLabel"                type=                "button"                information-toggle=                "dropdown"                aria-haspopup=                "truthful"                aria-expanded=                "faux"                >                Dropdown trigger                <span                class=                "caret"                ></span>                </push>                <ul                class=                "dropdown-bill of fare"                aria-labelledby=                "dLabel"                >                ...                </ul>                </div>                          

To go on URLs intact with link buttons, utilise the data-target attribute instead of href="#".

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

Via JavaScript

Call the dropdowns via JavaScript:

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

information-toggle="dropdown" still required

Regardless of whether you call your dropdown via JavaScript or instead use the data-api, data-toggle="dropdown" is always required to be 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-menu'southward parent chemical element.

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

Event Type Description
prove.bs.dropdown This effect fires immediately when the show instance method is called.
shown.bs.dropdown This issue is fired when the dropdown has been made visible to the user (will await for CSS transitions, to complete).
hide.bs.dropdown This event is fired immediately when the hide example method has been chosen.
hidden.bs.dropdown This event is fired when the dropdown has finished existence hidden from the user (will wait for CSS transitions, to complete).
                              $                (                '#myDropdown'                ).                on                (                'show.bs.dropdown'                ,                function                ()                {                // exercise something…                })                          

The ScrollSpy plugin is for automatically updating nav targets based on scroll position. Scroll the expanse below the navbar and sentry the active grade modify. The dropdown sub items will be highlighted too.

Requires relative positioning

No matter the implementation method, scrollspy requires the use of position: relative; on the element you're spying on. In nearly cases this is the <body>. When scrollspying on elements other than the <body>, be sure to take a meridian set and overflow-y: scroll; practical.

Via data attributes

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

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

Via JavaScript

Subsequently 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 adding or removing of elements from the DOM, y'all'll demand to telephone call the refresh method like so:

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

Options

Options tin can exist passed via data attributes or JavaScript. For data attributes, append the pick proper noun to data-, as in data-commencement="".

Name type default description
beginning number x Pixels to beginning from tiptop when computing position of roll.

Events

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

Case tabs

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

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

Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +i labore velit, web log sartorial PBR leggings next level wes anderson artisan four loko farm-to-tabular array craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco advertising vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-scrap, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.

Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi subcontract-to-table 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-chip cred pitchfork. Williamsburg banh mi whatever gluten-gratuitous, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred yous probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.

Trust fund seitan letterpress, keytar raw denim keffiyeh etsy fine art party before they sold out principal cleanse gluten-complimentary squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliché high life repeat park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out subcontract-to-tabular array VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh craft beer marfa ethical. Wolf salvia freegan, sartorial keffiyeh repeat park vegan.

Usage

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

                              $                (                '#myTabs a'                ).                click                (                function                (                e                )                {                e                .                preventDefault                ()                $                (                this                ).                tab                (                'show'                )                })                          

You lot can activate private tabs in several ways:

                              $                (                '#myTabs a[href="#profile"]'                ).                tab                (                'show'                )                // Select tab by name                $                (                '#myTabs a:commencement'                ).                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

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

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

Fade effect

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

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

Methods

$().tab

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

.tab('show')

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

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

Events

When showing a new tab, the events fire in the post-obit order:

  1. hide.bs.tab (on the current active tab)
  2. show.bs.tab (on the to-exist-shown tab)
  3. hidden.bs.tab (on the previous agile tab, the same one as for the hide.bs.tab outcome)
  4. shown.bs.tab (on the newly-active just-shown tab, the same one as for the show.bs.tab consequence)

If no tab was already agile, then the hibernate.bs.tab and hidden.bs.tab events will not be fired.

Consequence Type Description
testify.bs.tab This event fires on tab show, but earlier the new tab has been shown. Employ consequence.target and event.relatedTarget to target the active tab and the previous agile tab (if bachelor) respectively.
shown.bs.tab This event fires on tab prove subsequently a tab has been shown. Use event.target and result.relatedTarget to target the agile tab and the previous active tab (if bachelor) respectively.
hide.bs.tab This event fires when a new tab is to be shown (and thus the previous agile tab is to be hidden). Employ outcome.target and event.relatedTarget to target the current active tab and the new before longhoped-for-active tab, respectively.
subconscious.bs.tab This event fires afterward a new tab is shown (and thus the previous active tab is subconscious). Use event.target and event.relatedTarget to target the previous active tab and the new active tab, respectively.
                              $                (                'a[data-toggle="tab"]'                ).                on                (                'shown.bs.tab'                ,                part                (                e                )                {                e                .                target                // newly activated tab                e                .                relatedTarget                // previous active tab                })                          

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

Tooltips with zero-length titles are never displayed.

Hover over the links below to run into tooltips:

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

Static tooltip

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

Four directions

                              <push button                type=                "button"                course=                "btn btn-default"                information-toggle=                "tooltip"                data-placement=                "left"                title=                "Tooltip on left"                >Tooltip on left</push button>                <button                blazon=                "button"                class=                "btn btn-default"                data-toggle=                "tooltip"                information-placement=                "top"                title=                "Tooltip on tiptop"                >Tooltip on top</push>                <push button                type=                "button"                class=                "btn btn-default"                data-toggle=                "tooltip"                data-placement=                "bottom"                title=                "Tooltip on bottom"                >Tooltip on bottom</button>                <push                type=                "push"                class=                "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 past 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 data attribute and championship on the HTML element you wish to take a tooltip. The generated markup of a tooltip is rather simple, though information technology does require 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 past the plugin -->                <div                course=                "tooltip superlative"                function=                "tooltip"                >                <div                grade=                "tooltip-arrow"                ></div>                <div                grade=                "tooltip-inner"                >                Some tooltip text!                </div>                </div>                          

Options

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

Proper noun Type Default Description
animation boolean truthful Utilize a CSS fade transition to the tooltip
container string | simulated fake

Appends the tooltip to a specific element. Example: container: 'trunk'. This option is particularly useful in that information technology allows you to position the tooltip in the flow of the document virtually the triggering element - which will prevent 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 blazon

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

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

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

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

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

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

Base of operations HTML to use when creating the tooltip.

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

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

The outermost wrapper element should accept the .tooltip course.

title string | function ''

Default title value if title attribute isn't nowadays.

If a function is given, it will be called with its this reference set 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; separate them with a space. transmission cannot be combined with any other trigger.
viewport string | object | function { selector: 'torso', padding: 0 }

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

If a function is given, it is called with the triggering element DOM node every bit its only statement. The this context is set up to the tooltip instance.

Methods

$().tooltip(options)

Attaches a tooltip handler to an chemical element collection.

.tooltip('show')

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

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

.tooltip('hide')

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

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

.tooltip('toggle')

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

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

.tooltip('destroy')

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

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

Events

Result Type Description
show.bs.tooltip This upshot fires immediately when the show example method is chosen.
shown.bs.tooltip This event is fired when the tooltip has been made visible to the user (will await for CSS transitions to complete).
hide.bs.tooltip This consequence is fired immediately when the hide instance method has been called.
hidden.bs.tooltip This event is fired when the tooltip has finished existence subconscious from the user (will wait for CSS transitions to complete).
inserted.bs.tooltip This event is fired after the show.bs.tooltip outcome when the tooltip template has been added to the DOM.
                              $                (                '#myTooltip'                ).                on                (                'hidden.bs.tooltip'                ,                part                ()                {                // do something…                })                          

Add pocket-sized overlays of content, like those on the iPad, to whatsoever element for housing secondary data.

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

Opt-in functionality

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

One way to initialize all popovers on a folio would exist to select them by their data-toggle attribute:

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

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

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

Popovers on disabled elements require wrapper elements

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

Examples

Static popover

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

Popover peak

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

Popover bottom

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

Popover left

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

Live demo

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

4 directions

                              <button                type=                "button"                grade=                "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>                <push button                type=                "push button"                class=                "btn btn-default"                data-container=                "body"                data-toggle=                "popover"                data-placement=                "top"                information-content=                "Vivamus sagittis lacus vel augue laoreet rutrum faucibus."                >                Popover on top                </button>                <button                blazon=                "push button"                class=                "btn btn-default"                data-container=                "body"                information-toggle=                "popover"                data-placement=                "bottom"                data-content=                "Vivamus sagittis lacus vel augue laoreet rutrum faucibus."                >                Popover on bottom                </button>                <push button                type=                "button"                grade=                "btn btn-default"                data-container=                "body"                data-toggle=                "popover"                data-placement=                "right"                information-content=                "Vivamus sagittis lacus vel augue laoreet rutrum faucibus."                >                Popover on right                </button>                          

Dismiss on next click

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

Specific markup required for dismiss-on-next-click

For proper cross-browser and cross-platform beliefs, you must apply the <a> tag, not the <button> tag, and yous also must include the function="push button" and tabindex attributes.

                              <a                tabindex=                "0"                grade=                "btn btn-lg btn-danger"                function=                "push"                data-toggle=                "popover"                data-trigger=                "focus"                title=                "Dismissible popover"                data-content=                "And hither'due south some amazing content. It'south very engaging. Right?"                >Dismissible popover</a>                          

Usage

Enable popovers via JavaScript:

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

Options

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

Proper noun Type Default Description
animation boolean true Utilize a CSS fade transition to the popover
container cord | false false

Appends the popover to a specific element. Example: container: 'torso'. This option is especially useful in that information technology allows you lot to position the popover in the flow of the certificate almost the triggering element - which will foreclose the popover from floating abroad from the triggering element during a window resize.

content string | office ''

Default content value if data-content attribute isn't nowadays.

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

delay number | object 0

Delay showing and hiding the popover (ms) - does non apply to transmission trigger type

If a number is supplied, filibuster is applied to both hide/show

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

html boolean false Insert HTML into the popover. If simulated, jQuery'due south text method volition be used to insert content into the DOM. Use text if you're worried about XSS attacks.
placement string | function 'right'

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

When a function is used to determine the placement, information technology is called with the popover DOM node every bit its first argument and the triggering element DOM node as its second. The this context is set to the popover instance.

selector string 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 example.
template string '<div class="popover" part="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'

Base HTML to use when creating the popover.

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

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

.arrow volition get the popover's pointer.

The outermost wrapper element should have the .popover class.

title string | office ''

Default title value if title attribute isn't nowadays.

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

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

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

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

Information attributes for private popovers

Options for individual popovers can alternatively exist specified through the utilize of data attributes, as explained to a higher place.

Methods

$().popover(options)

Initializes popovers for an chemical element collection.

.popover('bear witness')

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

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

.popover('hide')

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

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

.popover('toggle')

Toggles an element'due south popover. Returns to the caller earlier the popover has actually been shown or hidden (i.due east. before the shown.bs.popover or hidden.bs.popover event occurs). This is considered a "manual" triggering of the popover.

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

.popover('destroy')

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

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

Events

Event Type Description
show.bs.popover This upshot fires immediately when the show instance method is called.
shown.bs.popover This event is fired when the popover has been fabricated visible to the user (will look for CSS transitions to complete).
hibernate.bs.popover This event is fired immediately when the hibernate instance method has been called.
hidden.bs.popover This consequence is fired when the popover has finished being hidden from the user (volition wait for CSS transitions to complete).
inserted.bs.popover This upshot is fired after the prove.bs.popover event when the popover template has been added to the DOM.
                              $                (                '#myPopover'                ).                on                (                'subconscious.bs.popover'                ,                office                ()                {                // do something…                })                          

Example alerts

Add dismiss functionality to all alert messages with this plugin.

When using a .close button, it must exist the get-go child of the .warning-dismissible and no text content may come before it in the markup.

Usage

But add data-dismiss="alarm" to your shut button to automatically give an alert shut functionality. Closing an warning removes it from the DOM.

                              <push                type=                "push"                grade=                "shut"                data-dismiss=                "alarm"                aria-characterization=                "Shut"                >                <span                aria-subconscious=                "true"                >                &times;                </span>                </push>                          

To have your alerts use blitheness when closing, make sure 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 data-dismiss="alert" aspect. (Non necessary when using the data-api's motorcar-initialization.)

$().alert('shut')

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

Events

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

Event Blazon Description
close.bs.alert This event fires immediately when the close instance method is called.
airtight.bs.warning This event is fired when the alert has been closed (volition wait for CSS transitions to consummate).
                              $                (                '#myAlert'                ).                on                (                'closed.bs.alert'                ,                function                ()                {                // exercise something…                })                          

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

Stateful

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

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

Apply whichever state y'all like!

For the sake of this demonstration, nosotros are using data-loading-text and $().button('loading'), but that's non the only state you can apply. Meet more on this beneath in the $().push(cord) documentation.

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

Single toggle

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

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

For pre-toggled buttons, y'all must add together the .active class and the aria-pressed="true" attribute to the button yourself.

                              <button                type=                "button"                class=                "btn btn-primary"                information-toggle=                "button"                aria-pressed=                "false"                autocomplete=                "off"                >                Unmarried toggle                </push button>                          

Checkbox / Radio

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

Preselected options need .agile

For preselected options, you must add the .active grade to the input's characterization yourself.

Visual checked country merely updated on click

If the checked state of a checkbox button is updated without firing a click event on the button (e.k. via <input type="reset"> or via setting the checked belongings of the input), you will need to toggle the .active class on the input's label yourself.

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

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

Methods

$().button('toggle')

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

$().push('reset')

Resets push land - swaps text to original text. This method is asynchronous and returns before the resetting has really completed.

$().button(string)

Swaps text to any data divers text state.

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

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

Plugin dependency

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

Example

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

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

You can utilise a link with the href attribute, or a push with the information-target attribute. In both cases, the information-toggle="plummet" is required.

Link with href

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

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

Accordion example

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

Collapsible Group Item #ane

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

Collapsible Group Detail #two

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

Collapsible Group Particular #3

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

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

It's likewise possible to swap out .console-bodys with .list-groups.

Collapsible list group

  • Bootply
  • 1 itmus ac facilin
  • 2nd eros

Make expand/collapse controls attainable

Exist sure to add aria-expanded to the control element. This aspect explicitly defines the current state of the collapsible element to screen readers and similar assistive technologies. If the collapsible element is closed by default, it should accept a value of aria-expanded="false". If you've set the collapsible element to exist open by default using the in form, prepare aria-expanded="true" on the control instead. The plugin will automatically toggle this attribute based on whether or non the collapsible chemical element has been opened or closed.

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

Usage

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

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

These classes tin can be constitute in component-animations.less.

Via data attributes

Just add together data-toggle="collapse" and a data-target to the element to automatically assign command of a collapsible chemical element. The data-target attribute accepts a CSS selector to employ the collapse to. Exist sure to add together the grade collapse to the collapsible chemical element. If you'd like information technology to default open up, add the additional class in.

To add squeeze box-like group direction to a collapsible control, add together the data attribute data-parent="#selector". Refer to the demo to come across this in activity.

Via JavaScript

Enable manually with:

                              $                (                '.collapse'                ).                plummet                ()                          

Options

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

Proper noun blazon default clarification
parent selector false If a selector is provided, then all collapsible elements under the specified parent will be closed when this collapsible particular is shown. (like to traditional piano accordion beliefs - this is dependent on the console class)
toggle boolean true Toggles the collapsible element on invocation

Methods

.collapse(options)

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

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

.collapse('toggle')

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

.collapse('evidence')

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

.collapse('hide')

Hides a collapsible element. Returns to the caller earlier the collapsible element has actually been subconscious (i.eastward. before the hidden.bs.collapse event occurs).

Events

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

Event Blazon Description
testify.bs.collapse This result fires immediately when the evidence instance method is called.
shown.bs.plummet This event is fired when a collapse element has been made visible to the user (volition wait for CSS transitions to complete).
hide.bs.collapse This event is fired immediately when the hide method has been called.
subconscious.bs.plummet This event is fired when a collapse chemical element has been hidden from the user (will wait for CSS transitions to complete).
                              $                (                '#myCollapsible'                ).                on                (                'hidden.bs.collapse'                ,                role                ()                {                // do something…                })                          

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

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

Optional captions

Add captions to your slides easily with the .carousel-explanation chemical element within any .detail. Place just about whatever optional HTML inside there and it will exist automatically aligned and formatted.

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

Multiple carousels

Carousels require the apply of an id on the outermost container (the .carousel) for carousel controls to function properly. When calculation multiple carousels, or when irresolute a carousel'southward id, be sure to update the relevant controls.

Via data attributes

Utilise data attributes to easily control the position of the carousel. information-slide accepts the keywords prev or side by side, which alters the slide position relative to its current position. Alternatively, apply data-slide-to to laissez passer a raw slide index to the carousel data-slide-to="2", which shifts the slide position to a particular index beginning with 0.

The data-ride="carousel" attribute is used to mark a carousel as animative starting at page load. It cannot exist used in combination with (redundant and unnecessary) explicit JavaScript initialization of the same carousel.

Via JavaScript

Phone call carousel manually with:

                              $                (                '.carousel'                ).                carousel                ()                          

Options can exist passed via data attributes or JavaScript. For data attributes, append the option name to data-, every bit 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 non automatically cycle.
pause cord | zip "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 to zilch, hovering over the carousel won't break it.
wrap boolean true Whether the carousel should cycle continuously or take hard stops.
keyboard boolean truthful 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('bicycle')

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 particular frame (0 based, similar to an array).

.carousel('prev')

Cycles to the previous detail.

.carousel('adjacent')

Cycles to the side by side item.

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

Both events take the post-obit additional properties:

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

All carousel events are fired at the carousel itself (i.due east. at the <div grade="carousel">).

Upshot Type Description
slide.bs.carousel This consequence 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                ()                {                // do something…                })                          

Example

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


Usage

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

Annotation: Exercise non use the braze plugin on an element contained in a relatively positioned element, such as a pulled or pushed cavalcade, due to a Safari rendering bug.

Positioning via CSS

The braze plugin toggles between iii classes, each representing a detail country: .affix, .affix-meridian, and .affix-bottom. You must provide the styles, with the exception of position: fixed; on .affix, for these classes yourself (independent of this plugin) to handle the bodily positions.

Here'south how the braze plugin works:

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

Follow the higher up steps to set your CSS for either of the usage options beneath.

Via data attributes

To hands add braze beliefs to any chemical element, just add data-spy="affix" to the element y'all want to spy on. Employ offsets to ascertain when to toggle the pinning of an chemical element.

                              <div                data-spy=                "braze"                data-offset-top=                "60"                data-beginning-lesser=                "200"                >                ...                </div>                          

Via JavaScript

Call the braze plugin via JavaScript:

                              $                (                '#myAffix'                ).                affix                ({                beginning                :                {                top                :                100                ,                lesser                :                part                ()                {                render                (                this                .                bottom                =                $                (                '.footer'                ).                outerHeight                (                true                ))                }                }                })                          

Options

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

Proper name type default description
starting time number | function | object x Pixels to showtime from screen when calculating position of scroll. If a single number is provided, the get-go will be applied in both top and bottom directions. To provide a unique, bottom and top offset only provide an object commencement: { top: 10 } or offset: { top: 10, lesser: 5 }. Utilize a part when yous demand to dynamically calculate an start.
target selector | node | jQuery element the window object Specifies the target element of the affix.

Methods

.affix(options)

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

                              $                (                '#myAffix'                ).                affix                ({                offset                :                15                })                          

.affix('checkPosition')

Recalculates the country of the affix based on the dimensions, position, and scroll position of the relevant elements. The .affix, .braze-top, and .braze-lesser classes are added to or removed from the affixed content according to the new state. This method needs to be chosen whenever the dimensions of the affixed content or the target element are changed, to ensure correct positioning of the affixed content.

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

Events

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

Event Blazon Clarification
affix.bs.affix This consequence fires immediately before the element has been affixed.
affixed.bs.affix This event is fired subsequently the chemical element has been affixed.
affix-peak.bs.braze This effect fires immediately before the chemical element has been affixed-top.
affixed-height.bs.affix This effect is fired after the element has been affixed-top.
affix-bottom.bs.braze This event fires immediately before the chemical element has been affixed-lesser.
affixed-bottom.bs.affix This event is fired subsequently the chemical element has been affixed-bottom.