This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
DropdownMenu
用于显示下拉菜单的 Jetpack Compose DropdownMenu 组件。
Expo UI DropdownMenu 与官方 Jetpack Compose Menu API 相匹配,并会在按下触发元素时显示下拉菜单。


安装
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
基本下拉菜单
将 React Native 组件用作触发元素
你可以将 React Native 视图(例如 Pressable)包裹在 RNHostView 中,作为下拉菜单的触发元素。
长按触发
Jetpack Compose 没有专用的长按菜单原语——你可以在触发视图上使用 combinedClickable 修饰符,并配合现有的受控 DropdownMenu 来组合实现。菜单会自动锚定到触发元素。
圆角
使用 cornerRadius 自定义圆角半径(单位为 dp),以覆盖默认的 Material3 菜单形状。
阴影高度
使用 shadowElevation 设置弹出菜单的阴影高度,单位为 dp。将其设为 0 可移除阴影;省略该属性则使用 Material 3 的默认值。应用于 DropdownMenu 的修饰符会作用于触发元素容器,因此阴影修饰符不会改变弹出菜单的阴影。
API
import { DropdownMenu } from '@expo/ui/jetpack-compose';
Components
Type: React.Element<DropdownMenuProps>
Props of the DropdownMenu component.
ReactNodeThe contents of the submenu are used as an anchor for the dropdown menu. The children will be wrapped in a pressable element, which triggers opening of the dropdown menu.
numberCorner radius in dp for the dropdown menu container. Defaults to the Material3
MenuDefaults.shape corner radius.
() => voidCallback fired when the menu requests to be dismissed (e.g. tapping outside).
Must be provided when expanded is true to allow the menu to close.
numberShadow elevation of the dropdown menu popup in dp. Set to 0 to remove the shadow.
Defaults to Material3's MenuDefaults.ShadowElevation.
Type: React.Element<DropdownMenuItemProps>
A dropdown menu item component that wraps Compose's DropdownMenuItem.
Should be used inside DropdownMenu.Items or ExposedDropdownMenu.
Type: React.Element<{
children: ReactNode
}>
Container for items displayed in the dropdown menu.
Children should be DropdownMenuItem components or other native views.