Skip to content

Navs

DropMenu

Bit.BlazorUI

DropMenu is a button that opens a callout hosting any content you put in it: an action list, a form, a filter panel, or a navigation menu. The callout is anchored to the button, flips to the side with the most room, can be sized in every direction, and closes on an outside click or the Escape key. It opens on a click or on hover, carries the menu-button semantics and the keyboard that goes with them, can keep the focus inside itself while it is open or close itself as soon as its content is clicked, and turns into a swipeable side panel on small screens. The button itself comes in the filled, outlined and text variants of every color of the library, in three sizes.

Usage

Every example is live. Open its code to see exactly what produced the component running underneath.

Basic

The Text parameter labels the button and the content of the component becomes the body of the callout. IsEnabled turns the whole drop menu off, down to the Open and Toggle methods, and closes a callout that was already open. Transparent drops the background of the button, NoShadow drops the box-shadow of the callout, and FullWidth stretches the button to the available width.

Quick settings

Quick settings

Quick settings

Quick settings

Quick settings

Background

Use the Background parameter to set the background color kind of the callout body. Transparent leaves the callout without a surface of its own, which is what you want when the content already paints one.

Background color kind

Quick settings

Border

Use the Border parameter to draw a border around the callout in the given color kind. It pairs well with NoShadow when a flat, outlined callout fits the design better than an elevated one, which is how the example below is set up so the border stands out.

Border color kind

Quick settings

Icon

IconName puts a leading icon in the button and ChevronDownIconName replaces the trailing chevron, which flips over while the callout is open. Set NoChevron to drop the chevron entirely, for example when the button is icon-only.


Filters

Jane Cooper

Product designer


Responsive

With Responsive, the callout becomes a panel on small screens (under 600px) that slides in from the edge given by PanelPosition and is swiped away along the same axis it slid in on: sideways for Start and End, up or down for Top and Bottom. Point ScrollContainerId at the scrollable element inside the content so the swipe gesture does not fight its scrolling. Resize the window to see it.

A list that scrolls inside the panel

A list that scrolls inside the panel

Swipe up to dismiss it

Swipe down to dismiss it

Template

Template replaces everything inside the button, including the icon, the text and the chevron, so the trigger can be anything. The callout content then goes into Body, which is an alias of ChildContent.

Flight BA 117

Departs 18:40 from gate B22

Loading

IsLoading swaps the icon of the button for a spinner, marks the button busy for the screen readers and blocks the callout from opening, which is what you want while the content of the menu is still being fetched. A callout that is already open is closed, so the content on the screen never outlives the data behind it, and the button wears the look of a disabled one for as long as it lasts rather than repainting under a pointer whose clicks it no longer answers.


Cloud sync

Last synced 5 minutes ago

Sizing the callout

By default the callout is exactly as large as its content needs. Width, MinWidth and MaxWidth size it with any CSS length: a minimum keeps a short menu from ending up cramped and a maximum makes a long text wrap instead of stretching across the screen. MatchWidth grows the callout to at least the width of the button, so a wide trigger never sits above a narrow menu, and it is applied after the callout is measured, which is why it wins over Width. MaxHeight caps the height and scrolls the content past that point, which keeps a long list usable. Without one, the callout is capped to the room the viewport leaves and scrolls on its own, so content taller than the screen never ends up out of reach below it; a MaxHeight takes that automatic cap over and is itself kept within the height of the screen, so a cap set taller than the shortest screen you target still leaves the callout scrolling inside the viewport rather than running off it.

MatchWidth

A callout of a fixed width

Short

A rather long piece of content that wraps instead of stretching the callout across the screen

Item 21
Item 21
Item 21
Item 21
Item 21
Item 21
Item 21
Item 21
Item 21
Item 21
Item 21
Item 21
Item 21
Item 21
Item 21
Item 21
Item 21
Item 21
Item 21
Item 21

DropDirection

The callout picks its side from the room left around the button. TopAndBottom (the default) only ever drops it above or below, while All also allows the sides when neither fits vertically. The menu below is deliberately long, so scroll the page until the button sits around the middle of the window, where neither the space above it nor the one below it can take the whole callout: All then moves the menu to the side of the button, while TopAndBottom keeps it above or below and scrolls its content.

Drop direction

Categories

Open on hover

OpenOnHover opens the callout as soon as the pointer reaches the drop menu and closes it once the pointer leaves both the button and the callout, which is what a navigation menu is usually expected to do. HoverOpenDelay keeps a pointer that is only passing by from opening it, and HoverCloseDelay (150ms by default) bridges the gap between the button and the callout so that moving from one to the other does not close what the pointer is on its way to. The mode turns itself off on touch screens, where there is no pointer to hover with, and the button keeps toggling the callout on a click either way, so the keyboard is never left without a way in.


Opens after 400ms, closes after 600ms
Documentation Release notes

Binding

IsOpen is two-way bindable, so the open state can be driven from outside the component and read back from it. DefaultIsOpen covers the uncontrolled case, where the callout only needs to start out open. The Open, Close and Toggle methods do the same through a component reference.


Filters



Keyboard & focus

The button carries the full menu-button semantics (aria-haspopup, aria-controls and aria-expanded), opens on Enter, Space, ArrowDown or ArrowUp, and closes on Escape. Every one of those keys hands the focus straight to the content, unlike a click, which leaves it on the button, and the arrow keys reach the content of an already open callout too. Tab off the button closes the callout and carries on through the page, and whenever the callout is closed while the focus is inside it the focus goes back to the button, so the keyboard never ends up at the top of the page. A click puts the focus on the button whichever browser dispatched it, so Escape reaches a menu opened with the pointer as well.

AutoFocus moves the focus into the callout as soon as it opens, to its first focusable element, so a pointer user reaches the content without an extra Tab too. TrapFocus goes further and keeps the keyboard inside: Tab and Shift+Tab cycle within the callout instead of running on into the page behind it, and the callout reports itself as a modal dialog to the screen readers. It is what a callout hosting a form or a filter panel needs, and it implies AutoFocus.

AriaLabel names the button for the screen readers where the visible text does not, which is the case of an icon-only drop menu, AriaDescription points at the id of an element describing it further, and AriaHidden takes the button out of the accessibility tree entirely, for the cases where something else already conveys it.


Events

OnClick fires on every activation of the button, OnOpen when the callout opens and OnDismiss when it closes, no matter how: an outside click, the Escape key, a swipe on a responsive panel, or another callout taking over.


Clicked: 0, Opened: 0, Dismissed: 0

Auto close

AutoClose closes the callout as soon as a click lands anywhere inside it, which is what an action list is expected to do: picking an item completes the interaction. It is off by default, so that a callout hosting a form, a filter panel or anything else that is used before it is dismissed stays open while the user works in it. The focus follows the callout back to the button, so a keyboard user carries on from the trigger they left.


Variant

Variant decides how the Color is painted onto the button: Fill is the default look, a solid surface in that color; Outline keeps the surface clear and draws the color as a border and as the label; Text drops the border too and leaves only the label. Outline and Text write the accent colors onto the page in their own color rather than in the contrast color a filled button needs, so a colored drop menu stays readable without a surface behind it. Transparent is the shorthand for a button with no surface at all, in any variant, and it keeps that background on hover as well.

Variant

Color

Color paints the button with one of the general colors of the library. The accent colors give a filled button with a matching text color, and the background, foreground and border colors give the neutral surfaces. Pair it with Variant to get the outlined and text-only looks of the same color.

Color

Jane Cooper

Product designer

External Icons

Use icons from external libraries like FontAwesome, Material Icons, and Bootstrap Icons with the Icon and ChevronDownIcon parameters.

For details on BitIconInfo and its factory methods (BitIconInfo.Css, BitIconInfo.Fa, BitIconInfo.Bi), see the BitIconInfo section in the parameters table. Built-in Fluent UI icons are documented at Iconography.


FontAwesome:



Favorites






Bootstrap Icons:



Settings

Size

Size scales the font and the padding of the button together, from Small through Medium (the default) to Large. The callout is not scaled, since its size comes from its content.

Filters

Filters

Filters

Style & Class

Style and Class land on the root element, while Styles and Classes reach every part of the component on their own: the root, the button, the spinner, the icon, the text, the chevron, the overlay, the callout, and the Opened slot that only applies while the callout is open. The root carries the border of the drop menu, so a border color set here paints one in any variant.


Component's Style & Class:






Styles & Classes:


RTL

Use Dir to render the drop menu right-to-left. The button mirrors its icon and chevron, the callout is anchored from the right edge of the button, and a responsive panel slides in from the mirrored side and is swiped away in the mirrored direction.

جین کوپر

طراح محصول


لیستی که داخل پنل اسکرول می شود

لیستی که داخل پنل اسکرول می شود

API

Every parameter, public member, sub-class and enum this component exposes.

BitDropMenu parameters

Name Type Default value Description
AriaDescription string? null The description of the drop menu for the benefit of screen readers, rendered as the aria-describedby of the button.
AriaHidden bool false If true, adds an aria-hidden attribute instructing screen readers to ignore the button of the drop menu.
AutoClose bool false Closes the callout as soon as a click lands anywhere inside it, which is what an action list is expected to do: picking an item completes the interaction. It is off by default, since a callout hosting a form or a filter panel is meant to stay open while it is being used.
AutoFocus bool false Moves the focus into the callout as soon as it opens, to its first focusable element, or to the callout itself when it holds none.
Background BitColorKind? null The color kind of the background of the callout of the drop menu.
Body RenderFragment? null Alias of the ChildContent.
Border BitColorKind? null The color kind of the border of the callout of the drop menu.
ChevronDownIcon BitIconInfo? null The icon for the chevron down part of the drop menu using custom CSS classes for external icon libraries. Takes precedence over ChevronDownIconName when both are set.
ChevronDownIconName string? null The icon name for the chevron down part of the drop menu from the built-in Fluent UI icons. For external icon libraries, use ChevronDownIcon instead.
ChildContent RenderFragment? null The content of the callout of the drop menu.
Classes BitDropMenuClassStyles? null Custom CSS classes for different parts of the drop menu.
Color BitColor? null The general color of the button of the drop menu.
DefaultIsOpen bool? null The initial opening state of the callout in the uncontrolled mode, which is when the IsOpen parameter is not set.
DropDirection BitDropDirection BitDropDirection.TopAndBottom Determines the allowed drop directions of the callout of the drop menu.
FullWidth bool false Expands the drop menu width to 100% of the available width.
HoverCloseDelay int 150 The delay in milliseconds before the callout closes once the pointer leaves the drop menu in the OpenOnHover mode. It bridges the gap between the button and the callout, so moving the pointer from one to the other does not close what the pointer is on its way to.
HoverOpenDelay int 0 The delay in milliseconds before the callout opens once the pointer enters the drop menu in the OpenOnHover mode, so that passing over the button on the way somewhere else does not open it.
Icon BitIconInfo? null The icon to display inside the header using custom CSS classes for external icon libraries. Takes precedence over IconName when both are set.
IconName string? null The name of the icon to display inside the header from the built-in Fluent UI icons. For external icon libraries, use Icon instead.
IsLoading bool false Determines whether the drop menu is in the loading state. It replaces the icon of the button with a spinner and disables the button, so the callout can no longer be opened by the user or by the Open and Toggle methods, and a callout that is already open is closed.
IsOpen bool false Determines the opening state of the callout of the drop menu.
MatchWidth bool false Expands the callout of the drop menu to at least the width of the button of the drop menu. It is applied after the callout is measured, so it takes precedence over Width.
MaxHeight string? null The maximum height of the callout of the drop menu as a CSS value (e.g. "20rem"), beyond which its content scrolls. It takes over from the automatic cap that otherwise keeps the callout within the room the viewport leaves, so it should stay within what the shortest screen the drop menu is used on can show.
MaxWidth string? null The maximum width of the callout of the drop menu as a CSS value (e.g. "20rem"), beyond which its content wraps.
MinWidth string? null The minimum width of the callout of the drop menu as a CSS value (e.g. "20rem"), so that a narrow content does not end up in a cramped callout.
NoChevron bool false Removes the chevron-down icon from the button of the drop menu.
NoShadow bool false Removes the box-shadow from the callout of the drop menu.
OnClick EventCallback The callback is called when the drop menu is clicked.
OnDismiss EventCallback The callback is called when the drop menu is dismissed.
OnOpen EventCallback The callback is called when the callout of the drop menu is opened.
OpenOnHover bool false Opens the callout when the pointer enters the drop menu and closes it when the pointer leaves it, which is what a navigation menu is usually expected to do. The button keeps toggling the callout on a click, so the keyboard and the touch screens - where hovering does not exist and this mode turns itself off - are left with a way to reach it.
PanelPosition BitPanelPosition? null The position of the responsive panel to show on the screen.
Responsive bool false Renders the drop menu in responsive mode on small screens.
ScrollContainerId string? null The id of the element which needs to be scrollable in the content of the callout of the drop menu.
Size BitSize? null The size of the button of the drop menu.
Styles BitDropMenuClassStyles? null Custom CSS styles for different parts of the drop menu.
Template RenderFragment? null The custom content to render inside the header of the drop menu.
Text string? null The text to show inside the header of the drop menu.
Title string? null The tooltip to show when the mouse is placed on the button of the drop menu.
Transparent bool false Makes the background of the header of the drop menu transparent.
TrapFocus bool false Keeps the keyboard inside the callout while it is open: the focus moves into it as it opens, Tab and Shift+Tab cycle within it instead of running on into the page behind it, and the callout reports itself as a modal dialog to the screen readers. It implies AutoFocus.
Variant BitVariant? null The visual variant of the button of the drop menu: filled (the default look), outlined, or text only. It decides how the Color is painted onto the button, so the two are set together.
Width string? null The width of the callout of the drop menu as a CSS value (e.g. "20rem"). By default the callout is only as wide as its content needs. MatchWidth takes precedence over it.

BitDropMenu public members

Name Type Default value Description
Open () => Task Opens the callout of the drop menu programmatically, unless the drop menu is disabled or loading.
Close () => Task Closes the callout of the drop menu programmatically.
Toggle () => Task Toggles the callout of the drop menu programmatically.

BitComponentBase parameters

Name Type Default value Description
AriaLabel string? null Gets or sets the accessible label for the component, used by assistive technologies.
Class string? null Gets or sets the CSS class name(s) to apply to the rendered element.
Dir BitDir? null Gets or sets the text directionality for the component's content.
ForceAnimation bool false Gets or sets a value indicating whether the component's animations play at their full duration even when reduced motion is requested.
HtmlAttributes Dictionary<string, object> new Dictionary<string, object>() Captures additional HTML attributes to be applied to the rendered element, in addition to the component's parameters.
Id string? null Gets or sets the unique identifier for the component's root element.
IsEnabled bool true Gets or sets a value indicating whether the component is enabled and can respond to user interaction.
Style string? null Gets or sets the CSS style string to apply to the rendered element.
TabIndex string? null Gets or sets the tab order index for the component when navigating with the keyboard.
Visibility BitVisibility BitVisibility.Visible Gets or sets the visibility state (visible, hidden, or collapsed) of the component.

BitComponentBase public members

Name Type Default value Description
UniqueId Guid Guid.NewGuid() Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed.
RootElement ElementReference Gets the reference to the root HTML element associated with this component.

BitDropMenuClassStyles properties

Name Type Default value Description
Root string? null Custom CSS classes/styles for the root element of the BitDropMenu.
Opened string? null Custom CSS classes/styles for the root element of the BitDropMenu while its callout is open, applied on top of the Root ones.
Button string? null Custom CSS classes/styles for the button of the BitDropMenu.
Spinner string? null Custom CSS classes/styles for the loading spinner of the BitDropMenu.
Icon string? null Custom CSS classes/styles for the icon of the BitDropMenu.
Text string? null Custom CSS classes/styles for the text of the BitDropMenu.
ChevronDown string? null Custom CSS classes/styles for the chevron-down icon of the BitDropMenu.
Overlay string? null Custom CSS classes/styles for the overlay of the BitDropMenu.
Callout string? null Custom CSS classes/styles for the callout of the BitDropMenu.

BitIconInfo properties

Name Type Default value Description
Name string? null Gets or sets the name of the icon.
BaseClass string? null Gets or sets the base CSS class for the icon. For built-in Fluent UI icons, this defaults to "bit-icon". For external icon libraries like FontAwesome, you might set this to "fa" or leave empty.
Prefix string? null Gets or sets the CSS class prefix used before the icon name. For built-in Fluent UI icons, this defaults to "bit-icon--". For external icon libraries, you might set this to "fa-" or leave empty.

BitColor enum

Name Value Description
Primary 0 Primary general color.
Secondary 1 Secondary general color.
Tertiary 2 Tertiary general color.
Info 3 Info general color.
Success 4 Success general color.
Warning 5 Warning general color.
SevereWarning 6 SevereWarning general color.
Error 7 Error general color.
PrimaryBackground 8 Primary background color.
SecondaryBackground 9 Secondary background color.
TertiaryBackground 10 Tertiary background color.
PrimaryForeground 11 Primary foreground color.
SecondaryForeground 12 Secondary foreground color.
TertiaryForeground 13 Tertiary foreground color.
PrimaryBorder 14 Primary border color.
SecondaryBorder 15 Secondary border color.
TertiaryBorder 16 Tertiary border color.

BitColorKind enum

Name Value Description
Primary 0 The primary color kind.
Secondary 1 The secondary color kind.
Tertiary 2 The tertiary color kind.
Transparent 3 The transparent color kind.

BitDropDirection enum

Name Value Description
All 0 The direction determined automatically based on the available spaces in all directions.
TopAndBottom 1 The direction determined automatically based on the available spaces in only top and bottom directions.

BitPanelPosition enum

Name Value Description
Start 0 The panel is positioned at the start edge (left in LTR).
End 1 The panel is positioned at the end edge (right in LTR).
Top 2 The panel is positioned at the top edge.
Bottom 3 The panel is positioned at the bottom edge.

BitSize enum

Name Value Description
Small 0 The small size.
Medium 1 The medium size.
Large 2 The large size.

BitVariant enum

Name Value Description
Fill 0 Fill styled variant.
Outline 1 Outline styled variant.
Text 2 Text styled variant.

BitVisibility enum

Name Value Description
Visible 0 The content of the component is visible.
Hidden 1 The content of the component is hidden, but the space it takes on the page remains (visibility:hidden).
Collapsed 2 The component is hidden (display:none).

BitDir enum

Name Value Description
Ltr 0 Ltr (left to right) is to be used for languages that are written from the left to the right (like English).
Rtl 1 Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic).
Auto 2 Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element.

Feedback

Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.