This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Tooltip
用于在长按时显示上下文信息的 Jetpack Compose Tooltip 组件。
Expo UI Tooltip 与官方 Jetpack Compose Tooltip 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.