本地行为的跨平台工具提示组件。
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.
overflow: hidden, and it never
fights the z-order of whatever is behind it.Modal uses.Tooltip and
Popover, so you get its positioning, focus handling and accessibility for
free — and the same JSX runs on native.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.npx expo install poppoToasts need Reanimated and Gesture Handler:
npx expo install react-native-reanimated react-native-gesture-handlerand Gesture Handler has to wrap your app once, at the root:
import { GestureHandlerRootView } from "react-native-gesture-handler";
;Web additionally needs the Base UI peer dependency:
yarn add @base-ui/reactExpo 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.
import { Tooltip } from "poppo";
import { Text } from "react-native";
Hover me
Saved to your library
;Same parts, one word changed — and now the content can hold a button:
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:
const [open, setOpen] = useState(false);
{/* ... */}
;Wrap the app once, render the visible toasts inside a viewport, then call
add from anywhere below the provider:
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.
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
· 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. |
TriggerAccepts 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 |
PopupAccepts 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 |
Toast.ProviderCreates 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,或尚未同步最近议题。