@pgy-eu/react-native-tour-guide 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +993 -2
- package/lib/commonjs/SpotlightOverlay.js +712 -0
- package/lib/commonjs/SpotlightOverlay.js.map +1 -0
- package/lib/commonjs/Tooltip.js +593 -0
- package/lib/commonjs/Tooltip.js.map +1 -0
- package/lib/commonjs/TourGuideContext.js +535 -0
- package/lib/commonjs/TourGuideContext.js.map +1 -0
- package/lib/commonjs/TourGuideOverlay.js +1173 -0
- package/lib/commonjs/TourGuideOverlay.js.map +1 -0
- package/lib/commonjs/TourTarget.js +80 -0
- package/lib/commonjs/TourTarget.js.map +1 -0
- package/lib/commonjs/accessibility.js +49 -0
- package/lib/commonjs/accessibility.js.map +1 -0
- package/lib/commonjs/dev.js +48 -0
- package/lib/commonjs/dev.js.map +1 -0
- package/lib/commonjs/events.js +56 -0
- package/lib/commonjs/events.js.map +1 -0
- package/lib/commonjs/index.js +169 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/shapes.js +158 -0
- package/lib/commonjs/shapes.js.map +1 -0
- package/lib/commonjs/storage.js +116 -0
- package/lib/commonjs/storage.js.map +1 -0
- package/lib/commonjs/themes.js +86 -0
- package/lib/commonjs/themes.js.map +1 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/useTourPersistence.js +135 -0
- package/lib/commonjs/useTourPersistence.js.map +1 -0
- package/lib/commonjs/useTourScroll.js +46 -0
- package/lib/commonjs/useTourScroll.js.map +1 -0
- package/lib/commonjs/utils.js +372 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/commonjs/validation.js +143 -0
- package/lib/commonjs/validation.js.map +1 -0
- package/lib/module/SpotlightOverlay.js +707 -0
- package/lib/module/SpotlightOverlay.js.map +1 -0
- package/lib/module/Tooltip.js +588 -0
- package/lib/module/Tooltip.js.map +1 -0
- package/lib/module/TourGuideContext.js +529 -0
- package/lib/module/TourGuideContext.js.map +1 -0
- package/lib/module/TourGuideOverlay.js +1167 -0
- package/lib/module/TourGuideOverlay.js.map +1 -0
- package/lib/module/TourTarget.js +74 -0
- package/lib/module/TourTarget.js.map +1 -0
- package/lib/module/accessibility.js +43 -0
- package/lib/module/accessibility.js.map +1 -0
- package/lib/module/dev.js +40 -0
- package/lib/module/dev.js.map +1 -0
- package/lib/module/events.js +51 -0
- package/lib/module/events.js.map +1 -0
- package/lib/module/index.js +25 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/shapes.js +152 -0
- package/lib/module/shapes.js.map +1 -0
- package/lib/module/storage.js +111 -0
- package/lib/module/storage.js.map +1 -0
- package/lib/module/themes.js +81 -0
- package/lib/module/themes.js.map +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/useTourPersistence.js +130 -0
- package/lib/module/useTourPersistence.js.map +1 -0
- package/lib/module/useTourScroll.js +41 -0
- package/lib/module/useTourScroll.js.map +1 -0
- package/lib/module/utils.js +361 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/module/validation.js +138 -0
- package/lib/module/validation.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/SpotlightOverlay.d.ts +46 -0
- package/lib/typescript/commonjs/src/SpotlightOverlay.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/Tooltip.d.ts +9 -0
- package/lib/typescript/commonjs/src/Tooltip.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/TourGuideContext.d.ts +46 -0
- package/lib/typescript/commonjs/src/TourGuideContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/TourGuideOverlay.d.ts +22 -0
- package/lib/typescript/commonjs/src/TourGuideOverlay.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/TourTarget.d.ts +36 -0
- package/lib/typescript/commonjs/src/TourTarget.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/accessibility.d.ts +22 -0
- package/lib/typescript/commonjs/src/accessibility.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/dev.d.ts +22 -0
- package/lib/typescript/commonjs/src/dev.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/events.d.ts +57 -0
- package/lib/typescript/commonjs/src/events.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +21 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/shapes.d.ts +50 -0
- package/lib/typescript/commonjs/src/shapes.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/storage.d.ts +15 -0
- package/lib/typescript/commonjs/src/storage.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/themes.d.ts +10 -0
- package/lib/typescript/commonjs/src/themes.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types.d.ts +599 -0
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useTourPersistence.d.ts +63 -0
- package/lib/typescript/commonjs/src/useTourPersistence.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/useTourScroll.d.ts +36 -0
- package/lib/typescript/commonjs/src/useTourScroll.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils.d.ts +97 -0
- package/lib/typescript/commonjs/src/utils.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/validation.d.ts +11 -0
- package/lib/typescript/commonjs/src/validation.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/SpotlightOverlay.d.ts +46 -0
- package/lib/typescript/module/src/SpotlightOverlay.d.ts.map +1 -0
- package/lib/typescript/module/src/Tooltip.d.ts +9 -0
- package/lib/typescript/module/src/Tooltip.d.ts.map +1 -0
- package/lib/typescript/module/src/TourGuideContext.d.ts +46 -0
- package/lib/typescript/module/src/TourGuideContext.d.ts.map +1 -0
- package/lib/typescript/module/src/TourGuideOverlay.d.ts +22 -0
- package/lib/typescript/module/src/TourGuideOverlay.d.ts.map +1 -0
- package/lib/typescript/module/src/TourTarget.d.ts +36 -0
- package/lib/typescript/module/src/TourTarget.d.ts.map +1 -0
- package/lib/typescript/module/src/accessibility.d.ts +22 -0
- package/lib/typescript/module/src/accessibility.d.ts.map +1 -0
- package/lib/typescript/module/src/dev.d.ts +22 -0
- package/lib/typescript/module/src/dev.d.ts.map +1 -0
- package/lib/typescript/module/src/events.d.ts +57 -0
- package/lib/typescript/module/src/events.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +21 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/shapes.d.ts +50 -0
- package/lib/typescript/module/src/shapes.d.ts.map +1 -0
- package/lib/typescript/module/src/storage.d.ts +15 -0
- package/lib/typescript/module/src/storage.d.ts.map +1 -0
- package/lib/typescript/module/src/themes.d.ts +10 -0
- package/lib/typescript/module/src/themes.d.ts.map +1 -0
- package/lib/typescript/module/src/types.d.ts +599 -0
- package/lib/typescript/module/src/types.d.ts.map +1 -0
- package/lib/typescript/module/src/useTourPersistence.d.ts +63 -0
- package/lib/typescript/module/src/useTourPersistence.d.ts.map +1 -0
- package/lib/typescript/module/src/useTourScroll.d.ts +36 -0
- package/lib/typescript/module/src/useTourScroll.d.ts.map +1 -0
- package/lib/typescript/module/src/utils.d.ts +97 -0
- package/lib/typescript/module/src/utils.d.ts.map +1 -0
- package/lib/typescript/module/src/validation.d.ts +11 -0
- package/lib/typescript/module/src/validation.d.ts.map +1 -0
- package/llms.txt +62 -0
- package/package.json +281 -4
- package/src/SpotlightOverlay.tsx +742 -0
- package/src/Tooltip.tsx +638 -0
- package/src/TourGuideContext.tsx +644 -0
- package/src/TourGuideOverlay.tsx +1382 -0
- package/src/TourTarget.tsx +74 -0
- package/src/accessibility.ts +60 -0
- package/src/dev.ts +39 -0
- package/src/events.ts +76 -0
- package/src/index.tsx +64 -0
- package/src/shapes.ts +184 -0
- package/src/storage.ts +114 -0
- package/src/themes.ts +83 -0
- package/src/types.ts +648 -0
- package/src/useTourPersistence.ts +147 -0
- package/src/useTourScroll.ts +60 -0
- package/src/utils.ts +401 -0
- package/src/validation.ts +248 -0
package/README.md
CHANGED
|
@@ -1,3 +1,994 @@
|
|
|
1
|
-
#
|
|
1
|
+
# React Native Tour Guide
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A lightweight React Native library for building app tours, walkthroughs, and coach marks. The spotlight automatically matches your component's shape — circles stay circular, pills stay pill-shaped, no manual configuration needed.
|
|
4
|
+
|
|
5
|
+
Works with Expo and React Native CLI. Zero native dependencies. New Architecture ready.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@wrack/react-native-tour-guide)
|
|
8
|
+
[](https://www.npmjs.com/package/@wrack/react-native-tour-guide)
|
|
9
|
+
[](https://github.com/himanshu-lal4/react-native-tour-guide/blob/main/LICENSE)
|
|
10
|
+
[](https://github.com/himanshu-lal4/react-native-tour-guide)
|
|
11
|
+
[](https://github.com/himanshu-lal4/react-native-tour-guide/blob/main/CONTRIBUTING.md)
|
|
12
|
+
[](https://github.com/himanshu-lal4/react-native-tour-guide/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
|
|
13
|
+
[](https://himanshu-lal4.github.io/react-native-tour-guide/)
|
|
14
|
+
|
|
15
|
+
📚 **[Documentation & guides](https://himanshu-lal4.github.io/react-native-tour-guide/)** · 📦 **[Install from npm](https://www.npmjs.com/package/@wrack/react-native-tour-guide)**
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<a href="https://github.com/sponsors/himanshu-lal4"><img src="https://img.shields.io/badge/GitHub_Sponsors-EA4AAA?style=for-the-badge&logo=githubsponsors&logoColor=white" height="32" alt="Sponsor on GitHub" /></a>
|
|
19
|
+
|
|
20
|
+
<a href="https://buymeacoffee.com/wrack"><img src="https://img.shields.io/badge/Buy_Me_a_Coffee-FFDD00?style=for-the-badge&logo=buymeacoffee&logoColor=black" height="32" alt="Buy Me a Coffee" /></a>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
<p align="center"><sub>If this library saves you a sprint of edge cases, a ⭐ and a coffee keep it maintained.</sub></p>
|
|
24
|
+
|
|
25
|
+
<p align="center">
|
|
26
|
+
<img src="https://raw.githubusercontent.com/himanshu-lal4/react-native-tour-guide/main/IOSDemo.gif" alt="React Native tour guide demo on iOS — live-blurred backdrop, custom tooltips, triangle/star/heart mask shapes, interactive steps, auto-scroll, and edge-aware tooltips" width="340" />
|
|
27
|
+
|
|
28
|
+
<img src="https://raw.githubusercontent.com/himanshu-lal4/react-native-tour-guide/main/AndroidDemo.gif" alt="React Native tour guide demo on Android — recorded on a physical device: shape-matched spotlights, custom overlay tints, motion presets, and safe-area-aware tooltips" width="340" />
|
|
29
|
+
</p>
|
|
30
|
+
<p align="center">
|
|
31
|
+
<sub>iOS simulator · physical Android device — the same demo, every step a different feature: blurred backdrop, custom Figma-style tooltips, triangle/star/heart cutouts, interactive tap-through, auto-scroll, edge-aware flips.</sub>
|
|
32
|
+
</p>
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## What does this library do?
|
|
37
|
+
|
|
38
|
+
It creates an overlay that highlights specific components in your app and shows tooltips explaining each one. You define a list of steps (which component to highlight, what to say), call `startTour()`, and the library handles everything else — measuring elements, positioning tooltips, scrolling to off-screen targets, animating between steps, and matching the spotlight shape to each component's border radius.
|
|
39
|
+
|
|
40
|
+
## How is it different from other tour libraries?
|
|
41
|
+
|
|
42
|
+
| Capability | This library | Alternatives |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| Auto shape matching | Spotlight matches target's border radius automatically | Manual shape selection |
|
|
45
|
+
| Auto-scroll | Scrolls to ensure target + tooltip both fit on screen | Manual or none |
|
|
46
|
+
| Smart tooltip positioning | Auto-detects best position, never renders off-screen | Manual per step |
|
|
47
|
+
| Theme presets | 4 built-in + `createTheme()` API | None |
|
|
48
|
+
| Per-corner border radius | Extracted automatically from `targetStyle` | Not supported |
|
|
49
|
+
| Pulse animation | Configurable animated spotlight border | Not supported |
|
|
50
|
+
| Pause/Resume | Built-in state preservation | Not supported |
|
|
51
|
+
| Tour persistence | Built-in "show only once" hook | DIY |
|
|
52
|
+
| Conditional steps | `active` flag with auto-renumbering | Filter manually |
|
|
53
|
+
| Bundle size | < 50KB, zero native dependencies | > 200KB |
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Installation
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# npm
|
|
61
|
+
npm install @wrack/react-native-tour-guide react-native-svg
|
|
62
|
+
|
|
63
|
+
# yarn
|
|
64
|
+
yarn add @wrack/react-native-tour-guide react-native-svg
|
|
65
|
+
|
|
66
|
+
# pnpm
|
|
67
|
+
pnpm add @wrack/react-native-tour-guide react-native-svg
|
|
68
|
+
|
|
69
|
+
# Expo (managed or bare)
|
|
70
|
+
npx expo install @wrack/react-native-tour-guide react-native-svg
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Requirements
|
|
74
|
+
|
|
75
|
+
| | Minimum |
|
|
76
|
+
|---|---|
|
|
77
|
+
| `react-native` | 0.71 |
|
|
78
|
+
| `react` | 18 |
|
|
79
|
+
| `react-native-svg` | 13 |
|
|
80
|
+
| `react-native-web` (web only) | 0.19 |
|
|
81
|
+
|
|
82
|
+
Works on the old architecture and the New Architecture (Fabric), on iOS, Android
|
|
83
|
+
and web. `react-native-safe-area-context` is optional — when installed, safe-area
|
|
84
|
+
insets are detected automatically.
|
|
85
|
+
|
|
86
|
+
### Optional dependencies
|
|
87
|
+
|
|
88
|
+
These are only needed for enhanced visual effects:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Blur effect
|
|
92
|
+
npm install @react-native-community/blur
|
|
93
|
+
|
|
94
|
+
# Gradient overlay
|
|
95
|
+
npm install react-native-linear-gradient
|
|
96
|
+
|
|
97
|
+
# Advanced blur masking
|
|
98
|
+
npm install @react-native-masked-view/masked-view
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Quick start
|
|
104
|
+
|
|
105
|
+
### 1. Wrap your app
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
import { TourGuideProvider, TourGuideOverlay } from '@wrack/react-native-tour-guide';
|
|
109
|
+
|
|
110
|
+
export default function App() {
|
|
111
|
+
return (
|
|
112
|
+
<TourGuideProvider>
|
|
113
|
+
<YourApp />
|
|
114
|
+
<TourGuideOverlay />
|
|
115
|
+
</TourGuideProvider>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### 2. Start a tour
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
import { useRef } from 'react';
|
|
124
|
+
import { View, Text, Pressable } from 'react-native';
|
|
125
|
+
import { useTourGuide } from '@wrack/react-native-tour-guide';
|
|
126
|
+
|
|
127
|
+
function HomeScreen() {
|
|
128
|
+
const { startTour } = useTourGuide();
|
|
129
|
+
const buttonRef = useRef(null);
|
|
130
|
+
const avatarRef = useRef(null);
|
|
131
|
+
|
|
132
|
+
const handleStart = () => {
|
|
133
|
+
startTour([
|
|
134
|
+
{
|
|
135
|
+
id: 'welcome',
|
|
136
|
+
targetRef: buttonRef,
|
|
137
|
+
title: 'Welcome',
|
|
138
|
+
description: 'Tap here to get started.',
|
|
139
|
+
targetStyle: styles.button, // spotlight matches button's border radius
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
id: 'avatar',
|
|
143
|
+
targetRef: avatarRef,
|
|
144
|
+
title: 'Your Profile',
|
|
145
|
+
description: 'Tap to view your profile.',
|
|
146
|
+
targetStyle: styles.avatar, // circular target gets circular spotlight
|
|
147
|
+
},
|
|
148
|
+
]);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<View>
|
|
153
|
+
<Pressable ref={buttonRef} style={styles.button} onPress={handleStart}>
|
|
154
|
+
<Text>Start Tour</Text>
|
|
155
|
+
</Pressable>
|
|
156
|
+
<View ref={avatarRef} style={styles.avatar} />
|
|
157
|
+
</View>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const styles = StyleSheet.create({
|
|
162
|
+
button: { borderRadius: 12, padding: 16, backgroundColor: '#007AFF' },
|
|
163
|
+
avatar: { width: 48, height: 48, borderRadius: 24, backgroundColor: '#ccc' },
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
That's it. The spotlight around the button will have 12px rounded corners. The spotlight around the avatar will be a perfect circle.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Declarative targeting with TourTarget
|
|
172
|
+
|
|
173
|
+
Skip ref-threading entirely: wrap any element in a `TourTarget` and reference it
|
|
174
|
+
from steps by id. The wrapper registers itself with the provider (and uses
|
|
175
|
+
`collapsable={false}` so Android's view flattening can never make the target
|
|
176
|
+
unmeasurable).
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
import { TourTarget, useTourGuide } from '@wrack/react-native-tour-guide';
|
|
180
|
+
|
|
181
|
+
<TourTarget id="compose" style={{ borderRadius: 24 }}>
|
|
182
|
+
<ComposeButton />
|
|
183
|
+
</TourTarget>;
|
|
184
|
+
|
|
185
|
+
// Steps reference the id — no refs anywhere:
|
|
186
|
+
startTour([
|
|
187
|
+
{ id: 'step1', targetId: 'compose', title: 'Compose', description: 'Start a new message.' },
|
|
188
|
+
]);
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
The `style` on `TourTarget` drives spotlight shape matching, exactly like a
|
|
192
|
+
step's `targetStyle`. If the target mounts after the tour starts (a screen you
|
|
193
|
+
navigate to), the tour waits briefly for it to register before falling back to
|
|
194
|
+
a centered tooltip. `targetRef` still works everywhere and wins when both are
|
|
195
|
+
given.
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Interactive steps — let users tap the real thing
|
|
200
|
+
|
|
201
|
+
By default the overlay uses a Modal, which swallows every touch. Switch to the
|
|
202
|
+
inline overlay and mark a step `interactive` to let touches pass through the
|
|
203
|
+
spotlight hole to the actual element underneath:
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
startTour(
|
|
207
|
+
[
|
|
208
|
+
{
|
|
209
|
+
id: 'send',
|
|
210
|
+
targetId: 'send-button',
|
|
211
|
+
title: 'Try it now',
|
|
212
|
+
description: 'Tap Send to continue.',
|
|
213
|
+
interactive: true, // touches reach the real button
|
|
214
|
+
hideNextButton: true,
|
|
215
|
+
completed: false, // Next stays disabled until you say so
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
{ overlayMode: 'inline' }
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
// In the button's own handler:
|
|
222
|
+
const { nextStep, setStepCompleted } = useTourGuide();
|
|
223
|
+
const onSend = () => {
|
|
224
|
+
setStepCompleted('send', true);
|
|
225
|
+
nextStep();
|
|
226
|
+
};
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
- `overlayMode: 'inline'` renders the overlay as an absolutely-positioned layer
|
|
230
|
+
instead of a Modal. Put `<TourGuideOverlay />` at the root of your app so it
|
|
231
|
+
covers the full screen. (The Android back button is not intercepted in this
|
|
232
|
+
mode.)
|
|
233
|
+
- `completed: false` disables the Next button until
|
|
234
|
+
`setStepCompleted(stepId, true)` is called — turn a slideshow into a guided
|
|
235
|
+
task.
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Async step preparation with before()
|
|
240
|
+
|
|
241
|
+
Navigate, open a sheet, or wait for data before a step is measured — the
|
|
242
|
+
spotlight only appears once the promise resolves. Prefer this over guessing a
|
|
243
|
+
`delayBefore`:
|
|
244
|
+
|
|
245
|
+
```tsx
|
|
246
|
+
{
|
|
247
|
+
id: 'profile-tab',
|
|
248
|
+
targetId: 'profile-header',
|
|
249
|
+
title: 'Your profile',
|
|
250
|
+
description: 'Everything about you lives here.',
|
|
251
|
+
before: async () => {
|
|
252
|
+
navigation.navigate('Profile');
|
|
253
|
+
await waitForProfileToLoad();
|
|
254
|
+
},
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
If `before()` throws or rejects, the tour warns (dev only) and shows the step
|
|
259
|
+
anyway rather than trapping the user.
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Named tours and canStartTour
|
|
264
|
+
|
|
265
|
+
Register tours up front and start them by id from anywhere — useful when steps
|
|
266
|
+
and triggers live in different parts of the app:
|
|
267
|
+
|
|
268
|
+
```tsx
|
|
269
|
+
const { defineTour, startTour, canStartTour } = useTourGuide();
|
|
270
|
+
|
|
271
|
+
// At setup time (e.g. app root):
|
|
272
|
+
defineTour('onboarding', onboardingSteps, { showProgressDots: true });
|
|
273
|
+
defineTour('power-features', powerSteps);
|
|
274
|
+
|
|
275
|
+
// Anywhere else:
|
|
276
|
+
startTour('onboarding'); // stored config
|
|
277
|
+
startTour('onboarding', { motion: 'bounce' }); // with overrides
|
|
278
|
+
|
|
279
|
+
// Wait until every <TourTarget> the tour references has mounted:
|
|
280
|
+
if (canStartTour('onboarding')) startTour('onboarding');
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
`canStartTour` also accepts a raw steps array. Steps with `targetRef`,
|
|
284
|
+
`targetRegion`, or no target always count as ready.
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## Highlighting a region without a ref
|
|
289
|
+
|
|
290
|
+
Maps, camera previews, canvases — anything you can't attach a ref to — can be
|
|
291
|
+
highlighted as a fixed window rectangle:
|
|
292
|
+
|
|
293
|
+
```tsx
|
|
294
|
+
{
|
|
295
|
+
id: 'map-pin',
|
|
296
|
+
targetRegion: { x: 40, y: 220, width: 320, height: 180 },
|
|
297
|
+
title: 'Your delivery zone',
|
|
298
|
+
description: 'Everything inside this area ships free.',
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
`targetRegion` skips measurement entirely and wins over `targetRef`/`targetId`.
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## Spotlight motion presets
|
|
307
|
+
|
|
308
|
+
Choose how the spotlight travels between steps — globally or per step:
|
|
309
|
+
|
|
310
|
+
```tsx
|
|
311
|
+
startTour(steps, { motion: 'bounce' }); // springy, with overshoot
|
|
312
|
+
// per step:
|
|
313
|
+
{ id: 'step3', targetId: 'send', motion: 'fade', ... }
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
| Motion | Behaviour |
|
|
317
|
+
|---|---|
|
|
318
|
+
| `morph` (default) | Position, size and radius tween in one smooth move |
|
|
319
|
+
| `bounce` | The same move on a spring |
|
|
320
|
+
| `fade` | The overlay dips out, jumps, and fades back in |
|
|
321
|
+
| `none` | Instant jump |
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## Custom spotlight shapes with maskPath
|
|
326
|
+
|
|
327
|
+
The ultimate escape hatch: return any SVG subpath and it becomes the hole in
|
|
328
|
+
the backdrop (evenodd fill). Overrides shape matching for every step:
|
|
329
|
+
|
|
330
|
+
```tsx
|
|
331
|
+
startTour(steps, {
|
|
332
|
+
spotlightStyles: {
|
|
333
|
+
// A star, a blob, an arrow — anything you can path:
|
|
334
|
+
maskPath: ({ bounds }) => {
|
|
335
|
+
const { x, y, width: w, height: h } = bounds;
|
|
336
|
+
const cx = x + w / 2;
|
|
337
|
+
return `M${cx},${y} L${x + w},${y + h} L${x},${y + h} Z`; // triangle
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
});
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
The function receives the measured `target`, the padded `bounds` the automatic
|
|
344
|
+
shape would use, and the screen size. Custom paths jump between steps (arbitrary
|
|
345
|
+
paths can't be tweened reliably); a throwing `maskPath` falls back to the
|
|
346
|
+
automatic shape.
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## Following the target while the user scrolls
|
|
351
|
+
|
|
352
|
+
Bind your scrollable to the tour with `useTourScroll`, and with
|
|
353
|
+
`followTarget: true` the spotlight and tooltip stay glued to the target while
|
|
354
|
+
the user scrolls freely:
|
|
355
|
+
|
|
356
|
+
```tsx
|
|
357
|
+
import { useTourScroll } from '@wrack/react-native-tour-guide';
|
|
358
|
+
|
|
359
|
+
const { scrollProps } = useTourScroll();
|
|
360
|
+
|
|
361
|
+
<ScrollView ref={scrollRef} {...scrollProps}>…</ScrollView>;
|
|
362
|
+
|
|
363
|
+
startTour(steps, { scrollRef, followTarget: true });
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Wiring `useTourScroll` also gives the tour two more things for free:
|
|
367
|
+
|
|
368
|
+
- **Exact auto-scroll settling** — `onMomentumScrollEnd` tells the tour the
|
|
369
|
+
programmatic scroll finished, so the highlight lands immediately instead of
|
|
370
|
+
waiting for position polling to detect the stop.
|
|
371
|
+
- **A tracked scroll offset** — `getCurrentScrollOffset` becomes redundant.
|
|
372
|
+
|
|
373
|
+
Have your own `onScroll`? Compose it: the hook also returns the individual
|
|
374
|
+
handlers.
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
## Analytics with the event emitter
|
|
379
|
+
|
|
380
|
+
Subscribe once — e.g. at app root — instead of threading callbacks through every
|
|
381
|
+
tour config:
|
|
382
|
+
|
|
383
|
+
```tsx
|
|
384
|
+
const { events } = useTourGuide();
|
|
385
|
+
|
|
386
|
+
useEffect(() => {
|
|
387
|
+
const offs = [
|
|
388
|
+
events.on('start', ({ tourId, totalSteps }) => track('tour_start', { tourId, totalSteps })),
|
|
389
|
+
events.on('stepChange', ({ from, to }) => track('tour_step', { from, to })),
|
|
390
|
+
events.on('end', ({ completed, tourId }) => track('tour_end', { completed, tourId })),
|
|
391
|
+
events.on('skip', ({ at }) => track('tour_skip', { at })),
|
|
392
|
+
];
|
|
393
|
+
return () => offs.forEach((off) => off());
|
|
394
|
+
}, [events]);
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
Events: `start`, `stepChange`, `end`, `skip`, `pause`, `resume`. A throwing
|
|
398
|
+
handler is isolated — analytics can never take the tour down. The config
|
|
399
|
+
callbacks (`onTourStart` etc.) still work; both fire.
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## Persistence without configuration
|
|
404
|
+
|
|
405
|
+
`useTourPersistence()` now auto-detects storage — MMKV (v2–v4) first, then
|
|
406
|
+
AsyncStorage:
|
|
407
|
+
|
|
408
|
+
```tsx
|
|
409
|
+
const { startTour } = useTourPersistence(); // no adapter needed
|
|
410
|
+
startTour(steps, { tourId: 'onboarding' });
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
With neither installed it falls back to in-memory storage (the tour works,
|
|
414
|
+
completion just isn't remembered across restarts) and says so in a dev warning.
|
|
415
|
+
Passing your own adapter still works and always wins.
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
## Keeping earlier spotlights lit
|
|
420
|
+
|
|
421
|
+
`keepSpotlight: true` on a step keeps its hole punched out of the backdrop
|
|
422
|
+
after the tour moves forward past it — for "these three things work together"
|
|
423
|
+
storytelling:
|
|
424
|
+
|
|
425
|
+
```tsx
|
|
426
|
+
startTour([
|
|
427
|
+
{ id: 'a', targetId: 'search', keepSpotlight: true, ... },
|
|
428
|
+
{ id: 'b', targetId: 'filters', keepSpotlight: true, ... },
|
|
429
|
+
{ id: 'c', targetId: 'results', title: 'Together…', ... }, // all three lit
|
|
430
|
+
]);
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
Kept holes are visual only (no pulse, no touch pass-through) and are dropped
|
|
434
|
+
when the user navigates back.
|
|
435
|
+
|
|
436
|
+
---
|
|
437
|
+
|
|
438
|
+
## Per-platform values
|
|
439
|
+
|
|
440
|
+
The layout-tuning config fields accept `{ ios, android, web, default }`
|
|
441
|
+
objects:
|
|
442
|
+
|
|
443
|
+
```tsx
|
|
444
|
+
startTour(steps, {
|
|
445
|
+
tooltipWidth: { ios: 320, android: 300, default: 320 },
|
|
446
|
+
motion: { ios: 'bounce', default: 'morph' },
|
|
447
|
+
});
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
Applies to `tooltipWidth`, `tooltipOffset`, `triangleSize`,
|
|
451
|
+
`animationDuration`, `safeZoneOffset`, and `motion`. Values are resolved once
|
|
452
|
+
at `startTour`; everything you read back from context is already plain.
|
|
453
|
+
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
## How does auto shape matching work?
|
|
457
|
+
|
|
458
|
+
Pass the same style you use on the component as `targetStyle` on the step. The library reads the `borderRadius` properties from that style and applies them to the spotlight.
|
|
459
|
+
|
|
460
|
+
- **Fully rounded** elements (where `borderRadius >= min(width, height) / 2`) stay fully rounded even when the spotlight is slightly larger
|
|
461
|
+
- **Per-corner radii** (`borderTopLeftRadius`, etc.) are preserved exactly — the spotlight matches the asymmetric shape
|
|
462
|
+
- **Partial radii** (like `borderRadius: 12` on a card) stay at exactly 12px on the spotlight
|
|
463
|
+
|
|
464
|
+
```tsx
|
|
465
|
+
// Chat bubble with asymmetric corners
|
|
466
|
+
const chatStyle = {
|
|
467
|
+
borderTopLeftRadius: 16,
|
|
468
|
+
borderTopRightRadius: 16,
|
|
469
|
+
borderBottomRightRadius: 16,
|
|
470
|
+
borderBottomLeftRadius: 4,
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
{ id: 'chat', targetRef: chatRef, targetStyle: chatStyle, title: '...', description: '...' }
|
|
474
|
+
// Spotlight will have 16px on top-left, top-right, bottom-right and 4px on bottom-left
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
You can also override the border radius manually:
|
|
478
|
+
|
|
479
|
+
```tsx
|
|
480
|
+
// Uniform override
|
|
481
|
+
{ id: 'step', targetRef: ref, spotlightBorderRadius: 20, title: '...', description: '...' }
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
Priority: `spotlightBorderRadius` > auto-extracted from `targetStyle` > default (12px).
|
|
485
|
+
|
|
486
|
+
---
|
|
487
|
+
|
|
488
|
+
## How to enable auto-scroll?
|
|
489
|
+
|
|
490
|
+
Set `scrollRef` on the tour config. The library automatically scrolls to ensure both the target and its tooltip are fully visible. `getCurrentScrollOffset` is optional — without it the destination is derived from the target's position inside the scroll content (`measureLayout`), which needs no offset tracking at all. Pass the getter only if you want the offset-based calculation.
|
|
491
|
+
|
|
492
|
+
```tsx
|
|
493
|
+
const scrollViewRef = useRef(null);
|
|
494
|
+
const [scrollY, setScrollY] = useState(0);
|
|
495
|
+
|
|
496
|
+
startTour(steps, {
|
|
497
|
+
scrollRef: scrollViewRef,
|
|
498
|
+
getCurrentScrollOffset: () => scrollY,
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
// In your JSX:
|
|
502
|
+
<ScrollView
|
|
503
|
+
ref={scrollViewRef}
|
|
504
|
+
onScroll={(e) => setScrollY(e.nativeEvent.contentOffset.y)}
|
|
505
|
+
scrollEventThrottle={16}
|
|
506
|
+
>
|
|
507
|
+
{/* your content */}
|
|
508
|
+
</ScrollView>
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
This works with `ScrollView`, `FlatList`, `SectionList`, `Animated.ScrollView` and
|
|
512
|
+
gesture-handler wrappers — the library detects each one's scroll method, so you
|
|
513
|
+
pass the ref the same way regardless:
|
|
514
|
+
|
|
515
|
+
```tsx
|
|
516
|
+
const listRef = useRef(null);
|
|
517
|
+
const [scrollY, setScrollY] = useState(0);
|
|
518
|
+
|
|
519
|
+
startTour(steps, {
|
|
520
|
+
scrollRef: listRef, // FlatList works exactly like ScrollView
|
|
521
|
+
getCurrentScrollOffset: () => scrollY,
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
<FlatList
|
|
525
|
+
ref={listRef}
|
|
526
|
+
onScroll={(e) => setScrollY(e.nativeEvent.contentOffset.y)}
|
|
527
|
+
scrollEventThrottle={16}
|
|
528
|
+
data={data}
|
|
529
|
+
renderItem={renderItem}
|
|
530
|
+
/>
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
> Attach the ref to the list itself, not to a wrapping `View`. If the ref has no
|
|
534
|
+
> scroll method the tour warns in development and highlights the target where it
|
|
535
|
+
> is, rather than scrolling.
|
|
536
|
+
|
|
537
|
+
You can also set `scrollToTarget` per step for fine-grained control:
|
|
538
|
+
|
|
539
|
+
```tsx
|
|
540
|
+
{
|
|
541
|
+
id: 'far-down',
|
|
542
|
+
targetRef: ref,
|
|
543
|
+
title: 'Scroll Target',
|
|
544
|
+
description: '...',
|
|
545
|
+
scrollToTarget: {
|
|
546
|
+
scrollRef: scrollViewRef,
|
|
547
|
+
offset: 50,
|
|
548
|
+
animated: true,
|
|
549
|
+
getCurrentScrollOffset: () => scrollY,
|
|
550
|
+
},
|
|
551
|
+
}
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
---
|
|
555
|
+
|
|
556
|
+
## How to use themes?
|
|
557
|
+
|
|
558
|
+
Four built-in themes are included. Spread them into your config:
|
|
559
|
+
|
|
560
|
+
```tsx
|
|
561
|
+
import { darkTheme, lightTheme, minimalTheme, vibrantTheme } from '@wrack/react-native-tour-guide';
|
|
562
|
+
|
|
563
|
+
startTour(steps, { ...darkTheme });
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
Create a custom theme with `createTheme()`:
|
|
567
|
+
|
|
568
|
+
```tsx
|
|
569
|
+
import { createTheme } from '@wrack/react-native-tour-guide';
|
|
570
|
+
|
|
571
|
+
const brandTheme = createTheme({
|
|
572
|
+
tooltipStyles: { primaryButtonColor: '#FF6B35', backgroundColor: '#1B1B3A' },
|
|
573
|
+
spotlightStyles: { overlayOpacity: 0.7 },
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
startTour(steps, { ...brandTheme });
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
---
|
|
580
|
+
|
|
581
|
+
## How to add pulse animation?
|
|
582
|
+
|
|
583
|
+
```tsx
|
|
584
|
+
startTour(steps, {
|
|
585
|
+
spotlightStyles: {
|
|
586
|
+
enablePulse: true,
|
|
587
|
+
pulseColor: '#00BFFF',
|
|
588
|
+
pulseWidth: 3,
|
|
589
|
+
pulseDuration: 1200,
|
|
590
|
+
pulseMinOpacity: 0.3,
|
|
591
|
+
pulseMaxOpacity: 0.9,
|
|
592
|
+
},
|
|
593
|
+
});
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
---
|
|
597
|
+
|
|
598
|
+
## How to show a tour only once?
|
|
599
|
+
|
|
600
|
+
Use the `useTourPersistence` hook with any storage backend:
|
|
601
|
+
|
|
602
|
+
```tsx
|
|
603
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
604
|
+
import { useTourPersistence } from '@wrack/react-native-tour-guide';
|
|
605
|
+
|
|
606
|
+
function MyScreen() {
|
|
607
|
+
const { startTour, resetTour } = useTourPersistence(AsyncStorage);
|
|
608
|
+
|
|
609
|
+
useEffect(() => {
|
|
610
|
+
// Automatically skips if user already completed this tour
|
|
611
|
+
startTour(steps, { tourId: 'onboarding' });
|
|
612
|
+
}, []);
|
|
613
|
+
|
|
614
|
+
// Force show again
|
|
615
|
+
const showAgain = async () => {
|
|
616
|
+
await resetTour('onboarding');
|
|
617
|
+
startTour(steps, { tourId: 'onboarding' }, true);
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
Works with MMKV too:
|
|
623
|
+
|
|
624
|
+
```tsx
|
|
625
|
+
import { MMKV } from 'react-native-mmkv';
|
|
626
|
+
const storage = new MMKV();
|
|
627
|
+
|
|
628
|
+
const adapter = {
|
|
629
|
+
getItem: (key) => storage.getString(key) ?? null,
|
|
630
|
+
setItem: (key, value) => storage.set(key, value),
|
|
631
|
+
removeItem: (key) => storage.delete(key),
|
|
632
|
+
};
|
|
633
|
+
|
|
634
|
+
const { startTour } = useTourPersistence(adapter);
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
---
|
|
638
|
+
|
|
639
|
+
## How to use conditional steps?
|
|
640
|
+
|
|
641
|
+
Set `active: false` to hide a step. Numbering adjusts automatically.
|
|
642
|
+
|
|
643
|
+
```tsx
|
|
644
|
+
const isPremium = useIsPremium();
|
|
645
|
+
|
|
646
|
+
startTour([
|
|
647
|
+
{ id: 'welcome', targetRef: welcomeRef, title: 'Welcome', description: '...' },
|
|
648
|
+
{
|
|
649
|
+
id: 'upgrade',
|
|
650
|
+
targetRef: upgradeRef,
|
|
651
|
+
title: 'Upgrade',
|
|
652
|
+
description: 'Only shown to free users.',
|
|
653
|
+
active: !isPremium,
|
|
654
|
+
},
|
|
655
|
+
{ id: 'done', targetRef: doneRef, title: 'All Set', description: '...' },
|
|
656
|
+
]);
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
---
|
|
660
|
+
|
|
661
|
+
## How to handle backdrop taps?
|
|
662
|
+
|
|
663
|
+
```tsx
|
|
664
|
+
startTour([
|
|
665
|
+
{
|
|
666
|
+
id: 'step1',
|
|
667
|
+
targetRef: ref,
|
|
668
|
+
title: 'Tap anywhere',
|
|
669
|
+
description: 'Tapping the dark overlay advances to the next step.',
|
|
670
|
+
backdropBehavior: 'next', // 'dismiss' | 'next' | 'none' | () => void
|
|
671
|
+
},
|
|
672
|
+
]);
|
|
673
|
+
|
|
674
|
+
// Or set globally
|
|
675
|
+
startTour(steps, { defaultBackdropBehavior: 'next' });
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
---
|
|
679
|
+
|
|
680
|
+
## How to pause and resume a tour?
|
|
681
|
+
|
|
682
|
+
```tsx
|
|
683
|
+
const { pauseTour, resumeTour, isPaused } = useTourGuide();
|
|
684
|
+
|
|
685
|
+
// Pause when opening a modal
|
|
686
|
+
const handleModalOpen = () => pauseTour();
|
|
687
|
+
|
|
688
|
+
// Resume when it closes — picks up where it left off
|
|
689
|
+
const handleModalClose = () => resumeTour();
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
---
|
|
693
|
+
|
|
694
|
+
## How to use a custom tooltip?
|
|
695
|
+
|
|
696
|
+
```tsx
|
|
697
|
+
import type { TooltipProps } from '@wrack/react-native-tour-guide';
|
|
698
|
+
|
|
699
|
+
const MyTooltip = (props: TooltipProps) => (
|
|
700
|
+
<View style={myStyles.tooltip}>
|
|
701
|
+
<Text>{props.title}</Text>
|
|
702
|
+
<Text>{props.description}</Text>
|
|
703
|
+
<Pressable onPress={props.onNext}><Text>Continue</Text></Pressable>
|
|
704
|
+
</View>
|
|
705
|
+
);
|
|
706
|
+
|
|
707
|
+
startTour(steps, {
|
|
708
|
+
renderTooltip: (props) => <MyTooltip {...props} />,
|
|
709
|
+
});
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
---
|
|
713
|
+
|
|
714
|
+
## Programmatic control
|
|
715
|
+
|
|
716
|
+
```tsx
|
|
717
|
+
const {
|
|
718
|
+
startTour, nextStep, prevStep, skipTour, endTour,
|
|
719
|
+
goToStep, pauseTour, resumeTour,
|
|
720
|
+
isActive, isPaused, currentStep, activeTourId,
|
|
721
|
+
} = useTourGuide();
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
---
|
|
725
|
+
|
|
726
|
+
## API reference
|
|
727
|
+
|
|
728
|
+
### TourStep
|
|
729
|
+
|
|
730
|
+
| Property | Type | Default | Description |
|
|
731
|
+
|---|---|---|---|
|
|
732
|
+
| `id` | `string` | required | Unique step identifier |
|
|
733
|
+
| `targetRef` | `RefObject` | — | Ref to the component to highlight |
|
|
734
|
+
| `targetId` | `string` | — | Id of a `<TourTarget>` to highlight — the ref-free alternative |
|
|
735
|
+
| `targetRegion` | `{x, y, width, height}` | — | Highlight a fixed window rectangle (no ref needed); wins over targetRef/targetId |
|
|
736
|
+
| `title` | `string` | required | Tooltip title |
|
|
737
|
+
| `description` | `string` | required | Tooltip body text |
|
|
738
|
+
| `tooltipPosition` | `'top' \| 'bottom' \| 'left' \| 'right' \| 'auto'` | `'auto'` | Tooltip placement (auto-detected by default) |
|
|
739
|
+
| `targetStyle` | `ViewStyle` | — | Style to extract border radius from for shape matching |
|
|
740
|
+
| `spotlightPadding` | `number \| {top,right,bottom,left}` | `0` | Padding around the spotlight — uniform or per-side |
|
|
741
|
+
| `spotlightBorderRadius` | `number` | — | Override border radius (takes priority over targetStyle) |
|
|
742
|
+
| `scrollToTarget` | `ScrollToTargetConfig` | — | Per-step scroll configuration |
|
|
743
|
+
| `active` | `boolean` | `true` | Whether this step is included |
|
|
744
|
+
| `backdropBehavior` | `BackdropBehavior` | `'none'` | What happens on backdrop tap |
|
|
745
|
+
| `autoAdvance` | `number` | `0` | Auto-advance after ms (0 = disabled) |
|
|
746
|
+
| `before` | `() => void \| Promise<void>` | — | Awaited before the step is measured — navigate/fetch here |
|
|
747
|
+
| `delayBefore` | `number` | `0` | Delay before showing step |
|
|
748
|
+
| `completed` | `boolean` | — | `false` disables Next until `setStepCompleted(id, true)` |
|
|
749
|
+
| `interactive` | `boolean` | `false` | Let touches through the spotlight to the real element (inline mode) |
|
|
750
|
+
| `renderTooltip` | `(props) => ReactNode` | — | Per-step custom tooltip (overrides the config one) |
|
|
751
|
+
| `motion` | `'morph' \| 'bounce' \| 'fade' \| 'none'` | config | Spotlight transition into this step |
|
|
752
|
+
| `keepSpotlight` | `boolean` | `false` | Keep this hole punched out after moving forward past the step |
|
|
753
|
+
| `waitForInteractions` | `boolean` | config | Wait for InteractionManager before measuring this step |
|
|
754
|
+
| `onNext` | `() => void` | — | Called on next |
|
|
755
|
+
| `onPrev` | `() => void` | — | Called on previous |
|
|
756
|
+
| `onSkip` | `() => void` | — | Called on skip |
|
|
757
|
+
| `onSpotlightPress` | `() => void` | — | Called when spotlight area is tapped |
|
|
758
|
+
| `hideNextButton` | `boolean` | `false` | Hide the next/done button |
|
|
759
|
+
| `hidePrevButton` | `boolean` | `false` | Hide the back button |
|
|
760
|
+
| `hideSkipButton` | `boolean` | `false` | Hide the skip button |
|
|
761
|
+
| `accessibilityLabel` | `string` | — | Custom screen reader label |
|
|
762
|
+
|
|
763
|
+
### TourGuideConfig
|
|
764
|
+
|
|
765
|
+
| Property | Type | Default | Description |
|
|
766
|
+
|---|---|---|---|
|
|
767
|
+
| `tooltipStyles` | `TooltipStyles` | — | Tooltip appearance |
|
|
768
|
+
| `spotlightStyles` | `SpotlightStyles` | — | Spotlight/overlay appearance |
|
|
769
|
+
| `scrollRef` | `RefObject` | — | Ref to the `ScrollView`, `FlatList` or `SectionList` to auto-scroll |
|
|
770
|
+
| `getCurrentScrollOffset` | `() => number` | — | Optional scroll-offset getter; without it the destination is derived via `measureLayout` |
|
|
771
|
+
| `overlayMode` | `'modal' \| 'inline'` | `'modal'` | `'inline'` renders without a Modal — required for `interactive` steps |
|
|
772
|
+
| `components` | `TooltipComponents` | — | Replace individual tooltip pieces (NextButton, SkipButton, dots…) |
|
|
773
|
+
| `allowFontScaling` | `boolean` | `true` | Tooltip text follows the OS font-size setting |
|
|
774
|
+
| `maxFontSizeMultiplier` | `number` | — | Cap on OS font scaling for tooltip text |
|
|
775
|
+
| `showProgressDots` | `boolean` | `false` | Show dot indicators |
|
|
776
|
+
| `showStepCounter` | `boolean` | `true` | Show "1/5" counter |
|
|
777
|
+
| `enableBackButton` | `boolean` | `true` | Show back button |
|
|
778
|
+
| `nextButtonText` | `string` | `'Next'` | Next button label |
|
|
779
|
+
| `prevButtonText` | `string` | `'Back'` | Back button label |
|
|
780
|
+
| `skipButtonText` | `string` | `'Skip'` | Skip button label |
|
|
781
|
+
| `doneButtonText` | `string` | `'Done'` | Done button label |
|
|
782
|
+
| `animationDuration` | `number` | `300` | Transition duration (ms) |
|
|
783
|
+
| `motion` | `'morph' \| 'bounce' \| 'fade' \| 'none'` | `'morph'` | Spotlight transition between steps (accepts per-platform values) |
|
|
784
|
+
| `followTarget` | `boolean` | `false` | Highlight tracks the target during free scrolling (needs `useTourScroll`) |
|
|
785
|
+
| `waitForInteractions` | `boolean` | `false` | Wait for navigation/layout animations before measuring each step |
|
|
786
|
+
| `statusBarStyle` | `'light-content' \| 'dark-content' \| 'auto'` | — | Status-bar style while the tour runs (restored after) |
|
|
787
|
+
| `supportedOrientations` | `Orientation[]` | all | iOS Modal orientations (default: rotate with the app) |
|
|
788
|
+
| `tooltipWidth` | `number` | `320` | Tooltip width (px) |
|
|
789
|
+
| `tourId` | `string` | — | Tour identifier (for persistence) |
|
|
790
|
+
| `autoPositionTooltip` | `boolean` | `true` | Flip the tooltip to whichever side has room. Set `false` to always honour each step's `tooltipPosition` |
|
|
791
|
+
| `defaultBackdropBehavior` | `BackdropBehavior` | `'none'` | Global backdrop behavior |
|
|
792
|
+
| `renderTooltip` | `(props) => ReactNode` | — | Custom tooltip renderer |
|
|
793
|
+
| `onTourStart` | `() => void` | — | Called when tour starts |
|
|
794
|
+
| `onTourEnd` | `(completed: boolean) => void` | — | Called when tour ends |
|
|
795
|
+
| `onStepChange` | `(from, to) => void` | — | Called on step change |
|
|
796
|
+
| `beforeStepChange` | `(from, to) => boolean \| Promise<boolean>` | — | Gate before step change. Return `false` to block it. On the final step `to` is `totalSteps` (one past the end), so `to > from` stays true when finishing |
|
|
797
|
+
| `enableAccessibility` | `boolean` | `true` | Enable screen reader announcements |
|
|
798
|
+
|
|
799
|
+
### SpotlightStyles
|
|
800
|
+
|
|
801
|
+
| Property | Type | Default | Description |
|
|
802
|
+
|---|---|---|---|
|
|
803
|
+
| `overlayOpacity` | `number` | `0.6` | Overlay darkness (0-1) |
|
|
804
|
+
| `overlayColor` | `string` | `'black'` | Overlay color |
|
|
805
|
+
| `maskPath` | `(args) => string` | — | Custom SVG subpath for the spotlight hole — draw any shape |
|
|
806
|
+
| `enableBlur` | `boolean` | `false` | Blur effect (requires optional dep) |
|
|
807
|
+
| `blurAmount` | `number` | `4` | Blur intensity |
|
|
808
|
+
| `enableGradient` | `boolean` | `false` | Gradient overlay |
|
|
809
|
+
| `gradientColors` | `string[]` | — | Gradient color stops |
|
|
810
|
+
| `enablePulse` | `boolean` | `false` | Pulsing spotlight border |
|
|
811
|
+
| `pulseColor` | `string` | `'#FFFFFF'` | Pulse color |
|
|
812
|
+
| `pulseWidth` | `number` | `2` | Pulse border width (px) |
|
|
813
|
+
| `pulseDuration` | `number` | `1500` | Full pulse cycle (ms) |
|
|
814
|
+
| `pulseMinOpacity` | `number` | `0.2` | Pulse min opacity |
|
|
815
|
+
| `pulseMaxOpacity` | `number` | `0.8` | Pulse max opacity |
|
|
816
|
+
|
|
817
|
+
### TooltipStyles
|
|
818
|
+
|
|
819
|
+
| Property | Type | Default | Description |
|
|
820
|
+
|---|---|---|---|
|
|
821
|
+
| `backgroundColor` | `string` | `'#2C2C2E'` | Tooltip background |
|
|
822
|
+
| `arrowStyle` | `ViewStyle` | — | Style merged onto the tooltip arrow/triangle |
|
|
823
|
+
| `borderRadius` | `number` | `16` | Tooltip corner radius |
|
|
824
|
+
| `titleColor` | `string` | `'#FFFFFF'` | Title text color |
|
|
825
|
+
| `descriptionColor` | `string` | `'#FFFFFF'` | Description text color |
|
|
826
|
+
| `buttonTextColor` | `string` | `'#FFFFFF'` | Button text color |
|
|
827
|
+
| `primaryButtonColor` | `string` | `'#007AFF'` | Next/Done button background |
|
|
828
|
+
| `secondaryButtonColor` | `string` | `'#3A3A3C'` | Back button background |
|
|
829
|
+
| `skipButtonColor` | `string` | `'#FFFFFF'` | Skip button color |
|
|
830
|
+
|
|
831
|
+
---
|
|
832
|
+
|
|
833
|
+
## Troubleshooting
|
|
834
|
+
|
|
835
|
+
In development the library validates your steps and config on every `startTour()`
|
|
836
|
+
and prints a warning naming the exact step and the fix. All warnings are stripped
|
|
837
|
+
from production builds, so check the Metro logs first — the answer is usually
|
|
838
|
+
there. Common cases:
|
|
839
|
+
|
|
840
|
+
**Tour not showing at all?**
|
|
841
|
+
- Render `<TourGuideOverlay />` exactly once, inside `<TourGuideProvider>` and after your main content. Calling `startTour()` with no overlay mounted warns: *"the tour is running invisibly"*.
|
|
842
|
+
- Check that every step is not `active: false` — a tour with no active steps does not start.
|
|
843
|
+
- Add `delayBefore: 500` to a step whose component needs time to render.
|
|
844
|
+
|
|
845
|
+
**Spotlight in the wrong place, or a centered tooltip instead of a spotlight?**
|
|
846
|
+
- The target must be a React Native host component (`View`, `Text`, `Pressable`…). A custom component must forward the ref with `React.forwardRef`, or there is nothing to measure and the step falls back to a centered tooltip.
|
|
847
|
+
- Pass the ref itself (`targetRef={myRef}`), not `myRef.current` and not a callback ref.
|
|
848
|
+
- The component must be laid out when measured — use `scrollRef` so off-screen targets are scrolled into view.
|
|
849
|
+
|
|
850
|
+
**Auto-scroll not working?**
|
|
851
|
+
- Attach `scrollRef` to the scrollable itself, not a wrapper `View`.
|
|
852
|
+
- Pass `getCurrentScrollOffset` as well. Without it the tour assumes the list sits at offset 0 and scrolls to the wrong place once the user has scrolled.
|
|
853
|
+
|
|
854
|
+
**Tooltip overlapping the target or running off-screen?**
|
|
855
|
+
- Leave `autoPositionTooltip` at its default (`true`) so the tooltip flips to whichever side has room.
|
|
856
|
+
- Pass `insets` (from `useSafeAreaInsets()`) and `extraInsets` for tab bars and headers so the tooltip stays clear of system chrome.
|
|
857
|
+
|
|
858
|
+
**The Done button does nothing on the last step?**
|
|
859
|
+
- If you use `beforeStepChange`, remember `to` is `totalSteps` on the final step. A guard that only allows known indices will block finishing.
|
|
860
|
+
|
|
861
|
+
**Nothing happens when I tap Next?**
|
|
862
|
+
- A `beforeStepChange` promise that never settles holds the transition lock. Make sure it always resolves.
|
|
863
|
+
|
|
864
|
+
---
|
|
865
|
+
|
|
866
|
+
## Best practices
|
|
867
|
+
|
|
868
|
+
1. Keep tours short — 3-7 steps for best engagement
|
|
869
|
+
2. Always allow skipping — never trap users
|
|
870
|
+
3. Use `targetStyle` — let the spotlight match automatically instead of manual configuration
|
|
871
|
+
4. Set `scrollRef` globally — handles all scroll scenarios without per-step config
|
|
872
|
+
5. Use `tourId` with `useTourPersistence` — show tours only once
|
|
873
|
+
6. Use `delayBefore` instead of `setTimeout` — the library handles timing
|
|
874
|
+
7. Use `active` for conditional steps — numbering adjusts automatically
|
|
875
|
+
8. Test with VoiceOver/TalkBack — accessibility is enabled by default
|
|
876
|
+
|
|
877
|
+
---
|
|
878
|
+
|
|
879
|
+
## Frequently asked questions
|
|
880
|
+
|
|
881
|
+
### How do I add an onboarding tour to a React Native app?
|
|
882
|
+
|
|
883
|
+
Install `@wrack/react-native-tour-guide` and `react-native-svg`, wrap your app in `TourGuideProvider` with a `TourGuideOverlay`, then call `startTour(steps)` from the `useTourGuide()` hook. Each step references the component to highlight (via a `ref`) and the title/description to show. See [Quick start](#quick-start).
|
|
884
|
+
|
|
885
|
+
### How do I highlight a specific component with a spotlight?
|
|
886
|
+
|
|
887
|
+
Attach a `ref` to the component and pass it as `targetRef` on a step. The library measures the component, dims the rest of the screen, and cuts out a spotlight that matches the component's border radius automatically. Pass the component's style as `targetStyle` so the spotlight matches its shape.
|
|
888
|
+
|
|
889
|
+
### Can I fully customize the tooltip?
|
|
890
|
+
|
|
891
|
+
Yes. Use `config.tooltipStyles` to restyle the built-in tooltip, or pass `config.renderTooltip` to render your own component — it receives the title, description, step index, and `onNext`/`onPrev`/`onSkip` handlers. See [How to use a custom tooltip?](#how-to-use-a-custom-tooltip).
|
|
892
|
+
|
|
893
|
+
### Does it work with Expo?
|
|
894
|
+
|
|
895
|
+
Yes. It works with Expo (managed and bare) and React Native CLI. The only required dependency is `react-native-svg`, which Expo supports out of the box.
|
|
896
|
+
|
|
897
|
+
### Does it support the New Architecture (Fabric)?
|
|
898
|
+
|
|
899
|
+
Yes. The dark overlay is drawn with a single even-odd SVG path (a real punched-out hole) rather than an SVG `<Mask>`, so the spotlight renders correctly on both the old architecture and Fabric, with no white film over the highlighted element.
|
|
900
|
+
|
|
901
|
+
### Does it work with `ScrollView`, `FlatList`, and `SectionList`?
|
|
902
|
+
|
|
903
|
+
Yes. Pass a `scrollRef` (and a `getCurrentScrollOffset` getter) on the config and the tour scrolls off-screen targets into view automatically, keeping both the target and its tooltip on screen. Each scrollable exposes a different imperative API — `scrollTo` on `ScrollView`, `scrollToOffset` on `FlatList`, a scroll responder on `SectionList` — and the library detects the right one, including `Animated.ScrollView` and gesture-handler wrappers.
|
|
904
|
+
|
|
905
|
+
### What are the dependencies and bundle size?
|
|
906
|
+
|
|
907
|
+
The library itself is under 50KB and has **zero native dependencies** — only `react-native-svg` as a peer. Blur and gradient effects are fully optional and load lazily only if you install them, degrading gracefully to the standard overlay otherwise.
|
|
908
|
+
|
|
909
|
+
### Does it work with Jest?
|
|
910
|
+
|
|
911
|
+
Yes, with no extra configuration. The package ships both a CommonJS and an ES module build with the right `require`/`import` export conditions, so it resolves correctly under the `react-native` Jest preset without adding it to `transformIgnorePatterns`.
|
|
912
|
+
|
|
913
|
+
### Is it written in TypeScript?
|
|
914
|
+
|
|
915
|
+
Yes — it ships with full TypeScript types for every step option, config field, and theme.
|
|
916
|
+
|
|
917
|
+
### How does it compare to react-native-copilot or rn-tourguide?
|
|
918
|
+
|
|
919
|
+
All three highlight UI elements with tooltips. This library additionally matches the spotlight shape to each target's border radius automatically (circles, pills, per-corner radii), auto-scrolls so the target *and* tooltip both fit on screen, and ships zero native dependencies — so it runs in Expo Go without a custom dev build.
|
|
920
|
+
|
|
921
|
+
### Can I show a tour only once per user?
|
|
922
|
+
|
|
923
|
+
Yes — use the `useTourPersistence` hook with any storage backend (AsyncStorage, MMKV, or a custom adapter). See [How to show a tour only once?](#how-to-show-a-tour-only-once).
|
|
924
|
+
|
|
925
|
+
---
|
|
926
|
+
|
|
927
|
+
## Roadmap & help wanted
|
|
928
|
+
|
|
929
|
+
Contributions are welcome — issues and pull requests of any size help. Good places to start:
|
|
930
|
+
|
|
931
|
+
- New features and enhancements
|
|
932
|
+
- More built-in themes
|
|
933
|
+
- Additional examples (drawer/tab navigators, modals, lists)
|
|
934
|
+
- Documentation improvements and tests
|
|
935
|
+
- Bug fixes of any size
|
|
936
|
+
|
|
937
|
+
Browse [good first issues](https://github.com/himanshu-lal4/react-native-tour-guide/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) or [open a discussion](https://github.com/himanshu-lal4/react-native-tour-guide/discussions).
|
|
938
|
+
|
|
939
|
+
---
|
|
940
|
+
|
|
941
|
+
## Installing from GitHub Packages (mirror)
|
|
942
|
+
|
|
943
|
+
<details>
|
|
944
|
+
<summary>Setup instructions (requires a GitHub personal access token)</summary>
|
|
945
|
+
|
|
946
|
+
This package is also mirrored to GitHub Packages as `@tinsson/react-native-tour-guide`. Note that GitHub Packages requires authentication even for public packages, so installing from npm (see [Installation](#installation)) is recommended for most users.
|
|
947
|
+
|
|
948
|
+
1. Create a GitHub [personal access token](https://github.com/settings/tokens) with the `read:packages` scope.
|
|
949
|
+
2. Add the scope routing and token to your project's `.npmrc`:
|
|
950
|
+
|
|
951
|
+
```ini
|
|
952
|
+
@tinsson:registry=https://npm.pkg.github.com
|
|
953
|
+
//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN
|
|
954
|
+
```
|
|
955
|
+
|
|
956
|
+
3. Install (only the `@tinsson` scope routes to GitHub — all other dependencies still come from npm):
|
|
957
|
+
|
|
958
|
+
```bash
|
|
959
|
+
npm install @tinsson/react-native-tour-guide react-native-svg
|
|
960
|
+
```
|
|
961
|
+
|
|
962
|
+
4. Import from the mirrored name:
|
|
963
|
+
|
|
964
|
+
```ts
|
|
965
|
+
import { TourGuideProvider } from '@tinsson/react-native-tour-guide';
|
|
966
|
+
```
|
|
967
|
+
|
|
968
|
+
</details>
|
|
969
|
+
|
|
970
|
+
---
|
|
971
|
+
|
|
972
|
+
## Contributing & community
|
|
973
|
+
|
|
974
|
+
Issues, ideas, and pull requests of every size are welcome — bug reports and docs improvements help just as much as features.
|
|
975
|
+
|
|
976
|
+
- 🐛 [Report a bug](https://github.com/himanshu-lal4/react-native-tour-guide/issues/new?template=bug_report.yml)
|
|
977
|
+
- 💡 [Request a feature](https://github.com/himanshu-lal4/react-native-tour-guide/issues/new?template=feature_request.yml)
|
|
978
|
+
- 💬 [Ask a question / share an idea](https://github.com/himanshu-lal4/react-native-tour-guide/discussions)
|
|
979
|
+
- 🔧 [Submit a pull request](https://github.com/himanshu-lal4/react-native-tour-guide/pulls)
|
|
980
|
+
- ⭐ Star the repo to help others discover it
|
|
981
|
+
|
|
982
|
+
New to the project? Read [CONTRIBUTING.md](CONTRIBUTING.md) for local setup, the project structure, and the development workflow.
|
|
983
|
+
|
|
984
|
+
## Also by the same author
|
|
985
|
+
|
|
986
|
+
- **[react-native-liquid-glassmorphism](https://github.com/himanshu-lal4/react-native-liquid-glassmorphism)** — authentic Liquid Glass for React Native on both iOS and Android: native `UIGlassEffect` on iOS 26, a real-time AGSL refraction shader on Android. [npm](https://www.npmjs.com/package/react-native-liquid-glassmorphism) · [docs](https://himanshu-lal4.github.io/react-native-liquid-glassmorphism/)
|
|
987
|
+
|
|
988
|
+
## License
|
|
989
|
+
|
|
990
|
+
MIT — see [LICENSE](LICENSE).
|
|
991
|
+
|
|
992
|
+
---
|
|
993
|
+
|
|
994
|
+
Created by [Himanshu Lal](https://github.com/himanshu-lal4)
|