This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
工具提示
用于在长按时显示上下文信息的 Jetpack Compose 工具提示组件。
Expo UI Tooltip 与官方的 Jetpack Compose Tooltip API 保持一致。TooltipBox 包裹锚点内容并显示提示。提示内容通过 TooltipBox.PlainTooltip 或 TooltipBox.RichTooltip 复合组件提供,它们分别对应 PlainTooltip 和 RichTooltip。Tooltip 可以通过长按触发,也可以通过 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.