Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stackbuilders/react-native-spotlight-tour

A highly customizable tour feature with an awesome spotlight effect
https://github.com/stackbuilders/react-native-spotlight-tour

android app-tour customizable hacktoberfest ios react react-native spotlight spotlight-tour step-by-step tour user-guide

Last synced: 4 days ago
JSON representation

A highly customizable tour feature with an awesome spotlight effect

Awesome Lists containing this project

README

        

# React Native Spotlight Tour

[![All Contributors](https://img.shields.io/badge/all_contributors-15-orange.svg?style=flat-square)](#contributors-)

[![CI](https://github.com/stackbuilders/react-native-spotlight-tour/actions/workflows/ci.yml/badge.svg)](https://github.com/stackbuilders/react-native-spotlight-tour/actions/workflows/ci.yml)
[![Release](https://github.com/stackbuilders/react-native-spotlight-tour/actions/workflows/release.yml/badge.svg)](https://github.com/stackbuilders/react-native-spotlight-tour/actions/workflows/release.yml)
[![NPM version](https://img.shields.io/npm/v/react-native-spotlight-tour)](https://www.npmjs.com/package/react-native-spotlight-tour)
[![NPM downloads](https://img.shields.io/npm/dm/react-native-spotlight-tour)](https://www.npmjs.com/package/react-native-spotlight-tour)
[![NPM license](https://img.shields.io/npm/l/react-native-spotlight-tour)](https://github.com/stackbuilders/react-native-spotlight-tour/blob/main/LICENSE)
[![GitHub Release Date](https://img.shields.io/github/release-date/stackbuilders/react-native-spotlight-tour)](https://github.com/stackbuilders/react-native-spotlight-tour/releases)
[![Known Vulnerabilities](https://snyk.io/test/github/stackbuilders/react-native-spotlight-tour/badge.svg)](https://snyk.io/test/github/stackbuilders/react-native-spotlight-tour)

`react-native-spotlight-tour` is a simple and intuitive library for React Native (Android, iOS, and Web
compatible). It uses [Floating UI](https://floating-ui.com) under the hood in order to handle elements
positioning, it re-exports all floating-ui middlewares to be configured in the tour.
It also allows you to implement a highly customizable tour feature with an awesome spotlight effect.
This library handles animations at the native level and is perfect
for the following:

- Guiding users on how to use your application
- Showing an introduction to your users

spotlight-bounce-gif
spotlight-fade-gif
spotlight-slide-gif
spotlight-rect-gif

## Requirements

- [ReactJS](https://reactjs.org/) >= 16.8.0
- [React Native](https://reactnative.dev/) >= 0.50.0
- [react-native-svg](https://github.com/react-native-svg/react-native-svg) >= 12.1.0

## Install

With `npm`:

```bash
npm install react-native-spotlight-tour
```

With `yarn`:

```bash
yarn add react-native-spotlight-tour
```

## 🚨 Breaking changes: v2 to v3

This major update brings a few fixes, some great new features, and some breaking changes. These are some highlight you'll need to consider while upgrading from v2 to v3:

- The package has been renamed from `@stackbuilders/react-native-spotlight-tour` to just `react-native-spotlight-tour`
- Don't worry, this library is still developed and maintained by the [Stack Builders Inc.](https://www.stackbuilders.com/) team!
- Remove the former package from your dependencies and use the command described in the [Install section](#install)
- Rename any import from the previous name to use just `react-native-spotlight-tour` instead
- Tooltip positioning was refactored
- Props related to the tooltip position were removed from `SpotlightTourProvider` and the `TourStep` object.
- Both `Align` and `Position` enums were removed
- Both `alignTo` and `position` props were removed
- We now delegate the positioning to [FloatingUI](https://floating-ui.com/), so you can use the `floatingProps` prop to configure its global behavior or granularly on each step.
- Middleware functions are re-exported from `@floating-ui/react-native` to `react-native-spotlight-tour`.
- You may not need to do changes on `floatingProps` since the default behavior is very similar to v2

## Usage

To be able to use the tour, you'll need to wrap everything around a `SpotlightTourProvider`. This provider component will also give you access to a hook to retrieve the `SpotlightTour` context, which gives information and fine control over the tour.

```tsx
import { Button, Text, View } from "react-native";
import {
AttachStep,
SpotlightTourProvider,
TourStep,
flip,
offset,
shift,
} from "react-native-spotlight-tour";

const mySteps: TourStep[] = [
// ...setup the steps
];

return (

{({ start }) => (
<>



Introduction


This is an example using the spotlight-tour library.
Press the Start button to see it in action.



Documentation


Please, read the documentation before installing.


>
)};

);
```

Floating-UI props can be defined in the `` and this will be applied to all tour steps. If no configuration is given it will take a default with the next values:
`middlewares: [flip(), offset(4), shift()]` and `placement: "bottom"`.

The tour requires an array of steps to be configured, which will map directly to each `` index. Bellow is a complete example of a `TourStep` array:

```tsx
import { Button, Text, View } from "react-native";
import {
Align,
TourStep,
useSpotlightTour
} from "react-native-spotlight-tour";

const mySteps: TourStep[] = [{
// This configurations will apply just for this step
floatingProps:{
middleware: [offset(0), shift(), flip()],
placement: "right",
},
render: ({ next }) => (

This is the first step of tour!


)
}, {
before: () => {
return DataService.fetchData()
.then(setData);
},
render: () => {
// You can also use the hook inside the step component!
const { previous, stop } = useSpotlightTour();

return (

This is the first step of tour!



);
}
}];
```

Floating-UI props can be defined in each step for a custom configuration. If no floating configuration is specified in the step it will take the one defined in the ``.

You can also find a complete example [here](example/).

## Built-in Helper Components

You can take advantage of the built-in customizable components. For example, our [TourBox](https://stackbuilders.github.io/react-native-spotlight-tour/docs/build/#tourbox) component can be used as a tooltip container for each step.

```tsx
import { Text } from "react-native";
import { Align, TourBox, TourStep } from "react-native-spotlight-tour";

const tourSteps: TourStep[] = [{
render: props => (


{"This is the third step of tour example.\n"}
{"If you want to go to the next step, please press "}{"Next.\n"}
{"If you want to go to the previous step, press "}{"Previous.\n"}


),
}];
```

### Tour customization

The [SpotlightTourProvider](https://stackbuilders.github.io/react-native-spotlight-tour/docs/build/#spotlighttourprovider) also allows you to customize the overlay through the [overlayColor](https://stackbuilders.github.io/react-native-spotlight-tour/docs/build/interfaces/SpotlightTourProviderProps.html#overlaycolor) and [overlayOpacity](https://stackbuilders.github.io/react-native-spotlight-tour/docs/build/interfaces/SpotlightTourProviderProps.html#overlayopacity) props.

```tsx
import { AttachStep, SpotlightTourProvider, TourStep } from "react-native-spotlight-tour";

const mySteps: TourStep[] = [
// ...
];

return (

{({ start }) => (
<>
{/* ... */}
>
)};

);
```

Besides above customizations, you can also define the transition animation [see motion](https://stackbuilders.github.io/react-native-spotlight-tour/docs/build/#motion) and the behavior when the user presses the backdrop [see onBackdropPress](https://stackbuilders.github.io/react-native-spotlight-tour/docs/build/#backdroppressbehavior). Otherwise if you wish to make them different for an specific step you could override this properties in the `TourStep` configuration.

```tsx
import { Button, Text, View } from "react-native";
import {
Align
AttachStep,
SpotlightTourProvider,
TourStep,
TourBox
} from "react-native-spotlight-tour";

const tourSteps: TourStep[] = [{
motion: "fade",
onBackdropPress: "stop",
render: props => (


{"This is the first step of tour example.\n"}
{"If you want to go to the next step, please press "}{"Next.\n"}
{"If you want to go to the previous step, press "}{"Previous.\n"}


),
}];

return (

{({ start }) => (
<>



Introduction


This is an example using the spotlight-tour library.
Press the Start button to see it in action.


>
)};

);
```

## API Reference

To view all the types, options, and props, please check the complete [API Reference](https://stackbuilders.github.io/react-native-spotlight-tour/docs/build/) documentation.

## Contributing

Do you want to contribute to this project? Please take a look at our [contributing guideline](/docs/CONTRIBUTING.md) to know how you can help us build it.

---
Stack Builders
[Check out our libraries](https://github.com/stackbuilders/) | [Join our team](https://www.stackbuilders.com/join-us/)

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):



Jose Luis Leon
Jose Luis Leon

πŸ’» ⚠️ πŸ“– πŸš‡ 🚧 πŸ‘€
SebastiΓ‘n Estrella
SebastiΓ‘n Estrella

πŸš‡
Angie Rojas
Angie Rojas

πŸ’» πŸ“–
Fernanda Andrade
Fernanda Andrade

πŸš‡ ⚠️
Steven Cuasqui
Steven Cuasqui

πŸ“–
Alexander MejΓ­a
Alexander MejΓ­a

πŸ’»
Carolina LΓ³pez
Carolina LΓ³pez

πŸ’» πŸ’‘


cmarcag
cmarcag

⚠️
Ricardo Arrobo
Ricardo Arrobo

πŸ’» πŸ“–
Mohammad Abkal
Mohammad Abkal

πŸ“–
Alexander Pokhil
Alexander Pokhil

πŸ’»
Alejandro Vivanco
Alejandro Vivanco

πŸ’» πŸ‘€
Wellington Mendoza
Wellington Mendoza

πŸ‘€
Christian Samaniego
Christian Samaniego

πŸ‘€


beKool.sh
beKool.sh

πŸ“–






Add your contributions



This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

## License

MIT, see [the LICENSE file](LICENSE).