# Element API

Each signal is fired when a new value is set to an element; some signals may not fire if the second argument to the setting function is **true**.

```lua
element:create_settings()
```

| Returns        | Type  | Description                                                                                                                                                                                                           |
| -------------- | ----- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| section (copy) | Table | This creates a fake section openable by the cog icon next to your element label. This fake section's create\_element function has identical functionality to juju.create\_element, just without the section name arg. |

```lua
element:set_visible(visible: Boolean)
```

| Returns | Description |
| ------- | ----------- |
| None    | N/A         |

## Toggle

Signal:

* on\_toggle\_change — This signal is fired with the first argument being the new value of the toggle. (Return: Connection)

Functions:

| Function    | Return Type | Description                                 |
| ----------- | ----------- | ------------------------------------------- |
| set\_toggle | None        | Sets the toggle state to the first argument |

Example:

```lua
local void_hide = example_section:create_element({["name"] = "void hide"}, {
    ["toggle"] = {["flag"] = "!void_hide", ["default"] = false}
})

local connection = lib["create_connection"](void_hide["on_toggle_change"], function(bool)
    print(bool) -- will print true after it is set below, unless void hide-
    -- is already on in which case this signal will not fire
end)

void_hide:set_toggle(true)
```

## Slider

Signal:

* on\_slider\_change — This signal is fired with the first argument being the new value of the slider. (Return: Connection)

Functions:

| Function    | Return Type | Description                                 |
| ----------- | ----------- | ------------------------------------------- |
| set\_slider | Number      | Sets the slider value to the first argument |

## Dropdown

Signal:

* on\_dropdown\_change — This signal is fired with the first argument being the new value of the dropdown. (Return: Connection)

Functions:

| Function      | Return Type | Description                                           |
| ------------- | ----------- | ----------------------------------------------------- |
| set\_dropdown | None        | Sets the selected dropdown option(s) to the argument  |
| set\_options  | None        | Sets the dropdown's available options to the argument |

## Colorpicker

Signals:

* on\_transparency\_change — Fired with the first argument being the new transparency of the colorpicker.
* on\_color\_change — Fired with the first argument being the new color of the colorpicker.

Functions:

| Function                       | Return Type | Description                                       |
| ------------------------------ | ----------- | ------------------------------------------------- |
| set\_colorpicker\_transparency | None        | Sets the colorpicker transparency to the argument |
| set\_colorpicker               | None        | Sets the colorpicker color to the argument        |

## Textbox

Signal:

* on\_textbox\_change — This signal is fired with the first argument being the new value of the textbox. (Return: Connection)

Functions:

| Function     | Return Type | Description                                  |
| ------------ | ----------- | -------------------------------------------- |
| set\_textbox | None        | Sets the textbox value to the first argument |

## Button

Signal:

* on\_clicked — This signal is fired when the button is clicked in the menu. (Return: Connection)


---

# 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://panduh.gitbook.io/panduh-docs/getting-started/elements/element-api.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.
