# Walk Through Component

## **Component Visuals**

{% tabs %}
{% tab title="Overview" %}

<figure><img src="/files/SfnDzPqE9QDotkMUKb1Q" alt="" width="563"><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Visual 1" %}

<figure><img src="/files/HLccsrzpVjR92jCydt11" alt="" width="563"><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

{% hint style="info" %}
To unlock early access to the component                                                           [**Get Access**](https://bijfwfnqtsj.typeform.com/to/eUXDpbuh)
{% endhint %}

### Demo

{% embed url="<https://drive.google.com/file/d/1iKnGhYJUfwxGobCAVT-OM-glJC_KZ0Ub/view?usp=sharing>" %}

### Installation

To integrate the `WalkThrough` component into your project, follow these steps:

1. Open your terminal/command prompt.
2. Navigate to your project's root directory using the `cd` command if you're not already there.
3. Run the following command to install the `@questlabs/react-sdk` package using npm:

   ```bash
   npm install @questlabs/react-sdk
   ```

   This command will download and install the package and its dependencies into your project.

   **Note:** Make sure your project has npm and Node.js installed, and that you have the necessary permissions to install packages in your project directory.

### Usage

Here's an example of how to use the `WalkThrough` component in your React application:

```jsx
import React from 'react';
import { QuestProvider, WalkThrough } from '@questlabs/react-sdk';

function App() {
  return (
    <QuestProvider apiKey={"your api key"} entityId={"your entityId"}>
      {/* Other components or content in your app */}
      <WalkThrough
        onFinish={() => {
          // Handle finish logic here
        }}
        isOpen={true} // Set to true to initially show the walkthrough
        questId="your-quest-id"
        userId="your-user-id"
        token="your-token"
        // backgroundColor="black"
        // color=""
        // btnBackGroundColor="white"
        // btnColor="black"
        onComplete={() => { alert('Welcome to the page'); setIsOpen(false) }}
        onRequestClose={() => setIsOpen(false)}
        onAfterOpen={() => document.documentElement.style.overflow = 'hidden'}
        onBeforeClose={() => document.documentElement.style.overflow = ''}
        tooltip={true}
      />
    </QuestProvider>
  );
}

export default App;
```

### Props

<table><thead><tr><th>Prop Name</th><th width="117">Type</th><th width="110">Required</th><th>Description</th></tr></thead><tbody><tr><td>onFinish</td><td>function</td><td>optional</td><td>A function to be executed when the walkthrough is finished.</td></tr><tr><td>onClose</td><td>function </td><td>optional</td><td>A function to be executed when the walkthrough is closed. If not provided, the walkthrough will be invisible by default.</td></tr><tr><td>isOpen</td><td>boolean</td><td>optional</td><td>If true, the walkthrough is visible; if false, it is hidden.</td></tr><tr><td>questId</td><td>string</td><td>required</td><td> The ID of the quest for which the walkthrough is being displayed.</td></tr><tr><td>token</td><td>string</td><td>required</td><td>An authentication token for accessing the quest data.</td></tr><tr><td>userId</td><td>string</td><td>required</td><td>The ID of the user for whom the walkthrough is being displayed.</td></tr><tr><td>backgroundColor</td><td>string</td><td>optional</td><td>Sets background color of component.</td></tr><tr><td>btnBackGroundColor</td><td>string</td><td>optional</td><td>Sets background color of next button.</td></tr><tr><td>btnColor</td><td>string</td><td>optional</td><td>Sets colour of next button.</td></tr><tr><td>tooltip</td><td>boolean</td><td>optional</td><td>if true tooltip will show else not</td></tr><tr><td>hideArrow</td><td>boolean</td><td>optional</td><td>if true arrow icon will show else not</td></tr><tr><td>onComplete</td><td>function</td><td>optional</td><td>Function to be executed when the walk through is completed</td></tr><tr><td>firstButtonText</td><td>string</td><td>optional</td><td>what should be your first button text</td></tr><tr><td>lastButtonText</td><td>string</td><td>optional</td><td>what should be your last button text</td></tr><tr><td>handleFirstButtonClick</td><td>function</td><td>optional</td><td>this functional is for handle your first action </td></tr><tr><td>handleLastButtonClick</td><td>function</td><td>optional</td><td>this functional is for handle your last action </td></tr><tr><td>Color</td><td>string</td><td>optional</td><td>Sets color of component.</td></tr><tr><td>actions</td><td>object of function</td><td>optional</td><td> it is an Object which<br>contains functions where you can trigger any action when user triggers the next button ex: actions={{ 2: () => { } }} means when user clicks on next button at step 1 this function will be triggered you can perform any actions inside callback.</td></tr></tbody></table>

### Component Behavior

* The `WalkThrough` component displays a series of steps to guide users through a quest.
* It can be shown or hidden based on the `isOpen` prop.
* Automatically scrolls to the next target element if autoScroll is on
* When the walkthrough is finished (`onFinish` is called), the component becomes invisible.

### Customization

You can customize the behavior of the `WalkThrough` component by providing the `onClose` function. If `onClose` is not provided, the walkthrough will be invisible by default.

Feel free to adjust the wording or add more details as needed! If you have specific requirements or if there's anything else you'd like to include, let me know.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.questera.ai/questera-ai-sdks/react-sdk-components/onboarding/walk-through-component.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
