### Integrate TourProvider at application root Source: https://github.com/elrumordelaluz/reactour/blob/main/apps/docs/app/tour/quickstart/page.mdx Illustrates the foundational setup for `@reactour/tour` by wrapping the root of a React application with `TourProvider`. This component requires a `steps` prop, an array of objects defining each tour step's target selector and content, enabling a guided user experience. ```js import { TourProvider } from '@reactour/tour' ReactDOM.render( , document.getElementById('root') ) const steps = [ { selector: '.first-step', content: 'This is my first Step', }, // ... ] ``` -------------------------------- ### Run Next.js Development Server Source: https://github.com/elrumordelaluz/reactour/blob/main/apps/web/README.md This command initiates the Next.js development server, allowing you to access the application locally in your browser. It's the standard first step to start developing or testing the application. ```bash yarn dev ``` -------------------------------- ### Install Reactour Library Source: https://github.com/elrumordelaluz/reactour/blob/main/packages/tour/README.md Instructions for installing the `@reactour/tour` package using npm or yarn. ```zsh npm i -S @reactour/tour # or yarn add @reactour/tour ``` -------------------------------- ### Install @reactour/tour package Source: https://github.com/elrumordelaluz/reactour/blob/main/apps/docs/app/tour/quickstart/page.mdx Provides the command to install the `@reactour/tour` package using npm, a prerequisite for integrating the tour functionality into a React application. ```sh npm i @reactour/tour ``` -------------------------------- ### Install @reactour/tour npm package Source: https://github.com/elrumordelaluz/reactour/blob/main/apps/docs/app/quickstart/page.mdx Instructions to install the @reactour/tour package using npm. This package provides the core components for building interactive tours. ```sh npm i @reactour/tour ``` -------------------------------- ### Install @reactour/utils Package Source: https://github.com/elrumordelaluz/reactour/blob/main/packages/utils/README.md Instructions to install the `@reactour/utils` package using npm or yarn, adding it as a dependency to your project. ```zsh npm i -S @reactour/utils # or yarn add @reacmask/utils ``` -------------------------------- ### Install @reactour/popover npm package Source: https://github.com/elrumordelaluz/reactour/blob/main/apps/docs/app/popover/quickstart/page.mdx Command to install the @reactour/popover library using npm, which provides a popover component for React applications. ```sh npm i @reactour/popover ``` -------------------------------- ### Install Reactour Popover Package Source: https://github.com/elrumordelaluz/reactour/blob/main/packages/popover/README.md Instructions for installing the `@reactour/popover` package using npm or yarn. ```zsh npm i -S @reactour/popover # or yarn add @reacmask/popover ``` -------------------------------- ### Install @reactour/mask package Source: https://github.com/elrumordelaluz/reactour/blob/main/apps/docs/app/mask/quickstart/page.mdx Demonstrates how to install the @reactour/mask package using npm, which provides an SVG mask component for React applications. ```sh npm i @reactour/mask ``` -------------------------------- ### Example: Applying Global Styles to Reactour Components in JavaScript Source: https://github.com/elrumordelaluz/reactour/blob/main/packages/tour/README.md Demonstrates how to define and apply global styles to different parts of the Reactour component, such as the mask wrapper, highlighted area, and badge, using a style object. ```js const styles = { maskWrapper: (base) => ({ ...base, color: 'red', }), highlightedArea: (base, { x, y }) => ({ ...base, x: x + 10, y: y + 10, }), badge: (base) => ({ ...base, color: 'blue' }), } ``` -------------------------------- ### Control Tour visibility using useTour hook Source: https://github.com/elrumordelaluz/reactour/blob/main/apps/docs/app/tour/quickstart/page.mdx Demonstrates how to programmatically control the tour's visibility within any child component of `TourProvider` using the `useTour` hook. By destructuring `setIsOpen` from the hook, developers can trigger the tour's display, for example, via a button click, providing dynamic control over the user's guided experience. ```js import { useTour } from '@reactour/tour' function App() { const { setIsOpen } = useTour() return ( <>

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent at finibus nulla, quis varius justo. Vestibulum lorem lorem, viverra porta metus nec, porta luctus orci

) } ``` -------------------------------- ### Using the getWindow Function Source: https://github.com/elrumordelaluz/reactour/blob/main/packages/utils/README.md Example of importing and using the `getWindow` function to destructure and access the current browser window's width and height. ```js import { getWindow } from '@reactour/utils' const { w, h } = getWindow() ``` -------------------------------- ### Example: Custom ContentComponent for Reactour Source: https://github.com/elrumordelaluz/reactour/blob/main/apps/docs/app/tour/props/page.mdx Demonstrates how to implement a custom `ContentComponent` for the Reactour Popover. This example shows how to render dynamic content based on the current step, handle navigation (next/close), and integrate with the `TourProvider`. ```javascript function ContentComponent(props) { const isLastStep = props.currentStep === props.steps.length - 1 const content = props.steps[props.currentStep].content return (
{/* Check if the step.content is a function or a string */} {typeof content === 'function' ? content({ ...props, someOtherStuff: 'Custom Text' }) : content}
) } const steps = [ /* ... */ ] function App() { return ( ({ ...base, padding: 0 }) }} > {/* ... */} ) } ``` -------------------------------- ### Customizing Tour Components Example (React) Source: https://github.com/elrumordelaluz/reactour/blob/main/apps/docs/app/tour/props/page.mdx This example demonstrates how to provide custom React components for the `Badge` and `Close` elements within the `TourProvider`, allowing for complete control over their appearance and behavior. ```javascript import { components } from '@reactour/tour' function Badge({ children }) { return ( ({ ...base, backgroundColor: 'red' }) }} > 👉 {children} 👈 ) } function Close({ onClick }) { return ( ) } const steps = [ /* ... */ ] export default function App() { return ( {/* ... */} ) } ``` -------------------------------- ### Install Reactour Mask Component Source: https://github.com/elrumordelaluz/reactour/blob/main/packages/mask/README.md Instructions for installing the `@reactour/mask` package using either npm or yarn package managers. ```zsh npm i -S @reactour/mask ``` ```zsh yarn add @reactour/mask ``` -------------------------------- ### Example: Customizing Reactour Popover Components in JavaScript Source: https://github.com/elrumordelaluz/reactour/blob/main/packages/tour/README.md Illustrates how to override default Reactour Popover components (e.g., Badge, Close) using the `components` prop in a React application. This example shows functional components for custom rendering. ```js import { components } from '@reactour/tour' function Badge({ children }) { return ( ({ ...base, backgroundColor: 'red' }) }} > 👉 {children} 👈 ) } function Close({ onClick }) { return ( ) } const steps = [ /* ... */ ] export default function App() { return ( {/* ... */} ) } ``` -------------------------------- ### Integrate TourProvider at Application Root Source: https://github.com/elrumordelaluz/reactour/blob/main/packages/tour/README.md Demonstrates how to wrap your React application with `TourProvider` at the root, passing an array of `steps` to define the tour's progression. ```js // ... import { TourProvider } from '@reactour/tour' ReactDOM.render( , document.getElementById('root') ) const steps = [ { selector: '.first-step', content: 'This is my first Step', }, // ... ] ``` -------------------------------- ### Customize Reactour Popover Content with ContentComponent Source: https://github.com/elrumordelaluz/reactour/blob/main/packages/tour/README.md Demonstrates how to provide a custom React component to render inside the Reactour popover, allowing for dynamic content and custom actions. Includes the TypeScript definition for `PopoverContentProps` and a JavaScript example of its implementation. ```typescript type PopoverContentProps = { styles?: StylesObj & PopoverStylesObj & MaskStylesObj badgeContent?: (badgeProps: BadgeProps) => any components?: PopoverComponentsType accessibilityOptions?: A11yOptions disabledActions?: boolean onClickClose?: (clickProps: ClickProps) => void setCurrentStep: Dispatch> currentStep: number transition?: boolean isHighlightingObserved?: boolean setIsOpen: Dispatch> steps: StepType[] showNavigation?: boolean showPrevNextButtons?: boolean showCloseButton?: boolean showBadge?: boolean nextButton?: (props: BtnFnProps) => void prevButton?: (props: BtnFnProps) => void disableDotsNavigation?: boolean rtl?: boolean } ``` ```javascript function ContentComponent(props) { const isLastStep = props.currentStep === props.steps.length - 1 const content = props.steps[props.currentStep].content return (
{/* Check if the step.content is a function or a string */} {typeof content === 'function' ? content({ ...props, someOtherStuff: 'Custom Text' }) : content}
) } const steps = [ /* ... */ ] function App() { return ( ({ ...base, padding: 0 }) }} > {/* ... */} ) } ``` -------------------------------- ### Integrate TourProvider at Application Root Source: https://github.com/elrumordelaluz/reactour/blob/main/apps/docs/app/quickstart/page.mdx Demonstrates how to wrap your entire application with the `TourProvider` component. This component requires an array of `steps` defining the tour's sequence and content, and should be placed at the root of your React application to make the tour context available globally. ```js import { TourProvider } from '@reactour/tour' ReactDOM.render( , document.getElementById('root') ) const steps = [ { selector: '.first-step', content: 'This is my first Step', }, // ... ] ``` -------------------------------- ### Callback After Tour Opens Source: https://github.com/elrumordelaluz/reactour/blob/main/packages/tour/README.md Action fired immediately after the Tour has successfully opened. ```APIDOC afterOpen?: (target: Element | null) => void ``` -------------------------------- ### Basic usage of Mask component in React Source: https://github.com/elrumordelaluz/reactour/blob/main/apps/docs/app/mask/quickstart/page.mdx Illustrates how to import and integrate the Mask component from @reactour/mask into a React functional component, demonstrating how to pass size properties to control the mask's appearance. ```js import { Mask } from '@reactour/mask' function App() { const sizes = { width: 100, height: 100, top: 100, left: 100, } return ( <> {/* ... */} ) } ``` -------------------------------- ### Example Customizing Popover Styles Source: https://github.com/elrumordelaluz/reactour/blob/main/apps/docs/app/popover/props/page.mdx An example demonstrating how to define and apply custom styles to the Popover component using the `styles` prop, which accepts a function to dynamically adjust styles based on component state like `position`. ```javascript const styles = { popover: (base, { position }) => ({ ...base, boxShadow: '0 0 3em rgba(0, 0, 0, 0.5)', backgroundColor: position === 'top' ? 'red' : '#dedede', }), } function App() { return } ``` -------------------------------- ### Example of Custom Styles for Mask Component Source: https://github.com/elrumordelaluz/reactour/blob/main/apps/docs/app/mask/props/page.mdx Illustrates how to apply custom styles to the Mask component using the `styles` prop. This example demonstrates modifying the `maskWrapper` and `highlightedArea` with dynamic values. ```javascript const styles = { maskWrapper: (base) => ({ ...base, color: 'red', }), highlightedArea: (base, { x, y }) => ({ ...base, x: x + 10, y: y + 10, }), } function App() { return } ``` -------------------------------- ### TourProvider `steps` Prop and `StepType` API Reference Source: https://github.com/elrumordelaluz/reactour/blob/main/packages/tour/README.md Detailed API documentation for the `steps` prop of the `TourProvider` component, which defines the sequence of elements to highlight during the tour, and the structure of `StepType`. ```APIDOC TourProvider steps?: StepType[] Description: Array of elements to highlight with special info and props. StepType selector: string | Element Description: A string containing one CSS Selector to match and highlight the element at the time of this step. content: string | ({ setCurrentStep, transition, isHighlightingObserved, currentStep, setIsOpen }) => void Description: The content to show inside the Popover at the time of this step. Using a function have parameters to use inside content. position?: 'top' | 'right' | 'bottom' | 'left' | 'center' | [number, number] Description: The preferred postion to position the Popover in relation with the highlighted element. Will be automatically calculated in case of unavailable space. highlightedSelectors?: string[] Description: Array of CSS Selector to be included (by union) in the highlighted region of the Mask. mutationObservables?: string[] Description: Array of CSS Selector that addition or removal will triggered a rerender of the Mask shape. resizeObservables?: string[] Description: Array of CSS Selector that when resizeing each will triggered a rerender of the Mask shape. navDotAriaLabel?: string Description: String to assign to aria-label attribute of the Dot of this step. stepInteraction?: boolean Description: Allow to reenable the interaction for this specific step, when disableInteraction (from TourProvider) is true. action?: (elem: Element | null) => void Description: Action fired when the Tour arrives in this step. actionAfter?: (elem: Element | null) => void Description: Action fired when the Tour leaves this step. ``` -------------------------------- ### Customizing Popover Styles Source: https://github.com/elrumordelaluz/reactour/blob/main/packages/popover/README.md An example demonstrating how to customize the `popover` style using the `styles` prop, applying a box shadow and background color. ```js const styles = { popover: (base) => ({ ...base, boxShadow: '0 0 3em rgba(0, 0, 0, 0.5)', backgroundColor: '#dedede', }), } ``` -------------------------------- ### Reactour Step-Specific Configuration Properties Source: https://github.com/elrumordelaluz/reactour/blob/main/packages/tour/README.md Documents properties that can be applied to individual steps within a Reactour tour, allowing fine-grained control over behavior, appearance, and interaction for each step. ```APIDOC disableActions: boolean Description: Allow to disable all possible actions (interaction with Mask, Navigation Arrows, Navigation Dots, Close button and keyboard events) when the Tour is in this step. padding: Padding Description: Control padding spaces for this specific step. bypassElem: boolean Description: Excludes the main selector when calculating highlited area if present highlightedSelectors. styles: StylesObj & PopoverStylesObj & MaskStylesObj Description: Customize styles fro this specific step. ``` -------------------------------- ### Using the Observables Component Source: https://github.com/elrumordelaluz/reactour/blob/main/packages/utils/README.md Example of integrating the `Observables` component to monitor specific DOM elements for mutations and resize events, triggering a custom `refresh` function upon detection. ```js import { Portal } from '@reactour/utils' function App() { function refresh() { console.log('mutated!') } return ( <>

Vestibulum maximus vitae