SwipeUI
DocsGuides

Overlay recipes

Copyable compositions for sheets, actions, routed modals and a Spotlight Tour.

Install and place providers

Install the component you need and its registry dependencies. Keep one OverlayProvider above the navigator, inside the safe-area provider. For attached sheets place SheetProvider inside the gesture root. A system modal has a separate window. Use NativeModalContent around its screen or place an OverlayScope around a custom screen body.

Filter with a draft

function RouteFilters({ value, onApply }: { value: string; onApply: (value: string) => void }) {
  const [open, setOpen] = useState(false);
  const [draft, setDraft] = useState(value);
  return (
    <>
      <Button onPress={() => { setDraft(value); setOpen(true); }}>Filter routes</Button>
      <Sheet presentation="attached" open={open} onOpenChange={setOpen} title="Distance">
        {['Any distance', 'Under 5 km', '5–15 km'].map((option) => (
          <ListRow key={option} title={option} subtitle={draft === option ? 'Selected' : undefined}
            onPress={() => setDraft(option)} />
        ))}
        <Button onPress={() => { onApply(draft); setOpen(false); }}>Apply filter</Button>
      </Sheet>
    </>
  );
}

Each open starts from the current saved filter. Swipe or tap outside to discard the draft.

Share a route

<Sheet presentation="attached" open={sharing} onOpenChange={setSharing} title="Share Cedar Hollow">
  <CopyButton value={publicLink} />
</Sheet>

Pass a link the app is allowed to share. The user explicitly chooses to copy it.

Quick actions and confirmation

<Menu
  mode="action-sheet"
  triggerLabel="Route actions"
  actions={[{ id: 'pin', label: 'Pin route' }, { id: 'remove', label: 'Remove', destructive: true }]}
  onSelect={(id) => id === 'remove' ? setConfirming(true) : pinRoute()}
/>
<Dialog
  open={confirming}
  onOpenChange={setConfirming}
  title="Remove saved route?"
  primaryActionId="remove"
  actions={[
    { id: 'cancel', label: 'Cancel' },
    { id: 'remove', label: 'Remove', destructive: true, onPress: removeRoute },
  ]}
/>

Return the app's promise from removeRoute so a rejection keeps the confirmation visible. Dismiss a task with its own close or save action. Use separate native-stack routes for linked screens so the navigator owns Back.

// app/_layout.tsx
const presets = useModalPresets();
return (
  <Stack>
    <Stack.Screen name="edit-route" options={presets.pageSheet} />
    <Stack.Screen name="route-notes" />
  </Stack>
);

// Inside edit-route.tsx
<NativeModalContent title="Edit route">
  <Button onPress={() => router.push('/route-notes')}>Edit notes</Button>
</NativeModalContent>

Spotlight Tour

Install spotlight-tour using a SwipeUI Pro licence. Import the installed component and put stable refs on actual rendered views. Keep the tour in the same overlay scope as its targets.

import { useRef, useState } from 'react';
import { View } from 'react-native';
import { Button } from '@/components/swipeui/ui/button';
import { Pressable } from '@/components/swipeui/ui/pressable';
import { Text } from '@/components/swipeui/ui/text';
import { SpotlightTour } from '@/components/swipeui/sheet/spotlight-tour';

export function RouteTour({ onFinished, openSavedRoutes, openFilters }: {
  onFinished: () => void;
  openSavedRoutes: () => void;
  openFilters: () => void;
}) {
  const [open, setOpen] = useState(false);
  const [step, setStep] = useState(0);
  const launch = useRef<View>(null);
  const saved = useRef<View>(null);
  const filters = useRef<View>(null);

  return (
    <View>
      <Pressable ref={launch} onPress={() => { setStep(0); setOpen(true); }}>
        <Text>Start tour</Text>
      </Pressable>
      <View ref={saved} collapsable={false}><Button onPress={openSavedRoutes}>Saved routes</Button></View>
      <View ref={filters} collapsable={false}><Button onPress={openFilters}>Filters</Button></View>
      <SpotlightTour
        open={open}
        onOpenChange={setOpen}
        step={step}
        onStepChange={setStep}
        returnFocusRef={launch}
        onComplete={onFinished}
        steps={[
          { id: 'saved', target: saved, title: 'Saved routes', description: 'Find your bookmarked walks.' },
          { id: 'filters', target: filters, title: 'Filters', description: 'Narrow routes by distance.' },
        ]}
      />
    </View>
  );

}

Keep target IDs stable. Render targets before opening the tour. When a target is unavailable, the panel offers Try again and Next or Finish. If the app scrolls a target into view, retry after layout. Closing returns focus to the launch area. Finish is the only action that calls onComplete. See the Spotlight Tour API for the full settings.

Single-screen and routed tours

Use Popover's controlled open, anchor, side and align when a step only needs a callout. The app can store a small record with the tour ID, current step ID, completed step IDs and whether the user skipped or finished. Use the app's existing store when several routes need that state. For a single screen, local state is enough.

Describe each step with a route, a stable target ID, placement and alignment. For a routed step, close the previous callout, navigate with the app router, then reopen only after the new screen is focused and its target has mounted. Store IDs in persistent progress and keep view refs in the mounted screen. If a target is missing, offer retry or skip. Apply a backdrop only for a step that must hold attention or block interaction.

On this page