Dropdowns
Mirrors the basic examples from Bootstrapâs dropdowns documentation.
Basic
<bs-dropdown stack="this.Html.GetStack()" btn-style="Secondary">
Dropdown button
<bs-dropdown-menu stack="this.Html.GetStack()">
<bs-dropdown-menu-item href="#">Action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Another action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Something else here</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown>
Split button
<bs-dropdown stack="this.Html.GetStack()" is-split="true" btn-style="Primary">
Primary
<bs-split-button>
<span class="visually-hidden">Toggle Dropdown</span>
</bs-split-button>
<bs-dropdown-menu stack="this.Html.GetStack()">
<bs-dropdown-menu-item href="#">Action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Another action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Something else here</bs-dropdown-menu-item>
<bs-dropdown-menu-divider />
<bs-dropdown-menu-item href="#">Separated link</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown>
Sizing
<bs-dropdown stack="this.Html.GetStack()" btn-style="Secondary" btn-size="Large">
Large button
<bs-dropdown-menu stack="this.Html.GetStack()">
<bs-dropdown-menu-item href="#">Action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Another action</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown>
<bs-dropdown stack="this.Html.GetStack()" btn-style="Secondary" btn-size="Small">
Small button
<bs-dropdown-menu stack="this.Html.GetStack()">
<bs-dropdown-menu-item href="#">Action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Another action</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown>
Directions
<bs-dropdown stack="this.Html.GetStack()" drop-direction="Up" btn-style="Secondary">
Dropup
<bs-dropdown-menu stack="this.Html.GetStack()">
<bs-dropdown-menu-item href="#">Action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Another action</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown>
<bs-dropdown stack="this.Html.GetStack()" drop-direction="End" btn-style="Secondary">
Dropend
<bs-dropdown-menu stack="this.Html.GetStack()">
<bs-dropdown-menu-item href="#">Action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Another action</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown>
<bs-dropdown stack="this.Html.GetStack()" drop-direction="Start" btn-style="Secondary">
Dropstart
<bs-dropdown-menu stack="this.Html.GetStack()">
<bs-dropdown-menu-item href="#">Action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Another action</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown>
Menu alignment
<bs-dropdown stack="this.Html.GetStack()" btn-style="Secondary">
End aligned
<bs-dropdown-menu stack="this.Html.GetStack()" class="dropdown-menu-end">
<bs-dropdown-menu-item href="#">Action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Another action</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown>
Responsive alignment
<bs-dropdown stack="this.Html.GetStack()" btn-style="Secondary" drop-alignment="End" drop-alignment-lg="Start">
Right-aligned but left aligned when large screen
<bs-dropdown-menu stack="this.Html.GetStack()">
<bs-dropdown-menu-item href="#">Action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Another action</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown>
Dark dropdown
<bs-dropdown stack="this.Html.GetStack()" btn-style="Secondary">
Dark menu
<bs-dropdown-menu stack="this.Html.GetStack()" class="dropdown-menu-dark">
<bs-dropdown-menu-item href="#">Action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Another action</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown>
Forms in dropdown
<bs-dropdown stack="this.Html.GetStack()" btn-style="Secondary">
Form menu
<bs-form x-padding="Default4" y-padding="Default3">
<bs-floating-label bottom-margin="Default3">
<bs-label>Email</bs-label>
<bs-input />
</bs-floating-label>
<bs-floating-label bottom-margin="Default3">
<bs-label>Password</bs-label>
<bs-input input-type="Password"/>
</bs-floating-label>
<bs-check name="dummyName" bottom-margin="Default3">
Remember me
</bs-check>
<bs-button btn-type="Submit" btn-style="Primary">Sign in</bs-button>
</bs-form>
</bs-dropdown>
Auto-close behavior
<!-- Close only on item clicks inside the menu -->
<bs-dropdown stack="this.Html.GetStack()" btn-style="Secondary" data-bs-auto-close="inside">
Inside only
<bs-dropdown-menu stack="this.Html.GetStack()">
<bs-dropdown-menu-item href="#">Action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Another action</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown>
<!-- Close on outside clicks only -->
<bs-dropdown stack="this.Html.GetStack()" btn-style="Secondary" data-bs-auto-close="outside">
Outside only
<bs-dropdown-menu stack="this.Html.GetStack()">
<bs-dropdown-menu-item href="#">Action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Another action</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown>
<!-- Do not auto-close (close programmatically) -->
<bs-dropdown stack="this.Html.GetStack()" btn-style="Secondary" data-bs-auto-close="false">
Manual
<bs-dropdown-menu stack="this.Html.GetStack()">
<bs-dropdown-menu-item href="#">Action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Another action</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown>
<!-- BCL: forms used as menus automatically set data-bs-auto-close="outside" -->
Note: when using a form as the menu container, BCL sets
data-bs-auto-close="outside"
on the toggle automatically so clicks inside the form donât close the menu.
Offsets and reference
<!-- Offset the menu via Popper (skid, distance) -->
<bs-dropdown stack="this.Html.GetStack()" btn-style="Secondary" data-bs-offset="10,20">
Offset 10,20
<bs-dropdown-menu stack="this.Html.GetStack()">
<bs-dropdown-menu-item href="#">Action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Another action</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown>
<!-- Change Popper reference element (split dropdown) -->
<bs-dropdown stack="this.Html.GetStack()" is-split="true" btn-style="Secondary" data-bs-reference="parent">
Split (reference: parent)
<bs-split-button>
<span class="visually-hidden">Toggle Dropdown</span>
</bs-split-button>
<bs-dropdown-menu stack="this.Html.GetStack()" class="dropdown-menu-end">
<bs-dropdown-menu-item href="#">Action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Another action</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown>
Static display
<!-- Keep menu positioned without dynamic repositioning -->
<bs-dropdown stack="this.Html.GetStack()" btn-style="Secondary" data-bs-display="static">
Display: static
<bs-dropdown-menu stack="this.Html.GetStack()">
<bs-dropdown-menu-item href="#">Action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Another action</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown>
Submenus (BCL extension)
<!-- Nest a menu inside a menu item -->
<bs-dropdown stack="this.Html.GetStack()" btn-style="Secondary">
With submenu
<bs-dropdown-menu stack="this.Html.GetStack()">
<bs-dropdown-menu-item href="#">Top action</bs-dropdown-menu-item>
<bs-dropdown-menu-item>
More options
<bs-dropdown-menu stack="this.Html.GetStack()">
<bs-dropdown-menu-item href="#">Sub item 1</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Sub item 2</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown>
Submenus arenât part of upstream Bootstrap 5.3; this is a BCL convenience with
accessible markup and proper toggle behavior built-in.
Events
<bs-dropdown stack="this.Html.GetStack()" btn-style="Secondary"
on-show="console.log('Dropdown show')"
on-shown="console.log('Dropdown shown')"
on-hide="console.log('Dropdown hide')"
on-hidden="console.log('Dropdown hidden')">
With events
<bs-dropdown-menu stack="this.Html.GetStack()">
<bs-dropdown-menu-item href="#">Action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#">Another action</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown>
These map to
show.bs.dropdown, shown.bs.dropdown,
hide.bs.dropdown, and hidden.bs.dropdown.
Headers, dividers, active and disabled
<bs-dropdown stack="this.Html.GetStack()" btn-style="Secondary">
Menu items
<bs-dropdown-menu stack="this.Html.GetStack()">
<bs-dropdown-menu-header>Header</bs-dropdown-menu-header>
<bs-dropdown-menu-item href="#">Action</bs-dropdown-menu-item>
<bs-dropdown-menu-item href="#" class="active">Active item</bs-dropdown-menu-item>
<bs-dropdown-menu-divider />
<bs-dropdown-menu-item href="#" disabled="true">Disabled</bs-dropdown-menu-item>
</bs-dropdown-menu>
</bs-dropdown>