New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-guide-step

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-guide-step

A lightweight, zero-dependency React component for building interactive product tours, onboarding walkthroughs, and step-by-step guided experiences with spotlight overlay

latest
Source
npmnpm
Version
0.7.0
Version published
Maintainers
1
Created
Source

react-guide-step

react-guide-step

npm version license downloads

English | 简体中文

🔗 Live Demo & Homepage

A lightweight, zero-dependency React component library for building interactive product tours, onboarding walkthroughs, and step-by-step guided experiences.

Features

  • Step-based tours — Define a sequence of steps targeting any DOM element
  • Spotlight overlay — Highlights target elements while dimming the rest of the page
  • Smart positioning — Auto-calculates tooltip placement with 12 positions and viewport flip logic
  • Keyboard navigation — Navigate with arrow keys, Enter, and Escape
  • Custom rendering — Full control over step content via render props
  • Persistence — Optional localStorage-based completion tracking to avoid re-showing tours
  • Auto-scroll — Automatically scrolls target elements into view
  • Element waiting — Waits for async/lazy DOM elements to appear before proceeding
  • Theming — Customize colors, border radius, z-index, and animation duration
  • i18n ready — All button labels are configurable
  • Lifecycle hooksbeforeEnter and afterLeave async hooks per step
  • Image preloading — Preload step images to prevent layout shifts
  • Tree-shakeable — Zero runtime dependencies, ESM and CJS support

Installation

npm install react-guide-step
yarn add react-guide-step
pnpm add react-guide-step

Peer dependencies: react >= 18.0.0 and react-dom >= 18.0.0

Quick Start

1. Define your tour steps

// tours/onboarding.ts
import type { GuideStep } from 'react-guide-step';

const steps: GuideStep[] = [
  {
    target: '#welcome-header',
    title: 'Welcome!',
    content: 'Let us show you around the app.',
    placement: 'bottom',
  },
  {
    target: '#sidebar-nav',
    title: 'Navigation',
    content: 'Use the sidebar to navigate between pages.',
    placement: 'right',
  },
  {
    target: '#create-btn',
    title: 'Create',
    content: 'Click here to create a new project.',
    placement: 'bottom',
    highlightPadding: 8,
  },
];

2. Set up the provider and start the tour

import { GuideProvider, useGuide } from 'react-guide-step';
import type { GuideOptions } from 'react-guide-step';
import { steps } from './tours/onboarding';

function App() {
  const options: GuideOptions = {
    steps,
    maskClosable: true,
    keyboardNavigation: true,
    onComplete: () => console.log('Tour completed!'),
    onSkip: (step) => console.log(`Skipped at step ${step}`),
  };

  const guide = useGuide(options);

  return (
    <GuideProvider guide={guide} options={options}>
      <YourApp />
      <button onClick={() => guide.start()}>Start Tour</button>
    </GuideProvider>
  );
}

API Reference

useGuide(options)

The main hook that creates a guide controller.

Returns: GuideController

PropertyTypeDescription
start()() => voidStart the tour
stop()() => voidStop the tour
next()() => voidGo to next step
prev()() => voidGo to previous step
goTo(index)(number) => voidJump to a specific step
isActivebooleanWhether the tour is currently running
currentStepnumberCurrent step index
totalStepsnumberTotal number of steps
isCompletedbooleanWhether the tour has been completed

GuideOptions

OptionTypeDefaultDescription
stepsGuideStep[]requiredArray of tour steps
initialStepnumber0Starting step index
autoStartbooleanfalseAuto-start the guide on mount
maskClosablebooleanfalseClose guide when clicking the overlay
keyboardNavigationbooleantrueEnable keyboard navigation
scrollBehaviorScrollBehavior'smooth'Scroll behavior when scrolling target into view
persistKeystringlocalStorage key; completed tours won't re-show
themeGuideThemeCustom theme overrides
labelsGuideLabelsCustom button labels for i18n
onComplete() => voidCalled when the tour finishes
onSkip(stepIndex) => voidCalled when the tour is skipped
onStepChange(stepIndex) => voidCalled on each step transition

GuideStep

PropertyTypeDefaultDescription
targetstring | HTMLElementrequiredCSS selector or element reference
titlestringStep title
contentReactNodeStep description (supports text, JSX, images)
placementPlacement'bottom'Tooltip position relative to target
customRender(props: StepRenderProps) => ReactNodeCustom render function
beforeEnter() => void | Promise<void>Async hook before entering step
afterLeave() => void | Promise<void>Async hook after leaving step
highlightPaddingnumberExtra padding around the spotlight (px)
waitForElementbooleanfalseWait for target element to appear in DOM
showArrowbooleantrueShow arrow pointing to target
allowInteractionbooleanfalseAllow user interaction with highlighted element
preloadImagesstring[]Image URLs to preload before this step is displayed

Placement

'top' | 'top-start' | 'top-end'
'bottom' | 'bottom-start' | 'bottom-end'
'left' | 'left-start' | 'left-end'
'right' | 'right-start' | 'right-end'
'center'

GuideTheme

PropertyTypeDescription
primaryColorstringPrimary button and accent color
textColorstringText color
bgColorstringTooltip background color
overlayColorstringOverlay/mask color
borderRadiusnumberBorder radius in px
zIndexnumberBase z-index for the guide layer
animationDurationnumberAnimation duration in ms

GuideLabels

PropertyTypeDescription
nextstring"Next" button text
prevstring"Previous" button text
skipstring"Skip" button text
finishstring"Finish" button text
stepOfstringStep counter template, e.g. "{current} of {total}"

Advanced Usage

Custom Step Rendering

const steps: GuideStep[] = [
  {
    target: '#feature',
    customRender: ({ step, stepIndex, totalSteps, next, prev, skip }) => (
      <div className="my-custom-tooltip">
        <h3>Step {stepIndex + 1} of {totalSteps}</h3>
        <p>Your custom content here</p>
        <div>
          <button onClick={prev}>Back</button>
          <button onClick={next}>Continue</button>
          <button onClick={skip}>Skip Tour</button>
        </div>
      </div>
    ),
  },
];

Persistence

Prevent completed tours from re-appearing by setting a persistKey:

const options: GuideOptions = {
  steps,
  persistKey: 'onboarding-v1',
};

Completion state is stored in localStorage under the key rgs:<persistKey>. To reset, remove the key:

localStorage.removeItem('rgs:onboarding-v1');

Async Step Hooks

Run async operations before entering or after leaving a step:

const steps: GuideStep[] = [
  {
    target: '#dynamic-section',
    title: 'Dynamic Content',
    content: 'This section was loaded just for you.',
    waitForElement: true,
    beforeEnter: async () => {
      await fetchAndRenderSection();
    },
    afterLeave: async () => {
      await trackStepViewed();
    },
  },
];

Keywords

react-guide-step

FAQs

Package last updated on 05 Mar 2026

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