# Element API

Each signal is fired when a new value is set to an element, some may not 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)
```

<table><thead><tr><th>Returns</th><th>Description</th><th data-hidden>Type</th></tr></thead><tbody><tr><td>None</td><td>N/A</td><td>Function</td></tr></tbody></table>

## Toggle

<table><thead><tr><th>Signal</th><th>Description</th><th data-hidden>Return Type</th></tr></thead><tbody><tr><td>on_toggle_change</td><td>This signal is fired the first argument being the new value of the toggle</td><td>Connection</td></tr></tbody></table>

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

```lua
local void_hide = juju["find_element"]("hvh", "void hide")

local connection = juju["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

<table><thead><tr><th>Signal</th><th>Description</th><th data-hidden>Return Type</th></tr></thead><tbody><tr><td>on_slider_change</td><td>This signal is fired the first argument being the new value of the slider</td><td>Connection</td></tr></tbody></table>

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

## Dropdown

<table><thead><tr><th>Signal</th><th>Description</th><th data-hidden>Return Type</th></tr></thead><tbody><tr><td>on_dropdown_change</td><td>This signal is fired the first argument being the new value of the dropdown</td><td>Connection</td></tr></tbody></table>

<table><thead><tr><th width="274">Function</th><th>Return Type</th><th>Description</th></tr></thead><tbody><tr><td>set_dropdown</td><td>None</td><td>Sets the selected dropdown options to the first argument</td></tr><tr><td>set_options</td><td>None</td><td>Sets the dropdown's available options to the first argument</td></tr></tbody></table>

### Colorpicker

<table><thead><tr><th>Signal</th><th>Description</th><th data-hidden></th></tr></thead><tbody><tr><td>on_transparency_change</td><td>This signal is fired with the first argument being the new transparency of the colorpicker</td><td></td></tr><tr><td>on_color_change</td><td>This signal is fired with the first argument being the new color of the colorpicker</td><td></td></tr></tbody></table>

<table><thead><tr><th width="274">Function</th><th>Return Type</th><th>Description</th></tr></thead><tbody><tr><td>set_colorpicker_transparency</td><td>None</td><td>Sets the colorpicker transparency to the first argument</td></tr><tr><td>set_colorpicker</td><td>None</td><td>Sets the colorpicker color to the first argument</td></tr></tbody></table>

### Textbox

<table><thead><tr><th>Signal</th><th>Description</th><th data-hidden>Return Type</th></tr></thead><tbody><tr><td>on_textbox_change</td><td>This signal is fired with the first argument being the new value of the textbox</td><td>Connection</td></tr></tbody></table>

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

### Button

<table><thead><tr><th>Signal</th><th>Description</th><th data-hidden>Type</th></tr></thead><tbody><tr><td>on_clicked</td><td>This signal is fired when the button is clicked in the menu</td><td>Connection</td></tr></tbody></table>


---

# 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://addons.juju.lol/documentation/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.
