> For the complete documentation index, see [llms.txt](https://fluentv2.hungquan99.site/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fluentv2.hungquan99.site/build-the-interface/add-elements.md).

# Add elements

Stateful elements take an `Idx` first. They register under `Fluent.Options[Idx]` and expose `:SetValue(...)`.

Use a stable, unique `Idx` for each persisted control. Do not reuse an `Idx`.

### Actions and information

Use `AddButton`, `AddParagraph`, and `AddDivider` for commands and supporting content.

```lua
Section:AddButton({
    Title = "Execute",
    Callback = function() print("Done") end,
})
Section:AddParagraph({ Title = "Note", Content = "Changes apply immediately." })
```

Buttons run their callback when selected. Paragraphs and dividers do not store values.

### Choices and inputs

Use `AddToggle`, `AddSlider`, `AddDropdown`, `AddColorpicker`, `AddKeybind`, and `AddInput` for values.

```lua
Section:AddToggle("AutoFarm", { Title = "Auto Farm", Default = false })
Section:AddSlider("WalkSpeed", { Title = "Walk Speed", Default = 16, Min = 16, Max = 200, Rounding = 0 })
Section:AddInput("Webhook", { Title = "Webhook URL", Default = "", Finished = true })
```

`AddSlider` requires `Default`, `Min`, `Max`, and `Rounding`. Missing fields raise an error.

With `Multi = true`, a dropdown returns a table of selected values. Set `AllowNull = true` to allow no selection.

### React to and update values

Use `Callback` for immediate updates. Use `:OnChanged(...)` when you need an additional listener.

```lua
local Toggle = Section:AddToggle("AutoFarm", {
    Title = "Auto Farm",
    Default = false,
    Callback = function(enabled)
        print("Auto Farm:", enabled)
    end,
})

Toggle:OnChanged(function(enabled)
    print("State changed:", enabled)
end)

Toggle:SetValue(true)
```

Every element supports `:SetTitle(text)`, `:SetDesc(text)`, and `:Visible(bool)`.

See [the full element reference](/fluent-v2.md) for every option and value shape.


---

# 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://fluentv2.hungquan99.site/build-the-interface/add-elements.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.
