Interactive tour guide for your react app
import React from 'react';
import ReactDOM from 'react-dom';
import { TourguideProvider } from 'react-interactive-guide';
import App from './App';
import './index.css';
ReactDOM.render(
<TourguideProvider>
<App />
</TourguideProvider>,
document.getElementById('root')
);
This provides the context to the tourguide's state and functions.
/**
* This should be a sibling of your app root in the DOM,
* It will be used by the tourguide portal as a container.
**/
const node = document.getElementById('tourguide-root');
// This gets passed to your tooltip component as a child.
const content = ['Content for first step', <AnyReactNodeForStepTwo />, 3];
function App() {
const {
curPos,
anchorEls,
getAnchorElProps,
next,
prev,
toggle,
close,
} = useGuide();
return (
<>
<div>
<div>
<h2 {...getAnchorElProps(1)}>Header</h2>
<Card {...getAnchorElProps(0)}>Some random card</Card>
<p {...getAnchorElProps(2)}>Descriptions</p>
</div>
<button onClick={toggle}>show</button>
<button onClick={prev}>prev</button>
<button onClick={next}>next</button>
</div>
<Tourguide tooltip={YourTooltipComponent} node={node} />
</>
);
}
getAnchorElProps
will map your element to a particular step for the tourguide.toggle
is used to enable/disable the tourguide.next
andprev
are handlers moves your tourguide forward or backward.
const node = document.getElementById('tourguide-root');
const content = ['Content for first step', <AnyReactNodeForStepTwo />, 3];
function App() {
const {
curPos,
anchorEls,
getAnchorElProps,
next,
prev,
toggle,
close,
} = useGuide();
return (
<>
<Tourguide
tooltip={content.map((content, index) => (
<YourToolTip backgroundColor={index === 0 ? 'white' : 'yellow'}>
{content}
</YourToolTip>
))}
node={node}
/>
</>
);
}
✨ Examples
yarn dev
yarn
yarn test
👤 Dominic Lee
- Website: https://github.com/dominictwlee
- Github: @dominictwlee
- LinkedIn: @dominictwlee
Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.
Give a ⭐️ if this project helped you!
Copyright © 2020 Dominic Lee.
This project is MIT licensed.
This README was generated with ❤️ by readme-md-generator