### 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 Title 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 ExampleUse 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
The defaultFocused props is set to true, card below is focused
by default
👇Scroll down
>
}
/>
>
);
}
```
--------------------------------
### Mantine Onboarding Tour Focus Reveal Group with Scale Mode
Source: https://gfazioli.github.io/mantine-onboarding-tour/index
This example demonstrates the OnboardingTour.FocusReveal.Group component with the 'scale' focusedMode. It sets the defaultFocused prop to true, making the first card focused by default. Users can scroll down to reveal more content.
```tsx
import { OnboardingTour } from '@gfazioli/mantine-onboarding-tour';
import { Center, Code, Divider, Stack, Text, Title } from '@mantine/core';
function Demo() {
return (
<>
Group Example
The defaultFocused props is set to true, card below is focused
by default
👇Scroll down
>
}
/>
>
);
}
```
--------------------------------
### FocusReveal with Customized Popover Props - React
Source: https://gfazioli.github.io/mantine-onboarding-tour/index
Shows how to customize the appearance and behavior of the popover in the FocusReveal component using `popoverProps`. This example sets the popover position to 'top', hides the arrow, applies a 'md' shadow, and sets a radius of 256.
```tsx
import { OnboardingTour } from '@gfazioli/mantine-onboarding-tour';
import { Button, Center, Divider, Stack, Title } from '@mantine/core';
import { useDisclosure } from '@mantine/hooks';
function Demo() {
const [focused, { close, open }] = useDisclosure(false);
return (
Popover example
);
}
```
--------------------------------
### Cycle FocusReveal Components with Keyboard Navigation - React
Source: https://gfazioli.github.io/mantine-onboarding-tour/index
Implements a cycling feature for multiple FocusReveal components using keyboard arrow keys. Users can navigate through testimonials using 'ArrowRight' and 'ArrowLeft'. The component also includes a 'Start' button to initiate the cycle and a 'Next' button within each testimonial for manual progression.
```tsx
import { useState } from 'react';
import { OnboardingTour } from '@gfazioli/mantine-onboarding-tour';
import { Button, Group, 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),
],
]);
return (
Cycle ExampleUse the arrow keys to cycle through the testimonials
{testimonials.map(
(_, index) =>
index < MAX_TESTIMONIALS && (
setFocusIndex(-1)}
focusedMode="zoom">
)
)}
);
}
```
--------------------------------
### Define Onboarding Tour Controller Interface (TypeScript)
Source: https://gfazioli.github.io/mantine-onboarding-tour/index
The OnboardingTourController interface defines the current state and available actions for managing an onboarding tour. It provides access to the tour steps, current step, current index, and methods to control the tour flow like starting, ending, moving to the next or previous step, and setting the current step index.
```typescript
export type OnboardingTourController = Readonly <{
/** List of tour steps */
tour: OnboardingTourStep[];
/** Current step */
currentStep: OnboardingTourStep | undefined;
/** Current step index of the tour. Zero-based index */
currentStepIndex: number | undefined;
/** ID of the selected tour */
selectedStepId: string | undefined;
/** Set the current index */
setCurrentStepIndex: (index: number) => void;
/** Start the tour */
startTour: () => void;
/** End the tour */
endTour: () => void;
/** Go to the next tour */
nextStep: () => void;
/** Go to the previous tour */
prevStep: () => void;
/** Options of the tour */
options: OnboardingTourOptions;
}>;
```
--------------------------------
### Customize Mantine Onboarding Tour Stepper with Rating Component
Source: https://gfazioli.github.io/mantine-onboarding-tour/index
This TypeScript code defines an example of using the `stepper` prop in the `OnboardingTour` component. It replaces the default stepper with a Mantine `Rating` component, allowing users to navigate tour steps by selecting a rating value. Dependencies include Mantine core components and hooks, as well as `@gfazioli/mantine-onboarding-tour`.
```typescript
import { FocusRevealProps } from '@gfazioli/mantine-focus-reveal';
import {
OnboardingTour,
OnboardingTourController,
type OnboardingTourStep,
} from '@gfazioli/mantine-onboarding-tour';
import { Badge, Button, Center, Divider, Group, Rating, Stack } from '@mantine/core';
import { useDisclosure } from '@mantine/hooks';
function Demo() {
const [started, { open, close }] = useDisclosure(false);
const focusRevealProps: FocusRevealProps = {
popoverProps: {
position: 'top',
},
};
const onboardingSteps: OnboardingTourStep[] = [
{
id: 'step-1',
title: 'Step-1',
content: 'Content of the Step 1',
},
{
id: 'step-2',
title: 'Step-2',
content: 'Content of the Step 2',
freeTrialBadge: (
);
return (
);
}
```
--------------------------------
### Override Step Content with OnboardingTour Component Props
Source: https://gfazioli.github.io/mantine-onboarding-tour/index
This example demonstrates how to override the `title`, `content`, `header`, and `footer` of individual tour steps by using the props of the `OnboardingTour` component itself. When these props are used, the `OnboardingTourStep` definitions for these properties are ignored. The `onboardingSteps` array still defines unique content for each step, but a global title is applied.
```typescript
import { OnboardingTour } from '@gfazioli/mantine-onboarding-tour';
import { Button, Code, Divider, Stack, Text, Title, Badge } 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: 'Content of the Step 1',
},
{
id: 'step-2',
title: 'Step-2',
content: 'Content of the Step 2',
myCustomInfo: Free trial available,
},
{
id: 'step-3',
title: 'Step-3',
content: 'Content of the Step 3',
},
];
return (
);
}
```