This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 57).
工具提示
用于在长按时显示上下文信息的 Jetpack Compose 工具提示组件。
Expo UI 提示框与官方 Jetpack Compose 提示框 API 保持一致。TooltipBox 包裹锚点内容并显示提示框。提示框内容通过 TooltipBox.PlainTooltip 或 TooltipBox.RichTooltip 组合组件提供,分别对应 PlainTooltip 和 RichTooltip。提示框可以通过长按触发,或通过 ref 以编程方式显示。


安装
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
简单提示框
长按锚点内容以显示提示框。
带标题和正文的富提示框
使用 TooltipBox.RichTooltip 与 Title 和 Text 组合组件模式,以提供更详细的上下文信息。
带操作的富提示框
使用 TooltipBox.RichTooltip.Action 添加一个可交互操作。使用 isPersistent 让提示框保持可见,方便用户点击。只要存在操作槽位,hasAction 就会自动推导。
以编程方式显示和关闭
使用 ref 可以不依赖长按,直接命令式调用 show() 或 dismiss() 来控制提示框。
API
import { TooltipBox } from '@expo/ui/jetpack-compose';
Component
Type: React.Element<TooltipBoxProps>
A container that wraps anchor content and shows a tooltip on long-press.
Provide the tooltip content via TooltipBox.PlainTooltip or TooltipBox.RichTooltip.
All other children are the anchor/trigger.
Use ref to imperatively show() or dismiss() the tooltip.
ReactNodeChildren containing a TooltipBox.PlainTooltip or TooltipBox.RichTooltip slot and the anchor/trigger content.
The anchor content triggers the tooltip on long-press.
boolean • Default: trueWhether user input (long-press, hover) triggers the tooltip.
booleanWhether the tooltip contains an action. Affects accessibility and dismiss behavior.
When not specified, this is automatically derived from the presence of a RichTooltip.Action slot.
boolean • Default: falseWhether the tooltip persists instead of auto-dismissing after a short timeout.