• Stars
    star
    407
  • Rank 106,183 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Intro.js react wrapper

intro.js-react

integration Coverage Status

A small React wrapper around Intro.js. The wrapper provides support for both steps and hints.

Quicklinks

Example

You can find a small example here on codesandbox.io.

Installation

Install using Npm (don't forget to add the --save option if you're still using npm < 5):

$ npm install intro.js-react

Or Yarn:

$ yarn add intro.js-react

Make sure to have React & Intro.js installed (they're peer dependencies) and the Intro.js CSS definitions properly loaded into your project.

This would usually looks like:

import 'intro.js/introjs.css';

Usage

Two component are available for both steps and hints:

import { Steps, Hints } from 'intro.js-react';

Steps

Note: Steps indexes always starts from 0 in this wrapper instead of 1 like in Intro.js.

Basic example:

<Steps
  enabled={stepsEnabled}
  steps={steps}
  initialStep={initialStep}
  onExit={this.onExit}
/>

Props

Name Description Type Required
enabled Defines if the steps are visible or not.
Default: false.
Boolean
initialStep Step index to start with when showing the steps. Number โœ…
steps All the steps. Step[] โœ…
onExit Callback called when the steps are disabled
Required to force keeping track of the state when the steps are dismissed with an Intro.js event and not the enabled prop.
Function
(stepIndex)
โœ…
onBeforeExit Callback called before exiting the intro.
If you want to prevent exiting the intro, you can return false in this callback (available since intro.js 0.2.7).
Function
(stepIndex)
onStart Callback called when the steps are enabled. Function
(stepIndex)
onChange Callback called when the current step is changed. Function
(nextStepIndex, nextElement)
onBeforeChange Callback called before changing the current step.
If you want to prevent the transition to the next / previous step, you can return false in this callback (available since intro.js 2.8.0).
Function
(nextStepIndex, nextElement)
onAfterChange Callback called after changing the current step. Function
(newStepIndex, newElement)
onPreventChange Callback called if you prevented transitioning to a new step by returning false in onBeforeChange. Function
(stepIndex)
onComplete Callback called when all the steps are completed. Function
()
options Intro.js options. Object

Step

const steps = [
  {
    element: '.selector1',
    intro: 'test 1',
    position: 'right',
    tooltipClass: 'myTooltipClass',
    highlightClass: 'myHighlightClass',
  },
  {
    element: '.selector2',
    intro: 'test 2',
  },
  {
    element: '.selector3',
    intro: 'test 3',
  },
];
Name Description Type Required
element CSS selector to use for the step. String
intro The tooltip content. String | React element โœ…
position Position of the tooltip. String
tooltipClass CSS class of the tooltip. String
highlightClass CSS class of the helperLayer. String

Dynamic elements

If you want to use Intro.js Steps with dynamically created elements, you have to update the element associated to the step when it's available.

To do that, you can use the updateStepElement() API and pass to it the index of the step to update:

<Steps
  enabled={stepsEnabled}
  steps={steps}
  ref={steps => (this.steps = steps)}
/>
onBeforeChange = nextStepIndex => {
  if (nextStepIndex === 4) {
    this.steps.updateStepElement(nextStepIndex);
  }
}

Hints

Basic example:

<Hints
  enabled={hintsEnabled}
  hints={hints}
/>

Props

Name Description Type Required
enabled Defines if the hints are visible or not.
Default: false.
Boolean
hints All the hints. Hint[] โœ…
onClick Callback called when a hint is clicked. Function
( )
onClose Callback called when a hint is closed. Function
( )
options Intro.js options. Object

Hint

const hints = [
  {
    element: '.selector1',
    hint: 'test 1',
    hintPosition: 'middle-middle',
  },
  {
    element: '.selector2',
    hint: 'test 2',
  },
];
Name Description Type Required
element CSS selector to use for the hint. String โœ…
hint The tooltip text. String โœ…
hintPosition Position of the tooltip. String

Intro.js API

If for some reasons you need to use the Intro.js API, you can still get the Intro.js instance by using a ref on either the <Steps /> or <Hints /> components and using this.refName.introJs.

<Hints
  enabled={hintsEnabled}
  hints={hints}
  ref={hints => (this.hints = hints)}
/>

Intro.js options

You can find more details regarding Intro.js options and their default values in the documentation or directly in their code.

The wrapper overrides some Intro.js default options in the helpers/defaultProps.js file.

Name Description Type
nextLabel Next button label. String
prevLabel Previous button label. String
skipLabel Skip button label. String
doneLabel Done button label. String
hidePrev Hides the Previous button in the first step. Boolean
hideNext Hide the Next button in the last step. Boolean
tooltipPosition Position of the tooltips. String
tooltipClass CSS class of the tooltips. String
highlightClass CSS class of the helperLayer. String
exitOnEsc Exit by pressing Escape. Boolean
exitOnOverlayClick Exit by clicking on the overlay layer. Boolean
showStepNumbers Show steps number in a red circle. Boolean
keyboardNavigation Allows navigation between steps using the keyboard. Boolean
showButtons Show navigation buttons. Boolean
showBullets Show bullets. Boolean
showProgress Show progress indicator. Boolean
scrollToElement Enables scrolling to hidden elements. Boolean
overlayOpacity Opacity of the overlay. Number
scrollPadding Padding when automatically scrolling to an element. Number
positionPrecedence Precedence of positions. String[]
disableInteraction Disables interaction inside elements. Boolean
hintPosition Position of the hints. String
hintButtonLabel Hint button label. String
hintAnimation Enables hint animations. Boolean

License

Licensed under the MIT License, Copyright ยฉ HiDeoo.

See LICENSE for more information.

More Repositories

1

starlight-blog

Starlight plugin to add a blog to your documentation
TypeScript
128
star
2

starlight-openapi

Starlight plugin to generate documentation from OpenAPI/Swagger specifications
TypeScript
108
star
3

starlight-typedoc

Starlight plugin to generate documentation from TypeScript using TypeDoc
TypeScript
70
star
4

starlight-obsidian

Starlight plugin to publish Obsidian vaults
TypeScript
62
star
5

YaTA

Yet another Twitch App
TypeScript
57
star
6

starlight-links-validator

Starlight plugin to validate internal links
TypeScript
56
star
7

starlight-image-zoom

Starlight plugin adding zoom capabilities to your documentation images
TypeScript
42
star
8

zod-matter

Typesafe front matter
TypeScript
23
star
9

toggler

Atom plugin - Toggle words and symbols
JavaScript
21
star
10

toggler-vscode

Visual Studio Code extension - Toggle words and symbols
TypeScript
21
star
11

astro-d2

Astro integration and remark plugin to transform D2 Markdown code blocks into diagrams
TypeScript
21
star
12

starlight-showcases

Set of Starlight components to author showcase pages
Astro
20
star
13

starlight-package-managers

Quickly display npm related commands for multiple package managers in your Starlight documentation site
TypeScript
17
star
14

astro-content-devtools

Browse Astro Content Collections, schemas and entry files in your browser
TypeScript
17
star
15

starlight-versions

Starlight plugin to version documentation pages
TypeScript
17
star
16

starlight-theme-rapide

Starlight theme inspired by the Visual Studio Code Vitesse theme
CSS
16
star
17

starlight-i18n

Visual Studio Code extension - Easily translate Starlight documentation pages.
TypeScript
14
star
18

dotfiles

Dotfiles collection to install & configure HiDeoo's macOS setup
Shell
14
star
19

vercel-env-push

The missing Vercel CLI command to push environment variables from .env files.
TypeScript
13
star
20

Couleur

Color picker & editor in SwiftUI
Swift
10
star
21

npm-package-manager-extension

Browser extension adding support for multiple package managers to npmjs.com.
TypeScript
10
star
22

starlight-heading-badges

Starlight plugin to add badges to your Markdown and MDX headings
TypeScript
10
star
23

Haku

Craft, consolidate and tackle your notebooks and to-do lists all in one place.
TypeScript
9
star
24

issue-form-block

GitHub Block to preview and edit issue forms as a custom file renderer in GitHub
TypeScript
9
star
25

create

Visual Studio Code extension - Quickly create new File(s) & Folder(s).
TypeScript
7
star
26

autocomplete-lodash

Atom plugin - Lodash methods autocompletion
JavaScript
7
star
27

Typedown

Visual Studio Code extension - Quickly export your TypeScript definitions to Markdown
TypeScript
7
star
28

starlight-overrides-map

An interactive map of Starlight component overrides
Astro
7
star
29

ts-playground-block

GitHub Block to embed a TypeScript Playground in Markdown files or as a custom file renderer in GitHub
TypeScript
6
star
30

trailing

Visual Studio Code extension - Toggle trailing symbols: commas, semicolons and colons.
TypeScript
6
star
31

iTerm2-theme-vitesse

A set of iTerm2 color themes based on the Vitesse Theme for VS Code
TypeScript
5
star
32

vitest-fs

Custom Vitest file system matchers.
TypeScript
5
star
33

hideoo

HiDeoo's profile README
TypeScript
5
star
34

starlight-head-generator

Quickly generate the configuration to add custom tags to your Starlight website head
Astro
5
star
35

starlight-server-islands-hyperping

A demo of Starlight using Server Islands to display an API status widget
Astro
5
star
36

npm-install-block

GitHub Block to display commands to install npm packages using multiple package managers in Markdown files in GitHub
TypeScript
4
star
37

KeyPrompter

Shortcut broadcaster for OBS
Go
4
star
38

lodash-doc-parser

Lodash documentation parser generating a JSON representation.
JavaScript
4
star
39

vitest-console

Quickly mock various console methods in Vitest and track their calls with custom matchers.
TypeScript
4
star
40

prisma-schema-block

GitHub Block to preview Prisma schemas in Markdown files or as a custom file renderer in GitHub
TypeScript
4
star
41

create-app

CLI utility to bootstrap a new project by creating a new app from scratch or update an existing app.
TypeScript
3
star
42

Unanimity

Unanimity add features to Discord.
JavaScript
3
star
43

tint

Color Picker and Editor PWA
TypeScript
3
star
44

hideoo.dev

HiDeoo's personal website
Astro
3
star
45

eslint-config

HiDeoo's ESLint configuration
TypeScript
3
star
46

Capture

Capture, Annotate & Share screenshots
TypeScript
3
star
47

vod

Twitch VODs downloader
TypeScript
3
star
48

image-size.macro

Babel macro to get the size of an image size at build time.
TypeScript
2
star
49

react-fzf

A tiny headless React fzf wrapper.
TypeScript
2
star
50

tsconfig

HiDeoo's TypeScript configuration
Shell
2
star
51

changelogithub-action

GitHub Action to generate changelog for GitHub releases from Conventional Commits.
TypeScript
2
star
52

generator-starlight-plugin

Yeoman generator for Starlight plugins
TypeScript
2
star
53

astro-loader-npm-packages

Astro Content Layer loader to load npm packages from a given author
TypeScript
2
star
54

alfred-theme-vitesse

A set of Alfred themes based on the Vitesse Theme for VS Code
TypeScript
2
star
55

insomnia-plugin-vitesse-theme

A set of Insomnia color themes based on the Vitesse Theme for VS Code
TypeScript
1
star
56

warp-theme-vitesse

A set of Warp themes based on the Vitesse Theme for VS Code
TypeScript
1
star
57

YaTA-API

YaTA API
TypeScript
1
star
58

twitch-emotes-viewer

Twitch emotes viewer
HTML
1
star
59

toggler-nova

Nova extension - Toggle words and symbols
TypeScript
1
star
60

astro-db-starlight-showcase

A Starlight showcase page using Astro DB
Astro
1
star
61

starlight-ui-strings-cli

CLI utility to quickly add, update or delete Starlight UI strings in all translation files
TypeScript
1
star
62

sjt

Quickly navigate to Starlight common webpages
Astro
1
star