> For the complete documentation index, see [llms.txt](https://idontgiveaf.gitbook.io/fluent/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://idontgiveaf.gitbook.io/fluent/elements/guide/toggles.md).

# Toggles

To create a toggle, use this.

```lua
local Toggle = Tabs.Main:AddToggle("MyToggle", 
{
    Title = "Toggle", 
    Description = "Toggle description",
    Default = false,
    Callback = function(state)
	if state then
	    print("Toggle On")
	else
	    print("Toggle Off")
        end
    end 
})
```

{% hint style="warning" %}
If you are having issues, you're supposed to replace "Tabs.Main" with your actual tab.&#x20;

Example: "Tabs.Exploits"&#x20;

Whatever you put in your [Tabs](/fluent/components/window/tabs.md) variable, it's what you need.
{% endhint %}

Change `local Toggle` to a different variable name every time. It can be anything.

`MyToggle` (name of toggle) is saved in the Options variable.

You can try to remove it, but I've never tried to.

You can get the value anywhere simply by using this: (Put your variable name)

```lua
Toggle.Value
```

{% hint style="warning" %}
Toggle.Value has not been tested by me and may not work. You can try the one below.
{% endhint %}

Or, whatever you put as the name of the toggle.

```lua
Options.MyToggle.Value
```

### Functions

You can check when the toggle is changed, but Callback does the same thing.

```lua
Toggle:OnChanged(function()
    print("Toggle changed:", Options.MyToggle.Value)
end)
```

To set the value of the toggle, use this.

```lua
Toggle:SetValue(false)
```

{% hint style="warning" %}
If you don't set the right variable name, it won't work.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://idontgiveaf.gitbook.io/fluent/elements/guide/toggles.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
