--- layout: default title: Bootstrap Documentation ---

Welcome

Welcome to the Bootstrap documentation, the living, interactive style and code guide for all things Bootstrap. If you're new here, continue reading to learn how to get started. Otherwise, carry on you beautiful person you.

There are a few easy ways to quickly get started with Bootstrap, each one appealing to a different skill level and use case. Read through to see what suits your particular needs.

Download compiled CSS and JS

The fastest way to get started is to get the compiled and minified versions of our CSS, JavaScript, and fonts. No documentation or original source files are included.

Download Bootstrap


More download options

Download latest source code

Get the original files for all CSS and JavaScript by downloading the latest version directly from GitHub.

Clone or fork via GitHub

Clone the entire project or fork your own version of Bootstrap to make it your own by visiting us on GitHub.

Install with Bower

Install and manage the original files for all CSS and JavaScript, along with a local copy of the docs, using Bower.

{% highlight bash %}$ bower install bootstrap{% endhighlight %}

Use the Bootstrap CDN

The folks over at NetDNA have graciously provided CDN support for Bootstrap's CSS and JavaScript. To use, swap your local instances for the Bootstrap CDN links listed below.

{% highlight html linenos %} {% endhighlight %}

Within the download you'll find the following directories and files, logically grouping common assets and providing both compiled and minified variations.

Once downloaded, unzip the compressed folder to see the structure of (the compiled) Bootstrap. You'll see something like this:

{% highlight bash %} bootstrap/ ├── css/ │ ├── bootstrap.css │ ├── bootstrap.min.css ├── js/ │ ├── bootstrap.js │ ├── bootstrap.min.js └── fonts/ ├── glyphiconshalflings-regular.eot ├── glyphiconshalflings-regular.otf ├── glyphiconshalflings-regular.svg ├── glyphiconshalflings-regular.ttf └── glyphiconshalflings-regular.woff {% endhighlight %}

This is the most basic form of Bootstrap: compiled files for quick drop-in usage in nearly any web project. We provide compiled CSS and JS (bootstrap.*), as well as compiled and minified CSS and JS (bootstrap.min.*). The image files are compressed using ImageOptim, a Mac app for compressing PNGs.

jQuery required

Please note that all JavaScript plugins require jQuery to be included, as shown in the starter template.

Make use of a super basic HTML template, or dive into a few examples we've started for you. We encourage folks to iterate on these examples and not simply use them as an end result.

HTML template

Copy and paste the HTML from below to get started with a bare bones Bootstrap document.

{% highlight html %} Bootstrap 101 Template

Hello, world!

{% endhighlight %}

Examples

Starter template

A barebones HTML page with Bootstrap's CSS and JavaScript included.

Basic grid layouts

Simple grid layouts to familiarize you with using the Bootstrap grid system.

Basic marketing site

Features a jumbotron for primary message and three supporting elements.

Narrow marketing

Slim, lightweight marketing template for small projects or teams.

Justified nav

Marketing page with equal-width navigation links in a modified navbar.

Sign in

Barebones sign in form with custom, larger form controls and a flexible layout.

Sticky footer

Pin a fixed-height footer to the bottom of the user's viewport.

Sticky footer w/ navbar

Add a fixed navbar to the default sticky footer template.

Carousel jumbotron

An interactive riff on the basic marketing site featuring a prominent carousel.

Navbar

Basic template for showcasing how the navbar works.

Static top navbar

Basic template for showcasing the static navbar variation.

Fixed top navbar

Basic template for showcasing the fixed navbar variation.

Customizing Bootstrap is best accomplished when you treat it as another dependency in your development stack. Doing so ensures future upgrades are as easy as possible while also familiarizing yourself to the intricacies of the framework.

Once you've downloaded and included Bootstrap's CSS into your templates, you can move on to customizing the included components. To do so, create a new stylesheet (LESS, if you like, or just plain CSS) to house your customizations.

Compiled or minified?

Unless you plan on reading a good chunk of the compiled CSS, go with the minified. It's the same code, just compacted. Less bandwidth is good, especially in production environments.

From there, include whatever Bootstrap components and HTML content you need to get your template setup. It's best to have a rough idea in mind of modifications to make and content to include, so be sure to spend a brief amount of time on that before moving on.

Customizing components

There are varying degrees to customizing components, but most fall into two camps: light customizations and complete visual overhauls. Luckily, there are plenty of examples of both.

We define light customizations as mostly surface layer changes, things like a color and font changes to existing Bootstrap components. A great example of this is the the Twitter Translation Center (coded by @mdo). Let's look at how to implement the custom button we wrote for this site, .btn-ttc.

Instead of using the provided Bootstrap buttons, which only require just one class to start, .btn, we'll add our own modifier class, .btn-ttc. This will give us a slightly custom look with minimal effort.

{% highlight html %} {% endhighlight %}

In the custom stylesheet, add the following CSS:

{% highlight css %} /* Custom button -------------------------------------------------- */ /* Override base .btn styles */ /* Apply text and background changes to three key states: default, hover, and active (click). */ .btn-ttc, .btn-ttc:hover, .btn-ttc:active { color: white; text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); background-color: #007da7; } /* Apply the custom-colored gradients */ /* Note: you'll need to include all the appropriate gradients for various browsers and standards. */ .btn-ttc { background-repeat: repeat-x; background-image: linear-gradient(top, #009ED2 0%, #007DA7 100%); ... } /* Set the hover state */ /* An easy hover state is just to move the gradient up a small amount. Add other embellishments as you see fit. */ .btn-ttc:hover { background-position: 0 -15px; } {% endhighlight %}

Customizing Bootstrap components takes time, but should be straightforward. Look to the source code often and duplicate the selectors you need for your modifications. Placing them after the Bootstrap source makes for easy overriding without complication. To recap, here's the basic workflow:

Going beyond light customizations and into visual overhauls is just as straightforward as the above custom button. For a site like Karma, which uses Bootstrap as a CSS reset with heavy modifications, more extensive work is involved, but well worth it in the end.

Alternate customization methods

While not recommended for folks new to Bootstrap, you may use one of two alternate methods for customization. The first is modifying the source .less files (making upgrades super difficult), and the second is mapping source LESS code to your own classes via mixins. For the time being, neither options are documented here.

Removing potential bloat

Not all sites and applications need to make use of everything Bootstrap has to offer, especially in production environments where bandwidth literally becomes a financial issue. We encourage folks to remove whatever is unused with our Customizer.

Using the Customizer, simply uncheck any component, feature, or asset you don't need. Hit download and swap out the default Bootstrap files with these newly customized ones. You'll get vanilla Bootstrap, but without the features *you* deem unnecessary. All custom builds include compiled and minified versions, so use whichever works for you.

CSS

Fundamental HTML elements styled and enhanced with extensible classes.

Get the lowdown on the key pieces of Bootstrap's infrastructure, including our approach to better, faster, stronger web development.

HTML5 doctype required

Bootstrap makes use of certain HTML elements and CSS properties that require the use of the HTML5 doctype. Include it at the beginning of all your projects.

{% highlight html %} ... {% endhighlight %}

Mobile first

With Bootstrap 2, we added optional mobile friendly styles for key aspects of the framework. With Bootstrap 3, we've rewritten the project to be mobile friendly from the start. Instead of adding on optional mobile styles, they're baked right into the core. In fact, Bootstrap is mobile first. Mobile first styles can be found throughout the entire library instead of in separate files.

To ensure proper rendering and touch zooming, add the viewport meta tag to your <head>.

{% highlight html %} {% endhighlight %}

Responsive images

We automatically attempt to scale images to appropriate sizes with a global max-width: 100%; on all <img> elements. If you run into problems (e.g., with Google Maps), be sure to disable this property on a per-case basis.

Typography and links

Bootstrap sets basic global display, typography, and link styles. Specifically, we:

These styles can be found within scaffolding.less.

Normalize reset

For improved cross-browser rendering, we use Normalize, a project by Nicolas Gallagher and Jonathan Neal.

Bootstrap includes a responsive, percent-based grid system that appropriately scales up to 12 columns as the device or viewport size increases—in other words, it's mobile first. It includes predefined classes for this, as well as powerful mixins for generating semantic layouts.

Grid example

On mobile devices, the grid starts out stacked. Above 768px, it becomes horizontal as media queries kick in to apply floats and widths. To create a basic grid layout, wrap a series of .col-span-* elements within a .row. As this is a 12-column grid, each .col-span-* spans a number of those 12 columns, and should always add up to 12 for each row (or the number of columns in the parent), even at mobile resolutions.

1
1
1
1
1
1
1
1
1
1
1
1
4
4
4
6
6
{% highlight html %}
1
1
1
1
1
1
1
1
1
1
1
1
4
4
4
6
6
{% endhighlight %}

Offsetting columns

Move columns to the right using .col-offset-* classes. These classes increase the left margin of a column by * columns. For example, .col-offset-4 moves .col col-lg-4 over four columns.

4
4 offset 4
3 offset 3
3 offset 3
6 offset 3
{% highlight html %}
...
...
3 offset 3
3 offset 3
...
{% endhighlight %}

Nesting columns

To nest your content with the default grid, add a new .row and set of .col-span-* columns within an existing .col-span-* column. Nested rows should include a set of columns that add up to 12.

Level 1: 9 columns
Level 2: 6 columns
Level 2: 6 columns
{% highlight html %}
Level 1: 9 columns
Level 2: 6 columns
Level 2: 6 columns
{% endhighlight %}

Column ordering

Easily change the order of our built-in grid columns with .col-push-* and .col-pull-* modifier classes.

9
3
{% highlight html %}
9
3
{% endhighlight %}

Small device grid

Use the small device grid classes, like .col-sm-6, to create columned layouts on phone and tablet devices (anything under 768px). Offsets, pushes, and pulls are not available with the small grid at this time.

4 cols, 6 small cols
4 cols, 6 small cols
4 cols, 12 small cols
{% highlight html %}
4 cols, 6 small cols
4 cols, 6 small cols
4 cols, 12 small cols
{% endhighlight %}

LESS mixins and variables

In addition to prebuilt grid classes for fast layouts, Bootstrap includes LESS variables and mixins for quickly generating your own simple, semantic layouts.

Variables

Variables determine the number of columns, the gutter width, and the media query point at which to begin floating columns. We use these to generate the predefined grid classes documented above, as well as for the custom mixins listed below.

{% highlight css %} @grid-columns: 12; @grid-gutter-width: 30px; @grid-float-breakpoint: 768px; {% endhighlight %}

Mixins

Mixins are used in conjunction with the grid variables to generate semantic CSS for individual grid columns.

{% highlight css %} // Creates a wrapper for a series of columns .make-row() { // Negative margin the row out to align the content of columns margin-left: (@grid-gutter-width / -2); margin-right: (@grid-gutter-width / -2); // Then clear the floated columns .clearfix(); } // Generate the columns .make-column(@columns) { @media (min-width: @grid-float-breakpoint) { float: left; // Calculate width based on number of columns available width: percentage(@columns / @grid-columns); } // Prevent columns from collapsing when empty min-height: 1px; // Set inner padding as gutters instead of margin padding-left: (@grid-gutter-width / 2); padding-right: (@grid-gutter-width / 2); } // Generate the column offsets .make-column-offset(@columns) { @media (min-width: @grid-float-breakpoint) { margin-left: percentage((@columns / @grid-columns)); } } {% endhighlight %}

Example usage

You can modify the variables to your own custom values, or just use the mixins with their default values. Here's an example of using the default settings to create a two-column layout with a gap between.

{% highlight css %} .wrapper { .make-row(); } .content-main { .make-column(8); } .content-secondary { .make-column(3); .make-column-offset(1); } {% endhighlight %} {% highlight html %}
...
...
{% endhighlight %}

Headings

All HTML headings, <h1> through <h6> are available.

Bootstrap heading

Semibold 38px

Bootstrap heading

Semibold 32px

Bootstrap heading

Semibold 24px

Bootstrap heading

Semibold 18px
Bootstrap heading
Semibold 16px
Bootstrap heading
Semibold 12px
{% highlight html %}

...

...

...

...

...
...
{% endhighlight %}

Body copy

Bootstrap's global default font-size is 14px, with a line-height of 20px. This is applied to the <body> and all paragraphs. In addition, <p> (paragraphs) receive a bottom margin of half their line-height (10px by default).

Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam id dolor id nibh ultricies vehicula.

Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec ullamcorper nulla non metus auctor fringilla. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Donec ullamcorper nulla non metus auctor fringilla.

Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.

{% highlight html %}

...

{% endhighlight %}

Lead body copy

Make a paragraph stand out by adding .lead.

Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Duis mollis, est non commodo luctus.

{% highlight html %}

...

{% endhighlight %}

Built with Less

The typographic scale is based on two LESS variables in variables.less: @font-size-base and @line-height-base. The first is the base font-size used throughout and the second is the base line-height. We use those variables and some simple math to create the margins, paddings, and line-heights of all our type and more. Customize them and Bootstrap adapts.

Emphasis

Make use of HTML's default emphasis tags with lightweight styles.

Small text

For de-emphasizing inline or blocks of text, use the <small> tag to set text at 85% the size of the parent. Heading elements receive their own font-size for nested <small> elements.

This line of text is meant to be treated as fine print.

{% highlight html %} This line of text is meant to be treated as fine print. {% endhighlight %}

Bold

For emphasizing a snippet of text with a heavier font-weight.

The following snippet of text is rendered as bold text.

{% highlight html %} rendered as bold text {% endhighlight %}

Italics

For emphasizing a snippet of text with italics.

The following snippet of text is rendered as italicized text.

{% highlight html %} rendered as italicized text {% endhighlight %}

Feel free to use <b> and <i> in HTML5. <b> is meant to highlight words or phrases without conveying additional importance while <i> is mostly for voice, technical terms, etc.

Alignment classes

Easily realign text to components with text alignment classes.

Left aligned text.

Center aligned text.

Right aligned text.

{% highlight html %}

Left aligned text.

Center aligned text.

Right aligned text.

{% endhighlight %}

Emphasis classes

Convey meaning through color with a handful of emphasis utility classes.

Fusce dapibus, tellus ac cursus commodo, tortor mauris nibh.

Etiam porta sem malesuada magna mollis euismod.

Donec ullamcorper nulla non metus auctor fringilla.

Duis mollis, est non commodo luctus, nisi erat porttitor ligula.

{% highlight html %}

...

...

...

...

{% endhighlight %}

Abbreviations

Stylized implementation of HTML's <abbr> element for abbreviations and acronyms to show the expanded version on hover. Abbreviations with a title attribute have a light dotted bottom border and a help cursor on hover, providing additional context on hover.

Basic abbreviation

For expanded text on long hover of an abbreviation, include the title attribute with the <abbr> element.

An abbreviation of the word attribute is attr.

{% highlight html %} attr {% endhighlight %}

Initialism

Add .initialism to an abbreviation for a slightly smaller font-size.

HTML is the best thing since sliced bread.

{% highlight html %} HTML {% endhighlight %}

Addresses

Present contact information for the nearest ancestor or the entire body of work. Preserve formatting by ending all lines with <br>.

Twitter, Inc.
795 Folsom Ave, Suite 600
San Francisco, CA 94107
P: (123) 456-7890
Full Name
first.last@example.com
{% highlight html %}
Twitter, Inc.
795 Folsom Ave, Suite 600
San Francisco, CA 94107
P: (123) 456-7890
Full Name
first.last@example.com
{% endhighlight %}

Blockquotes

For quoting blocks of content from another source within your document.

Default blockquote

Wrap <blockquote> around any HTML as the quote. For straight quotes we recommend a <p>.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.

{% highlight html %}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.

{% endhighlight %}

Blockquote options

Style and content changes for simple variations on a standard blockquote.

Naming a source

Add <small> tag for identifying the source. Wrap the name of the source work in <cite>.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.

Someone famous in Source Title
{% highlight html %}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.

Someone famous Source Title
{% endhighlight %}

Alternate displays

Use .pull-right for a floated, right-aligned blockquote.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.

Someone famous in Source Title
{% highlight html %}
...
{% endhighlight %}

Lists

Unordered

A list of items in which the order does not explicitly matter.

  • Lorem ipsum dolor sit amet
  • Consectetur adipiscing elit
  • Integer molestie lorem at massa
  • Facilisis in pretium nisl aliquet
  • Nulla volutpat aliquam velit
    • Phasellus iaculis neque
    • Purus sodales ultricies
    • Vestibulum laoreet porttitor sem
    • Ac tristique libero volutpat at
  • Faucibus porta lacus fringilla vel
  • Aenean sit amet erat nunc
  • Eget porttitor lorem
{% highlight html %} {% endhighlight %}

Ordered

A list of items in which the order does explicitly matter.

  1. Lorem ipsum dolor sit amet
  2. Consectetur adipiscing elit
  3. Integer molestie lorem at massa
  4. Facilisis in pretium nisl aliquet
  5. Nulla volutpat aliquam velit
  6. Faucibus porta lacus fringilla vel
  7. Aenean sit amet erat nunc
  8. Eget porttitor lorem
{% highlight html %}
  1. ...
{% endhighlight %}

Unstyled

Remove the default list-style and left margin on list items (immediate children only). This only applies to immediate children list items, meaning you will need to add the class for any nested lists as well.

  • Lorem ipsum dolor sit amet
  • Consectetur adipiscing elit
  • Integer molestie lorem at massa
  • Facilisis in pretium nisl aliquet
  • Nulla volutpat aliquam velit
    • Phasellus iaculis neque
    • Purus sodales ultricies
    • Vestibulum laoreet porttitor sem
    • Ac tristique libero volutpat at
  • Faucibus porta lacus fringilla vel
  • Aenean sit amet erat nunc
  • Eget porttitor lorem
{% highlight html %} {% endhighlight %}

Inline

Place all list items on a single line with inline-block and some light padding.

  • Lorem ipsum
  • Phasellus iaculis
  • Nulla volutpat
{% highlight html %} {% endhighlight %}

Description

A list of terms with their associated descriptions.

Description lists
A description list is perfect for defining terms.
Euismod
Vestibulum id ligula porta felis euismod semper eget lacinia odio sem nec elit.
Donec id elit non mi porta gravida at eget metus.
Malesuada porta
Etiam porta sem malesuada magna mollis euismod.
{% highlight html %}
...
...
{% endhighlight %}

Horizontal description

Make terms and descriptions in <dl> line up side-by-side.

Description lists
A description list is perfect for defining terms.
Euismod
Vestibulum id ligula porta felis euismod semper eget lacinia odio sem nec elit.
Donec id elit non mi porta gravida at eget metus.
Malesuada porta
Etiam porta sem malesuada magna mollis euismod.
Felis euismod semper eget lacinia
Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.
{% highlight html %}
...
...
{% endhighlight %}
Auto-truncating

Horizontal description lists will truncate terms that are too long to fit in the left column fix text-overflow. In narrower viewports, they will change to the default stacked layout.

Inline

Wrap inline snippets of code with <code>.

For example, <section> should be wrapped as inline.
{% highlight html %} For example, <section> should be wrapped as inline. {% endhighlight %}

Basic block

Use <pre> for multiple lines of code. Be sure to escape any angle brackets in the code for proper rendering.

<p>Sample text here...</p>
{% highlight html %}
<p>Sample text here...</p>
{% endhighlight %}

You may optionally add the .pre-scrollable class which will set a max-height of 350px and provide a y-axis scrollbar.

Basic example

For basic styling—light padding and only horizontal dividers—add the base class .table to any <table>. It may seem super redundant, but given the widespread use of tables for other plugins like calendars and date pickers, we've opted to isolate our custom table styles.

# First Name Last Name Username
1 Mark Otto @mdo
2 Jacob Thornton @fat
3 Larry the Bird @twitter
{% highlight html %} ...
{% endhighlight %}

Optional classes

Add any of the following classes to the .table base class.

Striped

Use .table-striped to add zebra-striping to any table row within the <tbody>.

Cross-browser compatibility

Striped tables are styled via the :nth-child CSS selector, which is not available in IE8.

# First Name Last Name Username
1 Mark Otto @mdo
2 Jacob Thornton @fat
3 Larry the Bird @twitter
{% highlight html %} ...
{% endhighlight %}

Bordered

Add .table-bordered for borders and rounded corners.

# First Name Last Name Username
1 Mark Otto @mdo
Mark Otto @TwBootstrap
2 Jacob Thornton @fat
3 Larry the Bird @twitter
{% highlight html %} ...
{% endhighlight %}

Hover rows

Add .table-hover to enable a hover state on table rows within a <tbody>.

# First Name Last Name Username
1 Mark Otto @mdo
2 Jacob Thornton @fat
3 Larry the Bird @twitter
{% highlight html %} ...
{% endhighlight %}

Condensed

Add .table-condensed to make tables more compact by cutting cell padding in half.

# First Name Last Name Username
1 Mark Otto @mdo
2 Jacob Thornton @fat
3 Larry the Bird @twitter
{% highlight html %} ...
{% endhighlight %}

Optional row classes

Use contextual classes to color table rows.

Class Description
.success Indicates a successful or positive action.
.danger Indicates a dangerous or potentially negative action.
.warning Indicates a warning that might need attention.
.info Used as an alternative to the default styles.
# Product Payment Taken Status
1 TB - Monthly 01/04/2012 Approved
2 TB - Monthly 02/04/2012 Declined
3 TB - Monthly 03/04/2012 Pending
{% highlight html %} ... 1 TB - Monthly 01/04/2012 Approved ... {% endhighlight %}

Basic example

Individual form controls automatically receive some global styling. By default, inputs are set to width: 100%;.

Legend

Example block-level help text here.

{% highlight html %}
Legend

Example block-level help text here.

{% endhighlight %}

Optional layouts

Included with Bootstrap are optional form layouts for common use cases.

Inline form

Add .form-inline for left-aligned and inline-block controls for a compact layout.

Requires custom widths

Inputs, selects, and textareas are 100% wide by default in Bootstrap. To use the inline form, you'll have to set a width on the form controls used within.

{% highlight html %}
{% endhighlight %}

Horizontal form

Right align labels and float them to the left to make them appear on the same line as controls. Requires the most markup changes from a default form:

{% highlight html %}
{% endhighlight %}

Supported form controls

Examples of standard form controls supported in an example form layout.

Inputs

Most common form control, text-based input fields. Includes support for all HTML5 types: text, password, datetime, datetime-local, date, month, time, week, number, email, url, search, tel, and color.

Type declaration required

Inputs will only be fully styled if their type is properly declared.

{% highlight html %} {% endhighlight %}

Textarea

Form control which supports multiple lines of text. Change rows attribute as necessary.

{% highlight html %} {% endhighlight %}

Checkboxes and radios

Checkboxes are for selecting one or several options in a list while radios are for selecting one option from many.

Default (stacked)


{% highlight html %}
{% endhighlight %}

Inline checkboxes

Use .checkbox-inline or .radio-inline class to a series of checkboxes or radios for controls appear on the same line.

{% highlight html %} {% endhighlight %}

Selects

Use the default option or specify a multiple="multiple" to show multiple options at once.


{% highlight html %} {% endhighlight %}

Form control states

Provide feedback to users or visitors with basic feedback states on form controls and labels.

Input focus

We remove the default outline styles on some form controls and apply a box-shadow in its place for :focus.

{% highlight html %} {% endhighlight %}

Invalid inputs

Style inputs via default browser functionality. Specify a type, add the required attribute if the field is not optional, and (if applicable) specify a pattern.

Cross-browser compatibility

Invalid inputs are styled via the :invalid CSS selector, which is not supported by Internet Explorer 9 and below.

{% highlight html %} {% endhighlight %}

Disabled inputs

Add the disabled attribute on an input to prevent user input and trigger a slightly different look.

{% highlight html %} {% endhighlight %}

Disabled fieldsets

Add the disabled attribute to a <fieldset> to disable all the controls within the <fieldset> at once.

Link functionality of <a> not impacted

This class will only change the appearance of <a class="btn"> buttons, not their functionality. Use custom JavaScript to disable links here.

Cross-browser compatibility

While Bootstrap will apply these styles in all browsers, IE and Safari don't actually support the <disabled> attribute on a <fieldset>. Use custom JavaScript to disable the fieldset in these browsers.

{% highlight html %}
{% endhighlight %}

Validation states

Bootstrap includes validation styles for error, warning, info, and success messages. To use:

Validation styles are applied on a per-input basis. With horizontal forms, the <label class="control-label"> will always be styled.

{% highlight html %}
{% endhighlight %}

Extending form controls

Adding on top of existing browser controls, Bootstrap includes other useful form components.

Input groups

Add text or buttons before, after, or on both sides of any text-based input. Use .input-group with a .add-on to prepend or append elements to an <input>.

Cross-browser compatibility

Avoid using <select> elements here as they cannot be fully styled in WebKit browsers.

@

.00

$ .00
{% highlight html %}
@
.00
$ .00
{% endhighlight %}

Optional sizes

Add the relative form sizing classes to the `.input-group-addon`.

@

@

@
{% highlight html %}
@
@
@
{% endhighlight %}

Buttons instead of text

Buttons in input groups are a bit different and require one extra level of nesting. Instead of .input-group-addon, you'll need to use .input-group-btn to wrap the buttons. This is required due to default browser styles that cannot be overridden.


{% highlight html %}
{% endhighlight %}

Button dropdowns


{% highlight html %} {% endhighlight %}

Segmented dropdown groups


{% highlight html %}
{% endhighlight %}

Control sizing

Use relative sizing classes like .input-large or match your inputs to the grid column sizes using .col-span-* classes.

Relative sizing

Create larger or smaller form controls that match button sizes.

{% highlight html %} {% endhighlight %}

Column sizing

Wrap inputs in grid columns, or any custom parent element, to easily enforce desired widths.

{% highlight html %}
{% endhighlight %}

Form actions

End a form with a group of actions (buttons). When placed within a .form-horizontal, the buttons will automatically indent to line up with the form controls.

{% highlight html %}
{% endhighlight %}

Help text

Inline and block level support for help text that appears around form controls.

Inline help

Inline help text
{% highlight html %} Inline help text {% endhighlight %}

Block help

A longer block of help text that breaks onto a new line and may extend beyond one line.
{% highlight html %} A longer block of help text that breaks onto a new line and may extend beyond one line. {% endhighlight %}

Button options

Use any of the available button classes to quickly create a styled button.

{% highlight html %} {% endhighlight %}

Button sizes

Fancy larger or smaller buttons? Add .btn-large, .btn-small, or .btn-mini for additional sizes.

{% highlight html %}

{% endhighlight %}

Create block level buttons—those that span the full width of a parent— by adding .btn-block.

{% highlight html %} {% endhighlight %}

Disabled state

Make buttons look unclickable by fading them back 50%.

Button element

Add the disabled attribute to <button> buttons.

{% highlight html %} {% endhighlight %}

Cross-browser compatibility

If you add the disabled attribute to a <button>, Internet Explorer 9 and below will render text gray with a nasty text-shadow that we cannot fix.

Anchor element

Add the .disabled class to <a> buttons.

Primary link Link

{% highlight html %} Primary link Link {% endhighlight %}

We use .disabled as a utility class here, similar to the common .active class, so no prefix is required.

Link functionality not impacted

This class will only change the <a>'s appearance, not its functionality. Use custom JavaScript to disable links here.

Using multiple tags

Use the button classes on an <a>, <button>, or <input> element.

Link
{% highlight html %} Link {% endhighlight %}

Cross-browser rendering

As a best practice, we highly recommend using the <button> element whenever possible to ensure matching cross-browser rendering.

Add classes to an <img> element to easily style images in any project.

Cross-browser compatibility

Keep in mind that Internet Explorer 8 lacks support for rounded corners.

{% highlight html %} {% endhighlight %}

Close icon

Use the generic close icon for dismissing content like modals and alerts.

{% highlight html %} {% endhighlight %}

.pull-left

Float an element left

{% highlight html %}
...
{% endhighlight %} {% highlight css %} .pull-left { float: left; } {% endhighlight %}

.pull-right

Float an element right

{% highlight html %}
...
{% endhighlight %} {% highlight css %} .pull-right { float: right; } {% endhighlight %}

.clearfix

Clear the float on any element. Utilizes the micro clearfix as popularized by Nicolas Gallagher.

{% highlight html %}
...
{% endhighlight %} {% highlight css %} // Mixin .clearfix { &:before, &:after { content: " "; display: table; } &:after { clear: both; } } // Usage .element { .clearfix(); } {% endhighlight %}

For faster mobile-friendly development, use these utility classes for showing and hiding content by device via media query. Also included are utility classes for toggling content when printed.

Responsive classes

Class Phones 767px and below Tablets 979px to 768px Desktops Default
.visible-phone Visible
.visible-tablet Visible
.visible-desktop Visible
.hidden-phone Visible Visible
.hidden-tablet Visible Visible
.hidden-desktop Visible Visible

Print classes

Class Browser Print
.visible-print Visible
.hidden-print Visible

When to use

Use on a limited basis and avoid creating entirely different versions of the same site. Instead, use them to complement each device's presentation. Responsive utilities should not be used with tables, and as such are not supported.

Test case

Resize your browser or load on different devices to test the above classes.

Visible on...

Green checkmarks indicate that class is visible in your current viewport.

Hidden on...

Here, green checkmarks indicate that class is hidden in your current viewport.

Components

Dozens of reusable components built to provide iconography, dropdowns, navigation, alerts, popovers, and much more.

Included glyphs

Bootstrap comes with all 160 of Glyphicons Halflings set, all available in font formats for easy coloring, sizing, and placement.

Glyphicons attribution

Glyphicons Halflings are normally not available for free, but an arrangement between Bootstrap and the Glyphicons creator have made this possible at no cost to you as developers. As a thank you, we ask you to include an optional link back to Glyphicons whenever practical.

How to use

Add the appropriate class to any inline element. All icon classes are prefixed with glyphicon- for easy styling. To use, place the following code just about anywhere:

{% highlight html %} {% endhighlight %}

Want to change the icon color? Just change the color of the parent element.

When using beside strings of text, as in buttons or nav links, be sure to leave a space after the icon for proper spacing.

Icon examples

Use them in buttons, button groups for a toolbar, navigation, or prepended form inputs.

Buttons

Button group in a button toolbar
{% highlight html %}
{% endhighlight %}

Accessibility

Keep in mind that using icons without any additional content means the icons are not represented to screen reader users.

Dropdown in a button group
{% highlight html %} {% endhighlight %}
Large button
{% highlight html %} Star {% endhighlight %}
Small button
{% highlight html %} {% endhighlight %}

Navigation

{% highlight html %} {% endhighlight %}

Form fields

{% highlight html %}
{% endhighlight %}

Group a series of buttons together on a single line with the button group. Add on optional JavaScript radio and checkbox style behavior with our buttons plugin.

Basic button group

Wrap a series of buttons with .btn in .btn-group.

{% highlight html %}
{% endhighlight %}

Multiple button groups

Combine sets of <div class="btn-group"> into a <div class="btn-toolbar"> for more complex components.

{% highlight html %}
...
...
...
{% endhighlight %}

Nested button groups

Place buttons groups within button groups when you want dropdown menus mixed with a series of buttons.

Vertical button groups

Make a set of buttons appear vertically stacked rather than horizontally.

{% highlight html %}
...
{% endhighlight %}

Justified button groups

Make a group of buttons stretch at the same size to span the entire width of its parent. This only works with <a> elements as the <button> doesn't pick up these styles.

{% highlight html %}
...
{% endhighlight %}

Use any button to trigger a dropdown menu by placing it within a .btn-group and providing the proper menu markup.

Plugin dependency

Button dropdowns require the dropdown plugin to be included in your version of Bootstrap.

Single button dropdowns

Turn a button into dropdown toggle with some basic markup changes.

{% highlight html %} {% endhighlight %}

Split button dropdowns

Similarly, create split button dropdowns with the same markup changes, only with a separate button.

{% highlight html %} {% endhighlight %}

Works with all button sizes

Button dropdowns work at any size: .btn-large, .btn-small, or .btn-mini.

{% highlight html %}
{% endhighlight %}

Dropup buttons

Trigger dropdown menus above elements by adding .dropup to the parent.

{% highlight html %}
{% endhighlight %}

Example

Example heading New

Example heading New

Example heading New

Example heading New

Example heading New
Example heading New
{% highlight html %}

Example heading New

{% endhighlight %}

Available variations

Add any of the below mentioned modifier classes to change the appearance of a label.

Default Success Warning Danger Info
{% highlight html %} Default Success Warning Danger Info {% endhighlight %}

Easily highlight new or unread items by adding a <span class="badge"> to links, Bootstrap navs, and more.

{% highlight html %} Inbox 42 {% endhighlight %}

Self collapsing

When there are no new or unread items, badges will simply collapse (via CSS's :empty selector) provided no content exists within.

Cross-browser compatibility

Badges won't self collapse in Internet Explorer 8 because it lacks support for the :empty selector.

Adapts to active nav states

Built-in styles are included for placing badges in active states in pill and list navigations.

{% highlight html %} {% endhighlight %}

Jumbotron

A lightweight, flexible component to showcase key content on your site. It works well on marketing and content-heavy sites.

Hello, world!

This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.

Learn more

{% highlight html %}

Hello, world!

...

Learn more

{% endhighlight %}

Page header

A simple shell for an h1 to appropriately space out and segment sections of content on a page. It can utilize the h1's default small element, as well as most other components (with additional styles).

{% highlight html %} {% endhighlight %}

Extend Bootstrap's grid system with the thumbnail component to easily display grids of images, videos, text, and more.

Default thumbnails

By default, Bootstrap's thumbnails are designed to showcase linked images with minimal required markup.

{% highlight html %}
...
{% endhighlight %}

Custom content thumbnails

With a bit of extra markup, it's possible to add any kind of HTML content like headings, paragraphs, or buttons into thumbnails.

Thumbnail label

Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.

Action Action

Thumbnail label

Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.

Action Action

Thumbnail label

Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.

Action Action

{% highlight html %}

Thumbnail label

...

Action Action

{% endhighlight %}

Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages. For inline dismissal, use the alerts jQuery plugin.

Default alert

Wrap any text and an optional dismiss button in .alert for a basic warning alert message. To ensure proper behavior across all devices, be sure to use <button> element with the data-dismiss="alert" data attribute.

Warning! Best check yo self, you're not looking too good.
{% highlight html %}
Warning! Best check yo self, you're not looking too good.
{% endhighlight %}

Block alerts

For longer messages, increase the padding on the top and bottom of the alert wrapper by adding .alert-block.

Warning!

Best check yo self, you're not looking too good. Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

{% highlight html %}

Warning!

...

{% endhighlight %}

Contextual alternatives

Add optional classes to change an alert's connotation.

Oh snap! Change a few things up and try submitting again.
Well done! You successfully read this important alert message.
Heads up! This alert needs your attention, but it's not super important.
{% highlight html %}
...
...
...
{% endhighlight %}

Provide up-to-date feedback on the progress of a workflow or action with simple yet flexible progress bars.

Cross-browser compatibility

Progress bars use CSS3 transitions and animations to achieve some of their effects. These features are not supported in Internet Explorer 9 and below or older versions of Firefox. Opera 12 does not support animations.

Basic

Default progress bar with a vertical gradient.

{% highlight html %}
{% endhighlight %}

Contextual alternatives

Progress bars use some of the same button and alert classes for consistent styles.

{% highlight html %}
{% endhighlight %}

Striped

Uses a gradient to create a striped effect. Not available in IE8.

{% highlight html %}
{% endhighlight %}

Animated

Add .active to .progress-striped to animate the stripes right to left. Not available in all versions of IE.

{% highlight html %}
{% endhighlight %}

Stacked

Place multiple bars into the same .progress to stack them.

{% highlight html %}
{% endhighlight %}

Abstract object styles for building various types of components (like blog comments, Tweets, etc) that feature a left- or right-aligned image alongside textual content.

Default example

The default media allow to float a media object (images, video, audio) to the left or right of a content block.

Media heading

Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.

Media heading

Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.

Media heading

Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
{% highlight html %}

Media heading

...
{% endhighlight %}

Media list

With a bit of extra markup, you can use media inside list (useful for comment threads or articles lists).

  • Media heading

    Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.

    Nested media heading

    Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.

    Nested media heading

    Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.

    Nested media heading

    Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.
  • Media heading

    Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.
{% highlight html %} {% endhighlight %}

List groups are a flexible and powerful component for displaying not only simple lists of elements, but complex ones with custom content.

Basic list group

The most basic list group is simply an unordered list with list items, and the proper classes. Build upon it with the options that follow, or your own CSS as needed.

  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Porta ac consectetur ac
  • Vestibulum at eros
{% highlight html %} {% endhighlight %}

With chevrons

Add Glyphicon chevrons that are automatically moved to the right.

  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
{% highlight html %} {% endhighlight %}

With badges

Add the badges component to any list group item and it will automatically be positioned on the right.

  • 14 Cras justo odio
  • 2 Dapibus ac facilisis in
  • 1 Morbi leo risus
{% highlight html %} {% endhighlight %}

With badges and chevrons

Why not both?

  • 14 Cras justo odio
  • 2 Dapibus ac facilisis in
  • 1 Morbi leo risus
{% highlight html %} {% endhighlight %}

Linked list group

Linkify list group items by using anchor tags instead of list items (that also means a parent <div> instead of an <ul>). No need for individual parents around each element.

{% highlight html %} {% endhighlight %}

Custom content

Add nearly any HTML within, even for linked list groups like the one below.

{% highlight html %} {% endhighlight %}

While not always necessary, sometimes you need to put your DOM in a box. For those situations, try the panel component.

Basic panel

By default, all the .panel does is apply some basic border and padding to contain some content.

Basic panel example
{% highlight html %}
Basic panel example
{% endhighlight %}

Panel with heading

Easily add a heading to your panel with .panel-heading. Use it on a <div> or any heading element (e.g., <h3>).

Panel heading
Panel content
{% highlight html %}
Panel heading
Panel content
{% endhighlight %}

Contextual alternatives

Like other components, easily make a panel more meaningful to a particular context by adding any of the contextual state classes.

Panel heading
Panel content
Panel heading
Panel content
Panel heading
Panel content
Panel heading
Panel content
Panel heading
Panel content
{% highlight html %}
...
...
...
...
...
{% endhighlight %}

With list groups

Easily include full-width list groups within any panel.

Panel heading

Some default panel content here. Nulla vitae elit libero, a pharetra augue. Aenean lacinia bibendum nulla sed consectetur. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Nullam id dolor id nibh ultricies vehicula ut id elit.

  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Porta ac consectetur ac
  • Vestibulum at eros
{% highlight html %}
Panel heading

...

  • Cras justo odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Porta ac consectetur ac
  • Vestibulum at eros
{% endhighlight %}

Default well

Use the well as a simple effect on an element to give it an inset effect.

Look, I'm in a well!
{% highlight html %}
...
{% endhighlight %}

Optional classes

Control padding and rounded corners with two optional modifier classes.

Look, I'm in a well!
{% highlight html %}
...
{% endhighlight %}
Look, I'm in a well!
{% highlight html %}
...
{% endhighlight %}

JavaScript plugins

Bring Bootstrap's components to life with over a dozen custom jQuery plugins. Easily include them all, or one by one.

Individual or compiled

Plugins can be included individually, or all at once. Do not attempt to include both. Both bootstrap.js and bootstrap.min.js contain all plugins in a single file.

Plugin dependencies

Some plugins and CSS components depend on other plugins. If you include plugins individually, make sure to check for these dependencies in the docs (in notes like this one).

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 class 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 also provide the ability to disable the data attribute API by unbinding all events on the body namespaced with `'data-api'`. This looks like this: {% highlight js %} $('body').off('.data-api') {% endhighlight %}

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

{% highlight js %} $('body').off('.alert.data-api') {% endhighlight %}

Programmatic API

We also believe you should be able to use all Bootstrap plugins purely through the JavaScript API. All public APIs are single, chainable methods, and return the collection acted upon.

{% highlight js %} $(".btn.danger").button("toggle").addClass("fat") {% endhighlight %}

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

{% highlight js %} $("#myModal").modal() // initialized with defaults $("#myModal").modal({ keyboard: false }) // initialized with no keyboard $("#myModal").modal('show') // initializes and invokes show immediately

{% endhighlight %}

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

No conflict

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

{% highlight js %} var bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value $.fn.bootstrapBtn = bootstrapButton // give $().bootstrapBtn the bootstrap functionality {% endhighlight %}

Events

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

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

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

About transitions

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

Use cases

A few examples of the transition plugin:

Examples

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

Static example

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

{% highlight html %} {% endhighlight %}

Live demo

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

{% highlight html %} Launch demo modal {% endhighlight %}

Usage

Via data 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.

{% highlight html %} {% endhighlight %}

Via JavaScript

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

{% highlight js %}$('#myModal').modal(options){% endhighlight %}

Options

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

Name type default description
backdrop boolean true 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 key is pressed
show boolean true Shows the modal when initialized.
remote path false

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

{% highlight html %} Click me {% endhighlight %}

Methods

.modal(options)

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

{% highlight js %} $('#myModal').modal({ keyboard: false }) {% endhighlight %}

.modal('toggle')

Manually toggles a modal.

{% highlight js %}$('#myModal').modal('toggle'){% endhighlight %}

.modal('show')

Manually opens a modal.

{% highlight js %}$('#myModal').modal('show'){% endhighlight %}

.modal('hide')

Manually hides a modal.

{% highlight js %}$('#myModal').modal('hide'){% endhighlight %}

Events

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

Event Description
show This event fires immediately when the show instance method is called.
shown This event is fired when the modal has been made visible to the user (will wait for css transitions to complete).
hide This event is fired immediately when the hide instance method has been called.
hidden This event is fired when the modal has finished being hidden from the user (will wait for css transitions to complete).
{% highlight js %} $('#myModal').on('hidden', function () { // do something… }) {% endhighlight %}

Example in navbar

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

@fat

Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you probably haven't heard of them et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.

@mdo

Veniam marfa mustache skateboard, adipisicing fugiat velit pitchfork beard. Freegan beard aliqua cupidatat mcsweeney's vero. Cupidatat four loko nisi, ea helvetica nulla carles. Tattooed cosby sweater food truck, mcsweeney's quis non freegan vinyl. Lo-fi wes anderson +1 sartorial. Carles non aesthetic exercitation quis gentrify. Brooklyn adipisicing craft beer vice keytar deserunt.

one

Occaecat commodo aliqua delectus. Fap craft beer deserunt skateboard ea. Lomo bicycle rights adipisicing banh mi, velit ea sunt next level locavore single-origin coffee in magna veniam. High life id vinyl, echo park consequat quis aliquip banh mi pitchfork. Vero VHS est adipisicing. Consectetur nisi DIY minim messenger bag. Cred ex in, sustainable delectus consectetur fanny pack iphone.

two

In incididunt echo park, officia deserunt mcsweeney's proident master cleanse thundercats sapiente veniam. Excepteur VHS elit, proident shoreditch +1 biodiesel laborum craft beer. Single-origin coffee wayfarers irure four loko, cupidatat terry richardson master cleanse. Assumenda you probably haven't heard of them art party fanny pack, tattooed nulla cardigan tempor ad. Proident wolf nesciunt sartorial keffiyeh eu banh mi sustainable. Elit wolf voluptate, lo-fi ea portland before they sold out four loko. Locavore enim nostrud mlkshk brooklyn nesciunt.

three

Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you probably haven't heard of them et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.

Keytar twee blog, culpa messenger bag marfa whatever delectus food truck. Sapiente synth id assumenda. Locavore sed helvetica cliche irony, thundercats you probably haven't heard of them consequat hoodie gluten-free lo-fi fap aliquip. Labore elit placeat before they sold out, terry richardson proident brunch nesciunt quis cosby sweater pariatur keffiyeh ut helvetica artisan. Cardigan craft beer seitan readymade velit. VHS chambray laboris tempor veniam. Anim mollit minim commodo ullamco thundercats.

Usage

Via data attributes

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

{% highlight html %} ... {% endhighlight %}

Via JavaScript

Call the scrollspy via JavaScript:

{% highlight js %} $('#navbar-example').scrollspy() {% endhighlight %}

Resolvable ID targets required

Navbar links must have resolvable id targets. For example, a <a href="#home">home</a> must correspond to something in the DOM like <div id="home"></div>.

Methods

.scrollspy('refresh')

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

{% highlight js %} $('[data-spy="scroll"]').each(function () { var $spy = $(this).scrollspy('refresh') }); {% endhighlight %}

Options

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

Name type default description
offset number 10 Pixels to offset from top when calculating position of scroll.

Events

Event Description
activate This event fires whenever a new item becomes activated by the scrollspy.

Example tabs

Add quick, dynamic tab functionality to transition through panes of local content, even via dropdown menus.

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 +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad 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-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.


Usage

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

{% highlight js %} $('#myTab a').click(function (e) { e.preventDefault(); $(this).tab('show'); }) {% endhighlight %}

You can activate individual tabs in several ways:

{% highlight js %} $('#myTab a[href="#profile"]').tab('show'); // Select tab by name $('#myTab a:first').tab('show'); // Select first tab $('#myTab a:last').tab('show'); // Select last tab $('#myTab li:eq(2) a').tab('show'); // Select third tab (0-indexed) {% endhighlight %}

Markup

You can activate a tab or pill navigation without writing any JavaScript by simply 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.

{% highlight html %} {% endhighlight %}

To make tabs fade in, add .fade to each .tab-pane.

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.

{% highlight html %}
...
...
...
...
{% endhighlight %}

Events

Event Description
show This event fires on tab show, but before the new tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively.
shown This event fires on tab show after a tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively.
{% highlight js %} $('a[data-toggle="tab"]').on('shown', function (e) { e.target // activated tab e.relatedTarget // previous tab }) {% endhighlight %}

Examples

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

Hover over the links below to see tooltips:

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

Four directions

Tooltips in input groups

When using tooltips and popovers with the Bootstrap input groups, you'll have to set the container (documented below) option to avoid unwanted side effects.


Usage

Trigger the tooltip via JavaScript:

{% highlight js %} $('#example').tooltip(options) {% endhighlight %}

Options

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

Name type default description
animation boolean true apply a css fade transition to the tooltip
html boolean false Insert html into the tooltip. If false, jquery's text method will be used to insert content into the dom. Use text if you're worried about XSS attacks.
placement string | function 'top' how to position the tooltip - top | bottom | left | right
selector string false If a selector is provided, tooltip objects will be delegated to the specified targets.
title string | function '' default title value if `title` tag isn't present
trigger string 'hover focus' how tooltip is triggered - click | hover | focus | manual. Note you case pass trigger multiple, space seperated, trigger types.
delay number | object 0

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

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

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

container string | false false

Appends the tooltip to a specific element container: 'body'

Data attributes for individual tooltips

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

Markup

{% highlight html %} Hover over me {% endhighlight %}

Methods

$().tooltip(options)

Attaches a tooltip handler to an element collection.

.tooltip('show')

Reveals an element's tooltip.

{% highlight js %}$('#element').tooltip('show'){% endhighlight %}

.tooltip('hide')

Hides an element's tooltip.

{% highlight js %}$('#element').tooltip('hide'){% endhighlight %}

.tooltip('toggle')

Toggles an element's tooltip.

{% highlight js %}$('#element').tooltip('toggle'){% endhighlight %}

.tooltip('destroy')

Hides and destroys an element's tooltip.

{% highlight js %}$('#element').tooltip('destroy'){% endhighlight %}

Examples

Add small overlays of content, like those on the iPad, to any element for housing secondary information. Hover over the button to trigger the popover.

Plugin dependency

Popovers require the tooltip plugin to be included in your version of Bootstrap.

Static popover

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

Popover top

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

Popover right

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

Popover bottom

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

Popover left

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

Live demo

Four directions


Usage

Enable popovers via JavaScript:

{% highlight js %}$('#example').popover(options){% endhighlight %}

Options

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

Name type default description
animation boolean true apply a css fade transition to the tooltip
html boolean false Insert html into the popover. If false, jquery's text method will be used to insert content into the dom. Use text if you're worried about XSS attacks.
placement string | function 'right' how to position the popover - top | bottom | left | right
selector string false if a selector is provided, tooltip objects will be delegated to the specified targets if a selector is provided, tooltip objects will be delegated to the specified targets. in practice, this is used to enable dynamic HTML content to have popovers added. See this and an informative example.
trigger string 'click' how popover is triggered - click | hover | focus | manual
title string | function '' default title value if `title` attribute isn't present
content string | function '' default content value if `data-content` attribute isn't present
delay number | object 0

delay showing and hiding the popover (ms) - does not apply to manual trigger type

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

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

container string | false false

Appends the popover to a specific element container: 'body'

Data attributes for individual popovers

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

Markup

For performance reasons, the Tooltip and Popover data-apis are opt in. If you would like to use them just specify a selector option.

Methods

$().popover(options)

Initializes popovers for an element collection.

.popover('show')

Reveals an elements popover.

{% highlight js %}$('#element').popover('show'){% endhighlight %}

.popover('hide')

Hides an elements popover.

{% highlight js %}$('#element').popover('hide'){% endhighlight %}

.popover('toggle')

Toggles an elements popover.

{% highlight js %}$('#element').popover('toggle'){% endhighlight %}

.popover('destroy')

Hides and destroys an element's popover.

{% highlight js %}$('#element').popover('destroy'){% endhighlight %}

Example alerts

Add dismiss functionality to all alert messages with this plugin.

Holy guacamole! Best check yo self, you're not looking too good.

Oh snap! You got an error!

Change this and that and try again. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.

Take this action Or do this


Usage

Enable dismissal of an alert via JavaScript:

{% highlight js %}$(".alert").alert(){% endhighlight %}

Markup

Just add data-dismiss="alert" to your close button to automatically give an alert close functionality.

{% highlight html %}×{% endhighlight %}

Methods

$().alert()

Wraps all alerts with close functionality. To have your alerts animate out when closed, make sure they have the .fade and .in class already applied to them.

.alert('close')

Closes an alert.

{% highlight js %}$(".alert").alert('close'){% endhighlight %}

Events

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

Event Description
close This event fires immediately when the close instance method is called.
closed This event is fired when the alert has been closed (will wait for css transitions to complete).
{% highlight js %} $('#my-alert').bind('closed', function () { // do something… }) {% endhighlight %}

Example uses

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

Stateful

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

{% highlight html %} {% endhighlight %}

Single toggle

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

{% highlight html %} {% endhighlight %}

Checkbox

Add data-toggle="buttons-checkbox" for checkbox style toggling on btn-group.

{% highlight html %}
{% endhighlight %}

Radio

Add data-toggle="buttons-radio" for radio style toggling on btn-group.

{% highlight html %}
{% endhighlight %}

Usage

Enable buttons via JavaScript:

{% highlight js %} $('.nav-tabs').button() {% endhighlight %}

Markup

Data attributes are integral to the button plugin. Check out the example code below for the various markup types.

Options

None

Methods

$().button('toggle')

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

Auto toggling

You can enable auto toggling of a button by using the data-toggle attribute.

{% highlight html %} {% endhighlight %}

$().button('loading')

Sets button state to loading - disables button and swaps text to loading text. Loading text should be defined on the button element using the data attribute data-loading-text.

{% highlight html %} {% endhighlight %}

Cross-browser compatibility

Firefox persists the disabled state across page loads. A workaround for this is to use autocomplete="off".

$().button('reset')

Resets button state - swaps text to original text.

$().button(string)

Resets button state - swaps text to any data defined text state.

{% highlight html %} {% endhighlight %}

About

Get base styles and flexible support for collapsible components like accordions and navigation.

Plugin dependency

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

Example accordion

Using the collapse plugin, we built a simple accordion style widget:

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

You can also use the plugin without the accordion markup. Make a button toggle the expanding and collapsing of another element.

{% highlight html %}
...
{% endhighlight %}

Usage

Via data attributes

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

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

Via JavaScript

Enable manually with:

{% highlight js %} $(".collapse").collapse() {% endhighlight %}

Options

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

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

Methods

.collapse(options)

Activates your content as a collapsible element. Accepts an optional options object. {% highlight js %} $('#myCollapsible').collapse({ toggle: false }) {% endhighlight %}

.collapse('toggle')

Toggles a collapsible element to shown or hidden.

.collapse('show')

Shows a collapsible element.

.collapse('hide')

Hides a collapsible element.

Events

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

Event Description
show This event fires immediately when the show instance method is called.
shown This event is fired when a collapse element has been made visible to the user (will wait for css transitions to complete).
hide This event is fired immediately when the hide method has been called.
hidden This event is fired when a collapse element has been hidden from the user (will wait for css transitions to complete).
{% highlight js %} $('#myCollapsible').on('hidden', function () { // do something… }) {% endhighlight %}

Example

A basic, easily extended plugin for quickly creating elegant typeaheads with any form text input.

{% highlight html %} {% endhighlight %}

You'll want to set autocomplete="off" to prevent default browser menus from appearing over the Bootstrap typeahead dropdown.


Usage

Via data attributes

Add data attributes to register an element with typeahead functionality as shown in the example above.

Via JavaScript

Call the typeahead manually with:

{% highlight js %} $('.typeahead').typeahead() {% endhighlight %}

Options

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

Name type default description
source array, function [ ] The data source to query against. May be an array of strings or a function. The function is passed two arguments, the query value in the input field and the process callback. The function may be used synchronously by returning the data source directly or asynchronously via the process callback's single argument.
items number 8 The max number of items to display in the dropdown.
minLength number 1 The minimum character length needed before triggering autocomplete suggestions
matcher function case insensitive The method used to determine if a query matches an item. Accepts a single argument, the item against which to test the query. Access the current query with this.query. Return a boolean true if query is a match.
sorter function exact match,
case sensitive,
case insensitive
Method used to sort autocomplete results. Accepts a single argument items and has the scope of the typeahead instance. Reference the current query with this.query.
updater function returns selected item The method used to return selected item. Accepts a single argument, the item and has the scope of the typeahead instance.
highlighter function highlights all default matches Method used to highlight autocomplete results. Accepts a single argument item and has the scope of the typeahead instance. Should return html.

Methods

.typeahead(options)

Initializes an input with a typeahead.

Example

The subnavigation on the left is a live demo of the affix plugin.


Usage

Via data attributes

To easily add affix behavior to any element, just add data-spy="affix" to the element you want to spy on. Then use offsets to define when to toggle the pinning of an element on and off.

{% highlight html %}
...
{% endhighlight %}

Requires positioning

You must manage the position of a pinned element and the behavior of its immediate parent. Position is controlled by affix, affix-top, and affix-bottom. Remember to check for a potentially collapsed parent when the affix kicks in as it's removing content from the normal flow of the page.

Via JavaScript

Call the affix plugin via JavaScript:

{% highlight js %} $('#navbar').affix() {% endhighlight %}

Methods

.affix('refresh')

When using affix in conjunction with adding or removing of elements from the DOM, you'll want to call the refresh method:

{% highlight js %} $('[data-spy="affix"]').each(function () { $(this).affix('refresh') }); {% endhighlight %}

Options

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

Name type default description
offset number | function | object 10 Pixels to offset from screen when calculating position of scroll. If a single number is provided, the offset will be applied in both top and left directions. To listen for a single direction, or multiple unique offsets, just provide an object offset: { x: 10 }. Use a function when you need to dynamically provide an offset (useful for some responsive designs).
Back to top