# toggleCaptions()

Toggles the captions panel visibility state.&#x20;

If the captions panel is currently shown, then it will be hidden. And vice-versa -> if the captions panel is currently hidden, then it will be shown. There is also an optional param to set a concrete target visibility state, but you may use [hideCaptions()](/reference/sdk/methods/hidecaptions.md) and [showCaptions()](/reference/sdk/methods/showcaptions.md) to achieve similar functionality.

```javascript
//This will toggle the captions panel visibility state
sambaFrame.toggleCaptions();

//This will show the captions panel, equivalent to sambaFrame.showCaptions();
sambaFrame.toggleCaptions(true); 

//This will hide the captions panel, equivalent to sambaFrame.hideCaptions();
sambaFrame.toggleCaptions(false);
```

**Sample use case**: \
You may have a custom button in your application to control the captions panel visibility.


---

# 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.digitalsamba.com/reference/sdk/methods/togglecaptions.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.
