Interactive Components
Hover lift, toggler, scrollspy, dialog, drawer, and avatar patterns.
1. Hover lift
A small hover animation can make clickable cards feel responsive. If your project does not provide a hover-lift utility, use this CSS fallback.
<div class="hover-lift">Card content</div>
/* CSS fallback */
.hover-lift {
transition: transform .2s ease, box-shadow .2s ease;
}
.hover-lift:hover {
transform: translateY(-4px);
box-shadow: 0 1rem 2rem rgba(0,0,0,.12);
}2. Toggler / collapse
Toggle content open and closed with Bootstrap's collapse component.
<button class="btn btn-solid theme-primary" data-bs-toggle="collapse"
data-bs-target="#details" aria-controls="details">
Toggle details
</button>
<div class="collapse" id="details">Collapsible content</div>3. Scrollspy
Scrollspy updates navigation state as the user scrolls through sections. The target links must match the section IDs.
Overview
Introductory content.
Details
More details. Scroll this panel.
Summary
Closing notes.
<nav id="sectionNav" class="nav nav-pills">
<a class="nav-link" href="#overview">Overview</a>
<a class="nav-link" href="#details">Details</a>
</nav>
<div data-bs-spy="scroll" data-bs-target="#sectionNav"
tabindex="0" style="height:240px;overflow-y:auto">
<section id="overview">...</section>
<section id="details">...</section>
</div>4. Dialog
A native <dialog> is useful for confirmation or a focused task without navigating away. Bootstrap 6 handles the backdrop, focus trap, and Escape key for you.
<button class="btn btn-solid theme-primary"
data-bs-toggle="dialog" data-bs-target="#confirmDialog">
Open dialog
</button>
<dialog class="dialog" id="confirmDialog"
aria-labelledby="confirmDialogTitle">
<div class="dialog-header">
<h5 class="dialog-title" id="confirmDialogTitle">Confirm action</h5>
<button class="btn-close" data-bs-dismiss="dialog"
aria-label="Close"></button>
</div>
<div class="dialog-body">
Are you sure you want to continue?
</div>
<div class="dialog-footer">
<button class="btn btn-solid theme-secondary"
data-bs-dismiss="dialog">Cancel</button>
<button class="btn btn-solid theme-primary"
data-bs-dismiss="dialog">Confirm</button>
</div>
</dialog>5. Drawer
A drawer is useful for filters, navigation, and contextual actions. Like the dialog, it is a native <dialog> element in Bootstrap 6.
<button class="btn btn-outline theme-primary"
data-bs-toggle="drawer" data-bs-target="#filterDrawer">
Open drawer
</button>
<dialog class="drawer drawer-end" id="filterDrawer"
aria-labelledby="filterDrawerTitle">
<div class="drawer-header">
<h5 class="drawer-title" id="filterDrawerTitle">Filter options</h5>
<button class="btn-close" data-bs-dismiss="drawer"
aria-label="Close"></button>
</div>
<div class="drawer-body">
Put filters and quick actions here.
</div>
<div class="drawer-footer">
<button class="btn btn-solid theme-secondary"
data-bs-dismiss="drawer">Reset</button>
<button class="btn btn-solid theme-primary"
data-bs-dismiss="drawer">Apply filters</button>
</div>
</dialog>6. Avatar
Use a photo or initials to identify a person. This initials avatar does not need an image file.
<div class="avatar" role="img" aria-label="Avatar for Yeshwanth">YK</div>
/* CSS fallback */
.avatar {
width: 3.2rem; height: 3.2rem; border-radius: 50%;
display: inline-grid; place-items: center;
background: #e8efff; color: #244aa5; font-weight: 800;
}