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

react-native-guide-mark

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-guide-mark

React Native Guide Mark / Coach Mark to guide first time app users

  • 1.0.61
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

React Native Guide Mark

This React Native module is for guiding the first time user throughout the app.

guide mark in action

Installation

yarn: yarn add react-native-guide-mark, npm: npm install react-native-guide-mark

Example

  1. import react-native-guide-mark:
import { GuideMark } from 'react-native-guide-mark';
  1. create a guide mark mask:
export const App = () => {
    const [visible, setVisible] = React.useState(true);
    return (
        <GuideMark
            title="Step 1"
            description="This is the first step"
            visible={visible}
            onButtonPress={() => setVisible(false)}
            top={100}
            left={150}
        />
    );
};

Using ref

export const App = () => {
    const buttonRef = useRef(null); //1. creating ref for the pointing element
    const [visible, setvisible] = useState(false);

    return (
        <View>
            <GuideMark
                visible={visible}
                title="Click here"
                description="To see a magic!"
                buttonTitle={'Show me!'}
                onButtonPress={() => {
                    setvisible(false);
                    setvisible2(true);
                    setshowImage(true);
                }}
                pointRef={buttonRef} //3. Passing ref of pointing element to guide mark
            />
            <View style={{ flexDirection: 'row', justifyContent: 'center' }}>
                <View style={{ paddingHorizontal: 30 }} ref={buttonRef} collapsable={false}>
                    {/* 2. assign ref to required pointing element */}
                    <Button
                        title="Click Here"
                        onPress={() => {
                            setvisible(true);
                        }}
                    />
                </View>
            </View>
        </View>
    );
};
  1. Create a ref with userRef.
  2. assign that ref to required View element and add collapsable={false} to it.
  3. pass the ref to pointRef prop.

Note: Make sure to add collapsable={false} to the View element, otherwise ref measurement will not be available in Android.

Props

NameTypeDefaultDescription
visibleBooleanfalsetrue:show | false:hide the mask
titleStringnulltitle of the mask
titleTextStyleObject{fontSize: 34, fontWeight: "bold",color: 'white'}Title text style
descriptionStringnullDescription of mask
descriptionStyleObject{fontSize: 14,color: 'white',fontWeight:"100"}Description text style
buttonTitleStringnullTitle of the button (Built in button will be enabled only if onButtonPress is set with function)
onButtonPressFunctionnullEvent on button press
onMarkPressFunctionnullEvent on press of marked spot
leftnumber | String0Position from left of the screen, Number: 0 to maximum display width, String: percentage valuefrom 0% to 100%
topNumber | String0Position from top of the screen, Number: 0 to maximum display height, String: percentage value from 0% to 100%
markSizeNumber150size of mark
markImageRequire | Objectrequire('mark.png')PNG image with transparent at middle & semi transparent at the edges (matching to mask color), Note: Make sure the image matches with mask, otherwise, square patch will be visible around the mark.
maskBgColorString"rgba(0,0,0,0.75)"Mask color.
buttonElmReact ComponentnullCustom button component
pointRefRefnullTo pont the mark on required View element, need to pass ref of the elemnt, mark will automatically calculates the measurements.

Tips on using single guide mark

Here are the some cool tips how you can use it in better way to guide users

  • When user open your app first time, trigger visible prop with true with componentDidMount ,useEffect or may be by default by keeping state to true.
  • You can make use of onButtonPress action to navigate to next screen, do some action or may be set the state of this mark to false & next mark as true. You can make use of onMarkPress action to do similar stuff as well
  • Make use of AsyncStorage by setting some status in store not to open the mask next time or you may use custom api call to do the same.
Next up
  • Provide ref to element
  • Wizard
  • Custom hook (if its worthy of doing!)

Keywords

FAQs

Package last updated on 25 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