Scrollspy is a functional component which synchronizes the active item display of the indicator (navigation or list group ) components and the horizontal scroll position of the content.
Scrollspy watches the scrolling content and update the position indicator (navigation or list group) with JavaScript. Requirements are as follows.
position: relative;
overflow-y: scroll;
height
setbody
, it satisfies above all requirementsbody
as the scrolling root, or set attributes to satisfy above requirementsdata-spy="scroll"
data-target="#{indicator-id}"
data-offset="{pixels}"
(scroll calculation offset, default="10"
)id="{target-id}"
to each scrolling target elementsid="{indicator-id}"
a
with href="#{target-id}"
into the correcponding indicator itemsSpinners can be used to show the loading states in your projects.
div.spinner-border
Attribute
role="status"
span.sr-only
Loading...
Add .text-(primary|secondary|success|danger|warning|info|light|dark)
.
.text-primary
.text-secondary
.text-success
.text-danger
.text-warning
.text-info
.text-light
.text-dark
div.spinner-grow
Attribute
role="status"
span.sr-only
Loading...
.text-primary
.text-secondary
.text-success
.text-danger
.text-warning
.text-info
.text-light
.text-dark
Use Spacing utility.
.m-0
.m-1
.m-2
.m-3
.m-4
.m-5
Various utilities are available for locating spinners to appropriate positions.
Example using Align items and Auto margins
div.d-flex.align-items-center
strong
Loading...
div.spinner-border
Attributes
role="status"
aria-hidden="true"
Example using Float with Clearfix.
.float-left
.float-right
div.clearfix
div.spinner-border
Attributes
.float-(left|right)
role="status"
span.sr-only
.text-left
.text-center
.text-right
div.text-(left|center|right)
div.spinner-border
Attribute
role="status"
span.sr-only
Add .spinner-(border|grow)-sm
for smaller spinners.
div.spinner-border.spinner-border-sm
div.spinner-grow.spinner-grow-sm
You can also use custom CSS or inline styles to set any sizes you need.
style="width: 1rem; height: 1rem;"
style="width: 2rem; height: 2rem;"
style="width: 3rem; height: 3rem;"
style="width: 4rem; height: 4rem;"
style="width: 5rem; height: 5rem;"
style="width: 6rem; height: 6rem;"
You can use spinners inside buttons to indicate current actions.
button.btn.btn-primary
Attributes
type="button"
disabled
div.spinner-(border|grow).spinner-(border|grow)-sm
Attributes
role="status"
aria-hidden="true"
span.sr-only
Loading...
Loading...
Toasts are used for short-time alert messages. To activate them, use JavaScript code as below.
$('.toast').toast('show');
Normally, it hides automatically after the short moment (500ms as default). You can change the delay time (or keep showing) with Data options.
div.toast
Attributes
role="alert"
aria-live="assertive"
aria-atomic="true"
data-autohide="false"
div.toast-header
img.rounded.mr-2
Attributes
src="../img/20x20-blue.svg"
alt="Logo placeholder"
strong.mr-auto
Bootstrap
small.muted
11 mins ago
button.ml-2.mb-1.close
Attributes
type="button"
data-dismiss="toast"
aria-label="Close"
span
Attribute
aria-hidden="true"
×
div.toast-body
Hello, world! This is a toast message.
Option attributes as below can be used for a toast frame div.toast
.
data-delay="{delay in milliseconds}"
sets delay time to hide a toast ("500"
[msec] as default).data-animation="(true|false)"
sets CSS animation ("true"
as default).data-autohide="(true|false)"
hides a toast automatically ("true"
as default).You can check data options above with the live demo below.
Toasts are translucent. They also attempt to blur background contents if the browser supports backdrop-filter
CSS property.
You can show multiple toasts. They display vertically stacked.
Use inline CSS style to locate a toast to the appropriate position (examle for the top-right below).
div.bg-secondary
Attributes
aria-live="polite"
aria-atomic="true"
style="position: relative; min-height: 200px;"
div.toast
Attributes
style="position: absolute; top: 0; right: 0;"
data-autohide="false"
You can also use a wrapper to locate mutiple toasts. See the example below.
div.bg-secondary
Attributes
aria-live="polite"
aria-atomic="true"
style="position: relative; min-height: 250px;"
div
Attribute
style="position: absolute; top: 0; right: 0;"
aria-live="(assertive|polite|...)"
aria-atomic="true"
role="(alert|status|...)"
Bootstrap tooltip is customization of tooltip display by title
attribute. It utilizes Popper.js for implementation.
a
, button
, etc.) also show tooltips on setting focus by Tab keys.Bootstrap tooltips are inactivated as defaut. JavaScript is required to activate. Below is a simple code to activate all tooltips.
$('[data-toggle="tooltip"]').tooltip();
data-toggle="tooltip"
title="{tooltip-text}"
Example ⇒ Hover here
Set attribute data-placement=("top"|"right"|"bottom"|"left")
( "top"
as default)
Example
data-html="true"
title="TNT(C<sub>6</sub>H<sub>2</sub>(NO<sub>2</sub>)<sub>3</sub>CH<sub>3</sub>)"
Example ⇒ Hover here
If the attribute disabled
is set to the element, it also disables a tooltip (example below).
button.btn.btn-primary
Attributes
type="button"
data-toggle="tooltip"
title="Disabled tooltip"
disabled
(also disables a tooltip)Disabled button
Example (does not show tooltip on hover)
To enable a tooltip for a disabled element, add a wrapping parent and set tooltip to it.
span
Attributes
.d-inline-block
(set to the same display
setting as button
)data-toggle="tooltip"
title="Disabled tooltip"
button.btn.btn-primary
Attributes
type="button"
style="pointer-events: none;"
(to prevent receiving pointer events)disabled
Disabled button
Example (the button is disabled but show a tooltip on hover by the parent)