百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
U

universal-tooltip

> 前端框架
开源

本地行为的跨平台工具提示组件。

193 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

本地行为的跨平台工具提示组件。

typescript
import { Tooltip, Popover, Toast, useToastManager } from "poppo";
Opens on For
Tooltip hover (web) · press (native) short hints — the content is a label, not a surface
Popover click / press interactive content — buttons inside work on every platform
Toast imperatively, via a manager notifications — queued or replaced, de-duplicated, pausable

All three are unstyled. You bring the look; poppo handles anchoring, presentation, scheduling and the platform differences underneath.

Why poppo

  • Native popup windows, not absolutely-positioned views. On iOS the bubble is a UIKit overlay on the window; on Android it is a Balloon-hosted window. It is never clipped by a scroll view or a parent with overflow: hidden, and it never fights the z-order of whatever is behind it.
  • Popover content is really interactive. Buttons, gestures and text inputs inside the bubble work, through the same touch-dispatch mechanism React Native's own Modal uses.
  • One component set for three platforms. Web wraps Base UI's Tooltip and Popover, so you get its positioning, focus handling and accessibility for free — and the same JSX runs on native.
  • A toast manager built for phones. Visible limit with a queue or replace overflow policy, one-toast-per-id de-duplication, and countdowns that pause while the toast is under a finger or the app is in the background. Toasts stack the way sonner's do — the newest in front, the ones behind scaled back and dimmed — and the stack drains from the back, so a burst of taps does not mean waiting out every timeout. On iOS the viewport can own a window, so a toast raised from inside a Modal shows above it instead of behind it.
  • Animations and gestures on the UI thread. Toast enter/exit, the stack reflow and swipe-to-dismiss all run through Reanimated and Gesture Handler, so a busy JS thread cannot stutter them.

Install

bash
npx expo install poppo

Toasts need Reanimated and Gesture Handler:

bash
npx expo install react-native-reanimated react-native-gesture-handler

and Gesture Handler has to wrap your app once, at the root:

typescript
import { GestureHandlerRootView } from "react-native-gesture-handler";

  
;

Web additionally needs the Base UI peer dependency:

bash
yarn add @base-ui/react

Expo SDK 53+ default build settings already satisfy the native requirements (iOS 16.4+, Swift 5.9). No expo-build-properties configuration is needed. The native module is autolinked; there is nothing to register.

Quick start

Tooltip

typescript
import { Tooltip } from "poppo";
import { Text } from "react-native";

  
    Hover me
  
  
    
      
        Saved to your library
        
      
    
  
;

Popover

Same parts, one word changed — and now the content can hold a button:

typescript
import { Popover } from "poppo";
import { Pressable, Text, View } from "react-native";

  
    Remove
  
  
    
      
        
          Remove download?
          
            Remove
          
        
        
      
    
  
;

Both are uncontrolled by default. Pass open to drive one yourself, and pair it with onOpenChange so the popup can still close itself:

typescript
const [open, setOpen] = useState(false);

  {/* ... */}
;

Toast

Wrap the app once, render the visible toasts inside a viewport, then call add from anywhere below the provider:

typescript
import { Toast, useToastManager } from "poppo";
import { useSafeAreaInsets } from "react-native-safe-area-context";

function Toasts() {
  const { toasts } = useToastManager();
  return (
    
      {toasts.map((toast) => (
        
          
          
          
            Dismiss
          
        
      ))}
    
  );
}

export default function App() {
  return (
    
      
      
    
  );
}

// anywhere below the provider
const toast = useToastManager();
toast.add({ title: "Saved", description: "Your booking was updated" });

Toast.Root handles the enter/exit animation, swipe-to-dismiss and pausing the countdown while it is touched. Everything inside it is yours.

Anatomy

Tooltip and Popover expose the same six parts:

                     open state
                what you press or hover
                   renders outside the parent
               side and offset
                    the bubble
        

The parts are read from the elements you write inside Root, so they cannot be wrapped in a component of your own — React has not rendered `` yet, so there is nothing to read. Fragments and conditionals are fine, and in development Root warns if it cannot find a Popup.

Toast is a provider plus parts you compose per toast:

           the manager: timeout, limit, overflow
           where toasts stack; position, insets, presentation
               one toast: animation, swipe, pause-on-touch
      
      
       · 

API — Tooltip and Popover

Props marked web are accepted everywhere but only take effect on web, and vice versa.

Root

Prop Type Notes
open boolean Controlled open state.
defaultOpen boolean Uncontrolled initial state.
onOpenChange (open: boolean) => void
onDismiss () => void Fires when the popup closes.
disableDismissWhenTouchOutside boolean native — keep it open on an outside press.
modal boolean web, popover only — trap focus.

Trigger

Accepts every Pressable prop. On native it renders a Pressable and toggles the popup on press.

Prop Type Notes
disabled boolean
delay number web, tooltip only — hover-open delay, ms.
closeDelay number web, tooltip only — hover-close delay, ms.

Portal

Prop Type Notes
container HTMLElement | null web — where to portal into.

Positioner

Prop Type Notes
side "top" | "right" | "bottom" | "left" Defaults to "top".
sideOffset number Distance from the trigger.
align "start" | "center" | "end" web

Popup

Accepts every View prop.

Prop Type Notes
style ViewStyle & TextStyle See Styling.
presetAnimation "none" | "fadeIn" | "zoomIn"
showDuration number iOS — ms.
dismissDuration number iOS — ms.
disableTapToDismiss boolean native — keep a tooltip open when its bubble is pressed.
onTap () => void native — fires when a tooltip's bubble is pressed.
className string web

Arrow

Prop Type Notes
width number
height number
backgroundColor string Defaults to the popup's style.backgroundColor. A natively drawn text bubble is one shape, so there it is the popup's colour that wins.
className string web

API — Toast

Toast.Provider

Creates the manager, or accepts one you made with createToastManager() via toastManager (useful for calling add from outside React).

Prop Type Default Notes
timeout number 5000 Auto-dismiss, ms. 0 keeps toasts until closed.
limit number Infinity How many toasts the manager keeps live. Nothing is held back by default — how many are drawn is Toast.Root's maxVisible.
overflow "queue" | "replace" "queue" What happens to the next toast once limit is reached. See Scheduling.
demotedTimeout number 2000 Ceiling on what a toast has left once a newer one pushes it back in the stack. Only ever shortens.
toastManager ToastManager An external manager; the props above are ignored when it is given.

useToastManager()

Returns the visible toasts plus the three calls a screen needs:

Notes
toasts ToastObject[], newest first. Queued toasts are not included until they are promoted.
add(options) Shows a toast and returns its id. Calling it again with the same id updates that toast and restarts its timer instead of stacking a duplicate.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptexpo-modulesreact-nativereact-native-tooltip

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架