DropdownWrapper opens a menu next to its trigger. It measures the trigger on screen and draws the menu in a transparent modal over everything else, under the trigger by default. If there is no room below, the menu opens above. Pressing outside the menu or the back button closes it. The menu is a Dropdown, the bordered surface, and its items are usually Options. See the web DropdownWrapper page for the web version.
Pass the trigger and the menu's content. The wrapper keeps its own open state. Pressing an Option calls onSelect with its value and closes the menu.
Pass open and onOpenChange to control the menu. selectedOption marks the Option with that value as selected, unless the option sets selected itself.
placement picks the side of the trigger and the edge the menu lines up with. It defaults to "bottom-start". fillWidth stretches the trigger and gives the menu its width. minWidth and maxWidth are in rem, as on the web. With closeAfterClick={false} the menu stays open after a pick.
- The menu is drawn in a transparent React Native Modal, placed with measureInWindow. It is placed when it opens and does not follow the trigger if the screen scrolls underneath it.
- onSelect, selectedOption and closeAfterClick reach every Option written in dropdown, also inside fragments and layout elements such as Column. They do not reach options rendered inside a component of your own, or other elements with a data-value: handle those with open and onOpenChange.
- A trigger that is pressable itself, such as a Button, keeps its own onPress; the wrapper adds its toggle after it. A screen reader reads the trigger as one button that opens a menu.
- isOpen is accepted as another name for open.
- There is no keyboard or arrow navigation, so handleArrowNavigation, navigationLayout, columns, optionsCount and dropdownId are not available. There is no nested mode, no onFocusCapture or onBlurCapture, and no className.
- The web's Dropdown is a row around a column; the native one is a column that scrolls when the screen holds it short.