SwipeUI

Popover

Show interactive details or a short hint by anchoring content to a trigger.

npx @swipeui/cli add popover
Variant
Preset
Material
Scheme
Feel
Real free component with a browser animation bridge. Native motion, haptics and materials need a device.

When to use it

  • Small panels attached to a button, such as a share target picker or a quick setting.
  • Explanations or controls that should appear next to what triggered them.
  • Content that must stay on screen around the keyboard and safe areas.

When not to use it

  • Use Menu for action lists.
  • Use Bottom Sheet for larger content.

Installation

Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.

npx @swipeui/cli add popover
  • Adds components/swipeui/overlay/placement.ts, components/swipeui/overlay/popover.tsx and 11 shared helpers.
  • Installs react-native-safe-area-context, react-native-reanimated, react-native-worklets, uniwind, clsx, tailwind-merge, expo-haptics, class-variance-authority, react-native-gesture-handler. In Expo apps it uses npx expo install so versions match your SDK.

Usage

import { Popover } from '@/components/swipeui/overlay/popover';

<Popover triggerLabel="Trail details" title="Cedar Hollow" width={280}>
  <TrailDetails route={route} />
</Popover>

<Popover triggerLabel="Route visibility" hint="Private routes are visible only to you." />

A hint describes the trigger. It stays non-modal and supports touch hold and web hover or focus. Use the interactive form for buttons, headings or longer content. Pass anchor and returnFocusRef when a caller owns the trigger.

API reference

PropTypeDefaultDescription
triggerLabelstring—

Trigger label, spoken by screen readers and shown when there is no custom trigger.

trigger?ReactNodethe label as text

Custom trigger content, such as an icon; triggerLabel still names it.

anchor?ReactNodeundefined

Your own trigger, such as a field, drawn without Popover's pressable: Popover only anchors to it, and you open it with open. Pass returnFocusRef so focus goes back to it.

returnFocusRef?OverlayFocusRefthe trigger

Where focus returns when the panel closes.

initialFocusRef?OverlayFocusRefthe heading

What takes focus when the panel opens, such as the chosen row of a list.

scrollRef?RefObject<ScrollViewInstance | null>—

The panel's scroll view, for scrolling a chosen row into sight.

triggerClassName?string'px-4 py-3'

Classes for the trigger pressable, replacing its default padding.

title?string—

Heading and initial modal focus.

hint?string—

Short non-interactive help text. Enables hint behavior when supplied.

messages?{ close?: string; }—

Localize the close action for an interactive popover.

showTitle?booleantrue

Shows the title; when hidden it still names the panel for screen readers.

closeButton?"always" | "never" | "screen-reader"'always'

The close button: always, only while a screen reader is on, or never.

closeButtonStyle?"icon" | "text"'text'

Use an accessible corner icon or a text action.

density?"comfortable" | "compact"'comfortable'

Panel spacing: roomy, or tight for menus.

align?PopoverAlign'auto'

Which edge of the trigger the panel lines up with.

side?PopoverSide'auto'

Prefer below the trigger and shrink to available room, or flip automatically.

pointer?boolean—

Draw a pointer toward the trigger with an explicit side.

clearBackdrop?boolean—

Keep the background visible while the popover is open.

maxContentHeight?numberunlimited

Maximum panel height before scrolling.

triggerMotion?MotionOverridemotion

Trigger-only press character, independent of the panel.

onViewportChange?((viewport: PopoverViewport | null) => void)undefined

Reports the placed, clipped window viewport; null while closed or unmeasured.

children?ReactNode—

Body/independent controls.

open?boolean—

Controlled visibility.

defaultOpen?booleanfalse

Initial visibility.

onOpenChange?((open: boolean) => void)—

Reports visibility intent.

activation?"longPress" | "tap"'tap'

Trigger convention.

modal?booleantrue

Modal focus behavior.

closeLabel?string'Close'

Close action label.

width?number | "anchor"320

Preferred width, or anchor to match the trigger's width; clamped to the viewport.

disabled?boolean—

Disable opening.

haptics?boolean—

Press feedback.

motion?MotionOverride—

Shared overlay/press character.

className?string—

Trigger wrapper classes.

presentation?"inline" | "window"'window'

Keep content in this scope's window for held gestures, or use a native modal window.

testID?string—

Root identifier.

Use side="top", "bottom", "left", or "right" to choose a preferred edge, and choose align="start", "center", or "end" independently. Explicit sides keep the panel inside the available screen and may flip when space runs out. Set pointer to draw a marker toward the trigger. Choose closeButtonStyle="icon" for a compact corner action.

Behavior and gestures

  • Tap the trigger (or long-press) to open a panel next to it.
  • The panel flips above or below and stays inside the screen, the safe area and above the keyboard.
  • Tap Close or outside to dismiss it.
  • With a screen reader on, a single activation opens it even in long-press mode.
  • trigger replaces the text trigger with custom content, such as an icon, while triggerLabel still names it; triggerClassName replaces its padding.
  • showTitle, closeButton ('always', 'screen-reader' or 'never'), density ('comfortable' or 'compact') and align ('start', 'end' or 'auto') shape the panel; auto lines it up with the trigger's end edge when the trigger is in the end half of the screen.
  • Hold the trigger on touch, or hover or focus it on the web, to read a non-modal hint.

Accessibility

  • Focus moves to the panel title and returns to the trigger when it closes.
  • In modal mode, focus stays inside until it closes.
  • The trigger reports expanded state and offers an activate action.

Motion

  • Uses the press and overlay motion roles, so it follows your app's feel. Pass motion to tune this one instance.
  • Opens with the overlay role; Reduce Motion fades.

Performance

  • Measures its trigger once per opening and on rotation or keyboard changes.

Notes for AI

  • Wrap the app in OverlayProvider; keep the panel short.
  • Use hint for short non-interactive help instead of a full interactive panel.

Compatibility

Runs onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items