Dropdown
Dropdown is a flexible family of components for displaying menus, popovers, and other floating content.
It supports placement, strategy, manual and automatic opening, and more.
Dropdown is a flexible family of components for displaying menus, popovers, and other floating content.
It supports placement, strategy, manual and automatic opening, and more.
The Dropdown components include the following:
DropdownContent.DropdownButton.The Dropdown component is the wrapper. Its props control appearance and behavior.
| Dropdown Props | Type | Description |
|---|---|---|
open | boolean | |
placement | string | Sets the side on which the dropdown will open. Options: - |
strategy | string | Determines the |
auto-focus | boolean | Enables a focus trap inside of the |
hover | boolean | Opens the dropdown on mouseover. Closes on mouseout. |
| delay-enter | number | Changes the hover wait time before the Dropdown opens. default: 0. |
| delay-leave | number | Changes the mouseout wait time before the Dropdown closes. default: 400. |
close-on-click-outside | boolean | Closes the dropdown when clicking outside of the element. |
random-id | string | Allows manually specifying the internal random id. This is required for SSR. |
| Dropdown Events | Arguments | Description |
|---|---|---|
update:open |
| Dropdown Slots | Description |
|---|---|
default | The default slot. Must contain a trigger component (like |
| Dropdown Provides | Type | Description |
|---|---|---|
isDropdownOpen | Whether the dropdown is open or closed. | |
dropdownAutoFocus | Whether the dropdown should automatically focus the first element. | |
dropdownId | The unique id of the dropdown. | |
buttonEl | The button element. | |
contentEl | The content element. | |
floatingStyles | The floating styles from floating-ui. | |
toggleDropdown | Toggles the dropdown. | |
openDropdown | Opens the dropdown. | |
closeDropdown | Closes the dropdown. |
shows/hides the DropdownContent.
⚠️ Must be a direct child of the Dropdown element.
is an unstyled alternative to DropdownButton. Use it when you want to style the trigger element to match its siblings.
⚠️ Must be a direct child of the Dropdown element.
contains the content to show when open. Don't style it. Style the child elements instead.
⚠️ Must be a direct child of the Dropdown element.
The default dropdown usage.
Control the open state programmatically.
The Dropdown closes when clicking outside by default. You can disable it by setting close-on-click-outside to false. Then you'll need to click the button to hide the dropdown.
Open the dropdown on hover.
Use delayEnter to set how long to wait before opening on hover. This example waits 1000ms before opening.
Use delayLeave to set how long to wait before closing after hover ends. The default is 300ms. This example waits 0ms before closing.
Use the position attribute to specify top, bottom, left, or right.
Dropdown positioned above the button.
Dropdown positioned to the right of the button.
Dropdown positioned to the left of the button.
Use the strategy prop set to fixed to allow the dropdown to escape its container and be visible even if the parent has overflow-hidden or similar styles.