Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-app-intro-slider

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-app-intro-slider

Simple and configurable app introduction slider for react native

  • 4.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
18K
increased by1.02%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-app-intro-slider

An easy-to-use yet very configurable app introduction slider/swiper based on FlatList that supports RTL.

yarn add react-native-app-intro-slider

Usage

Simple examples

BasicshowSkipButtonbottomButton and showSkipButton
Basic example gifshowSkipButton example imagebottomButton example image

The component is based on FlatList so usage is very similar. Pass a data-array to AppIntroSlider along with a renderItem-function:

import React from 'react';
import { StyleSheet } from 'react-native';
import AppIntroSlider from 'react-native-app-intro-slider';

const slides = [
  {
    key: 1,
    title: 'Title 1',
    text: 'Description.\nSay something cool',
    image: require('./assets/1.jpg'),
    backgroundColor: '#59b2ab',
  },
  {
    key: 2,
    title: 'Title 2',
    text: 'Other cool stuff',
    image: require('./assets/2.jpg'),
    backgroundColor: '#febe29',
  },
  {
    key: 3,
    title: 'Rocket guy',
    text: 'I\'m already out of descriptions\n\nLorem ipsum bla bla bla',
    image: require('./assets/3.jpg'),
    backgroundColor: '#22bcb5',
  }
];

export default class App extends React.Component {
  this.state = {
    showRealApp: false
  }
  _renderItem = ({ item }) => {
    return (
      <View style={styles.slide}>
        <Text style={styles.title}>{item.title}</Text>
        <Image source={item.image} />
        <Text style={styles.text}>{item.text}</Text>
      </View>
    );
  }
  _onDone = () => {
    // User finished the introduction. Show real app through
    // navigation or simply by controlling state
    this.setState({ showRealApp: true });
  }
  render() {
    if (this.state.showRealApp) {
      return <App />;
    } else {
      return <AppIntroSlider renderItem={this._renderItem} data={slides} onDone={this._onDone}/>;
    }
  }
}

Configuring buttons

Button example gif

import React from 'react';
import Icon from 'react-native-vector-icons/Ionicons';
import { StyleSheet, View } from 'react-native';
import AppIntroSlider from 'react-native-app-intro-slider';

const styles = StyleSheet.create({
  buttonCircle: {
    width: 40,
    height: 40,
    backgroundColor: 'rgba(0, 0, 0, .2)',
    borderRadius: 20,
    justifyContent: 'center',
    alignItems: 'center',
  },
  //[...]
});

// slides = [...]

export default class App extends React.Component {
  _renderItem = ({ item }) => {
    return (
      <View style={styles.slide}>
        <Text style={styles.title}>{item.title}</Text>
        <Image source={item.image} />
        <Text style={styles.text}>{item.text}</Text>
      </View>
    );
  }
  _renderNextButton = () => {
    return (
      <View style={styles.buttonCircle}>
        <Ion
          name="md-arrow-round-forward"
          color="rgba(255, 255, 255, .9)"
          size={24}
        />
      </View>
    );
  };
  _renderDoneButton = () => {
    return (
      <View style={styles.buttonCircle}>
        <Ion
          name="md-checkmark"
          color="rgba(255, 255, 255, .9)"
          size={24}
        />
      </View>
    );
  };
  render() {
    return (
      <AppIntroSlider
        data={slides}
        renderDoneButton={this._renderDoneButton}
        renderNextButton={this._renderNextButton}
      />
    );
  }
}

Here a custom renderItem is supplied and the bottomButton-props has been set to true. Notice how the setup of slides has been configured to support icons and gradient backgrounds.

Props and methods

The component extends FlatList so all FlatList-props are valid.

Props

NameTypeDefaultDescription
dataobjectNone, requiredAn array of objects (they should either contain a unique key-prop or you should pass a keyExtractor-function to the component)
renderItemfunctionNone, requiredFlatList's renderItem. Receives ({item, index, dimensions}) where dimensions contains height and width of the slides
onSlideChangefunctionvoidCalled when user goes changes slide (by swiping or pressing next/prev). Function called with arguments (index: number, lastIndex: number)
renderPaginationfunctionFunction to render a custom pagination/button component on top of slides. Receives the index of the currently active slide
onDonefunctionvoidCalled when user ends the introduction by pressing the done button
onSkipfunctionScrolls to the endCalled when user presses the skip button
bottomButtonbooleanfalseEnable to show a full-width button under pagination
dotStylestyle{backgroundColor: 'rgba(0, 0, 0, .2)'}Style of inactive pagination dots
activeDotStylestyle{backgroundColor: 'rgba(255, 255, 255, .9)'}Style of active pagination dot
skipLabelstringSkipCustom label for Skip button
doneLabelstringDoneCustom label for Done button
nextLabelstringNextCustom label for Next button
prevLabelstringBackCustom label for Prev button
showSkipButtonbooleanfalseEnable to show a skip button to the left of pagination dots. When bottomButton == true the skip button is a small text under the full-width next button
showPrevButtonbooleanfalseEnable to show a previous button. If showSkipButton is true, the skip button will be displayed on the first page and prev button on subsequent one
showNextButtonbooleantrueDisable to hide the next button
showDoneButtonbooleantrueDisable to hide the done button
renderNextButtonfunctionrenders a Text-componentUse to supply your own next button
renderPrevButtonfunctionrenders a Text-componentUse to supply your own prev button
renderDoneButtonfunctionrenders a Text-componentUse to supply your own done button
renderSkipButtonfunctionrenders a Text-componentUse to supply your own skip button

Methods

Method NameArgumentsDescription
goToSlidenumberChange to slide with specified index
getListRefnoneReturns the Flat List ref

Examples

Keywords

FAQs

Package last updated on 02 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc