Blazor Dropdown Overview
The Blazor Dropdown is a component, which displays a toggleable list of predefined values and allows users to easily select a single option item with a click. It can be quickly configured to act as a dropdown menu or you can simply use it to deliver more useful visual information by grouping data. With grouping you can use both flat and hierarchical data.
Blazor Dropdown Example
Before using the
IgbDropdown, you need to register it as follows:
The Dropdown list is positioned relatively to its target. The
target slot allows you to provide a built-in component which toggles the
open property on click. In some cases you would want to use an external target or use another event to toggle the opening of the Dropdown. You can achieve this using the
Toggle methods which allow you to provide the target as a parameter. By default, the Dropdown list uses
absolute CSS position. You will need to set the
PositionStrategy of the Dropdown to
fixed when the target element is inside a fixed container, but the Dropdown is not. The Dropdown list is automatically sized based on its content, if you want the list to have the same width as the target, you should set the
SameWidth property to
The preferred placement of the Dropdown can be set using the
Placement property. The default placement of the Dropdown is
Flip property determines whether the placement should be flipped if there is not enough space to display the Dropdown at the specified placement. The distance from the Dropdown list to its target can be specified using the
IgbDropdownItem represents a selectable item in the Dropdown list. You could predefine a selected item by setting the
Selected property. You could also disable an item so that it can't be selected using the
Disabled property. The
IgbDropdownItem has a default slot which allows you to specify the content of the item. You could also provide custom content to be rendered before or after the content using the
suffix slots. The
Value property allows you to provide a custom value to an item. If the
Value is not set, it resolves to the text content of the item.
You could use the
IgbDropdownHeader to provide a header for a group of items.
The Dropdown items can also be grouped using the
IgbDropdownGroup, making it easier for users to differentiate separate categories.
ScrollStrategy property determines the behavior of the component during scrolling the container of the target element. The default value is
scroll which means that the Dropdown will be scrolled with its target. Setting the property to
block will block the scrolling if the Dropdown is opened. You could also set the property to
close which means that the Dropdown will be closed automatically on scroll.
By default, the Dropdown is closed automatically when the user clicks outside of it or selects an item. You could prevent this behavior using the
You can change the appearance of the Dropdown and its items, by using the exposed CSS parts. The
list parts, the
suffix parts and the