Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages.
-
-
-
-
-
-
-
-
-
-
Examples
-
Alerts are available for any length of text, as well as an optional dismiss button. For proper styling, use one of the eight required contextual classes (e.g., .alert-success). For inline dismissal, use the alerts jQuery plugin.
-
-
- A simple primary alert—check it out!
-
-
- A simple secondary alert—check it out!
-
-
- A simple danger alert—check it out!
-
-
- A simple info alert—check it out!
-
-
- A simple success alert—check it out!
-
-
- A simple warning alert—check it out!
-
-
- A simple dark alert—check it out!
-
-
- A simple light alert—check it out!
-
-
-
-
-
Conveying meaning to assistive technologies
-
Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .sr-only class.
-
-
Link color
-
Use the .alert-link utility class to quickly provide matching colored links within any alert.
-
-
- A simple primary alert with an example link. Give it a click if you like.
-
-
- A simple secondary alert with an example link. Give it a click if you like.
-
-
- A simple danger alert with an example link. Give it a click if you like.
-
-
- A simple info alert with an example link. Give it a click if you like.
-
-
- A simple success alert with an example link. Give it a click if you like.
-
-
- A simple warning alert with an example link. Give it a click if you like.
-
-
- A simple dark alert with an example link. Give it a click if you like.
-
-
- A simple light alert with an example link. Give it a click if you like.
-
-
-
-
Additional content
-
Alerts can also contain additional HTML elements like headings, paragraphs and dividers.
-
-
-
Well done!
-
Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.
-
-
Whenever you need to, be sure to use margin utilities to keep things nice and tidy.
-
-
-
-
Dismissing
-
Using the alert JavaScript plugin, it’s possible to dismiss any alert inline. Here’s how:
-
-
Be sure you’ve loaded the alert plugin, or the compiled Bootstrap JavaScript.
-
If you’re building our JavaScript from source, it requires util.js. The compiled version includes this.
-
Add a dismiss button and the .alert-dismissible class, which adds extra padding to the right of the alert and positions the .close button.
-
On the dismiss button, add the data-dismiss="alert" attribute, which triggers the JavaScript functionality. Be sure to use the <button> element with it for proper behavior across all devices.
-
To animate alerts when dismissing them, be sure to add the .fade and .show classes.
-
-
You can see this in action with a live demo:
-
-
- Holy guacamole! You should check in on some of those fields below.
-
-
-
-
-
JavaScript behavior
-
Triggers
-
Enable dismissal of an alert via JavaScript:
-
-
Or with data attributes on a button within the alert, as demonstrated above:
-
-
Note that closing an alert will remove it from the DOM.
-
Methods
-
-
-
-
Method
-
Description
-
-
-
-
-
$().alert()
-
Makes an alert listen for click events on descendant elements which have the data-dismiss="alert" attribute. (Not necessary when using the data-api’s auto-initialization.)
-
-
-
$().alert('close')
-
Closes an alert by removing it from the DOM. If the .fade and .show classes are present on the element, the alert will fade out before it is removed.
-
-
-
$().alert('dispose')
-
Destroys an element’s alert.
-
-
-
-
-
Events
-
Bootstrap’s alert plugin exposes a few events for hooking into alert functionality.
-
-
-
-
Event
-
Description
-
-
-
-
-
close.bs.alert
-
This event fires immediately when the close instance method is called.
-
-
-
closed.bs.alert
-
This event is fired when the alert has been closed (will wait for CSS transitions to complete).
Documentation and examples for badges, our small count and labeling component.
-
-
-
-
-
-
-
-
-
-
Example
-
Badges scale to match the size of the immediate parent element by using relative font sizing and em units.
-
-
Example heading New
-
-
Example heading New
-
-
Example heading New
-
-
Example heading New
-
-
Example heading New
-
-
Example heading New
-
-
-
-
Badges can be used as part of links or buttons to provide a counter.
-
-
-
-
-
Note that depending on how they are used, badges may be confusing for users of screen readers and similar assistive technologies. While the styling of badges provides a visual cue as to their purpose, these users will simply be presented with the content of the badge. Depending on the specific situation, these badges may seem like random additional words or numbers at the end of a sentence, link, or button.
-
Unless the context is clear (as with the “Notifications” example, where it is understood that the “4” is the number of notifications), consider including additional context with a visually hidden piece of additional text.
-
-
-
-
-
Contextual variations
-
Add any of the below mentioned modifier classes to change the appearance of a badge.
Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .sr-only class.
-
-
Pill badges
-
Use the .badge-pill modifier class to make badges more rounded (with a larger border-radius and additional horizontal padding). Useful if you miss the badges from v3.
Indicate the current page's location within a navigational hierarchy that automatically adds separators via CSS.
-
-
-
-
-
-
-
-
-
-
Example
-
-
-
-
-
-
-
Changing the separator
-
Separators are automatically added in CSS through ::before and content. They can be changed by changing $breadcrumb-divider. The quote function is needed to generate the quotes around a string, so if you want > as separator, you can use this:
-
$breadcrumb-divider:quote(">");
-
-
It’s also possible to use a base64 embedded SVG icon:
The separator can be removed by setting $breadcrumb-divider to none:
-
$breadcrumb-divider:none;
-
-
Accessibility
-
Since breadcrumbs provide a navigation, it’s a good idea to add a meaningful label such as aria-label="breadcrumb" to describe the type of navigation provided in the <nav> element, as well as applying an aria-current="page" to the last item of the set to indicate that it represents the current page.
Group a series of buttons together on a single line with the button group, and super-power them with JavaScript.
-
-
-
-
-
-
-
-
-
-
Basic example
-
Wrap a series of buttons with .btn in .btn-group. Add on optional JavaScript radio and checkbox style behavior with our buttons plugin.
-
-
-
-
-
-
-
-
-
-
Ensure correct role and provide a label
-
In order for assistive technologies (such as screen readers) to convey that a series of buttons is grouped, an appropriate role attribute needs to be provided. For button groups, this would be role="group", while toolbars should have a role="toolbar".
-
In addition, groups and toolbars should be given an explicit label, as most assistive technologies will otherwise not announce them, despite the presence of the correct role attribute. In the examples provided here, we use aria-label, but alternatives such as aria-labelledby can also be used.
-
-
Button toolbar
-
Combine sets of button groups into button toolbars for more complex components. Use utility classes as needed to space out groups, buttons, and more.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Feel free to mix input groups with button groups in your toolbars. Similar to the example above, you’ll likely need some utilities though to space things properly.
-
-
-
-
-
-
-
-
-
-
-
@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@
-
-
-
-
-
-
-
Sizing
-
Instead of applying button sizing classes to every button in a group, just add .btn-group-* to each .btn-group, including each one when nesting multiple groups.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Nesting
-
Place a .btn-group within another .btn-group when you want dropdown menus mixed with a series of buttons.
Use Bootstrap's custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more.
-
-
-
-
-
-
-
-
-
-
Examples
-
Bootstrap includes several predefined button styles, each serving its own semantic purpose, with a few extras thrown in for more control.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Conveying meaning to assistive technologies
-
Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .sr-only class.
-
-
Disable text wrapping
-
If you don’t want the button text to wrap, you can add the .text-nowrap class to the button. In Sass, you can set $btn-white-space: nowrap to disable text wrapping for each button.
-
Button tags
-
The .btn classes are designed to be used with the <button> element. However, you can also use these classes on <a> or <input> elements (though some browsers may apply a slightly different rendering).
-
When using button classes on <a> elements that are used to trigger in-page functionality (like collapsing content), rather than linking to new pages or sections within the current page, these links should be given a role="button" to appropriately convey their purpose to assistive technologies such as screen readers.
In need of a button, but not the hefty background colors they bring? Replace the default modifier classes with the .btn-outline-* ones to remove all background images and colors on any button.
-
-
-
-
-
-
-
-
-
-
-
-
Sizes
-
Fancy larger or smaller buttons? Add .btn-lg or .btn-sm for additional sizes.
-
-
-
-
-
-
-
-
-
-
-
Create block level buttons—those that span the full width of a parent—by adding .btn-block.
-
-
-
-
-
-
Active state
-
Buttons will appear pressed (with a darker background, darker border, and inset shadow) when active. There’s no need to add a class to <button>s as they use a pseudo-class. However, you can still force the same active appearance with .active (and include the aria-pressed="true" attribute) should you need to replicate the state programmatically.
Make buttons look inactive by adding the disabled boolean attribute to any <button> element.
-
-
-
-
-
-
Disabled buttons using the <a> element behave a bit different:
-
-
-<a>s don’t support the disabled attribute, so you must add the .disabled class to make it visually appear disabled.
-
Some future-friendly styles are included to disable all pointer-events on anchor buttons. In browsers which support that property, you won’t see the disabled cursor at all.
-
Disabled buttons should include the aria-disabled="true" attribute to indicate the state of the element to assistive technologies.
The .disabled class uses pointer-events: none to try to disable the link functionality of <a>s, but that CSS property is not yet standardized. In addition, even in browsers that do support pointer-events: none, keyboard navigation remains unaffected, meaning that sighted keyboard users and users of assistive technologies will still be able to activate these links. So to be safe, add a tabindex="-1" attribute on these links (to prevent them from receiving keyboard focus) and use custom JavaScript to disable their functionality.
-
-
Button plugin
-
Do more with buttons. Control button states or create groups of buttons for more components like toolbars.
-
Toggle states
-
Add data-toggle="button" to toggle a button’s active state. If you’re pre-toggling a button, you must manually add the .active class andaria-pressed="true" to the <button>.
-
-
-
-
-
Checkbox and radio buttons
-
Bootstrap’s .button styles can be applied to other elements, such as <label>s, to provide checkbox or radio style button toggling. Add data-toggle="buttons" to a .btn-group containing those modified buttons to enable their toggling behavior via JavaScript and add .btn-group-toggle to style the <input>s within your buttons. Note that you can create single input-powered buttons or groups of them.
-
The checked state for these buttons is only updated via click event on the button. If you use another method to update the input—e.g., with <input type="reset"> or by manually applying the input’s checked property—you’ll need to toggle .active on the <label> manually.
-
Note that pre-checked buttons require you to manually add the .active class to the input’s <label>.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Methods
-
-
-
-
Method
-
Description
-
-
-
-
-
$().button('toggle')
-
Toggles push state. Gives the button the appearance that it has been activated.
Bootstrap's cards provide a flexible and extensible content container with multiple variants and options.
-
-
-
-
-
-
-
-
-
-
About
-
A card is a flexible and extensible content container. It includes options for headers and footers, a wide variety of content, contextual background colors, and powerful display options. If you’re familiar with Bootstrap 3, cards replace our old panels, wells, and thumbnails. Similar functionality to those components is available as modifier classes for cards.
-
Example
-
Cards are built with as little markup and styles as possible, but still manage to deliver a ton of control and customization. Built with flexbox, they offer easy alignment and mix well with other Bootstrap components. They have no margin by default, so use spacing utilities as needed.
-
Below is an example of a basic card with mixed content and a fixed width. Cards have no fixed width to start, so they’ll naturally fill the full width of its parent element. This is easily customized with our various sizing options.
-
-
-
-
-
Card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
Cards support a wide variety of content, including images, text, list groups, links, and more. Below are examples of what’s supported.
-
Body
-
The building block of a card is the .card-body. Use it whenever you need a padded section within a card.
-
-
-
- This is some text within a card body.
-
-
-
-
-
Titles, text, and links
-
Card titles are used by adding .card-title to a <h*> tag. In the same way, links are added and placed next to each other by adding .card-link to an <a> tag.
-
Subtitles are used by adding a .card-subtitle to a <h*> tag. If the .card-title and the .card-subtitle items are placed in a .card-body item, the card title and subtitle are aligned nicely.
-
-
-
-
Card title
-
Card subtitle
-
Some quick example text to build on the card title and make up the bulk of the card's content.
.card-img-top places an image to the top of the card. With .card-text, text can be added to the card. Text within .card-text can also be styled with the standard HTML tags.
-
-
-
-
-
Some quick example text to build on the card title and make up the bulk of the card's content.
-
-
-
-
-
List groups
-
Create lists of content in a card with a flush list group.
-
-
-
-
Cras justo odio
-
Dapibus ac facilisis in
-
Vestibulum at eros
-
-
-
-
-
-
-
- Featured
-
-
-
Cras justo odio
-
Dapibus ac facilisis in
-
Vestibulum at eros
-
-
-
-
-
-
-
-
Cras justo odio
-
Dapibus ac facilisis in
-
Vestibulum at eros
-
-
-
-
-
-
Kitchen sink
-
Mix and match multiple content types to create the card you need, or throw everything in there. Shown below are image styles, blocks, text styles, and a list group—all wrapped in a fixed-width card.
-
-
-
-
-
Card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
Cards assume no specific width to start, so they’ll be 100% wide unless otherwise stated. You can change this as needed with custom CSS, grid classes, grid Sass mixins, or utilities.
-
Using grid markup
-
Using the grid, wrap cards in columns and rows as needed.
-
-
-
-
-
-
Special title treatment
-
With supporting text below as a natural lead-in to additional content.
Cards include a few options for working with images. Choose from appending “image caps” at either end of a card, overlaying images with card content, or simply embedding the image in a card.
-
Image caps
-
Similar to headers and footers, cards can include top and bottom “image caps”—images at the top or bottom of a card.
-
-
-
-
-
Card title
-
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
Last updated 3 mins ago
-
-
-
-
-
Card title
-
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
Last updated 3 mins ago
-
-
-
-
-
-
Image overlays
-
Turn an image into a card background and overlay your card’s text. Depending on the image, you may or may not need additional styles or utilities.
-
-
-
-
-
Card title
-
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
Last updated 3 mins ago
-
-
-
-
-
-
Note that content should not be larger than the height of the image. If content is larger than the image the content will be displayed outside the image.
-
-
Horizontal
-
Using a combination of grid and utility classes, cards can be made horizontal in a mobile-friendly and responsive way. In the example below, we remove the grid gutters with .no-gutters and use .col-md-* classes to make the card horizontal at the md breakpoint. Further adjustments may be needed depending on your card content.
-
-
-
-
-
-
-
-
-
Card title
-
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
Last updated 3 mins ago
-
-
-
-
-
-
-
Card styles
-
Cards include various options for customizing their backgrounds, borders, and color.
Some quick example text to build on the card title and make up the bulk of the card's content.
-
-
-
-
Header
-
-
Secondary card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
-
-
-
-
Header
-
-
Danger card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
-
-
-
-
Header
-
-
Info card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
-
-
-
-
Header
-
-
Success card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
-
-
-
-
Header
-
-
Warning card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
-
-
-
-
Header
-
-
Dark card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
-
-
-
-
Header
-
-
Light card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
-
-
-
-
-
-
Conveying meaning to assistive technologies
-
Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .sr-only class.
-
-
Border
-
Use border utilities to change just the border-color of a card. Note that you can put .text-{color} classes on the parent .card or a subset of the card’s contents as shown below.
-
-
-
Header
-
-
Primary card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
-
-
-
-
Header
-
-
Secondary card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
-
-
-
-
Header
-
-
Danger card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
-
-
-
-
Header
-
-
Info card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
-
-
-
-
Header
-
-
Success card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
-
-
-
-
Header
-
-
Warning card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
-
-
-
-
Header
-
-
Dark card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
-
-
-
-
Header
-
-
Light card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
-
-
-
-
-
Mixins utilities
-
You can also change the borders on the card header and footer as needed, and even remove their background-color with .bg-transparent.
-
-
-
Header
-
-
Success card title
-
Some quick example text to build on the card title and make up the bulk of the card's content.
-
-
-
-
-
-
Card layout
-
In addition to styling the content within cards, Bootstrap includes a few options for laying out series of cards. For the time being, these layout options are not yet responsive.
-
Card groups
-
Use card groups to render cards as a single, attached element with equal width and height columns. Card groups start off stacked and use display: flex; to become attached with uniform dimensions starting at the sm breakpoint.
-
-
-
-
-
-
Card title
-
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
Last updated 3 mins ago
-
-
-
-
-
-
Card title
-
This card has supporting text below as a natural lead-in to additional content.
-
Last updated 3 mins ago
-
-
-
-
-
-
Card title
-
This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.
-
Last updated 3 mins ago
-
-
-
-
-
-
When using card groups with footers, their content will automatically line up.
-
-
-
-
-
-
Card title
-
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
-
-
-
-
-
Card title
-
This card has supporting text below as a natural lead-in to additional content.
-
-
-
-
-
-
-
Card title
-
This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.
-
-
-
-
-
-
-
Card decks
-
Need a set of equal width and height cards that aren’t attached to one another? Use card decks.
-
-
-
-
-
-
Card title
-
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
Last updated 3 mins ago
-
-
-
-
-
-
Card title
-
This card has supporting text below as a natural lead-in to additional content.
-
Last updated 3 mins ago
-
-
-
-
-
-
Card title
-
This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.
-
Last updated 3 mins ago
-
-
-
-
-
-
Just like with card groups, card footers in decks will automatically line up.
-
-
-
-
-
-
Card title
-
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
-
-
-
-
-
Card title
-
This card has supporting text below as a natural lead-in to additional content.
-
-
-
-
-
-
-
Card title
-
This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.
-
-
-
-
-
-
-
Grid cards
-
Use the Bootstrap grid system and its .row-cols classes to control how many grid columns (wrapped around your cards) you show per row. For example, here’s .row-cols-1 laying out the cards on one column, and .row-cols-md-2 splitting four cards to equal width across multiple rows, from the medium breakpoint up.
-
-
-
-
-
-
-
Card title
-
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
-
-
-
-
-
-
Card title
-
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
-
-
-
-
-
-
Card title
-
This is a longer card with supporting text below as a natural lead-in to additional content.
-
-
-
-
-
-
-
-
Card title
-
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
-
-
-
-
-
Change it to .row-cols-3 and you’ll see the fourth card wrap.
-
-
-
-
-
-
-
Card title
-
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
-
-
-
-
-
-
Card title
-
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
-
-
-
-
-
-
Card title
-
This is a longer card with supporting text below as a natural lead-in to additional content.
-
-
-
-
-
-
-
-
Card title
-
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
-
-
-
-
-
When you need equal height, add .h-100 to the cards. If you want equal heights by default, you can set $card-height: 100% in Sass.
-
-
-
-
-
-
-
Card title
-
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
-
-
-
-
-
-
Card title
-
This is a short card.
-
-
-
-
-
-
-
-
Card title
-
This is a longer card with supporting text below as a natural lead-in to additional content.
-
-
-
-
-
-
-
-
Card title
-
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
-
-
-
-
-
Card columns
-
Cards can be organized into Masonry-like columns with just CSS by wrapping them in .card-columns. Cards are built with CSS column properties instead of flexbox for easier alignment. Cards are ordered from top to bottom and left to right.
-
Heads up! Your mileage with card columns may vary. To prevent cards breaking across columns, we must set them to display: inline-block as column-break-inside: avoid isn’t a bulletproof solution yet.
-
-
-
-
-
-
Card title that wraps to a new line
-
This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-
-
-
-
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
-
-
-
-
-
-
-
Card title
-
This card has supporting text below as a natural lead-in to additional content.
-
Last updated 3 mins ago
-
-
-
-
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat.
-
-
-
-
-
-
Card title
-
This card has a regular title and short paragraphy of text below it.
-
Last updated 3 mins ago
-
-
-
-
-
-
-
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
-
-
-
-
-
-
Card title
-
This is another card with title and supporting text below. This card has some additional content to make it slightly taller overall.
-
Last updated 3 mins ago
-
-
-
-
-
-
Card columns can also be extended and customized with some additional code. Shown below is an extension of the .card-columns class using the same CSS we use—CSS columns— to generate a set of responsive tiers for changing the number of columns.
A slideshow component for cycling through elements—images or slides of text—like a carousel.
-
-
-
-
-
-
-
-
-
-
How it works
-
The carousel is a slideshow for cycling through a series of content, built with CSS 3D transforms and a bit of JavaScript. It works with a series of images, text, or custom markup. It also includes support for previous/next controls and indicators.
-
In browsers where the Page Visibility API is supported, the carousel will avoid sliding when the webpage is not visible to the user (such as when the browser tab is inactive, the browser window is minimized, etc.).
Please be aware that nested carousels are not supported, and carousels are generally not compliant with accessibility standards.
-
Lastly, if you’re building our JavaScript from source, it requires util.js.
-
Example
-
Carousels don’t automatically normalize slide dimensions. As such, you may need to use additional utilities or custom styles to appropriately size content. While carousels support previous/next controls and indicators, they’re not explicitly required. Add and customize as you see fit.
-
The .active class needs to be added to one of the slides otherwise the carousel will not be visible. Also be sure to set a unique id on the .carousel for optional controls, especially if you’re using multiple carousels on a single page. Control and indicator elements must have a data-target attribute (or href for links) that matches the id of the .carousel element.
-
Slides only
-
Here’s a carousel with slides only. Note the presence of the .d-block and .w-100 on carousel images to prevent browser default image alignment.
Add captions to your slides easily with the .carousel-caption element within any .carousel-item. They can be easily hidden on smaller viewports, as shown below, with optional display utilities. We hide them initially with .d-none and bring them back on medium-sized devices with .d-md-block.
-
-
-
-
-
-
-
-
-
-
-
-
First slide label
-
Nulla vitae elit libero, a pharetra augue mollis interdum.
-
-
-
-
-
-
Second slide label
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
-
-
-
-
-
-
Third slide label
-
Praesent commodo cursus magna, vel scelerisque nisl consectetur.
Use data attributes to easily control the position of the carousel. data-slide accepts the keywords prev or next, which alters the slide position relative to its current position. Alternatively, use data-slide-to to pass 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 animating starting at page load. If you don’t use data-ride="carousel" to initialize your carousel, you have to initialize it yourself. It cannot be used in combination with (redundant and unnecessary) explicit JavaScript initialization of the same carousel.
-
Via JavaScript
-
Call carousel manually with:
-
-
Options
-
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-interval="".
-
-
-
-
Name
-
Type
-
Default
-
Description
-
-
-
-
-
interval
-
number
-
5000
-
The amount of time to delay between automatically cycling an item. If false, carousel will not automatically cycle.
-
-
-
keyboard
-
boolean
-
true
-
Whether the carousel should react to keyboard events.
-
-
-
pause
-
string | boolean
-
"hover"
-
-
If set to "hover", pauses the cycling of the carousel on mouseenter and resumes the cycling of the carousel on mouseleave. If set to false, hovering over the carousel won't pause it.
-
On touch-enabled devices, when set to "hover", cycling will pause on touchend (once the user finished interacting with the carousel) for two intervals, before automatically resuming. Note that this is in addition to the above mouse behavior.
-
-
-
-
ride
-
string
-
false
-
Autoplays the carousel after the user manually cycles the first item. If "carousel", autoplays the carousel on load.
-
-
-
wrap
-
boolean
-
true
-
Whether the carousel should cycle continuously or have hard stops.
-
-
-
touch
-
boolean
-
true
-
Whether the carousel should support left/right swipe interactions on touchscreen devices.
-
-
-
-
Methods
-
-
Asynchronous methods and transitions
-
All API methods are asynchronous and start a transition. They returns to the caller as soon as the transition is started but before it ends. In addition, a method call on a transitioning component will be ignored.
-
-
.carousel(options)
-
Initializes the carousel with an optional options object and starts cycling through items.
-
-
.carousel('cycle')
-
Cycles through the carousel items from left to right.
-
.carousel('pause')
-
Stops the carousel from cycling through items.
-
.carousel(number)
-
Cycles the carousel to a particular frame (0 based, similar to an array). Returns to the caller before the target item has been shown (i.e. before the slid.bs.carousel event occurs).
-
.carousel('prev')
-
Cycles to the previous item. Returns to the caller before the previous item has been shown (i.e. before the slid.bs.carousel event occurs).
-
.carousel('next')
-
Cycles to the next item. Returns to the caller before the next item has been shown (i.e. before the slid.bs.carousel event occurs).
-
.carousel('dispose')
-
Destroys an element’s carousel.
-
Events
-
Bootstrap’s carousel class exposes two events for hooking into carousel functionality. Both events have the following additional properties:
-
-
-direction: The direction in which the carousel is sliding (either "left" or "right").
-
-relatedTarget: The DOM element that is being slid into place as the active item.
-
-from: The index of the current item
-
-to: The index of the next item
-
-
All carousel events are fired at the carousel itself (i.e. at the <div class="carousel">).
-
-
-
-
Event Type
-
Description
-
-
-
-
-
slide.bs.carousel
-
This event fires immediately when the slide instance method is invoked.
-
-
-
slid.bs.carousel
-
This event is fired when the carousel has completed its slide transition.
-
-
-
-
-
Change transition duration
-
The transition duration of .carousel-item can be changed with the $carousel-transition Sass variable before compiling or custom styles if you’re using the compiled CSS. If multiple transitions are applied, make sure the transform transition is defined first (eg. transition: transform 2s ease, opacity .5s ease-out).
Toggle the visibility of content across your project with a few classes and our JavaScript plugins.
-
-
-
-
-
-
-
-
-
-
How it works
-
The collapse JavaScript plugin is used to show and hide content. Buttons or anchors are used as triggers that are mapped to specific elements you toggle. Collapsing an element will animate the height from its current value to 0. Given how CSS handles animations, you cannot use padding on a .collapse element. Instead, use the class as an independent wrapping element.
- Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
-
-
-
-
-
Multiple targets
-
A <button> or <a> can show and hide multiple elements by referencing them with a JQuery selector in its href or data-target attribute.
-Multiple <button> or <a> can show and hide an element if they each reference it with their href or data-target attribute
- Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
-
-
-
-
-
-
- Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
-
-
-
-
-
-
-
Accordion example
-
Using the card component, you can extend the default collapse behavior to create an accordion. To properly achieve the accordion style, be sure to use .accordion as a wrapper.
-
-
-
-
-
-
-
-
-
-
- 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.
-
-
-
-
-
-
-
Accessibility
-
Be sure to add aria-expanded to the control element. This attribute explicitly conveys the current state of the collapsible element tied to the control to screen readers and similar assistive technologies. If the collapsible element is closed by default, the attribute on the control element should have a value of aria-expanded="false". If you’ve set the collapsible element to be open by default using the show class, set aria-expanded="true" on the control instead. The plugin will automatically toggle this attribute on the control based on whether or not the collapsible element has been opened or closed (via JavaScript, or because the user triggered another control element also tied to the same collapsible element). If the control element’s HTML element is not a button (e.g., an <a> or <div>), the attribute role="button" should be added to the element.
-
If your control element is targeting a single collapsible element – i.e. the data-target attribute is pointing to an id selector – you should add the aria-controls attribute to the control element, containing the id of the collapsible element. Modern screen readers and similar assistive technologies make use of this attribute to provide users with additional shortcuts to navigate directly to the collapsible element itself.
-
Note that Bootstrap’s current implementation does not cover the various keyboard interactions described in the WAI-ARIA Authoring Practices 1.1 accordion pattern - you will need to include these yourself with custom JavaScript.
-
Usage
-
The collapse plugin utilizes a few classes to handle the heavy lifting:
-
-
-.collapse hides the content
-
-.collapse.show shows the content
-
-.collapsing is added when the transition starts, and removed when it finishes
-
-
These classes can be found in _transitions.scss.
-
Via data attributes
-
Just add data-toggle="collapse" and a data-target to the element to automatically assign control of one or more collapsible elements. 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 show.
-
To add accordion-like group management to a collapsible area, add the data attribute data-parent="#selector". Refer to the demo to see this in action.
-
Via JavaScript
-
Enable manually with:
-
-
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 | jQuery object | DOM element
-
false
-
If parent is provided, then all collapsible elements under the specified parent will be closed when this collapsible item is shown. (similar to traditional accordion behavior - this is dependent on the card class). The attribute has to be set on the target collapsible area.
-
-
-
toggle
-
boolean
-
true
-
Toggles the collapsible element on invocation
-
-
-
-
Methods
-
-
Asynchronous methods and transitions
-
All API methods are asynchronous and start a transition. They returns to the caller as soon as the transition is started but before it ends. In addition, a method call on a transitioning component will be ignored.
-
-
.collapse(options)
-
Activates your content as a collapsible element. Accepts an optional options object.
-
-
.collapse('toggle')
-
Toggles a collapsible element to shown or hidden. Returns to the caller before the collapsible element has actually been shown or hidden (i.e. before the shown.bs.collapse or hidden.bs.collapse event occurs).
-
.collapse('show')
-
Shows a collapsible element. Returns to the caller before the collapsible element has actually been shown (i.e. before the shown.bs.collapse event occurs).
-
.collapse('hide')
-
Hides a collapsible element. Returns to the caller before the collapsible element has actually been hidden (i.e. before the hidden.bs.collapse event occurs).
-
.collapse('dispose')
-
Destroys an element’s collapse.
-
Events
-
Bootstrap’s collapse class exposes a few events for hooking into collapse functionality.
-
-
-
-
Event Type
-
Description
-
-
-
-
-
show.bs.collapse
-
This event fires immediately when the show instance method is called.
-
-
-
shown.bs.collapse
-
This event is fired when a collapse element has been made visible to the user (will wait for CSS transitions to complete).
-
-
-
hide.bs.collapse
-
This event is fired immediately when the hide method has been called.
-
-
-
hidden.bs.collapse
-
This event is fired when a collapse element has been hidden from the user (will wait for CSS transitions to complete).
Toggle contextual overlays for displaying lists of links and more with the Bootstrap dropdown plugin.
-
-
-
-
-
-
-
-
-
-
Overview
-
Dropdowns are toggleable, contextual overlays for displaying lists of links and more. They’re made interactive with the included Bootstrap dropdown JavaScript plugin. They’re toggled by clicking, not by hovering; this is an intentional design decision.
-
Dropdowns are built on a third party library, Popper.js, which provides dynamic positioning and viewport detection. Be sure to include popper.min.js before Bootstrap’s JavaScript or use bootstrap.bundle.min.js / bootstrap.bundle.js which contains Popper.js. Popper.js isn’t used to position dropdowns in navbars though as dynamic positioning isn’t required.
-
If you’re building our JavaScript from source, it requires util.js.
-
Accessibility
-
The WAI ARIA standard defines an actual role="menu" widget, but this is specific to application-like menus which trigger actions or functions. ARIA menus can only contain menu items, checkbox menu items, radio button menu items, radio button groups, and sub-menus.
-
Bootstrap’s dropdowns, on the other hand, are designed to be generic and applicable to a variety of situations and markup structures. For instance, it is possible to create dropdowns that contain additional inputs and form controls, such as search fields or login forms. For this reason, Bootstrap does not expect (nor automatically add) any of the role and aria- attributes required for true ARIA menus. Authors will have to include these more specific attributes themselves.
-
However, Bootstrap does add built-in support for most standard keyboard menu interactions, such as the ability to move through individual .dropdown-item elements using the cursor keys and close the menu with the ESC key.
-
Examples
-
Wrap the dropdown’s toggle (your button or link) and the dropdown menu within .dropdown, or another element that declares position: relative;. Dropdowns can be triggered from <a> or <button> elements to better fit your potential needs.
-
Single button
-
Any single .btn can be turned into a dropdown toggle with some markup changes. Here’s how you can put them to work with either <button> elements:
Similarly, create split button dropdowns with virtually the same markup as single button dropdowns, but with the addition of .dropdown-toggle-split for proper spacing around the dropdown caret.
-
We use this extra class to reduce the horizontal padding on either side of the caret by 25% and remove the margin-left that’s added for regular button dropdowns. Those extra changes keep the caret centered in the split button and provide a more appropriately sized hit area next to the main button.
Historically dropdown menu contents had to be links, but that’s no longer the case with v4. Now you can optionally use <button> elements in your dropdowns instead of just <a>s.
-
-
-
-
-
-
-
-
-
-
-
-
You can also create non-interactive dropdown items with .dropdown-item-text. Feel free to style further with custom CSS or text utilities.
By default, a dropdown menu is automatically positioned 100% from the top and along the left side of its parent. Add .dropdown-menu-right to a .dropdown-menu to right align the dropdown menu.
-
-
Heads up! Dropdowns are positioned thanks to Popper.js (except when they are contained in a navbar).
-
-
-
-
-
-
-
-
-
-
-
-
-
Responsive alignment
-
If you want to use responsive alignment, disable dynamic positioning by adding the data-display="static" attribute and use the responsive variation classes.
-
To align right the dropdown menu with the given breakpoint or larger, add .dropdown-menu{-sm|-md|-lg|-xl}-right.
-
-
-
-
-
-
-
-
-
-
-
-
To align left the dropdown menu with the given breakpoint or larger, add .dropdown-menu-right and .dropdown-menu{-sm|-md|-lg|-xl}-left.
-
-
-
-
-
-
-
-
-
-
-
-
Note that you don’t need to add a data-display="static" attribute to dropdown buttons in navbars, since Popper.js isn’t used in navbars.
-
Menu content
-
Headers
-
Add a header to label sections of actions in any dropdown menu.
Place any freeform text within a dropdown menu with text and use spacing utilities. Note that you’ll likely need additional sizing styles to constrain the menu width.
-
-
-
- Some example text that's free-flowing within the dropdown menu.
-
-
- And this is more example text.
-
-
-
-
-
Forms
-
Put a form within a dropdown menu, or make it into a dropdown menu, and use margin or padding utilities to give it the negative space you require.
Via data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) by toggling the .show class on the parent list item. The data-toggle="dropdown" attribute is relied on for closing dropdown menus at an application level, so it’s a good idea to always use it.
-
-
On touch-enabled devices, opening a dropdown adds empty ($.noop) mouseover handlers to the immediate children of the <body> element. This admittedly ugly hack is necessary to work around a quirk in iOS’ event delegation, which would otherwise prevent a tap anywhere outside of the dropdown from triggering the code that closes the dropdown. Once the dropdown is closed, these additional empty mouseover handlers are removed.
-
-
Via data attributes
-
Add data-toggle="dropdown" to a link or button to toggle a dropdown.
-
-
Via JavaScript
-
Call the dropdowns via JavaScript:
-
-
-
-data-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 present on the dropdown’s trigger element.
-
-
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 | string | function
-
0
-
-
Offset of the dropdown relative to its target.
-
When a function is used to determine the offset, it is called with an object containing the offset data as its first argument. The function must return an object with the same structure. The triggering element DOM node is passed as the second argument.
-
For more information refer to Popper.js's offset docs.
-
-
-
-
flip
-
boolean
-
true
-
Allow Dropdown to flip in case of an overlapping on the reference element. For more information refer to Popper.js's flip docs.
-
-
-
boundary
-
string | element
-
'scrollParent'
-
Overflow constraint boundary of the dropdown menu. Accepts the values of 'viewport', 'window', 'scrollParent', or an HTMLElement reference (JavaScript only). For more information refer to Popper.js's preventOverflow docs.
-
-
-
reference
-
string | element
-
'toggle'
-
Reference element of the dropdown menu. Accepts the values of 'toggle', 'parent', or an HTMLElement reference. For more information refer to Popper.js's referenceObject docs.
-
-
-
display
-
string
-
'dynamic'
-
By default, we use Popper.js for dynamic positioning. Disable this with static.
Note when boundary is set to any value other than 'scrollParent', the style position: static is applied to the .dropdown container.
-
Methods
-
-
-
-
Method
-
Description
-
-
-
-
-
$().dropdown('toggle')
-
Toggles the dropdown menu of a given navbar or tabbed navigation.
-
-
-
$().dropdown('show')
-
Shows the dropdown menu of a given navbar or tabbed navigation.
-
-
-
$().dropdown('hide')
-
Hides the dropdown menu of a given navbar or tabbed navigation.
-
-
-
$().dropdown('update')
-
Updates the position of an element’s dropdown.
-
-
-
$().dropdown('dispose')
-
Destroys an element’s dropdown.
-
-
-
-
Events
-
All dropdown events are fired at the .dropdown-menu’s parent element and have a relatedTarget property, whose value is the toggling anchor element.
-hide.bs.dropdown and hidden.bs.dropdown events have a clickEvent property (only when the original event type is click) that contains an Event Object for the click event.
-
-
-
-
Event
-
Description
-
-
-
-
-
show.bs.dropdown
-
This event fires immediately when the show instance method is called.
-
-
-
shown.bs.dropdown
-
This event is fired when the dropdown has been made visible to the user (will wait for CSS transitions, to complete).
-
-
-
hide.bs.dropdown
-
This event is fired immediately when the hide instance method has been called.
-
-
-
hidden.bs.dropdown
-
This event is fired when the dropdown has finished being hidden from the user (will wait for CSS transitions, to complete).
Examples and usage guidelines for form control styles, layout options, and custom components for creating a wide variety of forms.
-
-
-
-
-
-
-
-
-
-
Overview
-
Bootstrap’s form controls expand on our Rebooted form styles with classes. Use these classes to opt into their customized displays for a more consistent rendering across browsers and devices.
-
Be sure to use an appropriate type attribute on all inputs (e.g., email for email address or number for numerical information) to take advantage of newer input controls like email verification, number selection, and more.
-
Here’s a quick example to demonstrate Bootstrap’s form styles. Keep reading for documentation on required classes, form layout, and more.
-
-
-
-
-
Form controls
-
Textual form controls—like <input>s, <select>s, and <textarea>s—are styled with the .form-control class. Included are styles for general appearance, focus state, sizing, and more.
-
Be sure to explore our custom forms to further style <select>s.
-
-
-
-
-
For file inputs, swap the .form-control for .form-control-file.
-
-
-
-
-
Sizing
-
Set heights using classes like .form-control-lg and .form-control-sm.
-
-
-
-
-
-
-
-
-
-
-
-
-
Readonly
-
Add the readonly boolean attribute on an input to prevent modification of the input’s value. Read-only inputs appear lighter (just like disabled inputs), but retain the standard cursor.
-
-
-
-
-
Readonly plain text
-
If you want to have <input readonly> elements in your form styled as plain text, use the .form-control-plaintext class to remove the default form field styling and preserve the correct margin and padding.
-
-
-
-
-
-
-
-
-
Range Inputs
-
Set horizontally scrollable range inputs using .form-control-range.
-
-
-
-
-
Checkboxes and radios
-
Default checkboxes and radios are improved upon with the help of .form-check, a single class for both input types that improves the layout and behavior of their HTML elements. Checkboxes are for selecting one or several options in a list, while radios are for selecting one option from many.
-
Disabled checkboxes and radios are supported. The disabled attribute will apply a lighter color to help indicate the input’s state.
-
Checkboxes and radio buttons support HTML-based form validation and provide concise, accessible labels. As such, our <input>s and <label>s are sibling elements as opposed to an <input> within a <label>. This is slightly more verbose as you must specify id and for attributes to relate the <input> and <label>.
-
Default (stacked)
-
By default, any number of checkboxes and radios that are immediate sibling will be vertically stacked and appropriately spaced with .form-check.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Inline
-
Group checkboxes or radios on the same horizontal row by adding .form-check-inline to any .form-check.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Without labels
-
Add .position-static to inputs within .form-check that don’t have any label text. Remember to still provide some form of accessible name for assistive technologies (for instance, using aria-label).
-
-
-
-
-
-
-
-
-
-
Layout
-
Since Bootstrap applies display: block and width: 100% to almost all our form controls, forms will by default stack vertically. Additional classes can be used to vary this layout on a per-form basis.
-
Form groups
-
The .form-group class is the easiest way to add some structure to forms. It provides a flexible class that encourages proper grouping of labels, controls, optional help text, and form validation messaging. By default it only applies margin-bottom, but it picks up additional styles in .form-inline as needed. Use it with <fieldset>s, <div>s, or nearly any other element.
-
-
-
-
-
Form grid
-
More complex forms can be built using our grid classes. Use these for form layouts that require multiple columns, varied widths, and additional alignment options.
-
-
-
-
-
Form row
-
You may also swap .row for .form-row, a variation of our standard grid row that overrides the default column gutters for tighter and more compact layouts.
-
-
-
-
-
More complex layouts can also be created with the grid system.
-
-
-
-
-
Horizontal form
-
Create horizontal forms with the grid by adding the .row class to form groups and using the .col-*-* classes to specify the width of your labels and controls. Be sure to add .col-form-label to your <label>s as well so they’re vertically centered with their associated form controls.
-
At times, you maybe need to use margin or padding utilities to create that perfect alignment you need. For example, we’ve removed the padding-top on our stacked radio inputs label to better align the text baseline.
-
-
-
-
-
Horizontal form label sizing
-
Be sure to use .col-form-label-sm or .col-form-label-lg to your <label>s or <legend>s to correctly follow the size of .form-control-lg and .form-control-sm.
-
-
-
-
-
Column sizing
-
As shown in the previous examples, our grid system allows you to place any number of .cols within a .row or .form-row. They’ll split the available width equally between them. You may also pick a subset of your columns to take up more or less space, while the remaining .cols equally split the rest, with specific column classes like .col-7.
-
-
-
-
-
Auto-sizing
-
The example below uses a flexbox utility to vertically center the contents and changes .col to .col-auto so that your columns only take up as much space as needed. Put another way, the column sizes itself based on the contents.
-
-
-
-
-
You can then remix that once again with size-specific column classes.
Use the .form-inline class to display a series of labels, form controls, and buttons on a single horizontal row. Form controls within inline forms vary slightly from their default states.
-
-
Controls are display: flex, collapsing any HTML white space and allowing you to provide alignment control with spacing and flexbox utilities.
-
Controls and input groups receive width: auto to override the Bootstrap default width: 100%.
-
Controls only appear inline in viewports that are at least 576px wide to account for narrow viewports on mobile devices.
-
-
You may need to manually address the width and alignment of individual form controls with spacing utilities (as shown below). Lastly, be sure to always include a <label> with each form control, even if you need to hide it from non-screenreader visitors with .sr-only.
-
-
-
-
-
Custom form controls and selects are also supported.
-
-
-
-
-
-
Alternatives to hidden labels
-
Assistive technologies such as screen readers will have trouble with your forms if you don’t include a label for every input. For these inline forms, you can hide the labels using the .sr-only class. There are further alternative methods of providing a label for assistive technologies, such as the aria-label, aria-labelledby or title attribute. If none of these are present, assistive technologies may resort to using the placeholder attribute, if present, but note that use of placeholder as a replacement for other labelling methods is not advised.
-
-
Help text
-
Block-level help text in forms can be created using .form-text (previously known as .help-block in v3). Inline help text can be flexibly implemented using any inline HTML element and utility classes like .text-muted.
-
-
Associating help text with form controls
-
Help text should be explicitly associated with the form control it relates to using the aria-describedby attribute. This will ensure that assistive technologies—such as screen readers—will announce this help text when the user focuses or enters the control.
-
-
Help text below inputs can be styled with .form-text. This class includes display: block and adds some top margin for easy spacing from the inputs above.
-
-
-
-
- Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji.
-
-
-
-
Inline text can use any typical inline HTML element (be it a <small>, <span>, or something else) with nothing more than a utility class.
-
-
-
-
-
Disabled forms
-
Add the disabled boolean attribute on an input to prevent user interactions and make it appear lighter.
-
-
Add the disabled attribute to a <fieldset> to disable all the controls within.
-
-
-
-
-
-
Caveat with anchors
-
Browsers treat all native form controls (<input>, <select>, and <button> elements) inside a <fieldset disabled> as disabled, preventing both keyboard and mouse interactions on them.
-
However, if your form also includes custom button-like elements such as <a ... class="btn btn-*">, these will only be given a style of pointer-events: none. As noted in the section about disabled state for buttons (and specifically in the sub-section for anchor elements), this CSS property is not yet standardized and isn’t fully supported in Internet Explorer 10. The anchor-based controls will also still be focusable and operable using the keyboard. You must manually modify these controls by adding tabindex="-1" to prevent them from receiving focus and aria-disabled="disabled" to signal their state to assistive technologies.
-
-
-
Cross-browser compatibility
-
While Bootstrap will apply these styles in all browsers, Internet Explorer 11 and below don’t fully support the disabled attribute on a <fieldset>. Use custom JavaScript to disable the fieldset in these browsers.
-
-
Validation
-
Provide valuable, actionable feedback to your users with HTML5 form validation–available in all our supported browsers. Choose from the browser default validation feedback, or implement custom messages with our built-in classes and starter JavaScript.
-
-
We are aware that currently the client-side custom validation styles and tooltips are not accessible, since they are not exposed to assistive technologies. While we work on a solution, we’d recommend either using the server-side option or the default browser validation method.
-
-
How it works
-
Here’s how form validation works with Bootstrap:
-
-
HTML form validation is applied via CSS’s two pseudo-classes, :invalid and :valid. It applies to <input>, <select>, and <textarea> elements.
-
Bootstrap scopes the :invalid and :valid styles to parent .was-validated class, usually applied to the <form>. Otherwise, any required field without a value shows up as invalid on page load. This way, you may choose when to activate them (typically after form submission is attempted).
-
To reset the appearance of the form (for instance, in the case of dynamic form submissions using AJAX), remove the .was-validated class from the <form> again after submission.
-
As a fallback, .is-invalid and .is-valid classes may be used instead of the pseudo-classes for server side validation. They do not require a .was-validated parent class.
-
Due to constraints in how CSS works, we cannot (at present) apply styles to a <label> that comes before a form control in the DOM without the help of custom JavaScript.
-
All modern browsers support the constraint validation API, a series of JavaScript methods for validating form controls.
-
Feedback messages may utilize the browser defaults (different for each browser, and unstylable via CSS) or our custom feedback styles with additional HTML and CSS.
-
You may provide custom validity messages with setCustomValidity in JavaScript.
-
-
With that in mind, consider the following demos for our custom form validation styles, optional server side classes, and browser defaults.
-
Custom styles
-
For custom Bootstrap form validation messages, you’ll need to add the novalidate boolean attribute to your <form>. This disables the browser default feedback tooltips, but still provides access to the form validation APIs in JavaScript. Try to submit the form below; our JavaScript will intercept the submit button and relay feedback to you. When attempting to submit, you’ll see the :invalid and :valid styles applied to your form controls.
-
Custom feedback styles apply custom colors, borders, focus styles, and background icons to better communicate feedback. Background icons for <select>s are only available with .custom-select, and not .form-control.
-
-
-
-
-
-
Browser defaults
-
Not interested in custom validation feedback messages or writing JavaScript to change form behaviors? All good, you can use the browser defaults. Try submitting the form below. Depending on your browser and OS, you’ll see a slightly different style of feedback.
-
While these feedback styles cannot be styled with CSS, you can still customize the feedback text through JavaScript.
-
-
-
-
-
Server side
-
We recommend using client-side validation, but in case you require server-side validation, you can indicate invalid and valid form fields with .is-invalid and .is-valid. Note that .invalid-feedback is also supported with these classes.
-
For invalid fields, ensure that the invalid feedback/error message is associated with the relevant form field using aria-describedby. This attribute allows more than one id to be referenced, in case the field already points to additional form text.
-
-
-
-
-
Supported elements
-
Validation styles are available for the following form controls and components:
-
-
-<input>s and <textarea>s with .form-control (including up to one .form-control in input groups)
-
-<select>s with .form-control or .custom-select
-
-
-.form-checks
-
-.custom-checkboxs and .custom-radios
-
.custom-file
-
-
-
-
-
-
Tooltips
-
If your form layout allows it, you can swap the .{valid|invalid}-feedback classes for .{valid|invalid}-tooltip classes to display validation feedback in a styled tooltip. Be sure to have a parent with position: relative on it for tooltip positioning. In the example below, our column classes have this already, but your project may require an alternative setup.
-
-
-
-
-
Customizing
-
Validation states can be customized via Sass with the $form-validation-states map. Located in our _variables.scss file, this Sass map is looped over to generate the default valid/invalid validation states. Included is a nested map for customizing each state’s color and icon. While no other states are supported by browsers, those using custom styles can easily add more complex form feedback.
-
Please note that we do not recommend customizing these values without also modifying the form-validation-state mixin.
-
-
Custom forms
-
For even more customization and cross browser consistency, use our completely custom form elements to replace the browser defaults. They’re built on top of semantic and accessible markup, so they’re solid replacements for any default form control.
-
Checkboxes and radios
-
Each checkbox and radio <input> and <label> pairing is wrapped in a <div> to create our custom control. Structurally, this is the same approach as our default .form-check.
-
We use the sibling selector (~) for all our <input> states—like :checked—to properly style our custom form indicator. When combined with the .custom-control-label class, we can also style the text for each item based on the <input>’s state.
-
We hide the default <input> with opacity and use the .custom-control-label to build a new custom form indicator in its place with ::before and ::after. Unfortunately we can’t build a custom one from just the <input> because CSS’s content doesn’t work on that element.
-
In the checked states, we use base64 embedded SVG icons from Open Iconic. This provides us the best control for styling and positioning across browsers and devices.
-
Checkboxes
-
-
-
-
-
-
-
-
Custom checkboxes can also utilize the :indeterminate pseudo class when manually set via JavaScript (there is no available HTML attribute for specifying it).
-
-
-
-
-
-
-
If you’re using jQuery, something like this should suffice:
-
-
Radios
-
-
-
-
-
-
-
-
-
-
-
-
Inline
-
-
-
-
-
-
-
-
-
-
-
-
Disabled
-
Custom checkboxes and radios can also be disabled. Add the disabled boolean attribute to the <input> and the custom indicator and label description will be automatically styled.
-
-
-
-
-
-
-
-
-
-
-
-
Switches
-
A switch has the markup of a custom checkbox but uses the .custom-switch class to render a toggle switch. Switches also support the disabled attribute.
-
-
-
-
-
-
-
-
-
-
-
-
Select menu
-
Custom <select> menus need only a custom class, .custom-select to trigger the custom styles. Custom styles are limited to the <select>’s initial appearance and cannot modify the <option>s due to browser limitations.
-
-
-
-
-
You may also choose from small and large custom selects to match our similarly sized text inputs.
-
-
-
-
-
-
The multiple attribute is also supported:
-
-
-
-
-
As is the size attribute:
-
-
-
-
-
Range
-
Create custom <input type="range"> controls with .custom-range. The track (the background) and thumb (the value) are both styled to appear the same across browsers. As only IE and Firefox support “filling” their track from the left or right of the thumb as a means to visually indicate progress, we do not currently support it.
-
-
-
-
-
-
Range inputs have implicit values for min and max—0 and 100, respectively. You may specify new values for those using the min and max attributes.
-
-
-
-
-
-
By default, range inputs “snap” to integer values. To change this, you can specify a step value. In the example below, we double the number of steps by using step="0.5".
-
-
-
-
-
-
File browser
-
-
The recommended plugin to animate custom file input: bs-custom-file-input, that’s what we are using currently here in our docs.
-
-
The file input is the most gnarly of the bunch and requires additional JavaScript if you’d like to hook them up with functional Choose file… and selected file name text.
-
-
-
-
-
-
-
-
We hide the default file <input> via opacity and instead style the <label>. The button is generated and positioned with ::after. Lastly, we declare a width and height on the <input> for proper spacing for surrounding content.
-
Translating or customizing the strings with SCSS
-
The :lang() pseudo-class is used to allow for translation of the “Browse” text into other languages. Override or add entries to the $custom-file-text Sass variable with the relevant language tag and localized strings. The English strings can be customized the same way. For example, here’s how one might add a Spanish translation (Spanish’s language code is es):
-
-
Here’s lang(es) in action on the custom file input for a Spanish translation:
-
-
-
-
-
-
-
-
You’ll need to set the language of your document (or subtree thereof) correctly in order for the correct text to be shown. This can be done using the lang attribute on the <html> element or the Content-Language HTTP header, among other methods.
-
Translating or customizing the strings with HTML
-
Bootstrap also provides a way to translate the “Browse” text in HTML with the data-browse attribute which can be added to the custom input label (example in Dutch):
Easily extend form controls by adding text, buttons, or button groups on either side of textual inputs, custom selects, and custom file inputs.
-
-
-
-
-
-
-
-
-
-
Basic example
-
Place one add-on or button on either side of an input. You may also place one on both sides of an input. Remember to place <label>s outside the input group.
-
-
-
- @
-
-
-
-
-
-
- @example.com
-
-
-
-
-
- https://example.com/users/
-
-
-
-
-
- $
-
-
-
- .00
-
-
-
-
- With textarea
-
-
-
-
-
-
Wrapping
-
Input groups wrap by default via flex-wrap: wrap in order to accommodate custom form field validation within an input group. You may disable this with .flex-nowrap.
-
-
-
- @
-
-
-
-
-
-
Sizing
-
Add the relative form sizing classes to the .input-group itself and contents within will automatically resize—no need for repeating the form control size classes on each element.
-
Sizing on the individual input group elements isn’t supported.
-
-
-
- Small
-
-
-
-
-
- Default
-
-
-
-
-
- Large
-
-
-
-
-
-
Checkboxes and radios
-
Place any checkbox or radio option within an input group’s addon instead of text.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Multiple inputs
-
While multiple <input>s are supported visually, validation styles are only available for input groups with a single <input>.
-
-
-
- First and last name
-
-
-
-
-
-
-
Multiple addons
-
Multiple add-ons are supported and can be mixed with checkbox and radio input versions.
Input groups include support for custom selects and custom file inputs. Browser default versions of these are not supported.
-
Custom select
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Custom file input
-
-
-
- Upload
-
-
-
-
-
-
-
-
-
-
-
-
- Upload
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Accessibility
-
Ensure that all form controls have an appropriate accessible name so that their purpose can be conveyed to users of assistive technologies. The simplest way to achieve this is to use a <label> element, or—in the case of buttons—to include sufficiently descriptive text as part of the <button>...</button> content.
-
For situations where it’s not possible to include a visible <label> or appropriate text content, there are alternative ways of still providing an accessible name, such as:
-
-
-<label> elements hidden using the .visually-hidden class
-
Pointing to an existing element that can act as a label using aria-labelledby
-
-
Providing a title attribute
-
Explicitly setting the accessible name on an element using aria-label
-
-
-
If none of these are present, assistive technologies may resort to using the placeholder attribute as a fallback for the accessible name on <input> and <textarea> elements. The examples in this section provide a few suggested, case-specific approaches.
-
While using visually hidden content (.sr-only, aria-label, and even placeholder content, which disappears once a form field has content) will benefit assistive technology users, a lack of visible label text may still be problematic for certain users. Some form of visible label is generally the best approach, both for accessibility and usability.
To make the jumbotron full width, and without rounded corners, add the .jumbotron-fluid modifier class and add a .container or .container-fluid within.
-
-
-
-
Fluid jumbotron
-
This is a modified jumbotron that occupies the entire horizontal space of its parent.
List groups are a flexible and powerful component for displaying a series of content. Modify and extend them to support just about any content within.
-
-
-
-
-
-
-
-
-
-
Basic example
-
The most basic list group is an unordered list with list items and the proper classes. Build upon it with the options that follow, or with your own CSS as needed.
-
-
-
Cras justo odio
-
Dapibus ac facilisis in
-
Morbi leo risus
-
Porta ac consectetur ac
-
Vestibulum at eros
-
-
-
-
Active items
-
Add .active to a .list-group-item to indicate the current active selection.
-
-
-
Cras justo odio
-
Dapibus ac facilisis in
-
Morbi leo risus
-
Porta ac consectetur ac
-
Vestibulum at eros
-
-
-
-
Disabled items
-
Add .disabled to a .list-group-item to make it appear disabled. Note that some elements with .disabled will also require custom JavaScript to fully disable their click events (e.g., links).
-
-
-
Cras justo odio
-
Dapibus ac facilisis in
-
Morbi leo risus
-
Porta ac consectetur ac
-
Vestibulum at eros
-
-
-
-
Links and buttons
-
Use <a>s or <button>s to create actionable list group items with hover, disabled, and active states by adding .list-group-item-action. We separate these pseudo-classes to ensure list groups made of non-interactive elements (like <li>s or <div>s) don’t provide a click or tap affordance.
-
Be sure to not use the standard .btn classes here.
With <button>s, you can also make use of the disabled attribute instead of the .disabled class. Sadly, <a>s don’t support the disabled attribute.
-
-
-
-
-
-
-
-
-
-
-
Flush
-
Add .list-group-flush to remove some borders and rounded corners to render list group items edge-to-edge in a parent container (e.g., cards).
-
-
-
Cras justo odio
-
Dapibus ac facilisis in
-
Morbi leo risus
-
Porta ac consectetur ac
-
Vestibulum at eros
-
-
-
-
Horizontal
-
Add .list-group-horizontal to change the layout of list group items from vertical to horizontal across all breakpoints. Alternatively, choose a responsive variant .list-group-horizontal-{sm|md|lg|xl} to make a list group horizontal starting at that breakpoint’s min-width. Currently horizontal list groups cannot be combined with flush list groups.
-
ProTip: Want equal-width list group items when horizontal? Add .flex-fill to each list group item.
-
-
-
Cras justo odio
-
Dapibus ac facilisis in
-
Morbi leo risus
-
-
-
-
-
-
Cras justo odio
-
Dapibus ac facilisis in
-
Morbi leo risus
-
-
-
-
-
-
Cras justo odio
-
Dapibus ac facilisis in
-
Morbi leo risus
-
-
-
-
-
-
Cras justo odio
-
Dapibus ac facilisis in
-
Morbi leo risus
-
-
-
-
-
-
Cras justo odio
-
Dapibus ac facilisis in
-
Morbi leo risus
-
-
-
-
Contextual classes
-
Use contextual classes to style list items with a stateful background and color.
-
-
-
Dapibus ac facilisis in
-
A simple primary list group item
-
A simple secondary list group item
-
A simple danger list group item
-
A simple info list group item
-
A simple success list group item
-
A simple warning list group item
-
A simple dark list group item
-
A simple light list group item
-
-
-
-
Contextual classes also work with .list-group-item-action. Note the addition of the hover styles here not present in the previous example. Also supported is the .active state; apply it to indicate an active selection on a contextual list group item.
Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .sr-only class.
-
-
With badges
-
Add badges to any list group item to show unread counts, activity, and more with the help of some utilities.
-
-
-
- Cras justo odio
- 14
-
-
- Dapibus ac facilisis in
- 2
-
-
- Morbi leo risus
- 1
-
-
-
-
-
Custom content
-
Add nearly any HTML within, even for linked list groups like the one below, with the help of flexbox utilities.
Use the tab JavaScript plugin—include it individually or through the compiled bootstrap.js file—to extend our list group to create tabbable panes of local content.
Velit aute mollit ipsum ad dolor consectetur nulla officia culpa adipisicing exercitation fugiat tempor. Voluptate deserunt sit sunt nisi aliqua fugiat proident ea ut. Mollit voluptate reprehenderit occaecat nisi ad non minim tempor sunt voluptate consectetur exercitation id ut nulla. Ea et fugiat aliquip nostrud sunt incididunt consectetur culpa aliquip eiusmod dolor. Anim ad Lorem aliqua in cupidatat nisi enim eu nostrud do aliquip veniam minim.
-
-
-
Cupidatat quis ad sint excepteur laborum in esse qui. Et excepteur consectetur ex nisi eu do cillum ad laborum. Mollit et eu officia dolore sunt Lorem culpa qui commodo velit ex amet id ex. Officia anim incididunt laboris deserunt anim aute dolor incididunt veniam aute dolore do exercitation. Dolor nisi culpa ex ad irure in elit eu dolore. Ad laboris ipsum reprehenderit irure non commodo enim culpa commodo veniam incididunt veniam ad.
-
-
-
Ut ut do pariatur aliquip aliqua aliquip exercitation do nostrud commodo reprehenderit aute ipsum voluptate. Irure Lorem et laboris nostrud amet cupidatat cupidatat anim do ut velit mollit consequat enim tempor. Consectetur est minim nostrud nostrud consectetur irure labore voluptate irure. Ipsum id Lorem sit sint voluptate est pariatur eu ad cupidatat et deserunt culpa sit eiusmod deserunt. Consectetur et fugiat anim do eiusmod aliquip nulla laborum elit adipisicing pariatur cillum.
-
-
-
Irure enim occaecat labore sit qui aliquip reprehenderit amet velit. Deserunt ullamco ex elit nostrud ut dolore nisi officia magna sit occaecat laboris sunt dolor. Nisi eu minim cillum occaecat aute est cupidatat aliqua labore aute occaecat ea aliquip sunt amet. Aute mollit dolor ut exercitation irure commodo non amet consectetur quis amet culpa. Quis ullamco nisi amet qui aute irure eu. Magna labore dolor quis ex labore id nostrud deserunt dolor eiusmod eu pariatur culpa mollit in irure.
-
-
-
-
-
-
-
Using data attributes
-
You can activate a list group navigation without writing any JavaScript by simply specifying data-toggle="list" or on an element. Use these data attributes on .list-group-item.
-
-
-
-
Via JavaScript
-
Enable tabbable list item via JavaScript (each list item needs to be activated individually):
-
-
You can activate individual list item in several ways:
-
-
Fade effect
-
To make tabs panel fade in, add .fade to each .tab-pane. The first tab pane must also have .show to make the initial content visible.
-
-
Methods
-
$().tab
-
Activates a list item element and content container. Tab should have either a data-target or an href targeting a container node in the DOM.
-
-
.tab(‘show’)
-
Selects the given list item and shows its associated pane. Any other list item that was previously selected becomes unselected and its associated pane is hidden. Returns to the caller before the tab pane has actually been shown (for example, before the shown.bs.tab event occurs).
-
-
Events
-
When showing a new tab, the events fire in the following order:
-
-
-hide.bs.tab (on the current active tab)
-
-show.bs.tab (on the to-be-shown tab)
-
-hidden.bs.tab (on the previous active tab, the same one as for the hide.bs.tab event)
-
-shown.bs.tab (on the newly-active just-shown tab, the same one as for the show.bs.tab event)
-
-
If no tab was already active, the hide.bs.tab and hidden.bs.tab events will not be fired.
-
-
-
-
Event type
-
Description
-
-
-
-
-
show.bs.tab
-
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.bs.tab
-
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.
-
-
-
hide.bs.tab
-
This event fires when a new tab is to be shown (and thus the previous active tab is to be hidden). Use event.target and event.relatedTarget to target the current active tab and the new soon-to-be-active tab, respectively.
-
-
-
hidden.bs.tab
-
This event fires after a new tab is shown (and thus the previous active tab is hidden). Use event.target and event.relatedTarget to target the previous active tab and the new active tab, respectively.
Documentation and examples for Bootstrap's media object to construct highly repetitive components like blog comments, tweets, and the like.
-
-
-
-
-
-
-
-
-
-
Example
-
The media object helps build complex and repetitive components where some media is positioned alongside content that doesn’t wrap around said media. Plus, it does this with only two required classes thanks to flexbox.
-
Below is an example of a single media object. Only two classes are required—the wrapping .media and the .media-body around your content. Optional padding and margin can be controlled through spacing utilities.
-
-
-
-
-
Media heading
- Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
-
-
-
-
-
-
Flexbug #12: Inline elements aren’t treated as flex items
-
Internet Explorer 10-11 do not render inline elements like links or images (or ::before and ::after pseudo-elements) as flex items. The only workaround is to set a non-inline display value (e.g., block, inline-block, or flex). We suggest using .d-flex, one of our display utilities, as an easy fix.
Media objects can be infinitely nested, though we suggest you stop at some point. Place nested .media within the .media-body of a parent media object.
-
-
-
-
-
Media heading
- Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
-
- Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
-
-
-
-
-
-
-
Alignment
-
Media in a media object can be aligned with flexbox utilities to the top (default), middle, or end of your .media-body content.
-
-
-
-
-
Top-aligned media
-
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
-
Donec sed odio dui. Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
-
-
-
-
-
-
-
-
-
Center-aligned media
-
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
-
Donec sed odio dui. Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
-
-
-
-
-
-
-
-
-
Bottom-aligned media
-
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
-
Donec sed odio dui. Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
-
-
-
-
-
Order
-
Change the order of content in media objects by modifying the HTML itself, or by adding some custom flexbox CSS to set the order property (to an integer of your choosing).
-
-
-
-
Media object
- Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
-
-
-
-
-
-
Media list
-
Because the media object has so few structural requirements, you can also use these classes on list HTML elements. On your <ul> or <ol>, add the .list-unstyled to remove any browser default list styles, and then apply .media to your <li>s. As always, use spacing utilities wherever needed to fine tune.
-
-
-
-
-
-
List-based media object
- Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
-
-
-
-
-
-
List-based media object
- Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
-
-
-
-
-
-
List-based media object
- Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
-
Use Bootstrap's JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.
-
-
-
-
-
-
-
-
-
-
How it works
-
Before getting started with Bootstrap’s modal component, be sure to read the following as our menu options have recently changed.
-
-
Modals are built with HTML, CSS, and JavaScript. They’re positioned over everything else in the document and remove scroll from the <body> so that modal content scrolls instead.
-
Clicking on the modal “backdrop” will automatically close the modal.
-
Bootstrap only supports one modal window at a time. Nested modals aren’t supported as we believe them to be poor user experiences.
-
Modals use position: fixed, which can sometimes be a bit particular about its rendering. Whenever possible, place your modal HTML in a top-level position to avoid potential interference from other elements. You’ll likely run into issues when nesting a .modal within another fixed element.
-
Once again, due to position: fixed, there are some caveats with using modals on mobile devices. See our browser support docs for details.
-
Due to how HTML5 defines its semantics, the autofocus HTML attribute has no effect in Bootstrap modals. To achieve the same effect, use some custom JavaScript:
Below is a static modal example (meaning its position and display have been overridden). Included are the modal header, modal body (required for padding), and modal footer (optional). We ask that you include modal headers with dismiss actions whenever possible, or provide another explicit dismiss action.
-
-
-
-
-
-
Modal title
-
-
-
-
Modal body text goes here.
-
-
-
-
-
-
-
-
Live demo
-
Toggle a working modal demo by clicking the button below. It will slide down and fade in from the top of the page.
-
-
-
-
-
Modal title
-
-
-
-
Woohoo, you're reading this text in a modal!
-
-
-
-
-
-
-
-
-
-
Static backdrop
-
When backdrop is set to static, the modal will not close when clicking outside it. Click the button below to try it.
-
-
-
-
-
Modal title
-
-
-
-
I will not close if you click outside me. Don't even try to press escape key.
-
-
-
-
-
-
-
-
-
-
Scrolling long content
-
When modals become too long for the user’s viewport or device, they scroll independent of the page itself. Try the demo below to see what we mean.
-
-
-
-
-
Modal title
-
-
-
-
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
-
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
-
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
-
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
-
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
-
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
-
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
-
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
-
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
-
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
-
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
-
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
-
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
-
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
-
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
-
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
-
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
-
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
-
-
-
-
-
-
-
-
-
You can also create a scrollable modal that allows scroll the modal body by adding .modal-dialog-scrollable to .modal-dialog.
-
-
-
-
-
Modal title
-
-
-
-
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
-
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
-
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
-
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
-
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
-
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
-
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
-
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
-
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
-
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
-
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
-
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
-
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
-
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
-
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
-
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
-
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
-
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
-
-
-
-
-
-
-
-
-
-
Vertically centered
-
Add .modal-dialog-centered to .modal-dialog to vertically center the modal.
-
-
-
-
-
Modal title
-
-
-
-
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
-
-
-
-
-
-
-
-
-
-
Modal title
-
-
-
-
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
-
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
-
Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.
-
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
-
Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
-
-
-
-
-
-
-
-
-
-
-
Tooltips and popovers
-
Tooltips and popovers can be placed within modals as needed. When modals are closed, any tooltips and popovers within are also automatically dismissed.
Utilize the Bootstrap grid system within a modal by nesting .container-fluid within the .modal-body. Then, use the normal grid system classes as you would anywhere else.
-
-
-
-
-
Grids in modals
-
-
-
-
-
-
.col-md-4
-
.col-md-4 .ml-auto
-
-
-
.col-md-3 .ml-auto
-
.col-md-2 .ml-auto
-
-
-
.col-md-6 .ml-auto
-
-
-
- Level 1: .col-sm-9
-
-
- Level 2: .col-8 .col-sm-6
-
-
- Level 2: .col-4 .col-sm-6
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Varying modal content
-
Have a bunch of buttons that all trigger the same modal with slightly different contents? Use event.relatedTarget and HTML data-* attributes (possibly via jQuery) to vary the contents of the modal depending on which button was clicked.
-
Below is a live demo followed by example HTML and JavaScript. For more information, read the modal events docs for details on relatedTarget.
-
-
-
-
-
-
-
-
-
New message
-
-
-
-
-
-
-
-
-
-
-
-
-
Change animation
-
The $modal-fade-transform variable determines the transform state of .modal-dialog before the modal fade-in animation, the $modal-show-transform variable determines the transform of .modal-dialog at the end of the modal fade-in animation.
-
If you want for example a zoom-in animation, you can set $modal-fade-transform: scale(.8).
-
Remove animation
-
For modals that simply appear rather than fade in to view, remove the .fade class from your modal markup.
-
-
Dynamic heights
-
If the height of a modal changes while it is open, you should call $('#myModal').modal('handleUpdate') to readjust the modal’s position in case a scrollbar appears.
-
Accessibility
-
Be sure to add aria-labelledby="...", referencing the modal title, to .modal. Additionally, you may give a description of your modal dialog with aria-describedby on .modal. Note that you don’t need to add role="dialog" since we already add it via JavaScript.
-
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 information.
-
Optional sizes
-
Modals have three optional sizes, available via modifier classes to be placed on a .modal-dialog. These sizes kick in at certain breakpoints to avoid horizontal scrollbars on narrower viewports.
-
-
-
-
Size
-
Class
-
Modal max-width
-
-
-
-
-
Small
-
.modal-sm
-
300px
-
-
-
Default
-
None
-
500px
-
-
-
Large
-
.modal-lg
-
800px
-
-
-
Extra large
-
.modal-xl
-
1140px
-
-
-
-
Our default modal without modifier class constitutes the “medium” size modal.
-
-
-
-
-
-
-
-
-
-
-
Extra large modal
-
-
-
- ...
-
-
-
-
-
-
-
-
-
Large modal
-
-
-
- ...
-
-
-
-
-
-
-
-
-
Small modal
-
-
-
- ...
-
-
-
-
-
Usage
-
The modal plugin toggles your hidden content on demand, via data attributes or JavaScript. It also adds .modal-open to the <body> to override default scrolling behavior and generates a .modal-backdrop to provide a click area for dismissing shown modals when clicking outside the modal.
-
Via data attributes
-
Activate a modal without writing JavaScript. Set 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.
-
-
Via JavaScript
-
Call a modal with id myModal with a single line of JavaScript:
-
-
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 or the string 'static'
-
-
true
-
Includes a modal-backdrop element. Alternatively, specify static for a backdrop which doesn't close the modal on click.
-
-
-
keyboard
-
boolean
-
true
-
Closes the modal when escape key is pressed
-
-
-
focus
-
boolean
-
true
-
Puts the focus on the modal when initialized.
-
-
-
show
-
boolean
-
true
-
Shows the modal when initialized.
-
-
-
-
Methods
-
-
Asynchronous methods and transitions
-
All API methods are asynchronous and start a transition. They returns to the caller as soon as the transition is started but before it ends. In addition, a method call on a transitioning component will be ignored.
-
-
.modal(options)
-
Activates your content as a modal. Accepts an optional options object.
-
-
.modal('toggle')
-
Manually toggles a modal. Returns to the caller before the modal has actually been shown or hidden (i.e. before the shown.bs.modal or hidden.bs.modal event occurs).
-
-
.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).
-
-
.modal('hide')
-
Manually hides a modal. Returns to the caller before the modal has actually been hidden (i.e. before the hidden.bs.modal event occurs).
-
-
.modal('handleUpdate')
-
Manually readjust the modal’s position if the height of a modal changes while it is open (i.e. in case a scrollbar appears).
-
-
.modal('dispose')
-
Destroys an element’s modal.
-
Events
-
Bootstrap’s modal class exposes a few events for hooking into modal functionality. All modal events are fired at the modal itself (i.e. at the <div class="modal">).
-
-
-
-
Event Type
-
Description
-
-
-
-
-
show.bs.modal
-
This event fires immediately when the show instance method is called. If caused by a click, the clicked element is available as the relatedTarget property of the event.
-
-
-
shown.bs.modal
-
This event is fired when the modal has been made visible to the user (will wait for CSS transitions to complete). If caused by a click, the clicked element is available as the relatedTarget property of the event.
-
-
-
hide.bs.modal
-
This event is fired immediately when the hide instance method has been called.
-
-
-
hidden.bs.modal
-
This event is fired when the modal has finished being hidden from the user (will wait for CSS transitions to complete).
-
-
-
hidePrevented.bs.modal
-
This event is fired when the modal is shown, its backdrop is static and a click outside the modal or an escape key press is performed with the keyboard option or data-keyboard set to false.
Documentation and examples for Bootstrap's powerful, responsive navigation header, the navbar. Includes support for branding, navigation, and more, including support for our collapse plugin.
-
-
-
-
-
-
-
-
-
-
How it works
-
Here’s what you need to know before getting started with the navbar:
-
-
Navbars require a wrapping .navbar with .navbar-expand{-sm|-md|-lg|-xl} for responsive collapsing and color scheme classes.
-
Navbars and their contents are fluid by default. Use optional containers to limit their horizontal width.
-
Use our spacing and flex utility classes for controlling spacing and alignment within navbars.
-
Navbars are responsive by default, but you can easily modify them to change that. Responsive behavior depends on our Collapse JavaScript plugin.
-
Navbars are hidden by default when printing. Force them to be printed by adding .d-print to the .navbar. See the display utility class.
-
Ensure accessibility by using a <nav> element or, if using a more generic element such as a <div>, add a role="navigation" to every navbar to explicitly identify it as a landmark region for users of assistive technologies.
Read on for an example and list of supported sub-components.
-
Supported content
-
Navbars come with built-in support for a handful of sub-components. Choose from the following as needed:
-
-
-.navbar-brand for your company, product, or project name.
-
-.navbar-nav for a full-height and lightweight navigation (including support for dropdowns).
-
-.navbar-toggler for use with our collapse plugin and other navigation toggling behaviors.
-
-.form-inline for any form controls and actions.
-
-.navbar-text for adding vertically centered strings of text.
-
-.collapse.navbar-collapse for grouping and hiding navbar contents by a parent breakpoint.
-
-
Here’s an example of all the sub-components included in a responsive light-themed navbar that automatically collapses at the lg (large) breakpoint.
-
-
-
-
-
This example uses color (bg-light) and spacing (my-2, my-lg-0, mr-sm-0, my-sm-0) utility classes.
-
Brand
-
The .navbar-brand can be applied to most elements, but an anchor works best as some elements might require utility classes or custom styles.
-
-
-
-
-
-
-
-
Adding images to the .navbar-brand will likely always require custom styles or utilities to properly size. Here are some examples to demonstrate.
-
-
-
-
-
-
-
-
-
-
-
Nav
-
Navbar navigation links build on our .nav options with their own modifier class and require the use of toggler classes for proper responsive styling. Navigation in navbars will also grow to occupy as much horizontal space as possible to keep your navbar contents securely aligned.
-
Active states—with .active—to indicate the current page can be applied directly to .nav-links or their immediate parent .nav-items.
-
-
-
-
-
And because we use classes for our navs, you can avoid the list-based approach entirely if you like.
-
-
-
-
-
You may also utilize dropdowns in your navbar nav. Dropdown menus require a wrapping element for positioning, so be sure to use separate and nested elements for .nav-item and .nav-link as shown below.
-
-
-
-
-
Forms
-
Place various form controls and components within a navbar with .form-inline.
-
-
-
-
-
Immediate children elements in .navbar use flex layout and will default to justify-content: space-between. Use additional flex utilities as needed to adjust this behavior.
-
-
-
-
-
Input groups work, too:
-
-
-
-
-
Various buttons are supported as part of these navbar forms, too. This is also a great reminder that vertical alignment utilities can be used to align different sized elements.
-
-
-
-
-
Text
-
Navbars may contain bits of text with the help of .navbar-text. This class adjusts vertical alignment and horizontal spacing for strings of text.
-
-
-
-
-
Mix and match with other components and utilities as needed.
-
-
-
-
-
Color schemes
-
Theming the navbar has never been easier thanks to the combination of theming classes and background-color utilities. Choose from .navbar-light for use with light background colors, or .navbar-dark for dark background colors. Then, customize with .bg-* utilities.
-
-
-
-
-
-
-
Containers
-
Although it’s not required, you can wrap a navbar in a .container to center it on a page or add one within to only center the contents of a fixed or static top navbar.
-
-
-
-
-
-
-
When the container is within your navbar, its horizontal padding is removed at breakpoints lower than your specified .navbar-expand{-sm|-md|-lg|-xl} class. This ensures we’re not doubling up on padding unnecessarily on lower viewports when your navbar is collapsed.
-
-
-
-
-
Placement
-
Use our position utilities to place navbars in non-static positions. Choose from fixed to the top, fixed to the bottom, or stickied to the top (scrolls with the page until it reaches the top, then stays there). Fixed navbars use position: fixed, meaning they’re pulled from the normal flow of the DOM and may require custom CSS (e.g., padding-top on the <body>) to prevent overlap with other elements.
Navbars can utilize .navbar-toggler, .navbar-collapse, and .navbar-expand{-sm|-md|-lg|-xl} classes to change when their content collapses behind a button. In combination with other utilities, you can easily choose when to show or hide particular elements.
-
For navbars that never collapse, add the .navbar-expand class on the navbar. For navbars that always collapse, don’t add any .navbar-expand class.
-
Toggler
-
Navbar togglers are left-aligned by default, but should they follow a sibling element like a .navbar-brand, they’ll automatically be aligned to the far right. Reversing your markup will reverse the placement of the toggler. Below are examples of different toggle styles.
-
With no .navbar-brand shown in lowest breakpoint:
-
-
-
-
-
With a brand name shown on the left and toggler on the right:
-
-
-
-
-
With a toggler on the left and brand name on the right:
-
-
-
-
-
External content
-
Sometimes you want to use the collapse plugin to trigger hidden content elsewhere on the page. Because our plugin works on the id and data-target matching, that’s easily done!
Documentation and examples for how to use Bootstrap's included navigation components.
-
-
-
-
-
-
-
-
-
-
Base nav
-
Navigation available in Bootstrap share general markup and styles, from the base .nav class to the active and disabled states. Swap modifier classes to switch between each style.
-
The base .nav component is built with flexbox and provide a strong foundation for building all types of navigation components. It includes some style overrides (for working with lists), some link padding for larger hit areas, and basic disabled styling.
-
-
The base .nav component does not include any .active state. The following examples include the class, mainly to demonstrate that this particular class does not trigger any special styling.
Classes are used throughout, so your markup can be super flexible. Use <ul>s like above, <ol> if the order of your items is important, or roll your own with a <nav> element. Because the .nav uses display: flex, the nav links behave the same as nav items would, but without the extra markup.
-
-
-
-
-
Available styles
-
Change the style of .navs component with modifiers and utilities. Mix and match as needed, or build your own.
-
Horizontal alignment
-
Change the horizontal alignment of your nav with flexbox utilities. By default, navs are left-aligned, but you can easily change them to center or right aligned.
Stack your navigation by changing the flex item direction with the .flex-column utility. Need to stack them on some viewports but not others? Use the responsive versions (e.g., .flex-sm-column).
As always, vertical navigation is possible without <ul>s, too.
-
-
-
-
-
Tabs
-
Takes the basic nav from above and adds the .nav-tabs class to generate a tabbed interface. Use them to create tabbable regions with our tab JavaScript plugin.
Force your .nav’s contents to extend the full available width one of two modifier classes. To proportionately fill all available space with your .nav-items, use .nav-fill. Notice that all horizontal space is occupied, but not every nav item has the same width.
When using a <nav>-based navigation, be sure to include .nav-item on the anchors.
-
-
-
-
-
For equal-width elements, use .nav-justified. All horizontal space will be occupied by nav links, but unlike the .nav-fill above, every nav item will be the same width.
Similar to the .nav-fill example using a <nav>-based navigation, be sure to include .nav-item on the anchors.
-
-
-
-
-
Working with flex utilities
-
If you need responsive nav variations, consider using a series of flexbox utilities. While more verbose, these utilities offer greater customization across responsive breakpoints. In the example below, our nav will be stacked on the lowest breakpoint, then adapt to a horizontal layout that fills the available width starting from the small breakpoint.
-
-
-
-
-
Regarding accessibility
-
If you’re using navs to provide a navigation bar, be sure to add a role="navigation" to the most logical parent container of the <ul>, or wrap a <nav> element around the whole navigation. Do not add the role to the <ul> itself, as this would prevent it from being announced as an actual list by assistive technologies.
-
Note that navigation bars, even if visually styled as tabs with the .nav-tabs class, should not be given role="tablist", role="tab" or role="tabpanel" attributes. These are only appropriate for dynamic tabbed interfaces, as described in the WAI ARIA Authoring Practices. See JavaScript behavior for dynamic tabbed interfaces in this section for an example.
Use the tab JavaScript plugin—include it individually or through the compiled bootstrap.js file—to extend our navigational tabs and pills to create tabbable panes of local content, even via dropdown menus.
-
If you’re building our JavaScript from source, it requires util.js.
-
Dynamic tabbed interfaces, as described in the WAI ARIA Authoring Practices, require role="tablist", role="tab", role="tabpanel", and additional aria- attributes in order to convey their structure, functionality and current state to users of assistive technologies (such as screen readers).
-
Note that dynamic tabbed interfaces should not contain dropdown menus, as this causes both usability and accessibility issues. From a usability perspective, the fact that the currently displayed tab’s trigger element is not immediately visible (as it’s inside the closed dropdown menu) can cause confusion. From an accessibility point of view, there is currently no sensible way to map this sort of construct to a standard WAI ARIA pattern, meaning that it cannot be easily made understandable to users of assistive technologies.
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.
-
-
-
Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-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-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.
-
-
-
-
-
To help fit your needs, this works with <ul>-based markup, as shown above, or with any arbitrary “roll your own” markup. Note that if you’re using <nav>, you shouldn’t add role="tablist" directly to it, as this would override the element’s native role as a navigation landmark. Instead, switch to an alternative element (in the example below, a simple <div>) and wrap the <nav> around it.
-
-
-
-
-
Et et consectetur ipsum labore excepteur est proident excepteur ad velit occaecat qui minim occaecat veniam. Fugiat veniam incididunt anim aliqua enim pariatur veniam sunt est aute sit dolor anim. Velit non irure adipisicing aliqua ullamco irure incididunt irure non esse consectetur nostrud minim non minim occaecat. Amet duis do nisi duis veniam non est eiusmod tempor incididunt tempor dolor ipsum in qui sit. Exercitation mollit sit culpa nisi culpa non adipisicing reprehenderit do dolore. Duis reprehenderit occaecat anim ullamco ad duis occaecat ex.
-
-
-
Nulla est ullamco ut irure incididunt nulla Lorem Lorem minim irure officia enim reprehenderit. Magna duis labore cillum sint adipisicing exercitation ipsum. Nostrud ut anim non exercitation velit laboris fugiat cupidatat. Commodo esse dolore fugiat sint velit ullamco magna consequat voluptate minim amet aliquip ipsum aute laboris nisi. Labore labore veniam irure irure ipsum pariatur mollit magna in cupidatat dolore magna irure esse tempor ad mollit. Dolore commodo nulla minim amet ipsum officia consectetur amet ullamco voluptate nisi commodo ea sit eu.
-
-
-
Sint sit mollit irure quis est nostrud cillum consequat Lorem esse do quis dolor esse fugiat sunt do. Eu ex commodo veniam Lorem aliquip laborum occaecat qui Lorem esse mollit dolore anim cupidatat. Deserunt officia id Lorem nostrud aute id commodo elit eiusmod enim irure amet eiusmod qui reprehenderit nostrud tempor. Fugiat ipsum excepteur in aliqua non et quis aliquip ad irure in labore cillum elit enim. Consequat aliquip incididunt ipsum et minim laborum laborum laborum et cillum labore. Deserunt adipisicing cillum id nulla minim nostrud labore eiusmod et amet. Laboris consequat consequat commodo non ut non aliquip reprehenderit nulla anim occaecat. Sunt sit ullamco reprehenderit irure ea ullamco Lorem aute nostrud magna.
Consequat occaecat ullamco amet non eiusmod nostrud dolore irure incididunt est duis anim sunt officia. Fugiat velit proident aliquip nisi incididunt nostrud exercitation proident est nisi. Irure magna elit commodo anim ex veniam culpa eiusmod id nostrud sit cupidatat in veniam ad. Eiusmod consequat eu adipisicing minim anim aliquip cupidatat culpa excepteur quis. Occaecat sit eu exercitation irure Lorem incididunt nostrud.
-
-
-
Ad pariatur nostrud pariatur exercitation ipsum ipsum culpa mollit commodo mollit ex. Aute sunt incididunt amet commodo est sint nisi deserunt pariatur do. Aliquip ex eiusmod voluptate exercitation cillum id incididunt elit sunt. Qui minim sit magna Lorem id et dolore velit Lorem amet exercitation duis deserunt. Anim id labore elit adipisicing ut in id occaecat pariatur ut ullamco ea tempor duis.
-
-
-
Est quis nulla laborum officia ad nisi ex nostrud culpa Lorem excepteur aliquip dolor aliqua irure ex. Nulla ut duis ipsum nisi elit fugiat commodo sunt reprehenderit laborum veniam eu veniam. Eiusmod minim exercitation fugiat irure ex labore incididunt do fugiat commodo aliquip sit id deserunt reprehenderit aliquip nostrud. Amet ex cupidatat excepteur aute veniam incididunt mollit cupidatat esse irure officia elit do ipsum ullamco Lorem. Ullamco ut ad minim do mollit labore ipsum laboris ipsum commodo sunt tempor enim incididunt. Commodo quis sunt dolore aliquip aute tempor irure magna enim minim reprehenderit. Ullamco consectetur culpa veniam sint cillum aliqua incididunt velit ullamco sunt ullamco quis quis commodo voluptate. Mollit nulla nostrud adipisicing aliqua cupidatat aliqua pariatur mollit voluptate voluptate consequat non.
Cillum ad ut irure tempor velit nostrud occaecat ullamco aliqua anim Lorem sint. Veniam sint duis incididunt do esse magna mollit excepteur laborum qui. Id id reprehenderit sit est eu aliqua occaecat quis et velit excepteur laborum mollit dolore eiusmod. Ipsum dolor in occaecat commodo et voluptate minim reprehenderit mollit pariatur. Deserunt non laborum enim et cillum eu deserunt excepteur ea incididunt minim occaecat.
-
-
-
Culpa dolor voluptate do laboris laboris irure reprehenderit id incididunt duis pariatur mollit aute magna pariatur consectetur. Eu veniam duis non ut dolor deserunt commodo et minim in quis laboris ipsum velit id veniam. Quis ut consectetur adipisicing officia excepteur non sit. Ut et elit aliquip labore Lorem enim eu. Ullamco mollit occaecat dolore ipsum id officia mollit qui esse anim eiusmod do sint minim consectetur qui.
-
-
-
Fugiat id quis dolor culpa eiusmod anim velit excepteur proident dolor aute qui magna. Ad proident laboris ullamco esse anim Lorem Lorem veniam quis Lorem irure occaecat velit nostrud magna nulla. Velit et et proident Lorem do ea tempor officia dolor. Reprehenderit Lorem aliquip labore est magna commodo est ea veniam consectetur.
-
-
-
Eu dolore ea ullamco dolore Lorem id cupidatat excepteur reprehenderit consectetur elit id dolor proident in cupidatat officia. Voluptate excepteur commodo labore nisi cillum duis aliqua do. Aliqua amet qui mollit consectetur nulla mollit velit aliqua veniam nisi id do Lorem deserunt amet. Culpa ullamco sit adipisicing labore officia magna elit nisi in aute tempor commodo eiusmod.
-
-
-
-
-
-
-
Using data attributes
-
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. Use these data attributes on .nav-tabs or .nav-pills.
-
-
Via JavaScript
-
Enable tabbable tabs via JavaScript (each tab needs to be activated individually):
-
-
You can activate individual tabs in several ways:
-
-
Fade effect
-
To make tabs fade in, add .fade to each .tab-pane. The first tab pane must also have .show to make the initial content visible.
-
-
Methods
-
-
Asynchronous methods and transitions
-
All API methods are asynchronous and start a transition. They returns to the caller as soon as the transition is started but before it ends. In addition, a method call on a transitioning component will be ignored.
-
-
$().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.
-
-
.tab(‘show’)
-
Selects the given tab and shows its associated pane. Any other tab that was previously selected becomes unselected and its associated pane is hidden. Returns to the caller before the tab pane has actually been shown (i.e. before the shown.bs.tab event occurs).
-
-
.tab(‘dispose’)
-
Destroys an element’s tab.
-
Events
-
When showing a new tab, the events fire in the following order:
-
-
-hide.bs.tab (on the current active tab)
-
-show.bs.tab (on the to-be-shown tab)
-
-hidden.bs.tab (on the previous active tab, the same one as for the hide.bs.tab event)
-
-shown.bs.tab (on the newly-active just-shown tab, the same one as for the show.bs.tab event)
-
-
If no tab was already active, then the hide.bs.tab and hidden.bs.tab events will not be fired.
-
-
-
-
Event Type
-
Description
-
-
-
-
-
show.bs.tab
-
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.bs.tab
-
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.
-
-
-
hide.bs.tab
-
This event fires when a new tab is to be shown (and thus the previous active tab is to be hidden). Use event.target and event.relatedTarget to target the current active tab and the new soon-to-be-active tab, respectively.
-
-
-
hidden.bs.tab
-
This event fires after a new tab is shown (and thus the previous active tab is hidden). Use event.target and event.relatedTarget to target the previous active tab and the new active tab, respectively.
Documentation and examples for showing pagination to indicate a series of related content exists across multiple pages.
-
-
-
-
-
-
-
-
-
-
Overview
-
We use a large block of connected links for our pagination, making links hard to miss and easily scalable—all while providing large hit areas. Pagination is built with list HTML elements so screen readers can announce the number of available links. Use a wrapping <nav> element to identify it as a navigation section to screen readers and other assistive technologies.
-
In addition, as pages likely have more than one such navigation section, it’s advisable to provide a descriptive aria-label for the <nav> to reflect its purpose. For example, if the pagination component is used to navigate between a set of search results, an appropriate label could be aria-label="Search results pages".
-
-
-
-
-
Working with icons
-
Looking to use an icon or symbol in place of text for some pagination links? Be sure to provide proper screen reader support with aria attributes.
-
-
-
-
-
Disabled and active states
-
Pagination links are customizable for different circumstances. Use .disabled for links that appear un-clickable and .active to indicate the current page.
-
While the .disabled class uses pointer-events: none to try to disable the link functionality of <a>s, that CSS property is not yet standardized and doesn’t account for keyboard navigation. As such, you should always add tabindex="-1" on disabled links and use custom JavaScript to fully disable their functionality.
-
-
-
-
-
You can optionally swap out active or disabled anchors for <span>, or omit the anchor in the case of the prev/next arrows, to remove click functionality and prevent keyboard focus while retaining intended styles.
-
-
-
-
-
Sizing
-
Fancy larger or smaller pagination? Add .pagination-lg or .pagination-sm for additional sizes.
-
-
-
-
-
-
-
-
-
Alignment
-
Change the alignment of pagination components with flexbox utilities.
Documentation and examples for adding Bootstrap popovers, like those found in iOS, to any element on your site.
-
-
-
-
-
-
-
-
-
-
Overview
-
Things to know when using the popover plugin:
-
-
Popovers rely on the 3rd party library Popper.js for positioning. You must include popper.min.js before bootstrap.js or use bootstrap.bundle.min.js / bootstrap.bundle.js which contains Popper.js in order for popovers to work!
If you’re building our JavaScript from source, it requires util.js.
-
Popovers are opt-in for performance reasons, so you must initialize them yourself.
-
Zero-length title and content values will never show a popover.
-
Specify container: 'body' to avoid rendering problems in more complex components (like our input groups, button groups, etc).
-
Triggering popovers on hidden elements will not work.
-
Popovers for .disabled or disabled elements must be triggered on a wrapper element.
-
When triggered from anchors that wrap across multiple lines, popovers will be centered between the anchors’ overall width. Use .text-nowrap on your <a>s to avoid this behavior.
-
Popovers must be hidden before their corresponding elements have been removed from the DOM.
-
Popovers can be triggered thanks to an element inside a shadow DOM.
Keep reading to see how popovers work with some examples.
-
Example: Enable popovers everywhere
-
One way to initialize all popovers on a page would be to select them by their data-toggle attribute:
-
-
Example: Using the container option
-
When you have some styles on a parent element that interfere with a popover, you’ll want to specify a custom container so that the popover’s HTML appears within that element instead.
-
-
Example
-
-
-
-
-
Four directions
-
Four options are available: top, right, bottom, and left aligned.
-
-
-
-
-
-
-
-
-
-
Dismiss on next click
-
Use the focus trigger to dismiss popovers on the user’s next click of a different element than the toggle element.
-
-
Specific markup required for dismiss-on-next-click
-
For proper cross-browser and cross-platform behavior, you must use the <a> tag, not the <button> tag, and you also must include a tabindex attribute.
Elements with the disabled attribute aren’t interactive, meaning users cannot hover or click them to trigger a popover (or tooltip). As a workaround, you’ll want to trigger the popover from a wrapper <div> or <span> and override the pointer-events on the disabled element.
-
For disabled popover triggers, you may also prefer data-trigger="hover" so that the popover appears as immediate visual feedback to your users as they may not expect to click on a disabled element.
-
-
-
-
-
-
-
Usage
-
Enable popovers via JavaScript:
-
-
-
Making popovers work for keyboard and assistive technology users
-
To allow keyboard users to activate your popovers, you should only add them to HTML elements that are traditionally keyboard-focusable and interactive (such as links or form controls). Although arbitrary HTML elements (such as <span>s) can be made focusable by adding the tabindex="0" attribute, this will add potentially annoying and confusing tab stops on non-interactive elements for keyboard users, and most assistive technologies currently do not announce the popover’s content in this situation. Additionally, do not rely solely on hover as the trigger for your popovers, as this will make them impossible to trigger for keyboard users.
-
While you can insert rich, structured HTML in popovers with the html option, we strongly recommend that you avoid adding an excessive amount of content. The way popovers currently work is that, once displayed, their content is tied to the trigger element with the aria-describedby attribute. As a result, the entirety of the popover’s content will be announced to assistive technology users as one long, uninterrupted stream.
-
Additionally, while it is possible to also include interactive controls (such as form elements or links) in your popover (by adding these elements to the whiteList or allowed attributes and tags), be aware that currently the popover does not manage keyboard focus order. When a keyboard user opens a popover, focus remains on the triggering element, and as the popover usually does not immediately follow the trigger in the document’s structure, there is no guarantee that moving forward/pressing TAB will move a keyboard user into the popover itself. In short, simply adding interactive controls to a popover is likely to make these controls unreachable/unusable for keyboard users and users of assistive technologies, or at the very least make for an illogical overall focus order. In these cases, consider using a modal dialog instead.
-
-
Options
-
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-animation="".
-
-
Note that for security reasons the sanitize, sanitizeFn and whiteList options cannot be supplied using data attributes.
-
-
-
-
-
Name
-
Type
-
Default
-
Description
-
-
-
-
-
animation
-
boolean
-
true
-
Apply a CSS fade transition to the popover
-
-
-
container
-
string | element | false
-
false
-
-
Appends the popover to a specific element. Example: container: 'body'. This option is particularly useful in that it allows you to position the popover in the flow of the document near the triggering element - which will prevent the popover from floating away from the triggering element during a window resize.
-
-
-
-
content
-
string | element | function
-
''
-
-
Default content value if data-content attribute isn't present.
-
If a function is given, it will be called with its this reference set to the element that the popover is attached to.
-
-
-
-
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 }
-
-
-
-
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 - auto | top | bottom | left | right. When auto is specified, it will dynamically reorient the popover.
-
When a function is used to determine the placement, it is called with the popover DOM node as its first argument and the triggering element DOM node as its second. The this context is set to the popover instance.
-
-
-
-
selector
-
string | false
-
false
-
If a selector is provided, popover 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.
The popover's title will be injected into the .popover-header.
-
The popover's content will be injected into the .popover-body.
-
.arrow will become the popover's arrow.
-
The outermost wrapper element should have the .popover class.
-
-
-
-
title
-
string | element | function
-
''
-
-
Default title value if title attribute isn't present.
-
If a function is given, it will be called with its this reference set to the element that the popover is attached to.
-
-
-
-
trigger
-
string
-
'click'
-
How popover is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space. manual cannot be combined with any other trigger.
-
-
-
offset
-
number | string
-
0
-
Offset of the popover relative to its target. For more information refer to Popper.js's offset docs.
-
-
-
fallbackPlacement
-
string | array
-
'flip'
-
Allow to specify which position Popper will use on fallback. For more information refer to
- Popper.js's behavior docs
-
-
-
-
boundary
-
string | element
-
'scrollParent'
-
Overflow constraint boundary of the popover. Accepts the values of 'viewport', 'window', 'scrollParent', or an HTMLElement reference (JavaScript only). For more information refer to Popper.js's preventOverflow docs.
-
-
-
sanitize
-
boolean
-
true
-
Enable or disable the sanitization. If activated 'template', 'content' and 'title' options will be sanitized.
Options for individual popovers can alternatively be specified through the use of data attributes, as explained above.
-
-
Methods
-
-
Asynchronous methods and transitions
-
All API methods are asynchronous and start a transition. They returns to the caller as soon as the transition is started but before it ends. In addition, a method call on a transitioning component will be ignored.
-
-
$().popover(options)
-
Initializes popovers for an element collection.
-
.popover('show')
-
Reveals an element’s popover. Returns to the caller before the popover has actually been shown (i.e. before the shown.bs.popover event occurs). This is considered a “manual” triggering of the popover. Popovers whose title and content are both zero-length are never displayed.
-
-
.popover('hide')
-
Hides an element’s popover. Returns to the caller before the popover has actually been hidden (i.e. before the hidden.bs.popover event occurs). This is considered a “manual” triggering of the popover.
-
-
.popover('toggle')
-
Toggles an element’s popover. Returns to the caller before the popover has actually been shown or hidden (i.e. before the shown.bs.popover or hidden.bs.popover event occurs). This is considered a “manual” triggering of the popover.
-
-
.popover('dispose')
-
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.
-
-
.popover('enable')
-
Gives an element’s popover the ability to be shown. Popovers are enabled by default.
-
-
.popover('disable')
-
Removes the ability for an element’s popover to be shown. The popover will only be able to be shown if it is re-enabled.
-
-
.popover('toggleEnabled')
-
Toggles the ability for an element’s popover to be shown or hidden.
-
-
.popover('update')
-
Updates the position of an element’s popover.
-
-
Events
-
-
-
-
Event Type
-
Description
-
-
-
-
-
show.bs.popover
-
This event fires immediately when the show instance method is called.
-
-
-
shown.bs.popover
-
This event is fired when the popover has been made visible to the user (will wait for CSS transitions to complete).
-
-
-
hide.bs.popover
-
This event is fired immediately when the hide instance method has been called.
-
-
-
hidden.bs.popover
-
This event is fired when the popover has finished being hidden from the user (will wait for CSS transitions to complete).
-
-
-
inserted.bs.popover
-
This event is fired after the show.bs.popover event when the popover template has been added to the DOM.
Documentation and examples for using Bootstrap custom progress bars featuring support for stacked bars, animated backgrounds, and text labels.
-
-
-
-
-
-
-
-
-
-
How it works
-
Progress components are built with two HTML elements, some CSS to set the width, and a few attributes. We don’t use the HTML5 <progress> element, ensuring you can stack progress bars, animate them, and place text labels over them.
-
-
We use the .progress as a wrapper to indicate the max value of the progress bar.
-
We use the inner .progress-bar to indicate the progress so far.
-
The .progress-bar requires an inline style, utility class, or custom CSS to set their width.
-
The .progress-bar also requires some role and aria attributes to make it accessible.
-
-
Put that all together, and you have the following examples.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Bootstrap provides a handful of utilities for setting width. Depending on your needs, these may help with quickly configuring progress.
-
-
-
-
-
-
-
Labels
-
Add labels to your progress bars by placing text within the .progress-bar.
-
-
-
25%
-
-
-
-
Height
-
We only set a height value on the .progress, so if you change that value the inner .progress-bar will automatically resize accordingly.
-
-
-
-
-
-
-
-
-
-
Backgrounds
-
Use background utility classes to change the appearance of individual progress bars.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Multiple bars
-
Include multiple progress bars in a progress component if you need.
-
-
-
-
-
-
-
-
-
Striped
-
Add .progress-bar-striped to any .progress-bar to apply a stripe via CSS gradient over the progress bar’s background color.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Animated stripes
-
The striped gradient can also be animated. Add .progress-bar-animated to .progress-bar to animate the stripes right to left via CSS3 animations.
Automatically update Bootstrap navigation or list group components based on scroll position to indicate which link is currently active in the viewport.
-
-
-
-
-
-
-
-
-
-
How it works
-
Scrollspy has a few requirements to function properly:
-
-
If you’re building our JavaScript from source, it requires util.js.
Scrollspy requires position: relative; on the element you’re spying on, usually the <body>.
-
When spying on elements other than the <body>, be sure to have a height set and overflow-y: scroll; applied.
-
Anchors (<a>) are required and must point to an element with that id.
-
-
When successfully implemented, your nav or list group will update accordingly, moving the .active class from one item to the next based on their associated targets.
-
Example in navbar
-
Scroll the area below the navbar and watch the active class change. The dropdown 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.
-
-
-
-
-
Example with nested nav
-
Scrollspy also works with nested .navs. If a nested .nav is .active, its parents will also be .active. Scroll the area next to the navbar and watch the active class change.
-
-
-
-
-
-
-
-
Item 1
-
Ex consequat commodo adipisicing exercitation aute excepteur occaecat ullamco duis aliqua id magna ullamco eu. Do aute ipsum ipsum ullamco cillum consectetur ut et aute consectetur labore. Fugiat laborum incididunt tempor eu consequat enim dolore proident. Qui laborum do non excepteur nulla magna eiusmod consectetur in. Aliqua et aliqua officia quis et incididunt voluptate non anim reprehenderit adipisicing dolore ut consequat deserunt mollit dolore. Aliquip nulla enim veniam non fugiat id cupidatat nulla elit cupidatat commodo velit ut eiusmod cupidatat elit dolore.
-
Item 1-1
-
Amet tempor mollit aliquip pariatur excepteur commodo do ea cillum commodo Lorem et occaecat elit qui et. Aliquip labore ex ex esse voluptate occaecat Lorem ullamco deserunt. Aliqua cillum excepteur irure consequat id quis ea. Sit proident ullamco aute magna pariatur nostrud labore. Reprehenderit aliqua commodo eiusmod aliquip est do duis amet proident magna consectetur consequat eu commodo fugiat non quis. Enim aliquip exercitation ullamco adipisicing voluptate excepteur minim exercitation minim minim commodo adipisicing exercitation officia nisi adipisicing. Anim id duis qui consequat labore adipisicing sint dolor elit cillum anim et fugiat.
-
Item 1-2
-
Cillum nisi deserunt magna eiusmod qui eiusmod velit voluptate pariatur laborum sunt enim. Irure laboris mollit consequat incididunt sint et culpa culpa incididunt adipisicing magna magna occaecat. Nulla ipsum cillum eiusmod sint elit excepteur ea labore enim consectetur in labore anim. Proident ullamco ipsum esse elit ut Lorem eiusmod dolor et eiusmod. Anim occaecat nulla in non consequat eiusmod velit incididunt.
-
Item 2
-
Quis magna Lorem anim amet ipsum do mollit sit cillum voluptate ex nulla tempor. Laborum consequat non elit enim exercitation cillum aliqua consequat id aliqua. Esse ex consectetur mollit voluptate est in duis laboris ad sit ipsum anim Lorem. Incididunt veniam velit elit elit veniam Lorem aliqua quis ullamco deserunt sit enim elit aliqua esse irure. Laborum nisi sit est tempor laborum mollit labore officia laborum excepteur commodo non commodo dolor excepteur commodo. Ipsum fugiat ex est consectetur ipsum commodo tempor sunt in proident.
-
Item 3
-
Quis anim sit do amet fugiat dolor velit sit ea ea do reprehenderit culpa duis. Nostrud aliqua ipsum fugiat minim proident occaecat excepteur aliquip culpa aute tempor reprehenderit. Deserunt tempor mollit elit ex pariatur dolore velit fugiat mollit culpa irure ullamco est ex ullamco excepteur.
-
Item 3-1
-
Deserunt quis elit Lorem eiusmod amet enim enim amet minim Lorem proident nostrud. Ea id dolore anim exercitation aute fugiat labore voluptate cillum do laboris labore. Ex velit exercitation nisi enim labore reprehenderit labore nostrud ut ut. Esse officia sunt duis aliquip ullamco tempor eiusmod deserunt irure nostrud irure. Ullamco proident veniam laboris ea consectetur magna sunt ex exercitation aliquip minim enim culpa occaecat exercitation. Est tempor excepteur aliquip laborum consequat do deserunt laborum esse eiusmod irure proident ipsum esse qui.
-
Item 3-2
-
Labore sit culpa commodo elit adipisicing sit aliquip elit proident voluptate minim mollit nostrud aute reprehenderit do. Mollit excepteur eu Lorem ipsum anim commodo sint labore Lorem in exercitation velit incididunt. Occaecat consectetur nisi in occaecat proident minim enim sunt reprehenderit exercitation cupidatat et do officia. Aliquip consequat ad labore labore mollit ut amet. Sit pariatur tempor proident in veniam culpa aliqua excepteur elit magna fugiat eiusmod amet officia.
-
-
-
-
-
-
Example with list-group
-
Scrollspy also works with .list-groups. Scroll the area next to the list group and watch the active class change.
Ex consequat commodo adipisicing exercitation aute excepteur occaecat ullamco duis aliqua id magna ullamco eu. Do aute ipsum ipsum ullamco cillum consectetur ut et aute consectetur labore. Fugiat laborum incididunt tempor eu consequat enim dolore proident. Qui laborum do non excepteur nulla magna eiusmod consectetur in. Aliqua et aliqua officia quis et incididunt voluptate non anim reprehenderit adipisicing dolore ut consequat deserunt mollit dolore. Aliquip nulla enim veniam non fugiat id cupidatat nulla elit cupidatat commodo velit ut eiusmod cupidatat elit dolore.
-
Item 2
-
Quis magna Lorem anim amet ipsum do mollit sit cillum voluptate ex nulla tempor. Laborum consequat non elit enim exercitation cillum aliqua consequat id aliqua. Esse ex consectetur mollit voluptate est in duis laboris ad sit ipsum anim Lorem. Incididunt veniam velit elit elit veniam Lorem aliqua quis ullamco deserunt sit enim elit aliqua esse irure. Laborum nisi sit est tempor laborum mollit labore officia laborum excepteur commodo non commodo dolor excepteur commodo. Ipsum fugiat ex est consectetur ipsum commodo tempor sunt in proident.
-
Item 3
-
Quis anim sit do amet fugiat dolor velit sit ea ea do reprehenderit culpa duis. Nostrud aliqua ipsum fugiat minim proident occaecat excepteur aliquip culpa aute tempor reprehenderit. Deserunt tempor mollit elit ex pariatur dolore velit fugiat mollit culpa irure ullamco est ex ullamco excepteur.
-
Item 4
-
Quis anim sit do amet fugiat dolor velit sit ea ea do reprehenderit culpa duis. Nostrud aliqua ipsum fugiat minim proident occaecat excepteur aliquip culpa aute tempor reprehenderit. Deserunt tempor mollit elit ex pariatur dolore velit fugiat mollit culpa irure ullamco est ex ullamco excepteur.
-
-
-
-
-
-
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.
-
-
-
Via JavaScript
-
After adding position: relative; in your CSS, call the scrollspy via JavaScript:
-
-
-
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>.
-
-
-
Non-:visible target elements ignored
-
Target elements that are not :visible according to jQuery will be ignored and their corresponding nav items will never be highlighted.
-
-
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:
-
-
.scrollspy('dispose')
-
Destroys an element’s scrollspy.
-
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.
-
-
-
method
-
string
-
auto
-
Finds which section the spied element is in. auto will choose the best method to get scroll coordinates. offset will use jQuery offset method to get scroll coordinates. position will use jQuery position method to get scroll coordinates.
-
-
-
target
-
string
-
-
Specifies element to apply Scrollspy plugin.
-
-
-
-
Events
-
-
-
-
Event Type
-
Description
-
-
-
-
-
activate.bs.scrollspy
-
This event fires on the scroll element whenever a new item becomes activated by the scrollspy.
Indicate the loading state of a component or page with Bootstrap spinners, built entirely with HTML, CSS, and no JavaScript.
-
-
-
-
-
-
-
-
-
-
About
-
Bootstrap “spinners” can be used to show the loading state in your projects. They’re built only with HTML and CSS, meaning you don’t need any JavaScript to create them. You will, however, need some custom JavaScript to toggle their visibility. Their appearance, alignment, and sizing can be easily customized with our amazing utility classes.
-
For accessibility purposes, each loader here includes role="status" and a nested <span class="sr-only">Loading...</span>.
-
Border spinner
-
Use the border spinners for a lightweight loading indicator.
-
-
- Loading...
-
-
-
-
Colors
-
The border spinner uses currentColor for its border-color, meaning you can customize the color with text color utilities. You can use any of our text color utilities on the standard spinner.
-
-
- Loading...
-
-
- Loading...
-
-
- Loading...
-
-
- Loading...
-
-
- Loading...
-
-
- Loading...
-
-
- Loading...
-
-
- Loading...
-
-
-
-
-
Why not use border-color utilities? Each border spinner specifies a transparent border for at least one side, so .border-{color} utilities would override that.
-
-
Growing spinner
-
If you don’t fancy a border spinner, switch to the grow spinner. While it doesn’t technically spin, it does repeatedly grow!
-
-
- Loading...
-
-
-
-
Once again, this spinner is built with currentColor, so you can easily change its appearance with text color utilities. Here it is in blue, along with the supported variants.
-
-
- Loading...
-
-
- Loading...
-
-
- Loading...
-
-
- Loading...
-
-
- Loading...
-
-
- Loading...
-
-
- Loading...
-
-
- Loading...
-
-
-
-
Alignment
-
Spinners in Bootstrap are built with rems, currentColor, and display: inline-flex. This means they can easily be resized, recolored, and quickly aligned.
Add .spinner-border-sm and .spinner-grow-sm to make a smaller spinner that can quickly be used within other components.
-
-
- Loading...
-
-
- Loading...
-
-
-
-
Or, use custom CSS or inline styles to change the dimensions as needed.
-
-
- Loading...
-
-
- Loading...
-
-
-
-
Buttons
-
Use spinners within buttons to indicate an action is currently processing or taking place. You may also swap the text out of the spinner element and utilize button text as needed.
Push notifications to your visitors with a toast, a lightweight and easily customizable alert message.
-
-
-
-
-
-
-
-
-
-
Toasts are lightweight notifications designed to mimic the push notifications that have been popularized by mobile and desktop operating systems. They’re built with flexbox, so they’re easy to align and position.
-
Overview
-
Things to know when using the toast plugin:
-
-
If you’re building our JavaScript from source, it requires util.js.
-
Toasts are opt-in for performance reasons, so you must initialize them yourself.
-
Please note that you are responsible for positioning toasts.
-
Toasts will automatically hide if you do not specify autohide: false.
To encourage extensible and predictable toasts, we recommend a header and body. Toast headers use display: flex, allowing easy alignment of content thanks to our margin and flexbox utilities.
-
Toasts are as flexible as you need and have very little required markup. At a minimum, we require a single element to contain your “toasted” content and strongly encourage a dismiss button.
-
-
-
-
- Bootstrap
- 11 mins ago
-
-
-
- Hello, world! This is a toast message.
-
-
-
-
-
Translucent
-
Toasts are slightly translucent, too, so they blend over whatever they might appear over. For browsers that support the backdrop-filter CSS property, we’ll also attempt to blur the elements under a toast.
-
-
-
-
- Bootstrap
- 11 mins ago
-
-
-
- Hello, world! This is a toast message.
-
-
-
-
-
Stacking
-
When you have multiple toasts, we default to vertically stacking them in a readable manner.
-
-
-
-
- Bootstrap
- just now
-
-
-
- See? Just like this.
-
-
-
-
-
- Bootstrap
- 2 seconds ago
-
-
-
- Heads up, toasts will stack automatically
-
-
-
-
-
Placement
-
Place toasts with custom CSS as you need them. The top right is often used for notifications, as is the top middle. If you’re only ever going to show one toast at a time, put the positioning styles right on the .toast.
-
-
-
-
-
- Bootstrap
- 11 mins ago
-
-
-
- Hello, world! This is a toast message.
-
-
-
-
-
-
For systems that generate more notifications, consider using a wrapping element so they can easily stack.
-
-
-
-
-
-
-
-
- Bootstrap
- just now
-
-
-
- See? Just like this.
-
-
-
-
-
- Bootstrap
- 2 seconds ago
-
-
-
- Heads up, toasts will stack automatically
-
-
-
-
-
-
-
You can also get fancy with flexbox utilities to align toasts horizontally and/or vertically.
-
-
-
-
-
-
-
- Bootstrap
- 11 mins ago
-
-
-
- Hello, world! This is a toast message.
-
-
-
-
-
-
Accessibility
-
Toasts are intended to be small interruptions to your visitors or users, so to help those with screen readers and similar assistive technologies, you should wrap your toasts in an aria-live region. Changes to live regions (such as injecting/updating a toast component) are automatically announced by screen readers without needing to move the user’s focus or otherwise interrupt the user. Additionally, include aria-atomic="true" to ensure that the entire toast is always announced as a single (atomic) unit, rather than announcing what was changed (which could lead to problems if you only update part of the toast’s content, or if displaying the same toast content at a later point in time). If the information needed is important for the process, e.g. for a list of errors in a form, then use the alert component instead of toast.
-
Note that the live region needs to be present in the markup before the toast is generated or updated. If you dynamically generate both at the same time and inject them into the page, they will generally not be announced by assistive technologies.
-
You also need to adapt the role and aria-live level depending on the content. If it’s an important message like an error, use role="alert" aria-live="assertive", otherwise use role="status" aria-live="polite" attributes.
-
As the content you’re displaying changes, be sure to update the delay timeout to ensure people have enough time to read the toast.
-
-
When using autohide: false, you must add a close button to allow users to dismiss the toast.
-
-
-
-
- Bootstrap
- 11 mins ago
-
-
-
- Hello, world! This is a toast message.
-
-
-
-
-
JavaScript behavior
-
Usage
-
Initialize toasts via JavaScript:
-
-
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 toast
-
-
-
autohide
-
boolean
-
true
-
Auto hide the toast
-
-
-
delay
-
number
-
- 500
-
-
Delay hiding the toast (ms)
-
-
-
-
Methods
-
-
Asynchronous methods and transitions
-
All API methods are asynchronous and start a transition. They returns to the caller as soon as the transition is started but before it ends. In addition, a method call on a transitioning component will be ignored.
-
-
$().toast(options)
-
Attaches a toast handler to an element collection.
-
.toast('show')
-
Reveals an element’s toast. Returns to the caller before the toast has actually been shown (i.e. before the shown.bs.toast event occurs).
-You have to manually call this method, instead your toast won’t show.
-
-
.toast('hide')
-
Hides an element’s toast. Returns to the caller before the toast has actually been hidden (i.e. before the hidden.bs.toast event occurs). You have to manually call this method if you made autohide to false.
-
-
.toast('dispose')
-
Hides an element’s toast. Your toast will remain on the DOM but won’t show anymore.
-
-
Events
-
-
-
-
Event Type
-
Description
-
-
-
-
-
show.bs.toast
-
This event fires immediately when the show instance method is called.
-
-
-
shown.bs.toast
-
This event is fired when the toast has been made visible to the user.
-
-
-
hide.bs.toast
-
This event is fired immediately when the hide instance method has been called.
-
-
-
hidden.bs.toast
-
This event is fired when the toast has finished being hidden from the user.
Documentation and examples for adding custom Bootstrap tooltips with CSS and JavaScript using CSS3 for animations and data-attributes for local title storage.
-
-
-
-
-
-
-
-
-
-
Overview
-
Things to know when using the tooltip plugin:
-
-
Tooltips rely on the 3rd party library Popper.js for positioning. You must include popper.min.js before bootstrap.js or use bootstrap.bundle.min.js / bootstrap.bundle.js which contains Popper.js in order for tooltips to work!
-
If you’re building our JavaScript from source, it requires util.js.
-
Tooltips are opt-in for performance reasons, so you must initialize them yourself.
-
Tooltips with zero-length titles are never displayed.
-
Specify container: 'body' to avoid rendering problems in more complex components (like our input groups, button groups, etc).
-
Triggering tooltips on hidden elements will not work.
-
Tooltips for .disabled or disabled elements must be triggered on a wrapper element.
-
When triggered from hyperlinks that span multiple lines, tooltips will be centered. Use white-space: nowrap; on your <a>s to avoid this behavior.
-
Tooltips must be hidden before their corresponding elements have been removed from the DOM.
-
Tooltips can be triggered thanks to an element inside a shadow DOM.
Got all that? Great, let’s see how they work with some examples.
-
Example: Enable tooltips everywhere
-
One way to initialize all tooltips on a page would be to select them by their data-toggle attribute:
-
-
Examples
-
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.
-
-
-
Hover over the buttons below to see the four tooltips directions: top, right, bottom, and left.
-
-
-
-
-
-
-
-
-
-
-
And with custom HTML added:
-
-
Usage
-
The tooltip plugin generates content and markup on demand, and by default places tooltips after their trigger element.
-
Trigger the tooltip via JavaScript:
-
-
-
Overflow auto and scroll
-
-
Tooltip position attempts to automatically change when a parent container has overflow: auto or overflow: scroll like our .table-responsive, but still keeps the original placement’s positioning. To resolve, set the boundary option to anything other than default value, 'scrollParent', such as 'window':
-
-
-
Markup
-
The required markup for a tooltip is only a data attribute and title on the HTML element you wish to have a tooltip. The generated markup of a tooltip is rather simple, though it does require a position (by default, set to top by the plugin).
-
-
Making tooltips work for keyboard and assistive technology users
-
You should only add tooltips to HTML elements that are traditionally keyboard-focusable and interactive (such as links or form controls). Although arbitrary HTML elements (such as <span>s) can be made focusable by adding the tabindex="0" attribute, this will add potentially annoying and confusing tab stops on non-interactive elements for keyboard users, and most assistive technologies currently do not announce the tooltip in this situation. Additionally, do not rely solely on hover as the trigger for your tooltip, as this will make your tooltips impossible to trigger for keyboard users.
-
-
-
Disabled elements
-
Elements with the disabled attribute aren’t interactive, meaning users cannot focus, hover, or click them to trigger a tooltip (or popover). As a workaround, you’ll want to trigger the tooltip from a wrapper <div> or <span>, ideally made keyboard-focusable using tabindex="0", and override the pointer-events on the disabled element.
-
-
-
-
-
-
-
-
-
Options
-
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-animation="".
-
-
Note that for security reasons the sanitize, sanitizeFn and whiteList options cannot be supplied using data attributes.
-
-
-
-
-
Name
-
Type
-
Default
-
Description
-
-
-
-
-
animation
-
boolean
-
true
-
Apply a CSS fade transition to the tooltip
-
-
-
container
-
string | element | false
-
false
-
-
Appends the tooltip to a specific element. Example: container: 'body'. This option is particularly useful in that it allows you to position the tooltip in the flow of the document near the triggering element - which will prevent the tooltip from floating away from the triggering element during a window resize.
-
-
-
-
delay
-
number | object
-
0
-
-
Delay showing and hiding the tooltip (ms) - does not apply to manual trigger type
-
If a number is supplied, delay is applied to both hide/show
-
Object structure is: delay: { "show": 500, "hide": 100 }
-
-
-
-
html
-
boolean
-
false
-
-
Allow HTML in the tooltip.
-
If true, HTML tags in the tooltip's title will be rendered in 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 - auto | top | bottom | left | right. When auto is specified, it will dynamically reorient the tooltip.
-
When a function is used to determine the placement, it is called with the tooltip DOM node as its first argument and the triggering element DOM node as its second. The this context is set to the tooltip instance.
-
-
-
-
selector
-
string | false
-
false
-
If a selector is provided, tooltip objects will be delegated to the specified targets. In practice, this is used to also apply tooltips to dynamically added DOM elements (jQuery.on support). See this and an informative example.
The tooltip's title will be injected into the .tooltip-inner.
-
.arrow will become the tooltip's arrow.
-
The outermost wrapper element should have the .tooltip class and role="tooltip".
-
-
-
-
title
-
string | element | function
-
''
-
-
Default title value if title attribute isn't present.
-
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.
-
'manual' indicates that the tooltip will be triggered programmatically via the .tooltip('show'), .tooltip('hide') and .tooltip('toggle') methods; this value cannot be combined with any other trigger.
-
'hover' on its own will result in tooltips that cannot be triggered via the keyboard, and should only be used if alternative methods for conveying the same information for keyboard users is present.
-
-
-
-
offset
-
number | string | function
-
0
-
-
Offset of the tooltip relative to its target.
-
When a function is used to determine the offset, it is called with an object containing the offset data as its first argument. The function must return an object with the same structure. The triggering element DOM node is passed as the second argument.
-
For more information refer to Popper.js's offset docs.
-
-
-
-
fallbackPlacement
-
string | array
-
'flip'
-
Allow to specify which position Popper will use on fallback. For more information refer to
- Popper.js's behavior docs
-
-
-
-
boundary
-
string | element
-
'scrollParent'
-
Overflow constraint boundary of the tooltip. Accepts the values of 'viewport', 'window', 'scrollParent', or an HTMLElement reference (JavaScript only). For more information refer to Popper.js's preventOverflow docs.
-
-
-
sanitize
-
boolean
-
true
-
Enable or disable the sanitization. If activated 'template' and 'title' options will be sanitized.
Options for individual tooltips can alternatively be specified through the use of data attributes, as explained above.
-
-
Methods
-
-
Asynchronous methods and transitions
-
All API methods are asynchronous and start a transition. They returns to the caller as soon as the transition is started but before it ends. In addition, a method call on a transitioning component will be ignored.
-
-
$().tooltip(options)
-
Attaches a tooltip handler to an 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 zero-length titles are never displayed.
-
-
.tooltip('hide')
-
Hides an element’s tooltip. Returns to the caller before the tooltip has actually been hidden (i.e. before the hidden.bs.tooltip event occurs). This is considered a “manual” triggering of the tooltip.
-
-
.tooltip('toggle')
-
Toggles an element’s tooltip. Returns to the caller before the tooltip has actually been shown or hidden (i.e. before the shown.bs.tooltip or hidden.bs.tooltip event occurs). This is considered a “manual” triggering of the tooltip.
-
-
.tooltip('dispose')
-
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.
-
-
.tooltip('enable')
-
Gives an element’s tooltip the ability to be shown. Tooltips are enabled by default.
-
-
.tooltip('disable')
-
Removes the ability for an element’s tooltip to be shown. The tooltip will only be able to be shown if it is re-enabled.
-
-
.tooltip('toggleEnabled')
-
Toggles the ability for an element’s tooltip to be shown or hidden.
-
-
.tooltip('update')
-
Updates the position of an element’s tooltip.
-
-
Events
-
-
-
-
Event Type
-
Description
-
-
-
-
-
show.bs.tooltip
-
This event fires immediately when the show instance method is called.
-
-
-
shown.bs.tooltip
-
This event is fired when the tooltip has been made visible to the user (will wait for CSS transitions to complete).
-
-
-
hide.bs.tooltip
-
This event is fired immediately when the hide instance method has been called.
-
-
-
hidden.bs.tooltip
-
This event is fired when the tooltip has finished being hidden from the user (will wait for CSS transitions to complete).
-
-
-
inserted.bs.tooltip
-
This event is fired after the show.bs.tooltip event when the tooltip template has been added to the DOM.
Documentation and examples for displaying inline and multiline blocks of code with Bootstrap.
-
-
-
-
-
-
-
-
-
-
Inline code
-
Wrap inline snippets of code with <code>. Be sure to escape HTML angle brackets.
-
-For example, <section> should be wrapped as inline.
-
-
-
Code blocks
-
Use <pre>s for multiple lines of code. Once again, be sure to escape any angle brackets in the code for proper rendering. You may optionally add the .pre-scrollable class, which will set a max-height of 340px and provide a y-axis scrollbar.
-
-
<p>Sample text here...</p>
-<p>And another line of sample text here...</p>
-
-
-
-
Variables
-
For indicating variables use the <var> tag.
-
-y = mx + b
-
-
-
User input
-
Use the <kbd> to indicate input that is typically entered via keyboard.
-
-To switch directories, type cd followed by the name of the directory.
-To edit settings, press ctrl + ,
-
-
-
Sample output
-
For indicating sample output from a program use the <samp> tag.
-
-This text is meant to be treated as sample output from a computer program.
-
Documentation and examples for displaying related images and text with the figure component in Bootstrap.
-
-
-
-
-
-
-
-
-
-
Anytime you need to display a piece of content—like an image with an optional caption, consider using a <figure>.
-
Use the included .figure , .figure-img and .figure-caption classes to provide some baseline styles for the HTML5 <figure> and <figcaption> elements. Images in figures have no explicit size, so be sure to add the .img-fluid class to your <img> to make it responsive.
-
-
-
-
-
Aligning the figure’s caption is easy with our text utilities.
Documentation and examples for opting images into responsive behavior (so they never become larger than their parent elements) and add lightweight styles to them—all via classes.
-
-
-
-
-
-
-
-
-
-
Responsive images
-
Images in Bootstrap are made responsive with .img-fluid. max-width: 100%; and height: auto; are applied to the image so that it scales with the parent element.
-
-
-
-
-
-
SVG images and Internet Explorer
-
In Internet Explorer 10 and 11, SVG images with .img-fluid are disproportionately sized. To fix this, add width: 100%; or .w-100 where necessary. This fix improperly sizes other image formats, so Bootstrap doesn’t apply it automatically
-
-
Image thumbnails
-
In addition to our border-radius utilities, you can use .img-thumbnail to give an image a rounded 1px border appearance.
If you are using the <picture> element to specify multiple <source> elements for a specific <img>, make sure to add the .img-* classes to the <img> and not to the <picture> tag.
Reboot, a collection of element-specific CSS changes in a single file, kickstart Bootstrap to provide an elegant, consistent, and simple baseline to build upon.
-
-
-
-
-
-
-
-
-
-
Approach
-
Reboot builds upon Normalize, providing many HTML elements with somewhat opinionated styles using only element selectors. Additional styling is done only with classes. For example, we reboot some <table> styles for a simpler baseline and later provide .table, .table-bordered, and more.
-
Here are our guidelines and reasons for choosing what to override in Reboot:
-
-
Update some browser default values to use rems instead of ems for scalable component spacing.
-
Avoid margin-top. Vertical margins can collapse, yielding unexpected results. More importantly though, a single direction of margin is a simpler mental model.
-
For easier scaling across device sizes, block elements should use rems for margins.
-
Keep declarations of font-related properties to a minimum, using inherit whenever possible.
-
-
Page defaults
-
The <html> and <body> elements are updated to provide better page-wide defaults. More specifically:
-
-
The box-sizing is globally set on every element—including *::before and *::after, to border-box. This ensures that the declared width of element is never exceeded due to padding or border.
-
No base font-size is declared on the <html>, but 16px is assumed (the browser default). font-size: 1rem is applied on the <body> for easy responsive type-scaling via media queries while respecting user preferences and ensuring a more accessible approach.
-
The <body> also sets a global font-family, line-height, and text-align. This is inherited later by some form elements to prevent font inconsistencies.
-
For safety, the <body> has a declared background-color, defaulting to #fff.
-
-
Native font stack
-
The default web fonts (Helvetica Neue, Helvetica, and Arial) have been dropped in Bootstrap 4 and replaced with a “native font stack” for optimum text rendering on every device and OS. Read more about native font stacks in this Smashing Magazine article.
-
-
This font-family is applied to the <body> and automatically inherited globally throughout Bootstrap. To switch the global font-family, update $font-family-base and recompile Bootstrap.
-
Headings and paragraphs
-
All heading elements—e.g., <h1>—and <p> are reset to have their margin-top removed. Headings have margin-bottom: .5rem added and paragraphs margin-bottom: 1rem for easy spacing.
-
-
-
-
Heading
-
Example
-
-
-
-
-
-
<h1></h1>
-
-
h1. Bootstrap heading
-
-
-
-
<h2></h2>
-
-
h2. Bootstrap heading
-
-
-
-
<h3></h3>
-
-
h3. Bootstrap heading
-
-
-
-
<h4></h4>
-
-
h4. Bootstrap heading
-
-
-
-
<h5></h5>
-
-
h5. Bootstrap heading
-
-
-
-
<h6></h6>
-
-
h6. Bootstrap heading
-
-
-
-
Lists
-
All lists—<ul>, <ol>, and <dl>—have their margin-top removed and a margin-bottom: 1rem. Nested lists have no margin-bottom.
-
-
-
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
-
-
-
Lorem ipsum dolor sit amet
-
Consectetur adipiscing elit
-
Integer molestie lorem at massa
-
Facilisis in pretium nisl aliquet
-
Nulla volutpat aliquam velit
-
Faucibus porta lacus fringilla vel
-
Aenean sit amet erat nunc
-
Eget porttitor lorem
-
-
-
For simpler styling, clear hierarchy, and better spacing, description lists have updated margins. <dd>s reset margin-left to 0 and add margin-bottom: .5rem. <dt>s are bolded.
-
-
-
Description lists
-
A description list is perfect for defining terms.
-
Euismod
-
Vestibulum id ligula porta felis euismod semper eget lacinia odio sem.
-
Donec id elit non mi porta gravida at eget metus.
-
Malesuada porta
-
Etiam porta sem malesuada magna mollis euismod.
-
-
-
Preformatted text
-
The <pre> element is reset to remove its margin-top and use rem units for its margin-bottom.
-
-
-.example-element {
- margin-bottom: 1rem;
-}
-
-
-
Tables
-
Tables are slightly adjusted to style <caption>s, collapse borders, and ensure consistent text-align throughout. Additional changes for borders, padding, and more come with the .table class.
-
-
-
- This is an example table, and this is its caption to describe the contents.
-
-
-
-
Table heading
-
Table heading
-
Table heading
-
Table heading
-
-
-
-
-
Table cell
-
Table cell
-
Table cell
-
Table cell
-
-
-
Table cell
-
Table cell
-
Table cell
-
Table cell
-
-
-
Table cell
-
Table cell
-
Table cell
-
Table cell
-
-
-
-
-
Forms
-
Various form elements have been rebooted for simpler base styles. Here are some of the most notable changes:
-
-
-<fieldset>s have no borders, padding, or margin so they can be easily used as wrappers for individual inputs or groups of inputs.
-
-<legend>s, like fieldsets, have also been restyled to be displayed as a heading of sorts.
-
-<label>s are set to display: inline-block to allow margin to be applied.
-
-<input>s, <select>s, <textarea>s, and <button>s are mostly addressed by Normalize, but Reboot removes their margin and sets line-height: inherit, too.
-
-<textarea>s are modified to only be resizable vertically as horizontal resizing often “breaks” page layout.
-
-<button>s and <input> button elements have cursor: pointer when :not(:disabled).
-
-
These changes, and more, are demonstrated below.
-
-
Pointers on buttons
-
Reboot includes an enhancement for role="button" to change the default cursor to pointer. Add this attribute to elements to help indicate elements are interactive. This role isn’t necessary for <button> elements, which get their own cursor change.
-
-Non-button element button
-
-
-
Misc elements
-
Address
-
The <address> element is updated to reset the browser default font-style from italic to normal. line-height is also now inherited, and margin-bottom: 1rem has been added. <address>s are for presenting contact information for the nearest ancestor (or an entire body of work). Preserve formatting by ending lines with <br>.
-
-
- Twitter, Inc.
- 1355 Market St, Suite 900
- San Francisco, CA 94103
- P: (123) 456-7890
-
-
- Full Name
- first.last@example.com
-
-
-
Blockquote
-
The default margin on blockquotes is 1em 40px, so we reset that to 0 0 1rem for something more consistent with other elements.
-
-
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
-
-
-
-
Inline elements
-
The <abbr> element receives basic styling to make it stand out amongst paragraph text.
-
- Nulla attr vitae elit libero, a pharetra augue.
-
-
Summary
-
The default cursor on summary is text, so we reset that to pointer to convey that the element can be interacted with by clicking on it.
-
-
- Some details
-
More info about the details.
-
-
- Even more details
-
Here are even more details about the details.
-
-
-
HTML5 [hidden] attribute
-
HTML5 adds a new global attribute named [hidden], which is styled as display: none by default. Borrowing an idea from PureCSS, we improve upon this default by making [hidden] { display: none !important; } to help prevent its display from getting accidentally overridden. While [hidden] isn’t natively supported by IE10, the explicit declaration in our CSS gets around that problem.
-
-
-
jQuery incompatibility
-
[hidden] is not compatible with jQuery’s $(...).hide() and $(...).show() methods. Therefore, we don’t currently especially endorse [hidden] over other techniques for managing the display of elements.
-
-
To merely toggle the visibility of an element, meaning its display is not modified and the element can still affect the flow of the document, use the .invisible class instead.
Documentation and examples for opt-in styling of tables (given their prevalent use in JavaScript plugins) with Bootstrap.
-
-
-
-
-
-
-
-
-
-
Examples
-
Due to the widespread use of tables across third-party widgets like calendars and date pickers, we’ve designed our tables to be opt-in. Just add the base class .table to any <table>, then extend with custom styles or our various included modifier classes.
-
Using the most basic table markup, here’s how .table-based tables look in Bootstrap. All table styles are inherited in Bootstrap 4, meaning any nested tables will be styled in the same manner as the parent.
-
-
-
-
-
#
-
First
-
Last
-
Handle
-
-
-
-
-
1
-
Mark
-
Otto
-
@mdo
-
-
-
2
-
Jacob
-
Thornton
-
@fat
-
-
-
3
-
Larry
-
the Bird
-
@twitter
-
-
-
-
-
-
You can also invert the colors—with light text on dark backgrounds—with .table-dark.
-
-
-
-
-
#
-
First
-
Last
-
Handle
-
-
-
-
-
1
-
Mark
-
Otto
-
@mdo
-
-
-
2
-
Jacob
-
Thornton
-
@fat
-
-
-
3
-
Larry
-
the Bird
-
@twitter
-
-
-
-
-
-
Table head options
-
Similar to tables and dark tables, use the modifier classes .thead-light or .thead-dark to make <thead>s appear light or dark gray.
-
-
-
-
-
#
-
First
-
Last
-
Handle
-
-
-
-
-
1
-
Mark
-
Otto
-
@mdo
-
-
-
2
-
Jacob
-
Thornton
-
@fat
-
-
-
3
-
Larry
-
the Bird
-
@twitter
-
-
-
-
-
-
-
#
-
First
-
Last
-
Handle
-
-
-
-
-
1
-
Mark
-
Otto
-
@mdo
-
-
-
2
-
Jacob
-
Thornton
-
@fat
-
-
-
3
-
Larry
-
the Bird
-
@twitter
-
-
-
-
-
-
Striped rows
-
Use .table-striped to add zebra-striping to any table row within the <tbody>.
-
-
-
-
-
#
-
First
-
Last
-
Handle
-
-
-
-
-
1
-
Mark
-
Otto
-
@mdo
-
-
-
2
-
Jacob
-
Thornton
-
@fat
-
-
-
3
-
Larry
-
the Bird
-
@twitter
-
-
-
-
-
-
-
-
-
-
#
-
First
-
Last
-
Handle
-
-
-
-
-
1
-
Mark
-
Otto
-
@mdo
-
-
-
2
-
Jacob
-
Thornton
-
@fat
-
-
-
3
-
Larry
-
the Bird
-
@twitter
-
-
-
-
-
-
Bordered table
-
Add .table-bordered for borders on all sides of the table and cells.
-
-
-
-
-
#
-
First
-
Last
-
Handle
-
-
-
-
-
1
-
Mark
-
Otto
-
@mdo
-
-
-
2
-
Jacob
-
Thornton
-
@fat
-
-
-
3
-
Larry the Bird
-
@twitter
-
-
-
-
-
-
-
-
-
-
#
-
First
-
Last
-
Handle
-
-
-
-
-
1
-
Mark
-
Otto
-
@mdo
-
-
-
2
-
Jacob
-
Thornton
-
@fat
-
-
-
3
-
Larry the Bird
-
@twitter
-
-
-
-
-
-
Borderless table
-
Add .table-borderless for a table without borders.
-
-
-
-
-
#
-
First
-
Last
-
Handle
-
-
-
-
-
1
-
Mark
-
Otto
-
@mdo
-
-
-
2
-
Jacob
-
Thornton
-
@fat
-
-
-
3
-
Larry the Bird
-
@twitter
-
-
-
-
-
-
.table-borderless can also be used on dark tables.
-
-
-
-
-
#
-
First
-
Last
-
Handle
-
-
-
-
-
1
-
Mark
-
Otto
-
@mdo
-
-
-
2
-
Jacob
-
Thornton
-
@fat
-
-
-
3
-
Larry the Bird
-
@twitter
-
-
-
-
-
-
Hoverable rows
-
Add .table-hover to enable a hover state on table rows within a <tbody>.
-
-
-
-
-
#
-
First
-
Last
-
Handle
-
-
-
-
-
1
-
Mark
-
Otto
-
@mdo
-
-
-
2
-
Jacob
-
Thornton
-
@fat
-
-
-
3
-
Larry the Bird
-
@twitter
-
-
-
-
-
-
-
-
-
-
#
-
First
-
Last
-
Handle
-
-
-
-
-
1
-
Mark
-
Otto
-
@mdo
-
-
-
2
-
Jacob
-
Thornton
-
@fat
-
-
-
3
-
Larry the Bird
-
@twitter
-
-
-
-
-
-
Small table
-
Add .table-sm to make tables more compact by cutting cell padding in half.
-
-
-
-
-
#
-
First
-
Last
-
Handle
-
-
-
-
-
1
-
Mark
-
Otto
-
@mdo
-
-
-
2
-
Jacob
-
Thornton
-
@fat
-
-
-
3
-
Larry the Bird
-
@twitter
-
-
-
-
-
-
-
-
-
-
#
-
First
-
Last
-
Handle
-
-
-
-
-
1
-
Mark
-
Otto
-
@mdo
-
-
-
2
-
Jacob
-
Thornton
-
@fat
-
-
-
3
-
Larry the Bird
-
@twitter
-
-
-
-
-
-
Contextual classes
-
Use contextual classes to color table rows or individual cells.
-
-
-
-
-
Class
-
Heading
-
Heading
-
-
-
-
-
Active
-
Cell
-
Cell
-
-
-
Default
-
Cell
-
Cell
-
-
-
Primary
-
Cell
-
Cell
-
-
-
Secondary
-
Cell
-
Cell
-
-
-
Danger
-
Cell
-
Cell
-
-
-
Info
-
Cell
-
Cell
-
-
-
Success
-
Cell
-
Cell
-
-
-
Warning
-
Cell
-
Cell
-
-
-
Dark
-
Cell
-
Cell
-
-
-
Light
-
Cell
-
Cell
-
-
-
-
-
-
Regular table background variants are not available with the dark table, however, you may use text or background utilities to achieve similar styles.
-
-
-
-
-
#
-
Heading
-
Heading
-
-
-
-
-
1
-
Cell
-
Cell
-
-
-
2
-
Cell
-
Cell
-
-
-
3
-
Cell
-
Cell
-
-
-
4
-
Cell
-
Cell
-
-
-
5
-
Cell
-
Cell
-
-
-
6
-
Cell
-
Cell
-
-
-
7
-
Cell
-
Cell
-
-
-
8
-
Cell
-
Cell
-
-
-
9
-
Cell
-
Cell
-
-
-
-
-
-
-
Conveying meaning to assistive technologies
-
Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .sr-only class.
-
-
Create responsive tables by wrapping any .table with .table-responsive{-sm|-md|-lg|-xl}, making the table scroll horizontally at each max-width breakpoint of up to (but not including) 576px, 768px, 992px, and 1120px, respectively.
-
-
Note that since browsers do not currently support range context queries, we work around the limitations of min- and max- prefixes and viewports with fractional widths (which can occur under certain conditions on high-dpi devices, for instance) by using values with higher precision for these comparisons.
-
-
Captions
-
A <caption> functions like a heading for a table. It helps users with screen readers to find a table and understand what it’s about and decide if they want to read it.
-
-
-
List of users
-
-
-
#
-
First
-
Last
-
Handle
-
-
-
-
-
1
-
Mark
-
Otto
-
@mdo
-
-
-
2
-
Jacob
-
Thornton
-
@fat
-
-
-
3
-
Larry
-
the Bird
-
@twitter
-
-
-
-
-
-
Responsive tables
-
Responsive tables allow tables to be scrolled horizontally with ease. Make any table responsive across all viewports by wrapping a .table with .table-responsive. Or, pick a maximum breakpoint with which to have a responsive table up to by using .table-responsive{-sm|-md|-lg|-xl}.
-
-
Vertical clipping/truncation
-
Responsive tables make use of overflow-y: hidden, which clips off any content that goes beyond the bottom or top edges of the table. In particular, this can clip off dropdown menus and other third-party widgets.
-
-
Always responsive
-
Across every breakpoint, use .table-responsive for horizontally scrolling tables.
-
-
-
-
-
-
#
-
Heading
-
Heading
-
Heading
-
Heading
-
Heading
-
Heading
-
Heading
-
Heading
-
Heading
-
-
-
-
-
1
-
Cell
-
Cell
-
Cell
-
Cell
-
Cell
-
Cell
-
Cell
-
Cell
-
Cell
-
-
-
2
-
Cell
-
Cell
-
Cell
-
Cell
-
Cell
-
Cell
-
Cell
-
Cell
-
Cell
-
-
-
3
-
Cell
-
Cell
-
Cell
-
Cell
-
Cell
-
Cell
-
Cell
-
Cell
-
Cell
-
-
-
-
-
-
-
Breakpoint specific
-
Use .table-responsive{-sm|-md|-lg|-xl} as needed to create responsive tables up to a particular breakpoint. From that breakpoint and up, the table will behave normally and not scroll horizontally.
-
These tables may appear broken until their responsive styles apply at specific viewport widths.
Documentation and examples for Bootstrap typography, including global settings, headings, body text, lists, and more.
-
-
-
-
-
-
-
-
-
-
Global settings
-
Bootstrap sets basic global display, typography, and link styles. When more control is needed, check out the textual utility classes.
-
-
Use a native font stack that selects the best font-family for each OS and device.
-
For a more inclusive and accessible type scale, we assume the browser default root font-size (typically 16px) so visitors can customize their browser defaults as needed.
-
Use the $font-family-base, $font-size-base, and $line-height-base attributes as our typographic base applied to the <body>.
-
Set the global link color via $link-color and apply link underlines only on :hover.
-
Use $body-bg to set a background-color on the <body> (#fff by default).
-
-
These styles can be found within _reboot.scss, and the global variables are defined in _variables.scss. Make sure to set $font-size-base in rem.
-
Headings
-
All HTML headings, <h1> through <h6>, are available.
-
-
-
-
Heading
-
Example
-
-
-
-
-
-
<h1></h1>
-
-
h1. Bootstrap heading
-
-
-
-
<h2></h2>
-
-
h2. Bootstrap heading
-
-
-
-
<h3></h3>
-
-
h3. Bootstrap heading
-
-
-
-
<h4></h4>
-
-
h4. Bootstrap heading
-
-
-
-
<h5></h5>
-
-
h5. Bootstrap heading
-
-
-
-
<h6></h6>
-
-
h6. Bootstrap heading
-
-
-
-
-
.h1 through .h6 classes are also available, for when you want to match the font styling of a heading but cannot use the associated HTML element.
-
-
h1. Bootstrap heading
-
h2. Bootstrap heading
-
h3. Bootstrap heading
-
h4. Bootstrap heading
-
h5. Bootstrap heading
-
h6. Bootstrap heading
-
-
-
Customizing headings
-
Use the included utility classes to recreate the small secondary heading text from Bootstrap 3.
-
-
- Fancy display heading
- With faded secondary text
-
-
-
-
Display headings
-
Traditional heading elements are designed to work best in the meat of your page content. When you need a heading to stand out, consider using a display heading—a larger, slightly more opinionated heading style. Keep in mind these headings are not responsive by default, but it’s possible to enable responsive font sizes.
-
-
-
-
-
Display 1
-
-
-
Display 2
-
-
-
Display 3
-
-
-
Display 4
-
-
-
-
-
-
Lead
-
Make a paragraph stand out by adding .lead.
-
-
- Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Duis mollis, est non commodo luctus.
-
-
-
-
Inline text elements
-
Styling for common inline HTML5 elements.
-
-
You can use the mark tag to highlight text.
-
This line of text is meant to be treated as deleted text.
-
This line of text is meant to be treated as no longer accurate.
-
This line of text is meant to be treated as an addition to the document.
-
This line of text will render as underlined
-
This line of text is meant to be treated as fine print.
-
This line rendered as bold text.
-
This line rendered as italicized text.
-
-
-
.mark and .small classes are also available to apply the same styles as <mark> and <small> while avoiding any unwanted semantic implications that the tags would bring.
-
While not shown above, 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.
Stylized implementation of HTML’s <abbr> element for abbreviations and acronyms to show the expanded version on hover. Abbreviations have a default underline and gain a help cursor to provide additional context on hover and to users of assistive technologies.
-
Add .initialism to an abbreviation for a slightly smaller font-size.
-
-
attr
-
HTML
-
-
-
Blockquotes
-
For quoting blocks of content from another source within your document. Wrap <blockquote class="blockquote"> around any HTML as the quote.
-
-
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
-
-
-
-
Naming a source
-
Add a <footer class="blockquote-footer"> 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.
-
-
-
-
-
Alignment
-
Use text utilities as needed to change the alignment of your blockquote.
-
-
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
-
-
-
-
-
-
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
-
-
-
-
-
Lists
-
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
-
-
-
-
Inline
-
Remove a list’s bullets and apply some light margin with a combination of two classes, .list-inline and .list-inline-item.
-
-
-
Lorem ipsum
-
Phasellus iaculis
-
Nulla volutpat
-
-
-
-
Description list alignment
-
Align terms and descriptions horizontally by using our grid system’s predefined classes (or semantic mixins). For longer terms, you can optionally add a .text-truncate class to truncate the text with an ellipsis.
-
-
-
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.
-
Truncated term is truncated
-
Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.
-
Nesting
-
-
-
Nested definition list
-
Aenean posuere, tortor sed cursus feugiat, nunc augue blandit nunc.
-
-
-
-
-
-
Responsive font sizes
-
Bootstrap v4.3 ships with the option to enable responsive font sizes, allowing text to scale more naturally across device and viewport sizes. RFS can be enabled by changing the $enable-responsive-font-sizes Sass variable to true and recompiling Bootstrap.
-
To support RFS, we use a Sass mixin to replace our normal font-size properties. Responsive font sizes will be compiled into calc() functions with a mix of rem and viewport units to enable the responsive scaling behavior. More about RFS and its configuration can be found on its GitHub repository.
A brief overview of Bootstrap + Material UI features and limitations for the creation of accessible content.
-
-
-
-
-
-
-
-
-
-
Material UI provides an easy-to-use framework of ready-made styles, layout tools, and interactive components, allowing developers to create websites and applications that are visually appealing, functionally rich, and accessible out of the box.
-
Overview and Limitations
-
The overall accessibility of any project built with Material UI depends in large part on the author’s markup, additional styling, and scripting they’ve included. However, provided that these have been implemented correctly, it should be perfectly possible to create websites and applications with Material UI that fulfill WCAG 2.0 (A/AA/AAA), Section 508 and similar accessibility standards and requirements.
-
Structural markup
-
Material UI’s styling and layout can be applied to a wide range of markup structures. This documentation aims to provide developers with best practice examples to demonstrate the use of Material UI itself and illustrate appropriate semantic markup, including ways in which potential accessibility concerns can be addressed.
-
Interactive components
-
Bootstrap’s restyled interactive components—such as modal dialogs, dropdown menus and custom tooltips—are designed to work for touch, mouse and keyboard users. Through the use of relevant WAI-ARIA roles and attributes, these components should also be understandable and operable using assistive technologies (such as screen readers).
-
Because Bootstrap’s components are purposely designed to be fairly generic, authors may need to include further ARIA roles and attributes, as well as JavaScript behavior, to more accurately convey the precise nature and functionality of their component. This is usually noted in the documentation.
-
Color contrast
-
Most colors that currently make up Material UI’s default palette—used throughout the framework for things such as button variations, alert variations, form validation indicators—lead to insufficient color contrast (below the recommended WCAG 2.0 color contrast ratio of 4.5:1) when used against a light background. Authors will need to manually modify/extend these default colors to ensure adequate color contrast ratios.
-
Visually hidden content
-
Content which should be visually hidden, but remain accessible to assistive technologies such as screen readers, can be styled using the .sr-only class. This can be useful in situations where additional visual information or cues (such as meaning denoted through the use of color) need to also be conveyed to non-visual users.
-
-
For visually hidden interactive controls, such as traditional “skip” links, .sr-only can be combined with the .sr-only-focusable class. This will ensure that the control becomes visible once focused (for sighted keyboard users).
-
-
Reduced motion
-
Material UI includes support for the prefers-reduced-motion media feature. In browsers/environments that allow the user to specify their preference for reduced motion, most CSS transition effects in Material UI (for instance, when a modal dialog is opened or closed, or the sliding animation in carousels) will be disabled.
Learn about the browsers and devices, from modern to old, that are supported by Bootstrap, including known quirks and bugs for each.
-
-
-
-
-
-
-
-
-
-
Supported browsers
-
Bootstrap supports the latest, stable releases of all major browsers and platforms. On Windows, we support Internet Explorer 11 / Microsoft Edge.
-
Alternative browsers which use the latest version of WebKit, Blink, or Gecko, whether directly or via the platform’s web view API, are not explicitly supported. However, Bootstrap should (in most cases) display and function correctly in these browsers as well. More specific support information is provided below.
We use Autoprefixer to handle intended browser support via CSS prefixes, which uses Browserslist to manage these browser versions. Consult their documentation for how to integrate these tools into your projects.
-
Mobile devices
-
Generally speaking, Bootstrap supports the latest versions of each major platform’s default browsers. Note that proxy browsers (such as Opera Mini, Opera Mobile’s Turbo mode, UC Browser Mini, Amazon Silk) are not supported.
-
-
-
-
-
Chrome
-
Firefox
-
Safari
-
Android Browser & WebView
-
Microsoft Edge
-
-
-
-
-
Android
-
Supported
-
Supported
-
—
-
v6.0+
-
Supported
-
-
-
iOS
-
Supported
-
Supported
-
Supported
-
—
-
Supported
-
-
-
Windows 10 Mobile
-
—
-
—
-
—
-
—
-
Supported
-
-
-
-
Desktop browsers
-
Similarly, the latest versions of most desktop browsers are supported.
-
-
-
-
-
Chrome
-
Firefox
-
Internet Explorer
-
Microsoft Edge
-
Opera
-
Safari
-
-
-
-
-
Mac
-
Supported
-
Supported
-
—
-
Supported
-
Supported
-
Supported
-
-
-
Windows
-
Supported
-
Supported
-
IE11 only
-
Supported
-
Supported
-
—
-
-
-
-
For Firefox, in addition to the latest normal stable release, we also support the latest Extended Support Release (ESR) version of Firefox.
-
Unofficially, Bootstrap should look and behave well enough in Chromium and Chrome for Linux, Firefox for Linux, and Internet Explorer 9, though they are not officially supported.
-
Internet Explorer
-
Internet Explorer 11 is supported; IE10 and down is not. Please be aware that some CSS3 properties and HTML5 elements are not fully supported in IE10, or require prefixed properties for full functionality. Visit Can I use… for details on browser support of CSS3 and HTML5 features. If you require IE8-9 support, use Bootstrap 3.
-
Modals and dropdowns on mobile
-
Overflow and scrolling
-
Support for overflow: hidden; on the <body> element is quite limited in iOS and Android. To that end, when you scroll past the top or bottom of a modal in either of those devices’ browsers, the <body> content will begin to scroll. See Chrome bug #175502 (fixed in Chrome v40) and WebKit bug #153852.
-
iOS text fields and scrolling
-
As of iOS 9.2, while a modal is open, if the initial touch of a scroll gesture is within the boundary of a textual <input> or a <textarea>, the <body> content underneath the modal will be scrolled instead of the modal itself. See WebKit bug #153856.
-
Navbar Dropdowns
-
The .dropdown-backdrop element isn’t used on iOS in the nav because of the complexity of z-indexing. Thus, to close dropdowns in navbars, you must directly click the dropdown element (or any other element which will fire a click event in iOS).
-
Browser zooming
-
Page zooming inevitably presents rendering artifacts in some components, both in Bootstrap and the rest of the web. Depending on the issue, we may be able to fix it (search first and then open an issue if need be). However, we tend to ignore these as they often have no direct solution other than hacky workarounds.
-
Validators
-
In order to provide the best possible experience to old and buggy browsers, Bootstrap uses CSS browser hacks in several places to target special CSS to certain browser versions in order to work around bugs in the browsers themselves. These hacks understandably cause CSS validators to complain that they are invalid. In a couple places, we also use bleeding-edge CSS features that aren’t yet fully standardized, but these are used purely for progressive enhancement.
-
These validation warnings don’t matter in practice since the non-hacky portion of our CSS does fully validate and the hacky portions don’t interfere with the proper functioning of the non-hacky portion, hence why we deliberately ignore these particular warnings.
-
Our HTML docs likewise have some trivial and inconsequential HTML validation warnings due to our inclusion of a workaround for a certain Firefox bug.
Discover what's included in Bootstrap, including our precompiled and source code flavors. Remember, Bootstrap's JavaScript plugins require jQuery.
-
-
-
-
-
-
-
-
-
-
Precompiled Bootstrap
-
Once downloaded, unzip the compressed folder and you’ll see something like this:
-
-
-
This is the most basic form of Bootstrap: precompiled 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.*). source maps (bootstrap.*.map) are available for use with certain browsers’ developer tools. Bundled JS files (bootstrap.bundle.js and minified bootstrap.bundle.min.js) include Popper, but not jQuery.
-
CSS files
-
Bootstrap includes a handful of options for including some or all of our compiled CSS.
Similarly, we have options for including some or all of our compiled JavaScript.
-
-
-
-
JS files
-
Popper
-
jQuery
-
-
-
-
-
-
bootstrap.bundle.js
-
bootstrap.bundle.min.js
-
-
Included
-
Not included
-
-
-
-
bootstrap.js
-
bootstrap.min.js
-
-
Not included
-
Not included
-
-
-
-
Bootstrap source code
-
The Bootstrap source code download includes the precompiled CSS and JavaScript assets, along with source Sass, JavaScript, and documentation. More specifically, it includes the following and more:
-
-
The scss/ and js/ are the source code for our CSS and JavaScript. The dist/ folder includes everything listed in the precompiled download section above. The site/docs/ folder includes the source code for our documentation, and examples/ of Bootstrap usage. Beyond that, any other included file provides support for packages, license information, and development.
This is the most basic form of Material: precompiled files for quick drop-in usage in nearly any web project.
-
We provide compiled CSS and JavaScript (material.*), as well as compiled and minified CSS and JavaScript (material.min.*).
-Extra CSS for plugins is stored in (material-plugins.css) and minified in (material-plugins.min.css). Respective JavaScript for each plugin has to be imported manually (refer to Plugins section).
The Material source code download includes the precompiled CSS and JavaScript, along with documentation and source assets. More specifically, it includes the following and more:
-
-
The assets/ is the source code for our CSS and JavaScript.
-The css/ and js/ folders are the same in the precompiled download section above.
-The docs/ folder includes the source code for our documentation. Beyond that, any other included file provides support for development.
-
Check the theming guide for how to customise Material for your project using our source code.
-
Important globals
-
Material employs a handful of important global styles and settings that you’ll need to be aware of when using it, all of which are almost exclusively geared towards the normalization of cross browser styles. Let’s dive in.
-
Box-sizing
-
For more straightforward sizing in CSS, we switch the global box-sizing value from content-box to border-box. This ensures padding does not affect the final computed width of an element, but it can cause problems with some third party software like Google Maps.
-
On the rare occasion you need to override it, use something like the following:
-
-
With the above snippet, nested elements—including generated content via :before and :after will all inherit the specified box-sizing for that .selector-for-some-widget.
Material requires the use of the HTML5 doctype. Without it, you’ll see some funky incomplete styling, but including it shouldn’t cause any considerable hiccups.
-
-
Responsive meta tag
-
Material is developed mobile first, a strategy in which we optimize code for mobile devices first and then scale up components as necessary using CSS media queries. To ensure proper rendering and touch zooming for all devices, add the responsive viewport meta tag to your <head>.
-
-
Starter template
-
Be sure to have your pages set up with the latest design and development standards. That means using an HTML5 doctype and including a viewport meta tag for proper responsive behaviors. Put it all together and your pages should look like this:
-
-
That’s all you need for overall page requirements.
Material v4 is a major rewrite of the entire project. The most notable changes are summarized below.
-
-
-
-
-
-
-
-
-
-
Bootstrap changes
-
Material monitors the changes in the Bootstrap project so the exact same Bootstrap HTML markup can always work with Material. For example, when Bootstrap dropped .hidden-* classes for new display utilities, Material did the same by dropping .hidden-* classes and introducing .d-{value} and .d-{breakpoint}-{value} classes. If you are upgrading Material, please follow Bootstrap’s migration doc for details about breaking and/or notable changes in each release as the changes will apply to Material, too.
-
This page will focus on the changes that are unique to Material.
-
v4.5.2 - Release Candidate
-
Upgrade to Bootstrap 4.5.2, various changes (see CHANGELOG.md)
-
v4.5.0 - Release Candidate
-
Upgrade to Bootstrap 4.5.0, new ripple effect, fixes switch component, improve components, fix bugs
-
v4.4.1 - beta
-
Improve components, fix bugs
-
v4.4.1 - alpha
-
This release consisted of reviving the project, upgrading it to latest Bootstrap 4.4.1 version and adding latest Material styles.
-
v4.3.1 - Unreleased
-
This work focused on upgrading Components look according to Material design v2.
-
v4.1.1
-
This release mainly focuses on bug fixes, especially styles related to form controls.
-
Table
-
Because responsive table now again requires a wrapping element, it does not work well with .table-bordered as the card like box-shadow will be cut off. As a result, .table-bordered now reverts back to adding a border rather than a box-shadow to the table. However, it is very easy to combine .card and .table together to achieve how .table-bordered used to look like.
-
v4.1.0
-
This release consists of incorporating Bootstrap 4’s changes and minor bug fixes. v4.1 also introduces a couple of new features.
-
Default link colour
-
Changed default link colour to $secondary colour based on Google Material Design’s colour system guidelines.
-
Shadows
-
Added new .shadow-* utilities for quickly adding box-shadows. Details are documented here.
-
Snackbars
-
Added new .snackbar component. Details are documented here.
-
v4.0.0
-
All previous alpha and beta releases mainly focused on keeping up with Bootstrap 4’s continuous releases plus minor bug fixes. The stable v4.0.0 release addressed a few issues that have hinged on for a while.
-
Breakpoints
-
Material v4’s alpha and beta releases have a different set of breakpoints and container max-widths than Bootstrap’s default values. Material’s stable v4.0.0 reverts these values back to be the same as Bootstrap’s default values. The reason is that although the values used in Material v4’s alpha and beta releases are more in line with Google Material Design’s responsive UI guidelines, Bootstrap’s grid setup seems to work better in most cases.
-
Floating action buttons
-
Added Material specific .btn-float-dropdown to allow a floating action button to fling out related actions since the default dropdown menus do not work well with floating action buttons. For detailed usage, please visit buttons doc.
-
Input groups
-
Added Material specific .input-group-icon to allow an icon to change its colour based on the state of its associated form control. For detailed usage, please visit text fields doc.
-
Navigation drawer
-
Since Bootstrap introduced responsive .navbar-expand-{breakpoint}, navigation drawer has been due a similar change, too.
-
-
-
Permanent, persistent, and temporary navigation drawers now support responsive behaviours via .navdrawer-{type}-{breakpoint} classes.
-
-
-
Navigation drawer JavaScript is updated to provide an extra option, breakpoint, to allow a value from sm to xl to be passed in. This option can also be passed via data attribute as data-breakpoint. xs is not included because .navdrawer-{type}-xs would be applied from min-width: 0; and up which means it is not bound by a media query.
Two third party plugins, textarea-autosize and waves, are removed from the stable v4.0.0 release. The reason is that these third party plugins can be used without any modifications to work with Material, so leaving out these third party plugins can not only bring down the size of the CSS and JavaScript of Material a bit, but also provide some flexibility for developers to use their preferred plugins for the same job.
-
In case the two plugins are required, please check out the following two projects and incorporate them back in accordingly:
-
-
-
The plugin used in v4’s alpha and beta to adjust the height of the textarea automatically is: textarea-autosize
-
-
-
The plugin used in v4’s alpha and beta to create the ripple effect on click is : waves
Customise Material with our new built-in Sass variables for global style preferences for easy theming and component changes.
-
-
-
-
-
-
-
-
-
-
Browser support
-
Before you start, please be aware that Material supports the latest, stable releases of all major browsers and platforms. On Windows, we support Internet Explorer 10-11 / Microsoft Edge.
-
Alternative browsers which use the latest version of Blink, Gecko, or WebKit whether directly or via the platform’s web view API, are not explicitly supported. However, Material should (in most cases) display and function correctly in these browsers as well. More specific support information is provided below.
-
Desktop browsers
-
The latest versions of most desktop browsers are supported.
-
-
-
-
-
-
Chrome
-
Firefox
-
Internet Explorer
-
Microsoft Edge
-
Opera
-
Safari
-
-
-
-
-
Mac
-
Supported
-
Supported
-
N/A
-
N/A
-
Supported
-
Supported
-
-
-
Windows
-
Supported
-
Supported
-
Supported, IE10+
-
Supported
-
Supported
-
Not supported
-
-
-
-
-
For Firefox, in addition to the latest normal stable release, we also support the latest Extended Support Release (ESR) version of Firefox.
-
Unofficially, Material should behave and look well enough in Chrome for Linux and Chrome, Firefox for Linux, and Internet Explorer 9, though they are not officially supported.
-
Internet Explorer
-
Internet Explorer 10+ is supported; IE9 and down is not. Please be aware that some CSS3 properties and HTML5 elements are not fully supported in IE10, or require prefixed properties for full functionality. Visit Can I use for details on browser support of CSS3 and HTML5 features.
-
Mobile devices
-
Material supports the latest versions of each major platform’s default browsers. Note that proxy browsers (such as Opera Mini, Opera Mobile’s Turbo mode, UC Browser Mini) are not supported.
-
-
-
-
-
-
Android Browser & WebView
-
Chrome
-
Firefox
-
Microsoft Edge
-
Safari
-
-
-
-
-
Android
-
Android v5.0+ supported
-
Supported
-
Supported
-
Supported
-
N/A
-
-
-
iOS
-
N/A
-
Supported
-
Supported
-
Supported
-
Supported
-
-
-
Windows 10 Mobile
-
N/A
-
N/A
-
N/A
-
Supported
-
N/A
-
-
-
-
-
CSS variables
-
Material includes CSS custom properties (variables) in its compiled CSS. These provide easy access to some commonly used values like our breakpoints, colors and font stacks.
-
Available variables
-
Here are the variables we include:
-
-
Examples
-
CSS variables offer similar flexibility to Sass variables, but without the need for compilation before being served to the browser. For example, here we’re resetting our link styles with CSS variables.
-
-
While we include breakpoints in our CSS variables, they unfortunately cannot be used in media queries. These remain in the compiled CSS for backward compatibility given they can be utilised by JavaScript. Learn more in the spec.
-
Sass
-
Utilize our source Sass files to take advantage of mixins, variables and more.
-
Whenever possible, avoid modifying Material’s core files. For Sass, that means creating your own stylesheet that imports Material so you can modify and extend it.
-
For example, you can create a custom.scss and import either all of Material’s source Sass files or only selected parts you need. We encourage the latter, though be aware there are some dependencies and requirements across our components. You will also need to include some JavaScript for certain plugins.
-
-
-
With that setup in place, you can begin to modify any of the Sass maps and variables in your custom.scss. You can also start to add parts of Material under the // Optional section as needed. We suggest using the full import stack from our material.scss file as your starting point.
-
Default variables
-
Every Sass variable in Material includes the !default flag allowing you to override the variable’s default value in your own Sass without modifying Material’s source code. Copy and paste variables as needed, modify their values, and remove the !default flag. If a variable has already been assigned, then it won’t be re-assigned by the default values in Material.
-
Here’s an example that changes the background-color for the <body>:
-
-
Repeat as necessary for any variable in Material.
-
Maps
-
Material includes a handful of Sass maps that make it easier to generate families of related CSS. We use Sass maps for our breakpoints, colors, and more. Just like Sass variables, all Sass maps include the !default flag and can be overridden and extended.
-
Some of our Sass maps are merged into empty ones by default. This is done to allow easy expansion of a given Sass map, but comes at the cost of making removing items from a map slightly more difficult.
-
Add to map
-
To add a new item to $sizes, add the new key and value to your custom Sass file:
-
-
This will generate a new pair of .h-15 and .w-15 classes which will set height and width to be 15% respectively.
-
Modify map
-
To modify an existing item in our $spacers map, add the following to your custom Sass file:
-
-
Classes such as mb-5 will then set margin-bottom to be 5rem instead of the default 3rem.
-
Remove from map
-
To remove an item from a map, use map-remove. Be aware you must insert it between our requirements and options:
-
-
However, please be aware that Material assumes the presence of some specific keys within Sass maps. As you customise the included maps, you may encounter errors where a specific Sass map’s key is being used.
-
For example, we use the danger, success and warning keys from $theme-colors for styling different states of some components. Removing the values of these keys may cause Sass compilation issues. In these instances, you’ll need to modify the Sass code that makes use of those values.
-
Theme colors
-
Many of Material’s various components and utilities are built through a series of colors defined in a Sass map. This map can be looped over in Sass to quickly generate a series of rulesets.
-
All colors
-
All colors available in Material, are available as Sass variables in our assets/scss/_colors.scss file.
-
-
-
-
- 50
- #fff8e1
-
-
- 100
- #ffecb3
-
-
- 200
- #ffe082
-
-
- 300
- #ffd54f
-
-
- 400
- #ffca28
-
-
-
Amber
-
- 500
- #ffc107
-
-
-
- 500
- #ffc107
-
-
- 600
- #ffb300
-
-
- 700
- #ffa000
-
-
- 800
- #ff8f00
-
-
- 900
- #ff6f00
-
-
- A100
- #ffe57f
-
-
- A200
- #ffd740
-
-
- A400
- #ffc400
-
-
- A700
- #ffab00
-
-
-
-
-
-
- 50
- #e3f2fd
-
-
- 100
- #bbdefb
-
-
- 200
- #90caf9
-
-
- 300
- #64b5f6
-
-
- 400
- #42a5f5
-
-
-
Blue
-
- 500
- #2196f3
-
-
-
- 500
- #2196f3
-
-
- 600
- #1e88e5
-
-
- 700
- #1976d2
-
-
- 800
- #1565c0
-
-
- 900
- #0d47a1
-
-
- A100
- #82b1ff
-
-
- A200
- #448aff
-
-
- A400
- #2979ff
-
-
- A700
- #2962ff
-
-
-
-
-
-
- 50
- #eceff1
-
-
- 100
- #cfd8dc
-
-
- 200
- #b0bec5
-
-
- 300
- #90a4ae
-
-
- 400
- #78909c
-
-
-
Blue grey
-
- 500
- #607d8b
-
-
-
- 500
- #607d8b
-
-
- 600
- #546e7a
-
-
- 700
- #455a64
-
-
- 800
- #37474f
-
-
- 900
- #263238
-
-
-
-
-
-
- 50
- #efebe9
-
-
- 100
- #d7ccc8
-
-
- 200
- #bcaaa4
-
-
- 300
- #a1887f
-
-
- 400
- #8d6e63
-
-
-
Brown
-
- 500
- #795548
-
-
-
- 500
- #795548
-
-
- 600
- #6d4c41
-
-
- 700
- #5d4037
-
-
- 800
- #4e342e
-
-
- 900
- #3e2723
-
-
-
-
-
-
- 50
- #e0f7fa
-
-
- 100
- #b2ebf2
-
-
- 200
- #80deea
-
-
- 300
- #4dd0e1
-
-
- 400
- #26c6da
-
-
-
Cyan
-
- 500
- #00bcd4
-
-
-
- 500
- #00bcd4
-
-
- 600
- #00acc1
-
-
- 700
- #0097a7
-
-
- 800
- #00838f
-
-
- 900
- #006064
-
-
- A100
- #84ffff
-
-
- A200
- #18ffff
-
-
- A400
- #00e5ff
-
-
- A700
- #00b8d4
-
-
-
-
-
-
- 50
- #fbe9e7
-
-
- 100
- #ffccbc
-
-
- 200
- #ffab91
-
-
- 300
- #ff8a65
-
-
- 400
- #ff7043
-
-
-
Deep orange
-
- 500
- #ff5722
-
-
-
- 500
- #ff5722
-
-
- 600
- #f4511e
-
-
- 700
- #e64a19
-
-
- 800
- #d84315
-
-
- 900
- #bf360c
-
-
- A100
- #ff9e80
-
-
- A200
- #ff6e40
-
-
- A400
- #ff3d00
-
-
- A700
- #dd2c00
-
-
-
-
-
-
- 50
- #ede7f6
-
-
- 100
- #d1c4e9
-
-
- 200
- #b39ddb
-
-
- 300
- #9575cd
-
-
- 400
- #7e57c2
-
-
-
Deep purple
-
- 500
- #673ab7
-
-
-
- 500
- #673ab7
-
-
- 600
- #5e35b1
-
-
- 700
- #512da8
-
-
- 800
- #4527a0
-
-
- 900
- #311b92
-
-
- A100
- #b388ff
-
-
- A200
- #7c4dff
-
-
- A400
- #651fff
-
-
- A700
- #6200ea
-
-
-
-
-
-
- 50
- #e8f5e9
-
-
- 100
- #c8e6c9
-
-
- 200
- #a5d6a7
-
-
- 300
- #81c784
-
-
- 400
- #66bb6a
-
-
-
Green
-
- 500
- #4caf50
-
-
-
- 500
- #4caf50
-
-
- 600
- #43a047
-
-
- 700
- #388e3c
-
-
- 800
- #2e7d32
-
-
- 900
- #1b5e20
-
-
- A100
- #b9f6ca
-
-
- A200
- #69f0ae
-
-
- A400
- #00e676
-
-
- A700
- #00c853
-
-
-
-
-
-
- 50
- #fafafa
-
-
- 100
- #f5f5f5
-
-
- 200
- #eeeeee
-
-
- 300
- #e0e0e0
-
-
- 400
- #bdbdbd
-
-
-
Grey
-
- 500
- #9e9e9e
-
-
-
- 500
- #9e9e9e
-
-
- 600
- #757575
-
-
- 700
- #616161
-
-
- 800
- #424242
-
-
- 900
- #212121
-
-
-
-
-
-
- 50
- #e8eaf6
-
-
- 100
- #c5cae9
-
-
- 200
- #9fa8da
-
-
- 300
- #7986cb
-
-
- 400
- #5c6bc0
-
-
-
Indigo
-
- 500
- #3f51b5
-
-
-
- 500
- #3f51b5
-
-
- 600
- #3949ab
-
-
- 700
- #303f9f
-
-
- 800
- #283593
-
-
- 900
- #1a237e
-
-
- A100
- #8c9eff
-
-
- A200
- #536dfe
-
-
- A400
- #3d5afe
-
-
- A700
- #304ffe
-
-
-
-
-
-
- 50
- #e1f5fe
-
-
- 100
- #b3e5fc
-
-
- 200
- #81d4fa
-
-
- 300
- #4fc3f7
-
-
- 400
- #29b6f6
-
-
-
Light blue
-
- 500
- #03a9f4
-
-
-
- 500
- #03a9f4
-
-
- 600
- #039be5
-
-
- 700
- #0288d1
-
-
- 800
- #0277bd
-
-
- 900
- #01579b
-
-
- A100
- #80d8ff
-
-
- A200
- #40c4ff
-
-
- A400
- #00b0ff
-
-
- A700
- #0091ea
-
-
-
-
-
-
- 50
- #f1f8e9
-
-
- 100
- #dcedc8
-
-
- 200
- #c5e1a5
-
-
- 300
- #aed581
-
-
- 400
- #9ccc65
-
-
-
Light green
-
- 500
- #8bc34a
-
-
-
- 500
- #8bc34a
-
-
- 600
- #7cb342
-
-
- 700
- #689f38
-
-
- 800
- #558b2f
-
-
- 900
- #33691e
-
-
- A100
- #ccff90
-
-
- A200
- #b2ff59
-
-
- A400
- #76ff03
-
-
- A700
- #64dd17
-
-
-
-
-
-
- 50
- #f9fbe7
-
-
- 100
- #f0f4c3
-
-
- 200
- #e6ee9c
-
-
- 300
- #dce775
-
-
- 400
- #d4e157
-
-
-
Lime
-
- 500
- #cddc39
-
-
-
- 500
- #cddc39
-
-
- 600
- #c0ca33
-
-
- 700
- #afb42b
-
-
- 800
- #9e9d24
-
-
- 900
- #827717
-
-
- A100
- #f4ff81
-
-
- A200
- #eeff41
-
-
- A400
- #c6ff00
-
-
- A700
- #aeea00
-
-
-
-
-
-
- 50
- #fff3e0
-
-
- 100
- #ffe0b2
-
-
- 200
- #ffcc80
-
-
- 300
- #ffb74d
-
-
- 400
- #ffa726
-
-
-
Orange
-
- 500
- #ff9800
-
-
-
- 500
- #ff9800
-
-
- 600
- #fb8c00
-
-
- 700
- #f57c00
-
-
- 800
- #ef6c00
-
-
- 900
- #e65100
-
-
- A100
- #ffd180
-
-
- A200
- #ffab40
-
-
- A400
- #ff9100
-
-
- A700
- #ff6d00
-
-
-
-
-
-
- 50
- #fce4ec
-
-
- 100
- #f8bbd0
-
-
- 200
- #f48fb1
-
-
- 300
- #f06292
-
-
- 400
- #ec407a
-
-
-
Pink
-
- 500
- #e91e63
-
-
-
- 500
- #e91e63
-
-
- 600
- #d81b60
-
-
- 700
- #c2185b
-
-
- 800
- #ad1457
-
-
- 900
- #880e4f
-
-
- A100
- #ff80ab
-
-
- A200
- #ff4081
-
-
- A400
- #f50057
-
-
- A700
- #c51162
-
-
-
-
-
-
- 50
- #f3e5f5
-
-
- 100
- #e1bee7
-
-
- 200
- #ce93d8
-
-
- 300
- #ba68c8
-
-
- 400
- #ab47bc
-
-
-
Purple
-
- 500
- #9c27b0
-
-
-
- 500
- #9c27b0
-
-
- 600
- #8e24aa
-
-
- 700
- #7b1fa2
-
-
- 800
- #6a1b9a
-
-
- 900
- #4a148c
-
-
- A100
- #ea80fc
-
-
- A200
- #e040fb
-
-
- A400
- #d500f9
-
-
- A700
- #aa00ff
-
-
-
-
-
-
- 50
- #ffebee
-
-
- 100
- #ffcdd2
-
-
- 200
- #ef9a9a
-
-
- 300
- #e57373
-
-
- 400
- #ef5350
-
-
-
Red
-
- 500
- #f44336
-
-
-
- 500
- #f44336
-
-
- 600
- #e53935
-
-
- 700
- #d32f2f
-
-
- 800
- #c62828
-
-
- 900
- #b71c1c
-
-
- A100
- #ff8a80
-
-
- A200
- #ff5252
-
-
- A400
- #ff1744
-
-
- A700
- #d50000
-
-
-
-
-
-
- 50
- #e0f2f1
-
-
- 100
- #b2dfdb
-
-
- 200
- #80cbc4
-
-
- 300
- #4db6ac
-
-
- 400
- #26a69a
-
-
-
Teal
-
- 500
- #009688
-
-
-
- 500
- #009688
-
-
- 600
- #00897b
-
-
- 700
- #00796b
-
-
- 800
- #00695c
-
-
- 900
- #004d40
-
-
- A100
- #a7ffeb
-
-
- A200
- #64ffda
-
-
- A400
- #1de9b6
-
-
- A700
- #00bfa5
-
-
-
-
-
-
- 50
- #fffde7
-
-
- 100
- #fff9c4
-
-
- 200
- #fff59d
-
-
- 300
- #fff176
-
-
- 400
- #ffee58
-
-
-
Yellow
-
- 500
- #ffeb3b
-
-
-
- 500
- #ffeb3b
-
-
- 600
- #fdd835
-
-
- 700
- #fbc02d
-
-
- 800
- #f9a825
-
-
- 900
- #f57f17
-
-
- A100
- #ffff8d
-
-
- A200
- #ffff00
-
-
- A400
- #ffea00
-
-
- A700
- #ffd600
-
-
-
-
-
Here’s how you can use these in your Sass:
-
-
Theme colors
-
We use a subset of all colors to create a smaller colour palette for generating colour schemes, available in our assets/scss/variables/_palette.scss file.
-
-
-
-
-
- Primary
-
-
- Base
- #6200ee
-
-
-
- Dark
- #3700b3
-
-
- Light
- #bb86fc
-
-
-
-
-
-
-
- Secondary
-
-
- Base
- #03dac6
-
-
-
- Dark
- #018786
-
-
- Light
- #66fff8
-
-
-
-
-
-
-
- Danger
-
-
- Base
- #b00020
-
-
-
- Dark
- #d32f2f
-
-
- Light
- #c51162
-
-
-
-
-
-
-
- Info
-
-
- Base
- #714cfe
-
-
-
- Dark
- #021aee
-
-
- Light
- #d2c2fd
-
-
-
-
-
-
-
- Success
-
-
- Base
- #61d800
-
-
-
- Dark
- #41c300
-
-
- Light
- #c6f68d
-
-
-
-
-
-
-
- Warning
-
-
- Base
- #ff8d00
-
-
-
- Dark
- #ee6002
-
-
- Light
- #ffc77d
-
-
-
-
-
-
-
- Dark
-
-
- Base
- #424242
-
-
-
- Dark
- #212121
-
-
- Light
- #757575
-
-
-
-
-
-
-
- Light
-
-
- Base
- #f5f5f5
-
-
-
- Dark
- #e0e0e0
-
-
- Light
- #fafafa
-
-
-
-
-
Here’s how you can use these in your Sass:
-
-
Add a theme colour
-
To add a new colour to $theme-colors, add the new key and value to your custom Sass file. Please be aware that each new colour should also include darker and lighter shades of the primary colour to accent some parts of our components.
-
-
Or
-
-
Modify a theme colour
-
To modify an existing colour in our $theme-colors map, add the following to your custom Sass file. As aforementioned, each colour in our $theme-colors map contains not only the colour itself, but also darker and lighter shades of it, so please make sure to modify all three values.
Learn how to use Material's included npm scripts to build our documentation, compile source code, and more.
-
-
-
-
-
-
-
-
-
-
Getting started
-
Material uses NPM scripts for its build system. Our package.json includes convenient methods for working with the framework.
-
To use our build system, you’ll need a copy of Material’s source code and Node. Follow these steps and you should be ready to rock:
-
-
-Download and install Node.js, which we use to manage our dependencies. Then navigate to the root /daemonite-material directory and run npm install to install build dependencies.
-
-Download and install Ruby, install Bundler from a terminal with gem install bundler, and then run bundle install. This will install all Ruby dependencies, such as Jekyll (static site generator) and plugins.
-
-
When completed, you’ll be able to run the various commands provided from the command line. Our package.json includes the following commands and tasks:
-
-
-
-
Task
-
Description
-
-
-
-
-
npm run dist
-
-npm run dist creates the /css and /js directories with compiled files.
-
-
-
npm run docs
-
Builds CSS and JavaScript for docs. You can then run the documentation locally via npm run docs-serve.
-
-
-
-
Run npm run to see all the npm scripts.
-
Local documentation
-
Running our documentation locally requires the use of Jekyll, a decently flexible static site generator that provides us: basic includes, Markdown-based files, templates, and more. Here’s how to get it started:
-
-
Run through the getting started guide above to install Jekyll and other Ruby dependencies with bundle install.
-
From the root /daemonite-material directory, run npm run docs-serve in the command line.
-
Open http://127.0.0.1:9999/material/ in your browser, and voilà (or just click on the Server address returned by the Terminal).
-
-
PostCSS
-
Material uses Autoprefixer (included in our build process) to automatically add vendor prefixes to some CSS properties at build time. Doing so saves us time and code by allowing us to write key parts of our CSS a single time while eliminating the need for vendor mixins.
-
We maintain the list of browsers supported in our package.json file.
This is Bootstrap’s official documentation to import its JavaScript modules.
-
Import Bootstrap’s JavaScript by adding this line to your app’s entry point (usually index.js or app.js):
-
-
Alternatively, you may import plugins individually as needed:
-
-
Bootstrap depends on jQuery and Popper,
-which are specified in the peerDependencies property; this means that you will have to make sure to add both of them
-to your package.json using npm install --save jquery popper.js.
-
Importing Styles
-
Importing Precompiled Sass
-
To enjoy the full potential of Material UI and customize it to your needs, use the source files as a part of your project’s bundling process.
-
First, create your own _custom.scss and use it to override the built-in custom variables. Then, use your main Sass file to import your custom variables, followed by Material UI:
-
-
For Material UI to compile, make sure you install and use the required loaders: sass-loader, postcss-loader with Autoprefixer. With minimal setup, your webpack config should include this rule or similar:
-
-
Importing Compiled CSS
-
Alternatively, you may use Bootstrap’s ready-to-use CSS by simply adding this line to your project’s entry point:
-
-
In this case you may use your existing rule for css without any special modifications to webpack config, except you don’t need sass-loader just style-loader and css-loader.
Material v{{ site.current_version }} is available for download in several ways, including some of the favourite package managers.
+
Material CSS and JavaScript
+
+
+ cloud_download Download
+
+ Material's ready-to-use code to easily drop into any project. Includes compiled and minified versions of CSS and JavaScript plugins.
+
+
Package Managers
+
Pull in Material's source files with some of the most popular package managers.
The primary goal of this project is to give all Bootstrap components and elements a Google Material Design look, so it allows web developers to continue using the exact same Bootstrap HTML markup they are familiar with, but presents them a final outcome that is in line with the principles and specifics of Google Material Design.
+
+
+
Secondary
+
A secondary goal of this project is to add support for some unique Google Material Design components such as floating buttons, pickers, and steppers, to name a few, which cannot be achieved by transforming existing Bootstrap components.
+
Because these components will require additional markup (some may require additional JavaScript), they will be documented separately in Material's documentation.
+
+
+
+
+
+
Principles
+
+
+
CSS & HTML
+
If a Bootstrap component has an exact match in Google Material Design, this project will style this Bootstrap component based on the specifications laid out in Google Material Design guidelines. For example, Bootstrap's button = Google Material Design's button.
+
If a Bootstrap component lacks an exact match in Google Material Design, the specifications of a closest matching component in Google Material Design guidelines will be used to style this Bootstrap component. For example, Bootstrap's navbar = Google Material Design's toolbar.
+
If a Bootstrap component lacks a related counterpart completely in Google Material Design, this project will style this component based on our own iteration of Google Material Design guidelines. For example, Bootstrap's jumbotron and pagination, etc.
+
+
+
JavaScript
+
No modification has been made to Bootstrap's JavaScript. It is safe to use Bootstrap's JavaScript as it is.
+
However, in order to achieve some unique Material look such as floating labels, Material includes a handful of additional JavaScript to help bring some of the components to life.
Use our powerful mobile-first flexbox grid to build layouts of all shapes and sizes thanks to a twelve column system, five default responsive tiers, Sass variables and mixins, and dozens of predefined classes.
-
-
-
-
-
-
-
-
-
-
How it works
-
Bootstrap’s grid system uses a series of containers, rows, and columns to layout and align content. It’s built with flexbox and is fully responsive. Below is an example and an in-depth look at how the grid comes together.
The above example creates three equal-width columns on small, medium, large, and extra large devices using our predefined grid classes. Those columns are centered in the page with the parent .container.
-
Breaking it down, here’s how it works:
-
-
Containers provide a means to center and horizontally pad your site’s contents. Use .container for a responsive pixel width or .container-fluid for width: 100% across all viewport and device sizes.
-
Rows are wrappers for columns. Each column has horizontal padding (called a gutter) for controlling the space between them. This padding is then counteracted on the rows with negative margins. This way, all the content in your columns is visually aligned down the left side.
-
In a grid layout, content must be placed within columns and only columns may be immediate children of rows.
-
Thanks to flexbox, grid columns without a specified width will automatically layout as equal width columns. For example, four instances of .col-sm will each automatically be 25% wide from the small breakpoint and up. See the auto-layout columns section for more examples.
-
Column classes indicate the number of columns you’d like to use out of the possible 12 per row. So, if you want three equal-width columns across, you can use .col-4.
-
Column widths are set in percentages, so they’re always fluid and sized relative to their parent element.
-
Columns have horizontal padding to create the gutters between individual columns, however, you can remove the margin from rows and padding from columns with .no-gutters on the .row.
-
To make the grid responsive, there are five grid breakpoints, one for each responsive breakpoint: all breakpoints (extra small), small, medium, large, and extra large.
-
Grid breakpoints are based on minimum width media queries, meaning they apply to that one breakpoint and all those above it (e.g., .col-sm-4 applies to small, medium, large, and extra large devices, but not the first xs breakpoint).
-
You can use predefined grid classes (like .col-4) or Sass mixins for more semantic markup.
While Bootstrap uses ems or rems for defining most sizes, pxs are used for grid breakpoints and container widths. This is because the viewport width is in pixels and does not change with the font size.
-
See how aspects of the Bootstrap grid system work across multiple devices with a handy table.
-
-
-
-
-
- Extra small
- <576px
-
-
- Small
- ≥576px
-
-
- Medium
- ≥768px
-
-
- Large
- ≥992px
-
-
- Extra large
- ≥1200px
-
-
-
-
-
-
Max container width
-
None (auto)
-
540px
-
720px
-
960px
-
1140px
-
-
-
Class prefix
-
.col-
-
.col-sm-
-
.col-md-
-
.col-lg-
-
.col-xl-
-
-
-
# of columns
-
12
-
-
-
Gutter width
-
30px (15px on each side of a column)
-
-
-
Nestable
-
Yes
-
-
-
Column ordering
-
Yes
-
-
-
-
Auto-layout columns
-
Utilize breakpoint-specific column classes for easy column sizing without an explicit numbered class like .col-sm-6.
-
Equal-width
-
For example, here are two grid layouts that apply to every device and viewport, from xs to xl. Add any number of unit-less classes for each breakpoint you need and every column will be the same width.
-
-
-
-
-
- 1 of 2
-
-
- 2 of 2
-
-
-
-
- 1 of 3
-
-
- 2 of 3
-
-
- 3 of 3
-
-
-
-
-
-
-
Equal-width multi-line
-
Create equal-width columns that span multiple lines by inserting a .w-100 where you want the columns to break to a new line. Make the breaks responsive by mixing .w-100 with some responsive display utilities.
-
There was a Safari flexbox bug that prevented this from working without an explicit flex-basis or border. There are workarounds for older browser versions, but they shouldn’t be necessary if your target browsers don’t fall into the buggy versions.
-
-
-
-
-
col
-
col
-
-
col
-
col
-
-
-
-
-
-
Setting one column width
-
Auto-layout for flexbox grid columns also means you can set the width of one column and have the sibling columns automatically resize around it. You may use predefined grid classes (as shown below), grid mixins, or inline widths. Note that the other columns will resize no matter the width of the center column.
-
-
-
-
-
- 1 of 3
-
-
- 2 of 3 (wider)
-
-
- 3 of 3
-
-
-
-
- 1 of 3
-
-
- 2 of 3 (wider)
-
-
- 3 of 3
-
-
-
-
-
-
-
Variable width content
-
Use col-{breakpoint}-auto classes to size columns based on the natural width of their content.
-
-
-
-
-
- 1 of 3
-
-
- Variable width content
-
-
- 3 of 3
-
-
-
-
- 1 of 3
-
-
- Variable width content
-
-
- 3 of 3
-
-
-
-
-
-
-
Responsive classes
-
Bootstrap’s grid includes five tiers of predefined classes for building complex responsive layouts. Customize the size of your columns on extra small, small, medium, large, or extra large devices however you see fit.
-
All breakpoints
-
For grids that are the same from the smallest of devices to the largest, use the .col and .col-* classes. Specify a numbered class when you need a particularly sized column; otherwise, feel free to stick to .col.
-
-
-
-
-
col
-
col
-
col
-
col
-
-
-
col-8
-
col-4
-
-
-
-
-
-
Stacked to horizontal
-
Using a single set of .col-sm-* classes, you can create a basic grid system that starts out stacked and becomes horizontal at the small breakpoint (sm).
-
-
-
-
-
col-sm-8
-
col-sm-4
-
-
-
col-sm
-
col-sm
-
col-sm
-
-
-
-
-
-
Mix and match
-
Don’t want your columns to simply stack in some grid tiers? Use a combination of different classes for each tier as needed. See the example below for a better idea of how it all works.
-
-
-
-
-
-
.col-md-8
-
.col-6 .col-md-4
-
-
-
-
.col-6 .col-md-4
-
.col-6 .col-md-4
-
.col-6 .col-md-4
-
-
-
-
.col-6
-
.col-6
-
-
-
-
-
-
Gutters
-
Gutters can be responsively adjusted by breakpoint-specific padding and negative margin utility classes. To change the gutters in a given row, pair a negative margin utility on the .row and matching padding utilities on the .cols. The .container or .container-fluid parent may need to be adjusted too to avoid unwanted overflow, using again matching padding utility.
-
Here’s an example of customizing the Bootstrap grid at the large (lg) breakpoint and above. We’ve increased the .col padding with .px-lg-5, counteracted that with .mx-lg-n5 on the parent .row and then adjusted the .container wrapper with .px-lg-5.
-
-
-
-
Custom column padding
-
Custom column padding
-
-
-
-
-
Row columns
-
Use the responsive .row-cols-* classes to quickly set the number of columns that best render your content and layout. Whereas normal .col-* classes apply to the individual columns (e.g., .col-md-4), the row columns classes are set on the parent .row as a shortcut.
-
Use these row columns classes to quickly create basic grid layouts or to control your card layouts.
-
-
-
-
-
Column
-
Column
-
Column
-
Column
-
-
-
-
-
-
-
-
-
-
Column
-
Column
-
Column
-
Column
-
-
-
-
-
-
-
-
-
-
Column
-
Column
-
Column
-
Column
-
-
-
-
-
-
-
-
-
-
Column
-
Column
-
Column
-
Column
-
-
-
-
-
-
-
-
-
-
Column
-
Column
-
Column
-
Column
-
-
-
-
-
-
You can also use the accompanying Sass mixin, row-cols():
-
-
Alignment
-
Use flexbox alignment utilities to vertically and horizontally align columns. Internet Explorer 10-11 do not support vertical alignment of flex items when the flex container has a min-height as shown below.See Flexbugs #3 for more details.
-
Vertical alignment
-
-
-
-
-
- One of three columns
-
-
- One of three columns
-
-
- One of three columns
-
-
-
-
- One of three columns
-
-
- One of three columns
-
-
- One of three columns
-
-
-
-
- One of three columns
-
-
- One of three columns
-
-
- One of three columns
-
-
-
-
-
-
-
-
-
-
-
- One of three columns
-
-
- One of three columns
-
-
- One of three columns
-
-
-
-
-
-
-
Horizontal alignment
-
-
-
-
-
- One of two columns
-
-
- One of two columns
-
-
-
-
- One of two columns
-
-
- One of two columns
-
-
-
-
- One of two columns
-
-
- One of two columns
-
-
-
-
- One of two columns
-
-
- One of two columns
-
-
-
-
- One of two columns
-
-
- One of two columns
-
-
-
-
-
-
-
No gutters
-
The gutters between columns in our predefined grid classes can be removed with .no-gutters. This removes the negative margins from .row and the horizontal padding from all immediate children columns.
-
Here’s the source code for creating these styles. Note that column overrides are scoped to only the first children columns and are targeted via attribute selector. While this generates a more specific selector, column padding can still be further customized with spacing utilities.
-
Need an edge-to-edge design? Drop the parent .container or .container-fluid.
-
-
In practice, here’s how it looks. Note you can continue to use this with all other predefined grid classes (including column widths, responsive tiers, reorders, and more).
-
-
-
-
.col-sm-6 .col-md-8
-
.col-6 .col-md-4
-
-
-
-
-
Column wrapping
-
If more than 12 columns are placed within a single row, each group of extra columns will, as one unit, wrap onto a new line.
-
-
-
-
-
.col-9
-
.col-4 Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.
-
.col-6 Subsequent columns continue along the new line.
-
-
-
-
-
-
Column breaks
-
Breaking columns to a new line in flexbox requires a small hack: add an element with width: 100% wherever you want to wrap your columns to a new line. Normally this is accomplished with multiple .rows, but not every implementation method can account for this.
Use .order- classes for controlling the visual order of your content. These classes are responsive, so you can set the order by breakpoint (e.g., .order-1.order-md-2). Includes support for 1 through 12 across all five grid tiers.
-
-
-
-
-
- First in DOM, no order applied
-
-
- Second in DOM, with a larger order
-
-
- Third in DOM, with an order of 1
-
-
-
-
-
-
-
There are also responsive .order-first and .order-last classes that change the order of an element by applying order: -1 and order: 13 (order: $columns + 1), respectively. These classes can also be intermixed with the numbered .order-* classes as needed.
-
-
-
-
-
- First in DOM, ordered last
-
-
- Second in DOM, unordered
-
-
- Third in DOM, ordered first
-
-
-
-
-
-
-
Offsetting columns
-
You can offset grid columns in two ways: our responsive .offset- grid classes and our margin utilities. Grid classes are sized to match columns while margins are more useful for quick layouts where the width of the offset is variable.
-
Offset classes
-
Move columns to the right using .offset-md-* classes. These classes increase the left margin of a column by * columns. For example, .offset-md-4 moves .col-md-4 over four columns.
-
-
-
-
-
.col-md-4
-
.col-md-4 .offset-md-4
-
-
-
.col-md-3 .offset-md-3
-
.col-md-3 .offset-md-3
-
-
-
.col-md-6 .offset-md-3
-
-
-
-
-
-
In addition to column clearing at responsive breakpoints, you may need to reset offsets. See this in action in the grid example.
With the move to flexbox in v4, you can use margin utilities like .mr-auto to force sibling columns away from one another.
-
-
-
-
-
.col-md-4
-
.col-md-4 .ml-auto
-
-
-
.col-md-3 .ml-md-auto
-
.col-md-3 .ml-md-auto
-
-
-
.col-auto .mr-auto
-
.col-auto
-
-
-
-
-
-
Nesting
-
To nest your content with the default grid, add a new .row and set of .col-sm-* columns within an existing .col-sm-* column. Nested rows should include a set of columns that add up to 12 or fewer (it is not required that you use all 12 available columns).
-
-
-
-
-
- Level 1: .col-sm-9
-
-
- Level 2: .col-8 .col-sm-6
-
-
- Level 2: .col-4 .col-sm-6
-
-
-
-
-
-
-
-
-
Sass mixins
-
When using Bootstrap’s source Sass files, you have the option of using Sass variables and mixins to create custom, semantic, and responsive page layouts. Our predefined grid classes use these same variables and mixins to provide a whole suite of ready-to-use classes for fast responsive layouts.
-
Variables
-
Variables and maps 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.
-
-
Mixins
-
Mixins are used in conjunction with the grid variables to generate semantic CSS for individual grid columns.
-
-
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.
-
-
-
-
-
Main content
-
Secondary content
-
-
-
-
-
Customizing the grid
-
Using our built-in grid Sass variables and maps, it’s possible to completely customize the predefined grid classes. Change the number of tiers, the media query dimensions, and the container widths—then recompile.
-
Columns and gutters
-
The number of grid columns can be modified via Sass variables. $grid-columns is used to generate the widths (in percent) of each individual column while $grid-gutter-width sets the width for the column gutters.
-
-
Grid tiers
-
Moving beyond the columns themselves, you may also customize the number of grid tiers. If you wanted just four grid tiers, you’d update the $grid-breakpoints and $container-max-widths to something like this:
-
-
When making any changes to the Sass variables or maps, you’ll need to save your changes and recompile. Doing so will output a brand new set of predefined grid classes for column widths, offsets, and ordering. Responsive visibility utilities will also be updated to use the custom breakpoints. Make sure to set grid values in px (not rem, em, or %).
Components and options for laying out your Bootstrap project, including wrapping containers, a powerful grid system, a flexible media object, and responsive utility classes.
-
-
-
-
-
-
-
-
-
-
Containers
-
Containers are the most basic layout element in Bootstrap and are required when using our default grid system. Containers are used to contain, pad, and (sometimes) center the content within them. While containers can be nested, most layouts do not require a nested container.
-
Bootstrap comes with three different containers:
-
-
-.container, which sets a max-width at each responsive breakpoint
-
-.container-fluid, which is width: 100% at all breakpoints
-
-.container-{breakpoint}, which is width: 100% until the specified breakpoint
-
-
The table below illustrates how each container’s max-width compares to the original .container and .container-fluid across each breakpoint.
-
See them in action and compare them in our Grid example.
-
-
-
-
-
- Extra small
- <576px
-
-
- Small
- ≥576px
-
-
- Medium
- ≥768px
-
-
- Large
- ≥992px
-
-
- Extra large
- ≥1200px
-
-
-
-
-
-
.container
-
100%
-
540px
-
720px
-
960px
-
1140px
-
-
-
.container-sm
-
100%
-
540px
-
720px
-
960px
-
1140px
-
-
-
.container-md
-
100%
-
100%
-
720px
-
960px
-
1140px
-
-
-
.container-lg
-
100%
-
100%
-
100%
-
960px
-
1140px
-
-
-
.container-xl
-
100%
-
100%
-
100%
-
100%
-
1140px
-
-
-
.container-fluid
-
100%
-
100%
-
100%
-
100%
-
100%
-
-
-
-
All-in-one
-
Our default .container class is a responsive, fixed-width container, meaning its max-width changes at each breakpoint.
-
-
Fluid
-
Use .container-fluid for a full width container, spanning the entire width of the viewport.
-
-
Responsive
-
Responsive containers are new in Bootstrap v4.4. They allow you to specify a class that is 100% wide until the specified breakpoint is reached, after which we apply max-widths for each of the higher breakpoints. For example, .container-sm is 100% wide to start until the sm breakpoint is reached, where it will scale up with md, lg, and xl.
-
-
Responsive breakpoints
-
Since Bootstrap is developed to be mobile first, we use a handful of media queries to create sensible breakpoints for our layouts and interfaces. These breakpoints are mostly based on minimum viewport widths and allow us to scale up elements as the viewport changes.
-
Bootstrap primarily uses the following media query ranges—or breakpoints—in our source Sass files for our layout, grid system, and components.
-
-
Since we write our source CSS in Sass, all our media queries are available via Sass mixins:
-
-
We occasionally use media queries that go in the other direction (the given screen size or smaller):
-
-
-
Note that since browsers do not currently support range context queries, we work around the limitations of min- and max- prefixes and viewports with fractional widths (which can occur under certain conditions on high-dpi devices, for instance) by using values with higher precision for these comparisons.
-
-
Once again, these media queries are also available via Sass mixins:
-
-
There are also media queries and mixins for targeting a single segment of screen sizes using the minimum and maximum breakpoint widths.
-
-
These media queries are also available via Sass mixins:
-
-
Similarly, media queries may span multiple breakpoint widths:
-
-
The Sass mixin for targeting the same screen size range would be:
For faster mobile-friendly and responsive development, Bootstrap includes dozens of utility classes for showing, hiding, aligning, and spacing content.
-
-
-
-
-
-
-
-
-
-
Changing display
-
-
Use our display utilities for responsively toggling common values of the display property. Mix it with our grid system, content, or components to show or hide them across specific viewports.
-
Flexbox options
-
Bootstrap 4 is built with flexbox, but not every element’s display has been changed to display: flex as this would add many unnecessary overrides and unexpectedly change key browser behaviors. Most of our components are built with flexbox enabled.
-
Should you need to add display: flex to an element, do so with .d-flex or one of the responsive variants (e.g., .d-sm-flex). You’ll need this class or display value to allow the use of our extra flexbox utilities for sizing, alignment, spacing, and more.
-
Margin and padding
-
Use the margin and paddingspacing utilities to control how elements and components are spaced and sized. Bootstrap 4 includes a five-level scale for spacing utilities, based on a 1rem value default $spacer variable. Choose values for all viewports (e.g., .mr-3 for margin-right: 1rem), or pick responsive variants to target specific viewports (e.g., .mr-md-3 for margin-right: 1rem starting at the md breakpoint).
-
Toggle visibility
-
-
When toggling display isn’t needed, you can toggle the visibility of an element with our visibility utilities. Invisible elements will still affect the layout of the page, but are visually hidden from visitors.
Character or word counters should be used if there is a character or word limit. They display the ratio of characters used and the total character limit.
Stylesheet material-plugins.css is required as these material design themes for Select2 are fully designed by djibe.
-
-
Demo
-
-
-
-
-
-
Using Select2
-
Import material-plugins.css after your Material CSS. Don’t use official Select2 css.
-
-
Import Select2 after your Material JavaScripts.
-
-
Set HTML code of your select menu.
-
NB. With Select2, in simple select lists, you need to set a first blank <option> in order to set a placeholder.
-
-
Initialize plugin with jQuery parameters. Default theme is the same as default form inputs.
-Extra themes include filled (like the Demo above) and outlined.
Sliders allow users to make selections from a range of values.
-
-
-
-
-
-
-
-
-
-
Sliders allow users to view and select a value (or range) from the range along a bar. They’re ideal for adjusting settings such as volume and brightness, or for applying image filters.
-
Sliders can use icons on both ends of the bar to represent a numeric or relative scale. The range of values or the nature of the values, such as volume change, can be communicated with icons.
Multi-line text fields grow to accommodate multiple lines of text.
-
-
-
-
-
-
-
-
-
-
Multi-line text fields show all user input at once. Overflow text causes the text field to expand (shifting screen elements downward), and text wraps onto a new line.
-
These fields initially appear as single-line fields, which is useful for compact layouts that need to be able to accomodate large amounts of text.
Quickly and easily clear floated content within a container by adding a clearfix utility.
-
-
-
-
-
-
-
-
-
-
Easily clear floats by adding .clearfixto the parent element. Can also be used as a mixin.
-
-
-
The following example shows how the clearfix can be used. Without the clearfix the wrapping div would not span around the buttons which would cause a broken layout.
Convey meaning through color with a handful of color utility classes. Includes support for styling links with hover states, too.
-
-
-
-
-
-
-
-
-
-
Color
-
-
.text-primary
-
.text-secondary
-
.text-danger
-
.text-info
-
.text-success
-
.text-warning
-
.text-dark
-
.text-light
-
.text-body
-
.text-muted
-
.text-white
-
.text-black-50
-
.text-white-50
-
-
-
Contextual text classes also work well on anchors with the provided hover and focus states. Note that the .text-white and .text-muted class has no additional link styling beyond underline.
Similar to the contextual text color classes, easily set the background of an element to any contextual class. Anchor components will darken on hover, just like the text classes. Background utilities do not set color, so in some cases you’ll want to use .text-* utilities.
-
-
.bg-primary
-
.bg-secondary
-
.bg-danger
-
.bg-info
-
.bg-success
-
.bg-warning
-
.bg-dark
-
.bg-light
-
.bg-white
-
.bg-transparent
-
-
-
Background gradient
-
When $enable-gradients is set to true (default is false), you can use .bg-gradient- utility classes. Learn about our Sass options to enable these classes and more.
-
-
.bg-gradient-primary
-
.bg-gradient-secondary
-
.bg-gradient-danger
-
.bg-gradient-info
-
.bg-gradient-success
-
.bg-gradient-warning
-
.bg-gradient-dark
-
.bg-gradient-light
-
-
-
Dealing with specificity
-
Sometimes contextual classes cannot be applied due to the specificity of another selector. In some cases, a sufficient workaround is to wrap your element’s content in a <div> with the class.
-
-
-
Conveying meaning to assistive technologies
-
Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .sr-only class.
Quickly and responsively toggle the display value of components and more with our display utilities. Includes support for some of the more common values, as well as some extras for controlling display when printing.
-
-
-
-
-
-
-
-
-
-
How it works
-
Change the value of the display property with our responsive display utility classes. We purposely support only a subset of all possible values for display. Classes can be combined for various effects as you need.
-
Notation
-
Display utility classes that apply to all breakpoints, from xs to xl, have no breakpoint abbreviation in them. This is because those classes are applied from min-width: 0; and up, and thus are not bound by a media query. The remaining breakpoints, however, do include a breakpoint abbreviation.
-
As such, the classes are named using the format:
-
-
-.d-{value} for xs
-
-
-.d-{breakpoint}-{value} for sm, md, lg, and xl.
-
-
Where value is one of:
-
-
none
-
inline
-
inline-block
-
block
-
table
-
table-cell
-
table-row
-
flex
-
inline-flex
-
-
The display values can be altered by changing the $displays variable and recompiling the SCSS.
-
The media queries effect screen widths with the given breakpoint or larger. For example, .d-lg-none sets display: none; on both lg and xl screens.
-
Examples
-
-
d-inline
-
d-inline
-
-
-
-d-block
-d-block
-
-
-
Hiding elements
-
For faster mobile-friendly development, use responsive display classes for showing and hiding elements by device. Avoid creating entirely different versions of the same site, instead hide elements responsively for each screen size.
-
To hide elements simply use the .d-none class or one of the .d-{sm,md,lg,xl}-none classes for any responsive screen variation.
-
To show an element only on a given interval of screen sizes you can combine one .d-*-none class with a .d-*-* class, for example .d-none .d-md-block .d-xl-none will hide the element for all screen sizes except on medium and large devices.
-
-
-
-
Screen Size
-
Class
-
-
-
-
-
Hidden on all
-
.d-none
-
-
-
Hidden only on xs
-
.d-none .d-sm-block
-
-
-
Hidden only on sm
-
.d-sm-none .d-md-block
-
-
-
Hidden only on md
-
.d-md-none .d-lg-block
-
-
-
Hidden only on lg
-
.d-lg-none .d-xl-block
-
-
-
Hidden only on xl
-
.d-xl-none
-
-
-
Visible on all
-
.d-block
-
-
-
Visible only on xs
-
.d-block .d-sm-none
-
-
-
Visible only on sm
-
.d-none .d-sm-block .d-md-none
-
-
-
Visible only on md
-
.d-none .d-md-block .d-lg-none
-
-
-
Visible only on lg
-
.d-none .d-lg-block .d-xl-none
-
-
-
Visible only on xl
-
.d-none .d-xl-block
-
-
-
-
-
hide on lg and wider screens
-
hide on screens smaller than lg
-
-
-
Display in print
-
Change the display value of elements when printing with our print display utility classes. Includes support for the same display values as our responsive .d-* utilities.
-
-
.d-print-none
-
.d-print-inline
-
.d-print-inline-block
-
.d-print-block
-
.d-print-table
-
.d-print-table-row
-
.d-print-table-cell
-
.d-print-flex
-
.d-print-inline-flex
-
-
The print and display classes can be combined.
-
-
Screen Only (Hide on print only)
-
Print Only (Hide on screen only)
-
Hide up to large on screen, but always show on print
Create responsive video or slideshow embeds based on the width of the parent by creating an intrinsic ratio that scales on any device.
-
-
-
-
-
-
-
-
-
-
About
-
Rules are directly applied to <iframe>, <embed>, <video>, and <object> elements; optionally use an explicit descendant class .embed-responsive-item when you want to match the styling for other attributes.
-
Pro-Tip! You don’t need to include frameborder="0" in your <iframe>s as we override that for you.
-
Example
-
Wrap any embed like an <iframe> in a parent element with .embed-responsive and an aspect ratio. The .embed-responsive-item isn’t strictly required, but we encourage it.
-
-
-
-
-
-
-
Aspect ratios
-
Aspect ratios can be customized with modifier classes. By default the following ratio classes are provided:
-
-
Within _variables.scss, you can change the aspect ratios you want to use. Here’s an example of the $embed-responsive-aspect-ratios list:
Quickly manage the layout, alignment, and sizing of grid columns, navigation, components, and more with a full suite of responsive flexbox utilities. For more complex implementations, custom CSS may be necessary.
-
-
-
-
-
-
-
-
-
-
Enable flex behaviors
-
Apply display utilities to create a flexbox container and transform direct children elements into flex items. Flex containers and items are able to be modified further with additional flex properties.
-
-
I'm a flexbox container!
-
-
-
-
I'm an inline flexbox container!
-
-
-
Responsive variations also exist for .d-flex and .d-inline-flex.
-
-
.d-flex
-
.d-inline-flex
-
.d-sm-flex
-
.d-sm-inline-flex
-
.d-md-flex
-
.d-md-inline-flex
-
.d-lg-flex
-
.d-lg-inline-flex
-
.d-xl-flex
-
.d-xl-inline-flex
-
-
Direction
-
Set the direction of flex items in a flex container with direction utilities. In most cases you can omit the horizontal class here as the browser default is row. However, you may encounter situations where you needed to explicitly set this value (like responsive layouts).
-
Use .flex-row to set a horizontal direction (the browser default), or .flex-row-reverse to start the horizontal direction from the opposite side.
-
-
-
Flex item 1
-
Flex item 2
-
Flex item 3
-
-
-
Flex item 1
-
Flex item 2
-
Flex item 3
-
-
-
-
Use .flex-column to set a vertical direction, or .flex-column-reverse to start the vertical direction from the opposite side.
-
-
-
Flex item 1
-
Flex item 2
-
Flex item 3
-
-
-
Flex item 1
-
Flex item 2
-
Flex item 3
-
-
-
-
Responsive variations also exist for flex-direction.
-
-
.flex-row
-
.flex-row-reverse
-
.flex-column
-
.flex-column-reverse
-
.flex-sm-row
-
.flex-sm-row-reverse
-
.flex-sm-column
-
.flex-sm-column-reverse
-
.flex-md-row
-
.flex-md-row-reverse
-
.flex-md-column
-
.flex-md-column-reverse
-
.flex-lg-row
-
.flex-lg-row-reverse
-
.flex-lg-column
-
.flex-lg-column-reverse
-
.flex-xl-row
-
.flex-xl-row-reverse
-
.flex-xl-column
-
.flex-xl-column-reverse
-
-
Justify content
-
Use justify-content utilities on flexbox containers to change the alignment of flex items on the main axis (the x-axis to start, y-axis if flex-direction: column). Choose from start (browser default), end, center, between, or around.
-
-
-
Flex item
-
Flex item
-
Flex item
-
-
-
Flex item
-
Flex item
-
Flex item
-
-
-
Flex item
-
Flex item
-
Flex item
-
-
-
Flex item
-
Flex item
-
Flex item
-
-
-
Flex item
-
Flex item
-
Flex item
-
-
-
-
Responsive variations also exist for justify-content.
-
-
.justify-content-start
-
.justify-content-end
-
.justify-content-center
-
.justify-content-between
-
.justify-content-around
-
.justify-content-sm-start
-
.justify-content-sm-end
-
.justify-content-sm-center
-
.justify-content-sm-between
-
.justify-content-sm-around
-
.justify-content-md-start
-
.justify-content-md-end
-
.justify-content-md-center
-
.justify-content-md-between
-
.justify-content-md-around
-
.justify-content-lg-start
-
.justify-content-lg-end
-
.justify-content-lg-center
-
.justify-content-lg-between
-
.justify-content-lg-around
-
.justify-content-xl-start
-
.justify-content-xl-end
-
.justify-content-xl-center
-
.justify-content-xl-between
-
.justify-content-xl-around
-
-
Align items
-
Use align-items utilities on flexbox containers to change the alignment of flex items on the cross axis (the y-axis to start, x-axis if flex-direction: column). Choose from start, end, center, baseline, or stretch (browser default).
-
-
-
Flex item
-
Flex item
-
Flex item
-
-
-
Flex item
-
Flex item
-
Flex item
-
-
-
Flex item
-
Flex item
-
Flex item
-
-
-
Flex item
-
Flex item
-
Flex item
-
-
-
Flex item
-
Flex item
-
Flex item
-
-
-
-
Responsive variations also exist for align-items.
-
-
.align-items-start
-
.align-items-end
-
.align-items-center
-
.align-items-baseline
-
.align-items-stretch
-
.align-items-sm-start
-
.align-items-sm-end
-
.align-items-sm-center
-
.align-items-sm-baseline
-
.align-items-sm-stretch
-
.align-items-md-start
-
.align-items-md-end
-
.align-items-md-center
-
.align-items-md-baseline
-
.align-items-md-stretch
-
.align-items-lg-start
-
.align-items-lg-end
-
.align-items-lg-center
-
.align-items-lg-baseline
-
.align-items-lg-stretch
-
.align-items-xl-start
-
.align-items-xl-end
-
.align-items-xl-center
-
.align-items-xl-baseline
-
.align-items-xl-stretch
-
-
Align self
-
Use align-self utilities on flexbox items to individually change their alignment on the cross axis (the y-axis to start, x-axis if flex-direction: column). Choose from the same options as align-items: start, end, center, baseline, or stretch (browser default).
-
-
-
Flex item
-
Aligned flex item
-
Flex item
-
-
-
Flex item
-
Aligned flex item
-
Flex item
-
-
-
Flex item
-
Aligned flex item
-
Flex item
-
-
-
Flex item
-
Aligned flex item
-
Flex item
-
-
-
Flex item
-
Aligned flex item
-
Flex item
-
-
-
-
Responsive variations also exist for align-self.
-
-
.align-self-start
-
.align-self-end
-
.align-self-center
-
.align-self-baseline
-
.align-self-stretch
-
.align-self-sm-start
-
.align-self-sm-end
-
.align-self-sm-center
-
.align-self-sm-baseline
-
.align-self-sm-stretch
-
.align-self-md-start
-
.align-self-md-end
-
.align-self-md-center
-
.align-self-md-baseline
-
.align-self-md-stretch
-
.align-self-lg-start
-
.align-self-lg-end
-
.align-self-lg-center
-
.align-self-lg-baseline
-
.align-self-lg-stretch
-
.align-self-xl-start
-
.align-self-xl-end
-
.align-self-xl-center
-
.align-self-xl-baseline
-
.align-self-xl-stretch
-
-
Fill
-
Use the .flex-fill class on a series of sibling elements to force them into widths equal to their content (or equal widths if their content does not surpass their border-boxes) while taking up all available horizontal space.
-
-
-
Flex item with a lot of content
-
Flex item
-
Flex item
-
-
-
-
Responsive variations also exist for flex-fill.
-
-
.flex-fill
-
.flex-sm-fill
-
.flex-md-fill
-
.flex-lg-fill
-
.flex-xl-fill
-
-
Grow and shrink
-
Use .flex-grow-* utilities to toggle a flex item’s ability to grow to fill available space. In the example below, the .flex-grow-1 elements uses all available space it can, while allowing the remaining two flex items their necessary space.
-
-
-
Flex item
-
Flex item
-
Third flex item
-
-
-
-
Use .flex-shrink-* utilities to toggle a flex item’s ability to shrink if necessary. In the example below, the second flex item with .flex-shrink-1 is forced to wrap it’s contents to a new line, “shrinking” to allow more space for the previous flex item with .w-100.
-
-
-
Flex item
-
Flex item
-
-
-
-
Responsive variations also exist for flex-grow and flex-shrink.
-
-
.flex-{grow|shrink}-0
-
.flex-{grow|shrink}-1
-
.flex-sm-{grow|shrink}-0
-
.flex-sm-{grow|shrink}-1
-
.flex-md-{grow|shrink}-0
-
.flex-md-{grow|shrink}-1
-
.flex-lg-{grow|shrink}-0
-
.flex-lg-{grow|shrink}-1
-
.flex-xl-{grow|shrink}-0
-
.flex-xl-{grow|shrink}-1
-
-
Auto margins
-
Flexbox can do some pretty awesome things when you mix flex alignments with auto margins. Shown below are three examples of controlling flex items via auto margins: default (no auto margin), pushing two items to the right (.mr-auto), and pushing two items to the left (.ml-auto).
-
Unfortunately, IE10 and IE11 do not properly support auto margins on flex items whose parent has a non-default justify-content value.See this StackOverflow answer for more details.
-
-
-
Flex item
-
Flex item
-
Flex item
-
-
-
Flex item
-
Flex item
-
Flex item
-
-
-
Flex item
-
Flex item
-
Flex item
-
-
-
-
With align-items
-
Vertically move one flex item to the top or bottom of a container by mixing align-items, flex-direction: column, and margin-top: auto or margin-bottom: auto.
-
-
-
Flex item
-
Flex item
-
Flex item
-
-
-
Flex item
-
Flex item
-
Flex item
-
-
-
-
Wrap
-
Change how flex items wrap in a flex container. Choose from no wrapping at all (the browser default) with .flex-nowrap, wrapping with .flex-wrap, or reverse wrapping with .flex-wrap-reverse.
-
-
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
-
-
-
-
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
-
-
-
-
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
-
-
-
Responsive variations also exist for flex-wrap.
-
-
.flex-nowrap
-
.flex-wrap
-
.flex-wrap-reverse
-
.flex-sm-nowrap
-
.flex-sm-wrap
-
.flex-sm-wrap-reverse
-
.flex-md-nowrap
-
.flex-md-wrap
-
.flex-md-wrap-reverse
-
.flex-lg-nowrap
-
.flex-lg-wrap
-
.flex-lg-wrap-reverse
-
.flex-xl-nowrap
-
.flex-xl-wrap
-
.flex-xl-wrap-reverse
-
-
Order
-
Change the visual order of specific flex items with a handful of order utilities. We only provide options for making an item first or last, as well as a reset to use the DOM order. As order takes any integer value (e.g., 5), add custom CSS for any additional values needed.
-
-
-
First flex item
-
Second flex item
-
Third flex item
-
-
-
-
Responsive variations also exist for order.
-
-
.order-0
-
.order-1
-
.order-2
-
.order-3
-
.order-4
-
.order-5
-
.order-6
-
.order-7
-
.order-8
-
.order-9
-
.order-10
-
.order-11
-
.order-12
-
.order-sm-0
-
.order-sm-1
-
.order-sm-2
-
.order-sm-3
-
.order-sm-4
-
.order-sm-5
-
.order-sm-6
-
.order-sm-7
-
.order-sm-8
-
.order-sm-9
-
.order-sm-10
-
.order-sm-11
-
.order-sm-12
-
.order-md-0
-
.order-md-1
-
.order-md-2
-
.order-md-3
-
.order-md-4
-
.order-md-5
-
.order-md-6
-
.order-md-7
-
.order-md-8
-
.order-md-9
-
.order-md-10
-
.order-md-11
-
.order-md-12
-
.order-lg-0
-
.order-lg-1
-
.order-lg-2
-
.order-lg-3
-
.order-lg-4
-
.order-lg-5
-
.order-lg-6
-
.order-lg-7
-
.order-lg-8
-
.order-lg-9
-
.order-lg-10
-
.order-lg-11
-
.order-lg-12
-
.order-xl-0
-
.order-xl-1
-
.order-xl-2
-
.order-xl-3
-
.order-xl-4
-
.order-xl-5
-
.order-xl-6
-
.order-xl-7
-
.order-xl-8
-
.order-xl-9
-
.order-xl-10
-
.order-xl-11
-
.order-xl-12
-
-
Align content
-
Use align-content utilities on flexbox containers to align flex items together on the cross axis. Choose from start (browser default), end, center, between, around, or stretch. To demonstrate these utilities, we’ve enforced flex-wrap: wrap and increased the number of flex items.
-
Heads up! This property has no effect on single rows of flex items.
-
-
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
-
-
-
-
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
-
-
-
-
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
-
-
-
-
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
-
-
-
-
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
-
-
-
-
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
Flex item
-
-
-
-
Responsive variations also exist for align-content.
Toggle floats on any element, across any breakpoint, using our responsive float utilities.
-
-
-
-
-
-
-
-
-
-
Overview
-
These utility classes float an element to the left or right, or disable floating, based on the current viewport size using the CSS float property. !important is included to avoid specificity issues. These use the same viewport breakpoints as our grid system. Please be aware float utilities have no effect on flex items.
-
Classes
-
Toggle a float with a class:
-
-
Float left on all viewport sizes
-
-
Float right on all viewport sizes
-
-
Don't float on all viewport sizes
-
-
-
Mixins
-
Or by Sass mixin:
-
-
Responsive
-
Responsive variations also exist for each float value.
-
-
Float left on viewports sized SM (small) or wider
-
-
Float left on viewports sized MD (medium) or wider
-
-
Float left on viewports sized LG (large) or wider
-
-
Float left on viewports sized XL (extra-large) or wider
Use these shorthand utilities for quickly configuring the position of an element.
-
-
-
-
-
-
-
-
-
-
Common values
-
Quick positioning classes are available, though they are not responsive.
-
-
Fixed top
-
Position an element at the top of the viewport, from edge to edge. Be sure you understand the ramifications of fixed position in your project; you may need to add additional CSS.
-
-
Fixed bottom
-
Position an element at the bottom of the viewport, from edge to edge. Be sure you understand the ramifications of fixed position in your project; you may need to add additional CSS.
-
-
Sticky top
-
Position an element at the top of the viewport, from edge to edge, but only after you scroll past it. The .sticky-top utility uses CSS’s position: sticky, which isn’t fully supported in all browsers.
-
IE11 and IE10 will render position: sticky as position: relative. As such, we wrap the styles in a @supports query, limiting the stickiness to only browsers that can render it properly.
Use screen reader utilities to hide elements on all devices except screen readers.
-
-
-
-
-
-
-
-
-
-
Hide an element to all devices except screen readers with .sr-only. Combine .sr-only with .sr-only-focusable to show the element again when it’s focused (e.g. by a keyboard-only user). Can also be used as mixins.
Add or remove shadows to elements with box-shadow utilities.
-
-
-
-
-
-
-
-
-
-
Examples
-
While shadows on components are disabled by default in Bootstrap and can be enabled via $enable-shadows, you can also quickly add or remove a shadow with our box-shadow utility classes. Includes support for .shadow-none and three default sizes (which have associated variables to match).
Easily make an element as wide or as tall with our width and height utilities.
-
-
-
-
-
-
-
-
-
-
Relative to the parent
-
Width and height utilities are generated from the $sizes Sass map in _variables.scss. Includes support for 25%, 50%, 75%, 100%, and auto by default. Modify those values as you need to generate different utilities here.
-
-
Width 25%
-
Width 50%
-
Width 75%
-
Width 100%
-
Width auto
-
-
-
-
-
Height 25%
-
Height 50%
-
Height 75%
-
Height 100%
-
Height auto
-
-
-
-
You can also use max-width: 100%; and max-height: 100%; utilities as needed.
-
-
-
-
-
-
-
Max-height 100%
-
-
-
-
Relative to the viewport
-
You can also use utilities to set the width and height relative to the viewport.
Bootstrap includes a wide range of shorthand responsive margin and padding utility classes to modify an element's appearance.
-
-
-
-
-
-
-
-
-
-
How it works
-
Assign responsive-friendly margin or padding values to an element or a subset of its sides with shorthand classes. Includes support for individual properties, all properties, and vertical and horizontal properties. Classes are built from a default Sass map ranging from .25rem to 3rem.
-
Notation
-
Spacing utilities that apply to all breakpoints, from xs to xl, have no breakpoint abbreviation in them. This is because those classes are applied from min-width: 0 and up, and thus are not bound by a media query. The remaining breakpoints, however, do include a breakpoint abbreviation.
-
The classes are named using the format {property}{sides}-{size} for xs and {property}{sides}-{breakpoint}-{size} for sm, md, lg, and xl.
-
Where property is one of:
-
-
-m - for classes that set margin
-
-
-p - for classes that set padding
-
-
-
Where sides is one of:
-
-
-t - for classes that set margin-top or padding-top
-
-
-b - for classes that set margin-bottom or padding-bottom
-
-
-l - for classes that set margin-left or padding-left
-
-
-r - for classes that set margin-right or padding-right
-
-
-x - for classes that set both *-left and *-right
-
-
-y - for classes that set both *-top and *-bottom
-
-
blank - for classes that set a margin or padding on all 4 sides of the element
-
-
Where size is one of:
-
-
-0 - for classes that eliminate the margin or padding by setting it to 0
-
-
-1 - (by default) for classes that set the margin or padding to $spacer * .25
-
-
-2 - (by default) for classes that set the margin or padding to $spacer * .5
-
-
-3 - (by default) for classes that set the margin or padding to $spacer
-
-
-4 - (by default) for classes that set the margin or padding to $spacer * 1.5
-
-
-5 - (by default) for classes that set the margin or padding to $spacer * 3
-
-
-auto - for classes that set the margin to auto
-
-
(You can add more sizes by adding entries to the $spacers Sass map variable.)
-
Examples
-
Here are some representative examples of these classes:
-
-
Horizontal centering
-
Additionally, Bootstrap also includes an .mx-auto class for horizontally centering fixed-width block level content—that is, content that has display: block and a width set—by setting the horizontal margins to auto.
-
-
- Centered element
-
-
-
-
Negative margin
-
In CSS, margin properties can utilize negative values (padding cannot). As of 4.2, we’ve added negative margin utilities for every non-zero integer size listed above (e.g., 1, 2, 3, 4, 5). These utilities are ideal for customizing grid column gutters across breakpoints.
-
The syntax is nearly the same as the default, positive margin utilities, but with the addition of n before the requested size. Here’s an example class that’s the opposite of .mt-1:
-
-
Here’s an example of customizing the Bootstrap grid at the medium (md) breakpoint and above. We’ve increased the .col padding with .px-md-5 and then counteracted that with .mx-md-n5 on the parent .row.
Make any HTML element or Bootstrap component clickable by "stretching" a nested link via CSS.
-
-
-
-
-
-
-
-
-
-
Add .stretched-link to a link to make its containing block clickable via a ::after pseudo element. In most cases, this means that an element with position: relative; that contains a link with the .stretched-link class is clickable.
-
Cards have position: relative by default in Bootstrap, so in this case you can safely add the .stretched-link class to a link in the card without any other HTML changes.
-
Multiple links and tap targets are not recommended with stretched links. However, some position and z-index styles can help should this be required.
-
-
-
-
-
Card with stretched link
-
Some quick example text to build on the card title and make up the bulk of the card's content.
Media objects do not have position: relative by default, so we need to add the .position-relative here to prevent the link from stretching outside the media object.
-
-
-
-
-
Media with stretched link
-
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
Columns are position: relative by default, so clickable columns only require the .stretched-link class on a link. However, stretching a link over an entire .row requires .position-static on the column and .position-relative on the row.
-
-
-
-
-
-
-
Columns with stretched link
-
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
If the stretched link doesn’t seem to work, the containing block will probably be the cause. The following CSS properties will make an element the containing block:
-
-
A position value other than static
-
-
A transform or perspective value other than none
-
-
A will-change value of transform or perspective
-
-
A filter value other than none or a will-change value of filter (only works on Firefox)
-
-
-
-
-
-
Card with stretched links
-
Some quick example text to build on the card title and make up the bulk of the card's content.
Documentation and examples for common text utilities to control alignment, wrapping, weight, and more.
-
-
-
-
-
-
-
-
-
-
Text alignment
-
Easily realign text to components with text alignment classes.
-
-
Ambitioni dedisse scripsisse iudicaretur. Cras mattis iudicium purus sit amet fermentum. Donec sed odio operae, eu vulputate felis rhoncus. Praeterea iter est quasdam res quas ex communi. At nos hinc posthac, sitientis piros Afros. Petierunt uti sibi concilium totius Galliae in diem certam indicere. Cras mattis iudicium purus sit amet fermentum.
-
-
-
For left, right, and center alignment, responsive classes are available that use the same viewport width breakpoints as the grid system.
-
-
Left aligned text on all viewport sizes.
-
Center aligned text on all viewport sizes.
-
Right aligned text on all viewport sizes.
-
Left aligned text on viewports sized SM (small) or wider.
-
Left aligned text on viewports sized MD (medium) or wider.
-
Left aligned text on viewports sized LG (large) or wider.
-
Left aligned text on viewports sized XL (extra-large) or wider.
-
-
-
Text wrapping and overflow
-
Wrap text with a .text-wrap class.
-
-
- This text should wrap.
-
-
-
-
Prevent text from wrapping with a .text-nowrap class.
-
-
- This text should overflow the parent.
-
-
-
-
For longer content, you can add a .text-truncate class to truncate the text with an ellipsis. Requires display: inline-block or display: block.
-
-
-
-
- Praeterea iter est quasdam res quas ex communi.
-
-
-
-
- Praeterea iter est quasdam res quas ex communi.
-
-
-
-
Word break
-
Prevent long strings of text from breaking your components’ layout by using .text-break to set word-wrap: break-word and word-break: break-word. We use word-wrap instead of the more common overflow-wrap for wider browser support, and add the deprecated word-break: break-word to avoid issues with flex containers.
Easily change the vertical alignment of inline, inline-block, inline-table, and table cell elements.
-
-
-
-
-
-
-
-
-
-
Change the alignment of elements with the vertical-alignment utilities. Please note that vertical-align only affects inline, inline-block, inline-table, and table cell elements.
-
Choose from .align-baseline, .align-top, .align-middle, .align-bottom, .align-text-bottom, and .align-text-top as needed.
Control the visibility, without modifying the display, of elements with visibility utilities.
-
-
-
-
-
-
-
-
-
-
Set the visibility of elements with our visibility utilities. These utility classes do not modify the display value at all and do not affect layout – .invisible elements still take up space in the page. Content will be hidden both visually and for assistive technology/screen reader users.