### Advanced Onboarding Tour Setup with OnboardingTour.Target (React) Source: https://gfazioli.github.io/mantine-onboarding-tour/index An example showcasing a more complex onboarding tour setup. It utilizes `OnboardingTour.Target` for elements not directly nested within `OnboardingTour` and integrates Mantine hooks and components for managing tour state and UI elements. The `started` prop controls the tour's visibility. ```jsx import { OnboardingTour, type OnboardingTourStep } from '@gfazioli/mantine-onboarding-tour'; import { Badge, Button, Divider, Stack } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; function AnotherComponent({ open }: { open: () => void }) { return ( <> ); } function Demo() { const [started, { open, close }] = useDisclosure(false); const onboardingSteps: OnboardingTourStep[] = [ { id: 'step-1', title: 'Step-1', content: I'm a direct child of OnboardingTour, }, { id: 'step-2', title: 'Step-2', content: I'm not a direct child of OnboardingTour, }, { id: 'step-3', title: 'Step-3', content: I'm not a direct child of OnboardingTour, }, ]; return ( ); } ``` -------------------------------- ### Demo Usage Example Source: https://gfazioli.github.io/mantine-onboarding-tour/index An example demonstrating how to implement and use the OnboardingTour component with defined steps and control elements. ```APIDOC ## Demo Usage Example ### Description This example showcases the practical implementation of the `OnboardingTour` component using a list of `OnboardingTourStep` objects. It includes buttons to trigger the tour and buttons associated with specific tour steps. ### Code Snippet ```typescript import { OnboardingTour } from '@gfazioli/mantine-onboarding-tour'; import { Button, Code, Divider, Stack, Text, Title } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; function Demo() { const [started, { open, close }] = useDisclosure(false); const onboardingSteps: OnboardingTourStep[] = [ { id: 'step-1', title: 'Step 1 Title', content: 'Content for step 1', focusRevealProps: { popoverProps: { position: 'top', }, }, }, { id: 'step-2', title: 'Step 2 Title', content: 'Content for step 2', focusRevealProps: (tourController: OnboardingTourController) => { return { overlayProps: { color: '#f00', }, popoverProps: { position: 'bottom', }, }; }, }, { id: 'step-3', title: 'Step 3 Title', content: 'Content for step 3', focusRevealProps: { popoverProps: { position: 'top', shadow: '0 0 16px 8px rgba(0, 0, 255, 1)', }, }, }, ]; return ( ); } ``` ### Component Props - `tour`: An array of `OnboardingTourStep` objects defining the tour sequence. - `started`: A boolean controlling whether the tour is currently active. - `onOnboardingTourEnd`: Callback function executed when the tour ends. - `onOnboardingTourClose`: Callback function executed when the tour is closed. - `maw`: Maximum width of the tour component. ``` -------------------------------- ### Mantine Onboarding Tour: Responsive Behavior Configuration (React) Source: https://gfazioli.github.io/mantine-onboarding-tour/index This example demonstrates how to configure the responsive behavior of the OnboardingTour component. It allows enabling or disabling responsive features, setting a custom breakpoint for mobile detection, and defining the position of the tour guide on mobile devices ('top' or 'bottom'). ```jsx {/* Your content */} ``` -------------------------------- ### Mantine Onboarding Tour React Example Source: https://gfazioli.github.io/mantine-onboarding-tour/index A comprehensive example demonstrating the usage of the OnboardingTour component in a React application. It showcases how to define tour steps, manage tour state, and integrate with other Mantine components. ```jsx import { OnboardingTour } from '@gfazioli/mantine-onboarding-tour'; import { Button, Center, Code, Divider, Group, Stack, Text, Title } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; // Assuming Testimonials and OnboardingTourStep, OnboardingTourController types are defined elsewhere // type OnboardingTourStep = { id: string; title: string; content: React.ReactNode }; // type OnboardingTourController = { currentStepIndex: number }; function Demo() { const [started, { open, close }] = useDisclosure(false); const onboardingSteps = [ { id: 'welcome', title: 'Welcome to the Onboarding Tour Component', content: 'This is a demo of the Onboarding Tour component, which allows to create onboarding experiences for your users.', }, { id: 'subtitle', title: 'Subtitle', content: You can select any component by using the data-onboarding-tour-id attribute , }, { id: 'button-see-all', title: 'New Features', content: 'Now you can click on the button "See all" to display all the testimonials', }, { id: 'testimonial-2', title: 'New Testimonial Layout', content: 'We have improved the Testimonial layout', }, ]; return ( ( )} > A simple example of the Onboarding Tour component 👉 New amazing Mantine extension component
{/* Assuming Testimonials component is defined elsewhere */}
); } ``` -------------------------------- ### Install @gfazioli/mantine-onboarding-tour with Yarn Source: https://gfazioli.github.io/mantine-onboarding-tour/index Installs the Mantine Onboarding Tour package using the Yarn package manager. This is the first step to integrate the component into your project. ```bash yarn add @gfazioli/mantine-onboarding-tour ``` -------------------------------- ### Full Mantine Onboarding Tour Example with Custom Footer (TypeScript) Source: https://gfazioli.github.io/mantine-onboarding-tour/index This comprehensive example integrates custom step data (`price`) with the `OnboardingTour` component. The `footer` prop is used to display the price for steps that have it, or a 'Included in all plans' badge otherwise, showcasing dynamic footer content. ```typescript import { OnboardingTour } from '@gfazioli/mantine-onboarding-tour'; import { Button, Code, Divider, Stack, Text, Title, Center, Badge, Group } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; function Demo() { const [started, { open, close }] = useDisclosure(false); const onboardingSteps: OnboardingTourStep[] = [ { id: 'step-1', title: 'Step-1', content: 'Description of the Step 1', price: 12, }, { id: 'step-2', title: 'Step-2', content: 'Description of the Step 2', }, { id: 'step-3', title: 'Step-3', content: 'Description of the Step 3', price: 32, }, ]; return ( { if (onboardingTour.currentStep?.price) { return (
Price: ${onboardingTour.currentStep?.price}
); } return ( Included in all plans ); }} maw={400} >
); } ``` -------------------------------- ### Install @gfazioli/mantine-onboarding-tour with NPM Source: https://gfazioli.github.io/mantine-onboarding-tour/index Installs the Mantine Onboarding Tour package using the npm package manager. This command is an alternative to Yarn for adding the component to your project. ```bash npm install @gfazioli/mantine-onboarding-tour ``` -------------------------------- ### Implement Onboarding Tour with Custom Step Content and Titles Source: https://gfazioli.github.io/mantine-onboarding-tour/index Demonstrates the `OnboardingTour` component usage with custom React elements for step titles and content. It utilizes the `useDisclosure` hook for managing the tour's `started` state and passes an array of `OnboardingTourStep` objects to the `tour` prop. The example showcases dynamic content based on `tourController` and custom `data-onboarding-tour-id` attributes for triggering specific steps. ```typescript import { OnboardingTour } from '@gfazioli/mantine-onboarding-tour'; import { Button, Code, Divider, Stack, Text, Title } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; function Demo() { const [started, { open, close }] = useDisclosure(false); const onboardingSteps: OnboardingTourStep[] = [ { id: 'step-1', title: ( Title in a <Code>Title</Code> component ), content: ( Description in a Text component with color red ), }, { id: 'step-2', title: 'Simple Title String', content: (tourController: OnboardingTourController) => ( Description by using the function (tourController: OnboardingTourController) so we can get some more information such as the step: {tourController.currentStepIndex} ), }, { id: 'step-3', content: , }, ]; return ( ); } ``` -------------------------------- ### Mantine Onboarding Tour Setup with Multiple Steps Source: https://gfazioli.github.io/mantine-onboarding-tour/index This snippet shows how to set up the OnboardingTour component with a series of steps. It defines tour steps with IDs, titles, and content, and integrates with other components to act as tour targets. The tour is initiated by a button click and managed using the useDisclosure hook for its open/close state. ```jsx import { Badge, Button, Divider, Stack } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; // Assuming OnboardingTour and OnboardingTourStep are imported correctly // import { OnboardingTour, type OnboardingTourStep } from '@gfazioli/mantine-onboarding-tour'; function AnotherComponent({ open }: { open: () => void }) { return ( <> ); } function Demo() { const [started, { open, close }] = useDisclosure(false); const onboardingSteps: OnboardingTourStep[] = [ { id: 'step-1', title: 'Step-1', content: I'm a direct child of OnboardingTour, }, { id: 'step-2', title: 'Step-2', content: I'm not a direct child of OnboardingTour, }, { id: 'step-3', title: 'Step-3', content: I'm not a direct child of OnboardingTour, }, ]; return ( ); } ``` -------------------------------- ### Mantine FocusReveal: Overlay Props Example Source: https://gfazioli.github.io/mantine-onboarding-tour/index Demonstrates using `OnboardingTour.FocusReveal` with custom `overlayProps` to apply a red, blurred overlay with specific styling. This highlights a component by dimming the rest of the page with the defined overlay properties. ```jsx import { OnboardingTour } from '@gfazioli/mantine-onboarding-tour'; import { Button, Center, Divider, Group, Stack, Title } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; function Demo() { const [focused, { close, open }] = useDisclosure(false); return ( Overlay Example
); } ``` -------------------------------- ### Render Custom Data in Onboarding Tour Footer (TypeScript) Source: https://gfazioli.github.io/mantine-onboarding-tour/index This example demonstrates how to use the `footer` prop of the `OnboardingTour` component to conditionally render custom data from tour steps. It checks for a `price` property and displays it, or shows a default message if the property is not present. ```typescript { if (onboardingTour.currentStep?.price) { return onboardingTour.currentStep?.price; } return null; }} /> ``` -------------------------------- ### Basic Focus Reveal with Default Focus Source: https://gfazioli.github.io/mantine-onboarding-tour/index Demonstrates a simple uncontrolled example of `OnboardingTour.FocusReveal`. The `defaultFocused` prop is set to `true`, causing the card to be focused by default. Scrolling down reveals additional content. ```tsx import { OnboardingTour } from '@gfazioli/mantine-onboarding-tour'; import { Center, Code, Divider, Stack, Text, Title } from '@mantine/core'; function Demo() { return ( Simple (uncontrolled) Example
The defaultFocused props is set to true, card below is focused by default
👇 Scroll down } />
); } ``` -------------------------------- ### Mantine Onboarding Tour: Multiple Components with Arrow Key Navigation (React) Source: https://gfazioli.github.io/mantine-onboarding-tour/index This example shows how to integrate the OnboardingTour.FocusReveal component to create a multi-step tour where users can navigate through different sections using arrow keys. It utilizes React hooks for state management and hotkey handling. The component focuses on specific elements, allowing interaction via 'Next' buttons and ending the tour with a 'Stop' button. ```tsx import { useState } from 'react'; import { OnboardingTour } from '@gfazioli/mantine-onboarding-tour'; import { Button, Group, Paper, Stack, Text, Title } from '@mantine/core'; import { useHotkeys } from '@mantine/hooks'; function Demo() { const [focusIndex, setFocusIndex] = useState(-1); const MAX_TESTIMONIALS = 3; useHotkeys([ [ 'ArrowRight', () => focusIndex >= 0 && setFocusIndex(focusIndex + 1 < MAX_TESTIMONIALS ? focusIndex + 1 : 0), ], [ 'ArrowLeft', () => focusIndex >= 0 && setFocusIndex(focusIndex - 1 >= 0 ? focusIndex - 1 : MAX_TESTIMONIALS - 1), ], ]); const descriptions = [ 'This is the first description.', 'This is the second description.', 'This is the third description.', 'This is the fourth description.', ]; // Assuming 'testimonials' is defined elsewhere or is a placeholder for actual testimonial data const testimonials = Array(MAX_TESTIMONIALS).fill(null); // Placeholder return ( Multiple components Example Use the arrow keys to cycle through the testimonials {testimonials.map( (_, index) => index < MAX_TESTIMONIALS && ( setFocusIndex(-1)} focusedMode="zoom" > {/* Assuming Testimonials component is defined elsewhere */}
{/* Placeholder for Testimonials component */}
) )}
{focusIndex >= 0 && ( {descriptions[focusIndex]} )}
); } ``` -------------------------------- ### Custom Focus Mode with OnboardingTour.FocusReveal in React Source: https://gfazioli.github.io/mantine-onboarding-tour/index Illustrates creating a custom focus mode using OnboardingTour.FocusReveal and applying custom styles via CSS modules. This example requires Mantine UI components and the useDisclosure hook. The `classes.custom` prop applies the custom styling. ```tsx import { OnboardingTour } from '@gfazioli/mantine-onboarding-tour'; import { Button, Center, Divider, Group, Stack, Title } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; import classes from './CustomMode.module.css'; function Demo() { const [focused, { close, open }] = useDisclosure(false); return ( Custom Focused Mode Example
); } ``` -------------------------------- ### Customize Tour Popover Content with Custom Component (TypeScript) Source: https://gfazioli.github.io/mantine-onboarding-tour/index This TypeScript code snippet shows how to use the `content` prop of the `OnboardingTour` component to display custom content within the tour's popovers. It imports necessary components from Mantine and the onboarding tour library, defines tour steps, and passes a custom content function to the tour. The example customizes popover props and includes example buttons that trigger the tour steps. ```typescript import { OnboardingTour, type OnboardingTourStep } from '@gfazioli/mantine-onboarding-tour'; import { Button, Code, Divider, Stack, Text, Title } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; /** Your custom popover content */ import { customPopoverContent } from './customPopoverContent'; function Demo() { const [started, { open, close }] = useDisclosure(false); const onboardingSteps: OnboardingTourStep[] = [ { id: 'step-1', title: 'Step-1', content: 'Description of the Step 1', image: 'https://raw.githubusercontent.com/mantinedev/mantine/master/.demo/images/bg-1.png', }, { id: 'step-2', title: 'Step-2', content: 'Description of the Step 2', freeTrialBadge: (
Free trial available
), image: 'https://raw.githubusercontent.com/mantinedev/mantine/master/.demo/images/bg-2.png', }, { id: 'step-3', title: 'Step-3', content: 'Description of the Step 3', image: 'https://raw.githubusercontent.com/mantinedev/mantine/master/.demo/images/bg-3.png', }, ]; /** Since we are using the FocusReveal component, here we can interact and set all its props. */ const focusRevealProps: FocusRevealProps = { popoverProps: { arrowSize: 20, position: 'right', styles: { dropdown: { padding: 0, }, }, }, }; return ( null} content={customPopoverContent} withStepper={false} withSkipButton={false} withPrevButton={false} withNextButton={false} focusRevealProps={focusRevealProps} maw={400} > ); } ``` -------------------------------- ### Mantine Onboarding Tour Focus Reveal Group with Selectable Modes Source: https://gfazioli.github.io/mantine-onboarding-tour/index This example showcases the OnboardingTour.FocusReveal.Group component with a dynamic 'focusedMode' selected via a Mantine Select component. It also demonstrates setting 'defaultFocused' to false for specific reveal elements. The code imports necessary components from '@mantine/core' and '@gfazioli/mantine-onboarding-tour'. ```tsx import { useState } from 'react'; import { FocusRevealFocusedMode, focusRevealModes } from '@gfazioli/mantine-focus-reveal'; import { OnboardingTour } from '@gfazioli/mantine-onboarding-tour'; import { Center, Code, Divider, Group, Select, Stack, Text, Title } from '@mantine/core'; function Demo() { const [focusedMode, setFocusedMode] = useState('scale'); return ( <> Group Example