I am trying to use introJs with React but it seems not to work. How can I make it work? Can you give me an example?
-
1What does that mean _it doesn't work_? – B001ᛦ Nov 14 '16 at 09:27
-
3Great alternative library that is fully integrated with React is React Joyride https://gilbarbara.github.io/react-joyride/ – Mastergalen Feb 28 '17 at 01:02
-
1Searching something related, finished doing [this library](https://github.com/elrumordelaluz/reactour) – Lionel T Sep 14 '17 at 20:33
-
Since then, a package was developed for this: https://www.npmjs.com/package/intro.js-react – Teodor Sandu Dec 19 '19 at 11:10
2 Answers
You can just treat it like any other npm module you'd add to your React app.
Install using npm:
npm install intro.js --save
Import the module and css into the component where you want to use them:
import introJs from 'intro.js'; import 'intro.js/introjs.css';
When the component mounts call the necessary function:
componentDidMount() { introJs().start(); }
Add steps to the jsx as you normally would with html:
data-intro='Hello step one!'
One odd thing that was happening to me was that some the css in the intro.js
/ intro.min.js
wasn't operating as I expected. I had to jump into those files an tweak the opacity
on the .introjs-helperLayer
selector and the z-index
on .introjs-fixParent
but that could have been an edge case just for me.

- 533
- 5
- 7
-
1Since then, a package was developed for this: https://www.npmjs.com/package/intro.js-react – Teodor Sandu Dec 19 '19 at 11:11
Add the following to your index.html
<link href="https://cdn.jsdelivr.net/intro.js/2.3.0/introjs.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/intro.js/2.3.0/intro.min.js"></script>
Now, call introJs().start()
inside componentDidMount
class App extends React.Component{
componentDidMount(){
introJs().start()
}
render(){
return <div>
<a href='http://google.com/' data-intro='Hello step one!'>one</a>
<a href='http://google.com/' data-intro='Hello step two!'>two</a>
<a href='http://google.com/' data-intro='Hello step three!'>three</a>
<a href='http://google.com/' data-intro='Hello step four!'>four</a>
</div>
}
}
ReactDOM.render(<App/>, document.getElementById('app'))
a{
margin-left: 60px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<link href="https://cdn.jsdelivr.net/intro.js/2.3.0/introjs.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/intro.js/2.3.0/intro.min.js"></script>
<div id="app"></div>
Hope this helps!

- 18,642
- 9
- 46
- 70
-
-
-
Since then, a package was developed for this: https://www.npmjs.com/package/intro.js-react – Teodor Sandu Dec 19 '19 at 11:10