DropdownWrapper is a container component that handles the positioning and state management of dropdown menus. It provides a flexible way to create custom dropdown interfaces with various trigger elements and dropdown contents. It supports keyboard navigation when used with Option components.
A simple dropdown with a button trigger and custom content.
Control the placement of the dropdown relative to its trigger element.
Control the dimensions of the dropdown menu.
A panel opens on the option marked aria-selected="true", scrolled into view inside the panel, the way a native select opens on the value it is already showing. Option sets that attribute from its selected prop, so a list built from Option needs nothing further. With no selection the panel opens on its first enabled option; a selected option that is disabled is skipped.
A panel that leads with something other than its list — a searchable Select and its query field — opens on that instead.
A Button or IconButton passed as the trigger renders a real <button type="button"> with aria-haspopup and aria-expanded, so the dropdown opens from the keyboard as well as the mouse. There is no need to add type="button" or an empty onClick to make it one. A disabled trigger does not open the dropdown.