From 3e76d6565603fafa2c85ad81d7b6345c4e279c72 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Sun, 28 May 2017 22:50:57 -0700 Subject: Rearrange all the docs to allow for a docs/major.minor/ setup --- docs/components/alerts.md | 126 ----- docs/components/badge.md | 71 --- docs/components/breadcrumb.md | 34 -- docs/components/button-group.md | 201 -------- docs/components/buttons.md | 178 ------- docs/components/card.md | 720 --------------------------- docs/components/carousel.md | 298 ------------ docs/components/collapse.md | 235 --------- docs/components/dropdowns.md | 590 ----------------------- docs/components/forms.md | 1018 --------------------------------------- docs/components/input-group.md | 237 --------- docs/components/jumbotron.md | 31 -- docs/components/list-group.md | 356 -------------- docs/components/modal.md | 616 ----------------------- docs/components/navbar.md | 538 --------------------- docs/components/navs.md | 673 -------------------------- docs/components/pagination.md | 170 ------- docs/components/popovers.md | 372 -------------- docs/components/progress.md | 141 ------ docs/components/scrollspy.md | 327 ------------- docs/components/tooltips.md | 349 -------------- 21 files changed, 7281 deletions(-) delete mode 100644 docs/components/alerts.md delete mode 100644 docs/components/badge.md delete mode 100644 docs/components/breadcrumb.md delete mode 100644 docs/components/button-group.md delete mode 100644 docs/components/buttons.md delete mode 100644 docs/components/card.md delete mode 100644 docs/components/carousel.md delete mode 100644 docs/components/collapse.md delete mode 100644 docs/components/dropdowns.md delete mode 100644 docs/components/forms.md delete mode 100644 docs/components/input-group.md delete mode 100644 docs/components/jumbotron.md delete mode 100644 docs/components/list-group.md delete mode 100644 docs/components/modal.md delete mode 100644 docs/components/navbar.md delete mode 100644 docs/components/navs.md delete mode 100644 docs/components/pagination.md delete mode 100644 docs/components/popovers.md delete mode 100644 docs/components/progress.md delete mode 100644 docs/components/scrollspy.md delete mode 100644 docs/components/tooltips.md (limited to 'docs/components') diff --git a/docs/components/alerts.md b/docs/components/alerts.md deleted file mode 100644 index 3acfd2a79..000000000 --- a/docs/components/alerts.md +++ /dev/null @@ -1,126 +0,0 @@ ---- -layout: docs -title: Alerts -description: Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages. -group: components -toc: true ---- - -## Examples - -Alerts are available for any length of text, as well as an optional dismiss button. For proper styling, use one of the four **required** contextual classes (e.g., `.alert-success`). For inline dismissal, use the [alerts jQuery plugin](#dismissing). - -{% example html %} - - - - -{% endexample %} - -{% capture callout-include %}{% include callout-warning-color-assistive-technologies.md %}{% endcapture %} -{{ callout-include | markdownify }} - -### Link color - -Use the `.alert-link` utility class to quickly provide matching colored links within any alert. - -{% example html %} - - - - -{% endexample %} - -### Additional content - -Alerts can also contain additional HTML elements like headings, paragraphs and dividers. - -{% example html %} - -{% endexample %} - - -### 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. -- 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 ` - Holy guacamole! You should check in on some of those fields below. - -{% endexample %} - -## JavaScript behavior - -### Triggers - -Enable dismissal of an alert via JavaScript: - -{% highlight js %} -$(".alert").alert() -{% endhighlight %} - -Or with `data` attributes on a button **within the alert**, as demonstrated above: - -{% highlight html %} - -{% endhighlight %} - -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. | - -{% highlight js %}$(".alert").alert('close'){% endhighlight %} - -### 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). | - -{% highlight js %} -$('#myAlert').on('closed.bs.alert', function () { - // do something… -}) -{% endhighlight %} diff --git a/docs/components/badge.md b/docs/components/badge.md deleted file mode 100644 index 764e5a1cb..000000000 --- a/docs/components/badge.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -layout: docs -title: Badges -description: Documentation and examples for badges, our small count and labeling component. -group: components -toc: true ---- - -## 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
-
- -{% highlight html %} -

Example heading New

-

Example heading New

-

Example heading New

-

Example heading New

-
Example heading New
-
Example heading New
-{% endhighlight %} - -## Contextual variations - -Add any of the below mentioned modifier classes to change the appearance of a badge. - -{% example html %} -Default -Primary -Success -Info -Warning -Danger -{% endexample %} - -{% capture callout-include %}{% include callout-warning-color-assistive-technologies.md %}{% endcapture %} -{{ callout-include | markdownify }} - -## 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. - -{% example html %} -Default -Primary -Success -Info -Warning -Danger -{% endexample %} - -## Links - -Using the `.badge` classes with the `` element quickly provide _actionable_ badges with hover and focus states. - -{% example html %} -Default -Primary -Success -Info -Warning -Danger -{% endexample %} diff --git a/docs/components/breadcrumb.md b/docs/components/breadcrumb.md deleted file mode 100644 index eb286d847..000000000 --- a/docs/components/breadcrumb.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -layout: docs -title: Breadcrumb -description: Indicate the current page's location within a navigational hierarchy that automatically adds separators via CSS. -group: components ---- - -Separators are automatically added in CSS through [`::before`](https://developer.mozilla.org/en-US/docs/Web/CSS/::before) and [`content`](https://developer.mozilla.org/en-US/docs/Web/CSS/content). - -{% example html %} - - - -{% endexample %} - -Similar to our navigation components, breadcrumbs work fine with or without the usage of list markup. - -{% example html %} - -{% endexample %} diff --git a/docs/components/button-group.md b/docs/components/button-group.md deleted file mode 100644 index f328b9422..000000000 --- a/docs/components/button-group.md +++ /dev/null @@ -1,201 +0,0 @@ ---- -layout: docs -title: Button group -description: Group a series of buttons together on a single line with the button group, and super-power them with JavaScript. -group: components -toc: true ---- - -## 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]({{ site.baseurl }}/components/buttons/#button-plugin). - -{% example html %} -
- - - -
-{% endexample %} - -{% callout warning %} -#### 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. -{% endcallout %} -## 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. - -{% example html %} - -{% endexample %} - -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. - -{% example html %} - - - -{% endexample %} - -## 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. - -
-
- - - -
-
-
- - - -
-
-
- - - -
-
- -{% highlight html %} -
...
-
...
-
...
-{% endhighlight %} - -## Nesting - -Place a `.btn-group` within another `.btn-group` when you want dropdown menus mixed with a series of buttons. - -{% example html %} -
- - - -
- - -
-
-{% endexample %} - -## Vertical variation - -Make a set of buttons appear vertically stacked rather than horizontally. **Split button dropdowns are not supported here.** - -
-
- - - - - - -
-
- - -
-
- - -
- - -
- - -
- - -
-
- - -
-
- - -
-
-
- -{% highlight html %} -
- ... -
-{% endhighlight %} - -## Tooltips and popovers - -Due to the specific implementation (and some other components), a bit of special casing is required for tooltips and popovers within button groups. **You'll have to specify the option `container: 'body'`** to avoid unwanted side effects (such as the element growing wider and/or losing its rounded corners when the tooltip or popover is triggered). diff --git a/docs/components/buttons.md b/docs/components/buttons.md deleted file mode 100644 index cfd243dad..000000000 --- a/docs/components/buttons.md +++ /dev/null @@ -1,178 +0,0 @@ ---- -layout: docs -title: Buttons -description: Use Bootstrap's custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more. -group: components -redirect_from: "/components/" -toc: true ---- - -## Examples - -Bootstrap includes six predefined button styles, each serving its own semantic purpose. - -{% example html %} - - - - - - - - - - - - - - - - - - - - -{% endexample %} - -{% capture callout-include %}{% include callout-warning-color-assistive-technologies.md %}{% endcapture %} -{{ callout-include | markdownify }} - -## Button tags - -The `.btn` classes are designed to be used with the ` - - - -{% endexample %} - -## Outline buttons - -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. - -{% example html %} - - - - - - -{% endexample %} - - -## Sizes - -Fancy larger or smaller buttons? Add `.btn-lg` or `.btn-sm` for additional sizes. - -{% example html %} - - -{% endexample %} - -{% example html %} - - -{% endexample %} - -Create block level buttons—those that span the full width of a parent—by adding `.btn-block`. - -{% example html %} - - -{% endexample %} - -## 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 ` - -{% endexample %} - -Disabled buttons using the `` element behave a bit different: - -- ``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. - -{% example html %} -Primary link -Link -{% endexample %} - -{% callout warning %} -#### Link functionality caveat - -The `.disabled` class uses `pointer-events: none` to try to disable the link functionality of ``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. -{% endcallout %} - -## 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 **and** `aria-pressed="true"` to the ` -{% endexample %} - -### Checkbox and radio buttons - -Bootstrap's `.button` styles can be applied to other elements, such as `
- Card image cap - -
-{% endexample %} - -## Content types - -Cards support a wide variety of content, including images, text, list groups, links, and more. Below are examples of what's supported. - -### Blocks - -The building block of a card is the `.card-block`. Use it whenever you need a padded section within a card. - -{% example html %} -
-
- This is some text within a card block. -
-
-{% endexample %} - -### Titles, text, and links - -Card titles are used by adding `.card-title` to a `` tag. In the same way, links are added and placed next to each other by adding `.card-link` to a `` tag. - -Subtitles are used by adding a `.card-subtitle` to a `` tag. If the `.card-title` and the `.card-subtitle` items are placed in a `.card-block` item, the card title and subtitle are aligned nicely. - -{% example html %} - -{% endexample %} - -### Images - -`.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. - -{% example html %} -
- Card image cap -
-

Some quick example text to build on the card title and make up the bulk of the card's content.

-
-
-{% endexample %} - -### List groups - -Create lists of content in a card with a flush list group. - -{% example html %} -
-
    -
  • Cras justo odio
  • -
  • Dapibus ac facilisis in
  • -
  • Vestibulum at eros
  • -
-
-{% endexample %} - -### 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. - -{% example html %} -
- Card image cap -
-

Card title

-

Some quick example text to build on the card title and make up the bulk of the card's content.

-
-
    -
  • Cras justo odio
  • -
  • Dapibus ac facilisis in
  • -
  • Vestibulum at eros
  • -
- -
-{% endexample %} - -### Header and footer - -Add an optional header and/or footer within a card. - -{% example html %} -
-
- Featured -
-
-

Special title treatment

-

With supporting text below as a natural lead-in to additional content.

- Go somewhere -
-
-{% endexample %} - -Card headers can be styled by adding `.card-header` to `` elements. - -{% example html %} -
-

Featured

-
-

Special title treatment

-

With supporting text below as a natural lead-in to additional content.

- Go somewhere -
-
-{% endexample %} - -{% example html %} -
-
- Quote -
-
-
-

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

-
Someone famous in Source Title
-
-
-
-{% endexample %} - -{% example html %} -
-
- Featured -
-
-

Special title treatment

-

With supporting text below as a natural lead-in to additional content.

- Go somewhere -
- -
-{% endexample %} - -## Sizing - -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. - -{% example html %} -
-
-
-
-

Special title treatment

-

With supporting text below as a natural lead-in to additional content.

- Go somewhere -
-
-
-
-
-
-

Special title treatment

-

With supporting text below as a natural lead-in to additional content.

- Go somewhere -
-
-
-
-{% endexample %} - -### Using utilities - -Use our handful of [available sizing utilities]({{ site.baseurl }}/utilities/sizing/) to quickly set a card's width. - -{% example html %} -
-
-

Card title

-

With supporting text below as a natural lead-in to additional content.

- Button -
-
- -
-
-

Card title

-

With supporting text below as a natural lead-in to additional content.

- Button -
-
-{% endexample %} - -### Using custom CSS - -Use custom CSS in your stylesheets or as inline styles to set a width. - -{% example html %} -
-
-

Special title treatment

-

With supporting text below as a natural lead-in to additional content.

- Go somewhere -
-
-{% endexample %} - -## Text alignment - -You can quickly change the text alignment of any card—in its entirety or specific parts—with our [text align classes]({{ site.baseurl }}/utilities/typography/#text-alignment). - -{% example html %} -
-
-

Special title treatment

-

With supporting text below as a natural lead-in to additional content.

- Go somewhere -
-
- -
-
-

Special title treatment

-

With supporting text below as a natural lead-in to additional content.

- Go somewhere -
-
- -
-
-

Special title treatment

-

With supporting text below as a natural lead-in to additional content.

- Go somewhere -
-
-{% endexample %} - -## Navigation - -Add some navigation to a card's header (or block) with Bootstrap's [nav components]({{ site.baseurl }}/components/navs/). - -{% example html %} -
-
- -
-
-

Special title treatment

-

With supporting text below as a natural lead-in to additional content.

- Go somewhere -
-
-{% endexample %} - -{% example html %} -
-
- -
-
-

Special title treatment

-

With supporting text below as a natural lead-in to additional content.

- Go somewhere -
-
-{% endexample %} - -## Images - -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. - -{% example html %} -
- Card image cap -
-

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

-
- Card image cap -
-{% endexample %} - -### 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 `.card-inverse` (see below). - -{% example html %} -
- Card image -
-

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

-
-
-{% endexample %} - -## Card styles - -Cards include various options for customizing their backgrounds, borders, and color. - -### Inverted text - -By default, cards use dark text and assume a light background. You can reverse that by toggling the `color` of text within, as well as that of the card's subcomponents, with `.card-inverse`. Then, specify a dark `background-color` and `border-color` to go with it. - -You can also use `.card-inverse` with the [contextual backgrounds variants](#background-variants). - -{% example html %} -
-
Header
-
-

Special title treatment

-

With supporting text below as a natural lead-in to additional content.

- Go somewhere -
- -
-{% endexample %} - -### Background variants - -Cards include their own variant classes for quickly changing the `background-color` and `border-color` of a card. **Darker colors require the use of `.card-inverse`.** - -{% example html %} -
-
-
-

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

-
Someone famous in Source Title
-
-
-
-
-
-
-

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

-
Someone famous in Source Title
-
-
-
-
-
-
-

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

-
Someone famous in Source Title
-
-
-
-
-
-
-

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

-
Someone famous in Source Title
-
-
-
-
-
-
-

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

-
Someone famous in Source Title
-
-
-
-{% endexample %} - -{% capture callout-include %}{% include callout-warning-color-assistive-technologies.md %}{% endcapture %} -{{ callout-include | markdownify }} - -### Outline cards - -In need of a colored card, but not the hefty background colors they bring? Replace the default modifier classes with the `.card-outline-*` ones to style just the `border-color` of a card. - -{% example html %} -
-
-
-

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

-
Someone famous in Source Title
-
-
-
-
-
-
-

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

-
Someone famous in Source Title
-
-
-
-
-
-
-

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

-
Someone famous in Source Title
-
-
-
-
-
-
-

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

-
Someone famous in Source Title
-
-
-
-
-
-
-

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

-
Someone famous in Source Title
-
-
-
-
-
-
-

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

-
Someone famous in Source Title
-
-
-
-{% endexample %} - -## 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 use `display: flex;` to achieve their uniform sizing. - -{% example html %} -
-
- Card image cap -
-

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 image cap -
-

Card title

-

This card has supporting text below as a natural lead-in to additional content.

-

Last updated 3 mins ago

-
-
-
- Card image cap -
-

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

-
-
-
-{% endexample %} - -When using card groups with footers, their content will automatically line up. - -{% example html %} -
-
- Card image cap -
-

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 image cap -
-

Card title

-

This card has supporting text below as a natural lead-in to additional content.

-
- -
-
- Card image cap -
-

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.

-
- -
-
-{% endexample %} - -### Card decks - -Need a set of equal width and height cards that aren't attached to one another? Use card decks. - -{% example html %} -
-
- Card image cap -
-

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 image cap -
-

Card title

-

This card has supporting text below as a natural lead-in to additional content.

-

Last updated 3 mins ago

-
-
-
- Card image cap -
-

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

-
-
-
-{% endexample %} - -Just like with card groups, card footers in decks will automatically line up. - -{% example html %} -
-
- Card image cap -
-

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 image cap -
-

Card title

-

This card has supporting text below as a natural lead-in to additional content.

-
- -
-
- Card image cap -
-

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.

-
- -
-
-{% endexample %} - -### Card columns - -Cards can be organized into [Masonry](http://masonry.desandro.com)-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. - -{% example html %} -
-
- Card image cap -
-

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.

-
- - Someone famous in Source Title - -
-
-
-
- Card image cap -
-

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.

-
- - Someone famous in Source Title - -
-
-
-
-
-

Card title

-

This card has supporting text below as a natural lead-in to additional content.

-

Last updated 3 mins ago

-
-
-
- Card image -
-
-
-

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

-
- - Someone famous in Source Title - -
-
-
-
-
-

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

-
-
-
-{% endexample %} - -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. - -{% highlight scss %} -.card-columns { - @include media-breakpoint-only(lg) { - column-count: 4; - } - @include media-breakpoint-only(xl) { - column-count: 5; - } -} -{% endhighlight %} diff --git a/docs/components/carousel.md b/docs/components/carousel.md deleted file mode 100644 index ae82eb08f..000000000 --- a/docs/components/carousel.md +++ /dev/null @@ -1,298 +0,0 @@ ---- -layout: docs -title: Carousel -description: A slideshow component for cycling through elements—images or slides of text—like a carousel. -group: components -toc: true ---- - -## 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](https://www.w3.org/TR/page-visibility/) 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. - -## 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. - -Be sure to set a unique id on the `.carousel` for optional controls, especially if you're using multiple carousels on a single page. - -### Slides only - -Here's a carousel with slides only. Note the presence of the `.d-block` and `.img-fluid` on carousel images to prevent browser default image alignment. - -{% example html %} - -{% endexample %} - -### With controls - -Adding in the previous and next controls: - -{% example html %} - -{% endexample %} - -### With indicators - -You can also add the indicators to the carousel, alongside the controls, too. - -{% example html %} - -{% endexample %} - -{% callout warning %} -#### Initial active element required - -The `.active` class needs to be added to one of the slides. Otherwise, the carousel will not be visible. -{% endcallout %} - -### With captions - -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]({{ site.baseurl }}/utilities/display-property/). We hide them initially with `.d-none` and bring them back on medium-sized devices with `.d-md-block`. - -
- -
- -{% highlight html %} - -{% endhighlight %} - -## Usage - -### Via data attributes - -Use data attributes to easily control the position of the carousel. `data-slide` accepts the keywords `prev` or `next`, which alters the slide position relative to its current position. Alternatively, use `data-slide-to` to 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. **It cannot be used in combination with (redundant and unnecessary) explicit JavaScript initialization of the same carousel.** - -### Via JavaScript - -Call carousel manually with: - -{% highlight js %} -$('.carousel').carousel() -{% endhighlight %} - -### Options - -Options can be passed via data attributes or JavaScript. For data attributes, append the option name to `data-`, as in `data-interval=""`. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDefaultDescription
intervalnumber5000The amount of time to delay between automatically cycling an item. If false, carousel will not automatically cycle.
keyboardbooleantrueWhether the carousel should react to keyboard events.
pausestring | 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.

ridestringfalseAutoplays the carousel after the user manually cycles the first item. If "carousel", autoplays the carousel on load.
wrapbooleantrueWhether the carousel should cycle continuously or have hard stops.
- -### Methods - -{% capture callout-include %}{% include callout-danger-async-methods.md %}{% endcapture %} -{{ callout-include | markdownify }} - -#### `.carousel(options)` - -Initializes the carousel with an optional options `object` and starts cycling through items. - -{% highlight js %} -$('.carousel').carousel({ - interval: 2000 -}) -{% endhighlight %} - -#### `.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). - -### 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 ` -{% endexample %} - -And with `` elements: - -{% example html %} - -{% endexample %} - -The best part is you can do this with any button variant, too: - - - -{% highlight html %} - - -{% endhighlight %} - -### Split button dropdowns - -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. - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
- -{% highlight html %} - -
- - - -
-{% endhighlight %} - -## Sizing - -Button dropdowns work with buttons of all sizes, including default and split dropdown buttons. - -
- - -
- -{% highlight html %} - -
- - -
-
- - - -
- - -
- - -
-
- - - -
-{% endhighlight %} - -## Dropup variation - -Trigger dropdown menus above elements by adding `.dropup` to the parent element. - -
- - -
- - - -
-
- -{% highlight html %} - -
- - - -
- - -
- - - -
-{% endhighlight %} - -## Menu items - -Historically dropdown menu contents *had* to be links, but that's no longer the case with v4. Now you can optionally use ` - - -{% endexample %} - -## Menu alignment - -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. - -{% callout info %} -**Heads up!** Dropdowns are positioned only with CSS and may need some additional styles for exact alignment. -{% endcallout %} - -{% example html %} -
- - -
-{% endexample %} - -## Menu headers - -Add a header to label sections of actions in any dropdown menu. - -{% example html %} -
-{% endexample %} - -## Menu dividers - -Separate groups of related menu items with a divider. - -{% example html %} - -{% endexample %} - -## Disabled menu items - -Add `.disabled` to items in the dropdown to **style them as disabled**. - -{% example html %} - -{% endexample %} - -## Usage - -Via data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) by toggling the `.show` class on the parent list item. - -{% callout info %} -On touch-enabled devices, opening a dropdown adds empty (`$.noop`) `mouseover` handlers to the immediate children of the `` element. This admittedly ugly hack is necessary to work around a [quirk in iOS' event delegation](https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html), 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. -{% endcallout %} - -Note: 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. - -### Via data attributes - -Add `data-toggle="dropdown"` to a link or button to toggle a dropdown. - -{% highlight html %} - -{% endhighlight %} - -### Via JavaScript - -Call the dropdowns via JavaScript: - -{% highlight js %} -$('.dropdown-toggle').dropdown() -{% endhighlight %} - -{% callout info %} -##### `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. -{% endcallout %} - -### Options - -Options can be passed via data attributes or JavaScript. For data attributes, append the option name to `data-`, as in `data-placement=""`. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDefaultDescription
placementstring'bottom' -

How to position the popover - top | bottom.

-
offsetnumber | string0Offset of the dropdown relative to its target. For more information refer to Popper.js's offset docs.
flipbooleantrueAllow Dropdown to flip in case of an overlapping on the reference element. For more information refer to Popper.js's flip docs.
- -### Methods - -| Method | Description | -| --- | --- | -| `$().dropdown('toggle')` | Toggles the dropdown menu of a given navbar or tabbed navigation. | -| `$().dropdown('update')` | Updates the position of 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. - -| 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). | - -{% highlight js %} -$('#myDropdown').on('show.bs.dropdown', function () { - // do something… -}) -{% endhighlight %} diff --git a/docs/components/forms.md b/docs/components/forms.md deleted file mode 100644 index 366f8f625..000000000 --- a/docs/components/forms.md +++ /dev/null @@ -1,1018 +0,0 @@ ---- -layout: docs -title: Forms -description: Examples and usage guidelines for form control styles, layout options, and custom components for creating a wide variety of forms. -group: components -toc: true ---- - -## Form controls - -Bootstrap's form controls expand on [our Rebooted form styles]({{ site.baseurl }}/content/reboot/#forms) with classes. Use these classes to opt into their customized displays for a more consistent rendering across browsers and devices. The example form below demonstrates common HTML form elements that receive updated styles from Bootstrap with additional classes. - -Remember, since Bootstrap utilizes the HTML5 doctype, **all inputs must have a `type` attribute**. - -{% example html %} -
-
- - - We'll never share your email with anyone else. -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - - This is some placeholder block-level help text for the above input. It's a bit lighter and easily wraps to a new line. -
-
- Radio buttons -
- -
-
- -
-
- -
-
-
- -
- -
-{% endexample %} - -Below is a complete list of the specific form controls supported by Bootstrap and the classes that customize them. Additional documentation is available for each group. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ClassesUsed forSupported variations
- {% markdown %}`.form-group`{% endmarkdown %} - - Any group of form controls - - {% markdown %}Use with any block-level element like `
` or `
`{% endmarkdown %} -
- {% markdown %}`.form-control`{% endmarkdown %} - - Textual inputs - - {% markdown %}`text`, `password`, `datetime-local`, `date`, `month`, `time`, `week`, `number`, `email`, `url`, `search`, `tel`, `color`{% endmarkdown %} -
- Select menus - - {% markdown %}`multiple`, `size`{% endmarkdown %} -
- Textareas - - N/A -
- {% markdown %}`.form-control-file`{% endmarkdown %} - - File inputs - - {% markdown %}`file`{% endmarkdown %} -
-{% markdown %} -`.form-check` -{% endmarkdown %} - - Checkboxes and radios - - N/A -
- -### Textual inputs - -Here are examples of `.form-control` applied to each textual HTML5 `` `type`. - -{% example html %} -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-{% endexample %} - -## Form layouts - -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. Its only purpose is to provide `margin-bottom` around a label and control pairing. As a bonus, since it's a class you can use it with `
`s, `
`s, or nearly any other element. - -{% example html %} -
-
- - -
-
- - -
-
-{% endexample %} - -### Inline forms - -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]({{ site.baseurl }}/utilities/spacing/) and [flexbox]({{ site.baseurl }}/utilities/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]({{ site.baseurl }}/utilities/spacing/) (as shown below). Lastly, be sure to always include a `
-{% endexample %} - -## Contextual classes - -Use contextual classes to style list items with a stateful background and color. - -{% example html %} -
    -
  • Dapibus ac facilisis in
  • -
  • Dapibus ac facilisis in
  • -
  • Cras sit amet nibh libero
  • -
  • Porta ac consectetur ac
  • -
  • Vestibulum at eros
  • -
-{% endexample %} - -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. - -{% example html %} -
-{% endexample %} - -{% capture callout-include %}{% include callout-warning-color-assistive-technologies.md %}{% endcapture %} -{{ callout-include | markdownify }} - -## With badges - -Add badges to any list group item to show unread counts, activity, and more with the help of some [utilities]({{ site.baseurl }}/utilities/flexbox/). - -{% example html %} -
    -
  • - Cras justo odio - 14 -
  • -
  • - Dapibus ac facilisis in - 2 -
  • -
  • - Morbi leo risus - 1 -
  • -
-{% endexample %} - -## Custom content - -Add nearly any HTML within, even for linked list groups like the one below, with the help of [flexbox utilities]({{ site.baseurl }}/utilities/flexbox/). - -{% example html %} - -{% endexample %} - -## JavaScript behavior - -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. - -
-
-
- -
-
- -
-
-
- -{% highlight html %} -
-
- -
-
- -
-
-{% endhighlight %} - -### 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`. - -
-{% highlight html %} - - - - -
-
...
-
...
-
...
-
...
-
-{% endhighlight %} -
- -### Via JavaScript - -Enable tabbable list item via JavaScript (each list item needs to be activated individually): - -{% highlight js %} -$('#myList a').click(function (e) { - e.preventDefault() - $(this).tab('show') -}) -{% endhighlight %} - -You can activate individual list item in several ways: - -{% highlight js %} -$('#myList a[href="#profile"]').tab('show') // Select tab by name -$('#myList a:first').tab('show') // Select first tab -$('#myList a:last').tab('show') // Select last tab -$('#myList li:eq(2) a').tab('show') // Select third tab (0-indexed) -{% endhighlight %} - -### 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. - -{% highlight html %} -
-
...
-
...
-
...
-
...
-
-{% endhighlight %} - -### 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. - -{% highlight html %} - - -
-
...
-
...
-
...
-
...
-
- - -{% endhighlight %} - -#### .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). - -{% highlight js %} -$('#someListItem').tab('show') -{% endhighlight %} - -### Events - -When showing a new tab, the events fire in the following order: - -1. `hide.bs.tab` (on the current active tab) -2. `show.bs.tab` (on the to-be-shown tab) -3. `hidden.bs.tab` (on the previous active tab, the same one as for the `hide.bs.tab` event) -4. `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 typeDescription
show.bs.tabThis 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.tabThis 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.tabThis 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.tabThis 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.
- -{% highlight js %} -$('a[data-toggle="list"]').on('shown.bs.tab', function (e) { - e.target // newly activated tab - e.relatedTarget // previous active tab -}) -{% endhighlight %} diff --git a/docs/components/modal.md b/docs/components/modal.md deleted file mode 100644 index 8abb6a9c2..000000000 --- a/docs/components/modal.md +++ /dev/null @@ -1,616 +0,0 @@ ---- -layout: docs -title: Modal -description: Use Bootstrap's JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content. -group: components -toc: true ---- - -## 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 `` 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]({{ site.baseurl }}/getting-started/browsers-devices/#modals-and-dropdowns-on-mobile) for details. -- Lastly, the `autofocus` HTML attribute has no effect in modals. Here's how you can achieve the same effect with custom JavaScript. - -Keep reading for demos and usage guidelines. - - -- Due to how HTML5 defines its semantics, [the `autofocus` HTML attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-autofocus) has no effect in Bootstrap modals. To achieve the same effect, use some custom JavaScript: - -{% highlight js %} -$('#myModal').on('shown.bs.modal', function () { - $('#myInput').focus() -}) -{% endhighlight %} - -## Examples - -### Modal components - -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. - -
- -
- -{% highlight html %} - -{% endhighlight %} - -### 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. - - - -
- -
- -{% highlight html %} - - - - - -{% endhighlight %} - -### 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. - - - -
- -
- -{% highlight html %} - - - - - -{% endhighlight %} - -### Tooltips and popovers - -[Tooltips]({{ site.baseurl }}/components/tooltips/) and [popovers]({{ site.baseurl }}/components/popovers/) can be placed within modals as needed. When modals are closed, any tooltips and popovers within are also automatically dismissed. - - - -
- -
- -{% highlight html %} - -{% endhighlight %} - -### Using the grid - -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. - - - -
- -
- -{% highlight html %} - -{% endhighlight %} - -### 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](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes) (possibly [via jQuery](https://api.jquery.com/data/)) 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](#events) for details on `relatedTarget`. - -{% example html %} - - - - - -{% endexample %} - -{% highlight js %} -$('#exampleModal').on('show.bs.modal', function (event) { - var button = $(event.relatedTarget) // Button that triggered the modal - var recipient = button.data('whatever') // Extract info from data-* attributes - // If necessary, you could initiate an AJAX request here (and then do the updating in a callback). - // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead. - var modal = $(this) - modal.find('.modal-title').text('New message to ' + recipient) - modal.find('.modal-body input').val(recipient) -}) -{% endhighlight %} - -### Remove animation - -For modals that simply appear rather than fade in to view, remove the `.fade` class from your modal markup. - -{% highlight html %} - -{% endhighlight %} - -### Dynamic heights - -If the height of a modal changes while it is open, you should call `$('#myModal').data('bs.modal').handleUpdate()` or `$('#myModal').modal('handleUpdate')` to readjust the modal's position in case a scrollbar appears. - -### Accessibility - -Be sure to add `role="dialog"` and `aria-labelledby="..."`, referencing the modal title, to `.modal`, and `role="document"` to the `.modal-dialog` itself. Additionally, you may give a description of your modal dialog with `aria-describedby` on `.modal`. - -### Embedding YouTube videos - -Embedding YouTube videos in modals requires additional JavaScript not in Bootstrap to automatically stop playback and more. [See this helpful Stack Overflow post](https://stackoverflow.com/questions/18622508/bootstrap-3-and-youtube-in-modal) for more information. - -## Optional sizes - -Modals have two 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. - -
- - -
- -{% highlight html %} - - - - - - - - - -{% endhighlight %} - - - - - -## Usage - -The modal plugin toggles your hidden content on demand, via data attributes or JavaScript. It also adds `.modal-open` to the `` 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. - -{% highlight html %} - -{% endhighlight %} - -### Via JavaScript - -Call a modal with id `myModal` with a single line of JavaScript: - -{% highlight js %}$('#myModal').modal(options){% endhighlight %} - -### Options - -Options can be passed via data attributes or JavaScript. For data attributes, append the option name to `data-`, as in `data-backdrop=""`. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDefaultDescription
backdropboolean or the string 'static'trueIncludes a modal-backdrop element. Alternatively, specify static for a backdrop which doesn't close the modal on click.
keyboardbooleantrueCloses the modal when escape key is pressed
focusbooleantruePuts the focus on the modal when initialized.
showbooleantrueShows the modal when initialized.
- -### Methods - -{% capture callout-include %}{% include callout-danger-async-methods.md %}{% endcapture %} -{{ callout-include | markdownify }} - -#### `.modal(options)` - -Activates your content as a modal. Accepts an optional options `object`. - -{% highlight js %} -$('#myModal').modal({ - keyboard: false -}) -{% endhighlight %} - -#### `.modal('toggle')` - -Manually toggles a modal. **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). - -{% highlight js %}$('#myModal').modal('toggle'){% endhighlight %} - -#### `.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). - -{% highlight js %}$('#myModal').modal('show'){% endhighlight %} - -#### `.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). - -{% highlight js %}$('#myModal').modal('hide'){% endhighlight %} - -#### `.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). - -{% highlight js %}$('#myModal').modal('handleUpdate'){% endhighlight %} - -### 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 `