div.carousel.slide Attribute
data-ride="carousel" (remove to slide by controls only)div.carousel-inner
div.carousel-item (×3) Attributes
.active to the initially-visible itemdata-interval="{msec}".img.d-block.w-100 Attribute
src="..."div.carousel.slide Attribute
id="{carousel-id}"div.carousel-inner - same as Basic (auto-slide only)a.carousel-control-prev Attributes
href="#{carousel-id}"data-slide="prev"span.carousel-control-prev-icon Attribute
aria-hidden="true"span.sr-only
Previousa.carousel-control-next Attributes
href="#{carousel-id}"data-slide="next"span.carousel-control-next-icon Attribute
aria-hidden="true"span.sr-only
Nextdiv.carousel.slide Attribute
id="{carousel-id}"ol.carousel-indicators
li (×3) Attributes
data-target="#{carousel-id}"data-slide-to="{index}" (index = 0,1,2).active to an initially-visible itemdiv.carousel-inner
div-carousel-item(.active)?
img.d-block.w-100div.carousel-caption.d-none.d-md-block
h5
First slide labelp
Nulla vitae ....carousel-fade to Carousel (outer) div.carousel.slideYou can toggle collapse (hidden) and expanded (shown) states of a target element with a button.
Live examples below (a on left, button on right, both switch the same target div.collapse#ex-collapse).
div.collaps#ex-collapseAnim 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.
button or a
a ⇒ a.btn.btn-(primary|secondary|...) Attributes
data-toggle="collapse"href="#{target-id}" (or an arbitrary CSS selector)role="button"button ⇒ button.btn.btn-(primary|secondary|...) Attributes
type="button"data-toggle="collapse"data-target="#{target-id}" (or an arbitrary CSS selector)aria-expanded="false" (or "true" for initially-shown)aria-controls="{target-id}".collapse (hidden as default).show to set initially-shownid="{target-id}"Multiple targets can be specified by a class.
Structurea
href=".{target-class}"button
data-target=".{target-class}"class="{target-class}" to targetsExample 1: With a's, used ID's for each (1) and (2), class for (1)+(2)
Toggle (1)Toggle (2)Toggle (1)+(2)
Example 2: With button's
Extended example using cards.
div Attribute
id="{parent-id}"div.card (×3)
div.card-header Attribute
id="{header-id}"h5
button.btn.btn-link Attributes
data-toggle="collapse"data-target="#{target-id}"aria-expanded="false" (or "true" for initially-shown)aria-controls="{target-id}"div.collapse Attributes
.show for initially-shown itemid="{target-id}"data-parent="#{parent-id}"aria-labelledby="{header-id}"buttondiv.dropdown (any element with position: relative;)
button.btn.btn-(primary|secondary|success|info|warning|danger) Attributes
type="button"data-toggle="dropdown"id="{dropdown-id}"aria-haspopup="true"aria-expanded="false"Dropdown buttondiv.dropdown-menu Attribute
aSame as above except a trigger element.
a.btn.btn-(primary|secondary|success|info|warning|danger).dropdown-toggle Attributes
href="..."data-toggle="dropdown"role="button"id , aria-haspopup , and aria-expanded ) are the same.btn-(primary|secondary|success|info|warning|danger)
div.btn-group
div.btn-group
(Caution: Do not use .dropdown for split buttons)
button.btn.btn-(primary|secondary|success|info|warning|danger)
Primary.dropdown-toggle-split
span.sr-only
Toggle DropdownAdd .btn-(lg|sm)
(a|button).btn.btn-secondary.btn-lg
(Default)
(a|button).btn.btn-secondary.btn-sm
Add .(dropup|dropright|dropleft) to a parent div.btn-group
div.btn-group.dropup
div.btn-group.dropright
div.btn-group.dropleft
Structures are basically the same. But the split dropleft has a slightly different structure.
Split dropleft structurediv.btn-group
div.btn-group.dropleft Attribute
role="group"button.btn.dropdown-toggle.dropdown-toggle-split ...button.btn ...button.dropdown-item elements can be used for items (does not jump on click by default).
button.dropdown-item (does not link on click)
You can use (span).dropdown-item-text to create static (not selectable) text items. You can also add any text formatting with tags and CSS to items. See the example below.
Add .active to a item to display as active state (white text on primary/blue background).
Add .disabled to an item to display as disabled (grayed text).
However, both classes have no behavior effect. An item with .active does not change when a user select another item. Also, an item with .disabled can be selected. Furthermore, it links to the target if its element is a (not disabled). You can check these behaviors with above examples.
JavaScript is required for appropriate behaviors. See the example below.
id="active-disabled-example".active to Item 1.disabled to Item 5 (disabled)span#active-indicator for displaying a currently active item// Dropdown: Active/disabled states demo
$('#active-disabled-example').delegate('a', 'click', function(event) {
var item = $(this);
event.preventDefault(); // prevent default link behaviors
if (item.hasClass('disabled')) return; // implement disabled behaviors
// update the active item
$('#active-disabled-example a').removeClass('active');
item.addClass('active');
$('#active-indicator').text(item.text());
});
click event handler to a parent (item list)
a (more efficient than children receive directly)event.preventDefault() prevents an item's defaut behavior.
a (or it jumps to the target[href] on click)button.disabled and just returns (does nothig) if sets.active from all items first.active to a clicked itemA dropdown menu aligns left to a parent (same as a trigger button) as default. Adding .dropdown-menu-right to an item list, it alignes right at a parent (trigger button)'s right side.
Use h6.dropdown-header for menu headers (static i.e. not selectable). The example below sets a header as the first item Dropdown header.
Use div.dropdown-divider to separate item groups.
You can also use dropdowns for showing popup text contents.
div.dropdown
button.btn.btn-secondary.dropdown-togglediv.dropdown-menu Attributes
.p-3.text-fadedstyle="width: 180px;"p Attribute
.mb-0A form can be used as a dropdown item.
div.dropdown
button.btn.btn-secondary.dropdown-togglediv.dropdown-menu
form Attribute
.px-4.py-3div.dropdown-dividerYou can specify menu position offset with data-offset="{x-offset-px},{y-offset-px}".
div.dropdown
button.btn.btn-secondary.dropdown-toggle
data-offset="100,20"You can change menu position reference to the parent with data-reference="parent". It is useful for a split button to show menu from its parent frame.
div.btn-group
button.btn.btn-secondary.dropdown-togglebutton.btn.btn-secondary.dropdown-toggle.dropdown-toggle-split
data-reference="parent"Finally, you can fix (always dropdown) the menu direction with data-display="static". It disables (Popper's) dynamic positioning.
div.dropdown
button.btn.btn-secondary.dropdown-toggle
data-display="static"