> ## Documentation Index
> Fetch the complete documentation index at: https://developers.gotolstoy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Widget (Bubble)

> Learn how to configure your Tolstoy widget to perform different functions on your site.

## Settings

We support the following additional configurations for the floating widget:

<ParamField query="alwaysShow" default="true" type="boolean">
  In case a user closed the widget and you want to keep showing it to him.
</ParamField>

<ParamField query="loadHidden" default="true" type="boolean">
  Load the widget without showing it.
</ParamField>

<ParamField query="stopPreviewLoop" default="true" type="boolean">
  Stop the preview window from endlessly looping.
</ParamField>

<ParamField query="noCloseOption" default="true" type="boolean">
  No option to close the widget.
</ParamField>

Add the following code to the page in order to set the settings:

```javascript theme={null}
window.tolstoySettings = {
  alwaysShow: true,
  loadHidden: true,
  stopPreviewLoop: true,
  noCloseOption: true,
};
```

## start()

Start the widget, open it expanded and plays immediately

```javascript theme={null}
window.tolstoyWidget.start();
```

## startPart(partNumber)

Start the widget at a specific part number, open it expanded and plays immediately. If the widget is already open it will start to play the given part.

```javascript theme={null}
window.tolstoyWidget.startPart(partNumber);
```

## show()

Show the widget bubble if it was loaded hidden or closed

```javascript theme={null}
window.tolstoyWidget.show();
```

### hide()

Hide the widget bubble from screen

```javascript theme={null}
window.tolstoyWidget.hide();
```

## recreate(tolstoyWidgetId, settings)

Load a new widget with a different Tolstoy Id, remember to replace the {{TOLSTOY_ID}}

```javascript theme={null}
window.tolstoyWidget.recreate("{{TOLSTOY_ID}}");
```

## on(eventType, callback)

Trigger a callback on a specific event

Params:

<ParamField query="eventType" type="&#x22;onWidgetOpen&#x22; | &#x22;onWidgetClose&#x22; | &#x22;onWidgetReady&#x22; | &#x22;onTolstoyClose&#x22;">
  **Supported events**:

  onWidgetOpen - triggers when the widget is opened \\

  onWidgetClose - triggers when the widget is closed \\

  onWidgetReady - triggers when the widget is ready \\

  onTolstoyClose - triggers when the tolstoy bubble is closed
</ParamField>

<ParamField query="callback" type="function">
  A function to trigger
</ParamField>

```javascript theme={null}
window.tolstoyWidget.on("onWidgetOpen", () => {
  console.log("Widget Opened");
});
```
