Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-native-onboarding-swiper

jfilter20.6kMIT1.3.0TypeScript support: definitely-typed

Delightful Onboarding for your React-Native App

React, Native, React-Native, Component, Onboarding, Tutorial, Intro, Swiper, Welcome, Introduction, Instructions

readme

<Onboarding /> npm npm

There are many ways to onboard people to your mobile app. But for React-Native, there is solely one component that is a) easy to setup and b) highly customizable: react-native-onboarding-swiper.

Your new users shouldn't jump in at the deep end. First give them a pleasurable, delightful introduction and only then let them explore your awesome app.

Getting everything running merely takes a minute. Try out the example running in your browser. Or check out this tutorial on YouTube.

Install

npm i react-native-onboarding-swiper
yarn add react-native-onboarding-swiper

Usage

import Onboarding from 'react-native-onboarding-swiper';

<Onboarding
  pages={[
    {
      backgroundColor: '#fff',
      image: <Image source={require('./images/circle.png')} />,
      title: 'Onboarding',
      subtitle: 'Done with React Native Onboarding Swiper',
    },
    ...
  ]}
/>

Examples

Check out the three examples files: the simple example, the example with a Call-to-Action button or the example with custom button components.

Required Properties

  • pages (required): an array of pages in the following shape:
    • backgroundColor (required): a background color. The color of the font and dots adapts to the background color.
    • image (required): a component (e.g. <Image />) to display at the top of the page.
    • title (required): a string OR a React-Native component.
    • subtitle (required): a string OR a React-Native component.

Optional Properties

Buttons

  • nextLabel (optional): a string OR a React-Native component for the Next label. Defaults to Next.
  • showNext (optional): a bool flag indicating whether the Next button is visible. Defaults to true.
  • skipLabel (optional): a string OR a React-Native component for the Skip label. Defaults to Skip.
  • showSkip (optional): a bool flag indicating whether the Skip button is visible. Defaults to true.
  • onSkip (optional): a callback that is fired if the Onboarding is skipped.
  • skipToPage (optional): when pressing skip, go to that page (e.g. skipToPage={2}). If this prop is provided, ignores onSkip.
  • onDone (optional): a callback that is fired after the Onboarding is completed.
  • showDone (optional): a bool flag indicating whether the Done checkmark button is visible. Defaults to true.

General

  • bottomBarHeight (optional): a number for the height of the bottom bar. Defaults to 60.
  • bottomBarColor (optional): backgroundColor of the bottom bar. Defaults to transparent.
  • bottomBarHighlight (optional): a bool flag indicating whether the bottom bar should be highlighted. Defaults to true.
  • controlStatusBar (optional): a bool flag indicating whether the status bar should change with the background color. Defaults to true.
  • showPagination (optional): whether to show the bottom pagination bar. Defaults to true.
  • flatlistProps (optional): additional props for the FlatList which holds all the pages.
  • transitionAnimationDuration (optional): The duration in milliseconds for the animation of the background color for the page transition. Defaults to 500.
  • allowFontScalingText (optional): Font scaling can cause troubles with high-resolution screens. You may want to disable it. Defaults to true.
  • allowFontScalingButtons (optional): Font scaling can cause troubles with high-resolution screens. You may want to disable it. Defaults to true.
  • pageIndexCallback (optional): a function that receives the page index as a parameter on page change. Example Usage

Default Page Styles

For the pages in the pages array, you can set the default styles (and override the styles set by this component).

  • containerStyles (optional): override the default container styles.
  • imageContainerStyles (optional): override the default image container styles e.g. the paddingBottom of 60.
  • titleStyles (optional): override the default title styles.
  • subTitleStyles (optional): override the default subtitle styles.

Adjust Individual Page Styles

For each page in the pages array, you can override the default page styles. An example.

  • titleStyles (optional): modify styles of a specific page's title.
  • subTitleStyles (optional): modify styles of a specific page's subtitle.

Custom Components Properties

You can also provide your own custom components for the buttons and the dots. All of them have access to a isLight prop but it's up to you what you do with it. Also checkout this example.

  • SkipButtonComponent (optional): Skip Button, gets skipLabel as prop.
  • NextButtonComponent (optional): Next Button, gets nextLabel as prop.
  • DoneButtonComponent (optional): Done Button.
  • DotComponent (optional): Dot for the pagination, gets selected as prop to indicate the active page.

Controlling the pages imperatively

You can control the Onboarding component imperatively with useRef.

const onboardingRef = useRef<Onboarding>(null);

<Onboarding
    ref={onboardingRef}
    pages={pages}
/>

onboardingRef.current.goNext()
onboardingRef.current.goToPage(2, true)
onboardingRef.current.goToPage(2, false)

Methods:

  • goNext() : Go to the next page.
  • goToPage(pageIndex, animated) : Go to the selected page.

Contributing

If you have a question, found a bug or want to propose a new feature, have a look at the issues page.

Pull requests are especially welcomed when they fix bugs or improve the code quality.

Acknowledgements

Built upon the work by Gosha Arinich which was originally inspired by AndroidOnboarder.

License

MIT.

changelog

1.1.1 (April 15, 2020)

  • fix RTL
  • use useNativeDrive for RN v0.62+

1.1.0 (May 01, 2019)

  • add more props for special cases

1.0.0 (January 04, 2019)

  • stable release (no changes)

0.10.0 (November 25, 2018)

  • override default pages styles

0.9.0 (October 29, 2018)

  • add pageIndexCallback to get the page index on change

0.8.0 (October 21, 2018)

  • add props for title's styles
  • fix font scaling for symbol buttons

0.7.0 (July 27, 2018)

  • add some more props and re-work how the statusbar color gets reset to default

0.6.0 (April 08, 2018)

  • iPhone X support (thanks to @nbolender)
  • new props: flatlistProps and controlStatusBar
  • fade-in animation for Done button

0.5.0 (March 24, 2018)

  • allow customization of image container styles
  • fix several propTypes warnings

0.4.0 (February 23, 2018)

  • Listen to orientation changes and adjust content appropiatly
  • Add animations between page chagnes
  • Make buttons, dots etc. adjustable via a wide range of different props
  • Change next arrow to text button next.

0.3.0 (October 18, 2017)

  • Increase touchable Radius for Buttons

0.2.0 (October 16, 2017)

  • Change name to react-native-onboarding-swiper
  • Change from ScrollView to FlatList
  • Add skipLabel prop
  • Title and subtitle can be components
  • Change onEnd to onSkip and onDone
  • Remove check mark dot because it's not useful
  • Adapt StatusBar color
  • Refactor most of the internal components

0.1.1 (October 11, 2016)

  • Detect light background and adapt the text and controls to it.
  • Allow to disable the bottom bar overlay via the bottomOverlay prop.
  • Allow to disable either of the skip, next, or done buttons.

0.1.0 (October 10, 2016)

Initial release.