> For the complete documentation index, see [llms.txt](https://lua2.axeprimecs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lua2.axeprimecs.com/global-functions/global-functions/render/ui.md).

# UI

Create **ImGui-based** menu elements. Register UI callbacks with `ui.register()` to add elements into menu sections.

***

## 📋 Registration

| Function                          | Description                                                                                                                                                                                                                                                                                                 |
| --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ui.register(callback, section?)` | Register a UI callback. Sections: `"visuals"`, `"misc"`, `"world"`, `"lua"` (default). Built-in sections render your widgets in their own **Script UI** panel at the bottom of that tab, not mixed into the cheat's own panels. The panel only appears when at least one script registers for that section. |
| `ui.unregister(callback)`         | Remove a registered UI callback                                                                                                                                                                                                                                                                             |
| `ui.clear()`                      | Remove all UI callbacks                                                                                                                                                                                                                                                                                     |

***

## 🗂️ Custom Tabs

Scripts can create their own top-level menu tabs.

| Function                                                                    | Parameters                                       | Returns  | Description                             |
| --------------------------------------------------------------------------- | ------------------------------------------------ | -------- | --------------------------------------- |
| `ui.add_tab(id, title, icon?, group?, order?)`                              | `string`, `string`, `string?`, `string?`, `int?` | `string` | Create a new tab, returns tab reference |
| `ui.set_tab_style(tab_ref, mode, primary_color?, secondary_color?, speed?)` | `object`, `object`, `color?`, `color?`, `float?` | `bool`   | Set visual style of a tab               |

```lua
local my_tab = ui.add_tab("my_script_tab", "My Script", nil, nil, 99)

ui.register(function()
    ui.text("Hello from custom tab!")
end, my_tab)
```

***

## 🧩 Widgets

| Function                                                   | Returns      | Description                                                                                                                                                                                         |
| ---------------------------------------------------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ui.check_box(label, default)`                             | `bool`       | Checkbox toggle                                                                                                                                                                                     |
| `ui.check_box_gear(label, default, content_fn)`            | `bool`       | Checkbox with a gear icon on the right. Clicking the gear opens a popup; `content_fn` is called each frame the popup is open and draws its contents with any `ui.*` widget.                         |
| `ui.gear_popup(id, content_fn)`                            |              | Standalone gear icon + popup, without a checkbox. `id` only identifies the popup and is not drawn.                                                                                                  |
| `ui.keybind(label, default_vk?)`                           | `active, vk` | Key capture widget: click it then press a key to bind (Esc clears). Returns whether the bound key is held now, plus its virtual-key. Read held state outside the menu with `input.is_key_down(vk)`. |
| `ui.slider_float(label, default, min, max, format?)`       | `float`      | Float slider                                                                                                                                                                                        |
| `ui.slider_int(label, default, min, max, format?)`         | `int`        | Integer slider                                                                                                                                                                                      |
| `ui.combo(label, default, options)`                        | `int`        | Dropdown combo box (`options`: table or string)                                                                                                                                                     |
| `ui.multi_combo(label, default, options)`                  | `int`        | Multi-select combo box, returns bitmask (`options`: table or string)                                                                                                                                |
| `ui.button(label, w?, h?)`                                 | `bool`       | Clickable button                                                                                                                                                                                    |
| `ui.input_text(label, default, flags?)`                    | `string`     | Text input field                                                                                                                                                                                    |
| `ui.input_text_multiline(label, default, w, h, flags?)`    | `string`     | Multi-line text input                                                                                                                                                                               |
| `ui.drag_float(label, value, speed?, min?, max?, format?)` | `float`      | Draggable float                                                                                                                                                                                     |
| `ui.drag_int(label, value, speed?, min?, max?, format?)`   | `int`        | Draggable int                                                                                                                                                                                       |
| `ui.color_edit(label, color, flags?)`                      | `color`      | Color editor                                                                                                                                                                                        |
| `ui.color_picker(label, color, flags?)`                    | `color`      | Full color picker                                                                                                                                                                                   |

***

## 📐 Layout

| Function                                                       | Description                                             |
| -------------------------------------------------------------- | ------------------------------------------------------- |
| `ui.text(text)`                                                | Static text                                             |
| `ui.text_wrapped(text)`                                        | Word-wrapped text                                       |
| `ui.text_colored(color, text)`                                 | Colored text                                            |
| `ui.bullet_text(text)`                                         | Bulleted text                                           |
| `ui.separator()`                                               | Horizontal separator line                               |
| `ui.same_line(offset?, spacing?)`                              | Place next element on same line                         |
| `ui.spacing()`                                                 | Vertical spacing                                        |
| `ui.dummy(w, h)`                                               | Invisible spacer                                        |
| `ui.tree_node(label)`                                          | Collapsible tree node (call `tree_pop` if returns true) |
| `ui.tree_pop()`                                                | End tree node                                           |
| `ui.collapsing_header(label, open?, flags?)` → `visible, open` |                                                         |
| `ui.selectable(label, selected?, flags?, w?, h?)` → `bool`     |                                                         |
| `ui.invisible_button(id, w, h)` → `bool`                       |                                                         |

***

## 🪟 Windows & Children

| Function                                                    | Description                  |
| ----------------------------------------------------------- | ---------------------------- |
| `ui.begin(name, open?, flags?)` → `visible, open`           | Begin a window or child      |
| `ui.end()` / `ui.done()`                                    | End the current window/child |
| `ui.begin_child(name, w?, h?, border?, flags?)` → `visible` |                              |
| `ui.end_child()`                                            | End child window             |
| `ui.set_next_window_pos(x, y, cond?, pivot_x?, pivot_y?)`   |                              |
| `ui.set_next_window_size(w, h, cond?)`                      |                              |
| `ui.get_window_pos()` → `x, y`                              |                              |
| `ui.get_window_size()` → `w, h`                             |                              |
| `ui.get_cursor_pos()` → `x, y`                              |                              |
| `ui.set_cursor_pos(x, y)`                                   |                              |
| `ui.set_cursor_pos_x(x)`                                    |                              |
| `ui.set_cursor_pos_y(y)`                                    |                              |

***

## 💾 State Management

| Function                        | Description            |
| ------------------------------- | ---------------------- |
| `ui.set_bool(name, value)`      | Store a boolean value  |
| `ui.set_int(name, value)`       | Store an integer value |
| `ui.set_float(name, value)`     | Store a float value    |
| `ui.set_string(name, value)`    | Store a string value   |
| `ui.get_bool(name, default?)`   | Retrieve a boolean     |
| `ui.get_int(name, default?)`    | Retrieve an integer    |
| `ui.get_float(name, default?)`  | Retrieve a float       |
| `ui.get_string(name, default?)` | Retrieve a string      |

***

## 🔎 Item Queries

| Function                                | Returns        |
| --------------------------------------- | -------------- |
| `ui.is_item_hovered()`                  | `bool`         |
| `ui.is_item_active()`                   | `bool`         |
| `ui.is_item_clicked(button?)`           | `bool`         |
| `ui.get_item_rect_min()`                | `x, y`         |
| `ui.get_item_rect_max()`                | `x, y`         |
| `ui.drag_area(id, x, y, w, h, button?)` | `x, y, active` |

***

## ⌨️ Input (UI Context)

| Function                               | Returns |
| -------------------------------------- | ------- |
| `ui.is_key_down(key)`                  | `bool`  |
| `ui.is_key_pressed(key)`               | `bool`  |
| `ui.is_mouse_down(button)`             | `bool`  |
| `ui.is_mouse_clicked(button, repeat?)` | `bool`  |
| `ui.is_mouse_released(button)`         | `bool`  |
| `ui.get_mouse_pos()`                   | `x, y`  |

***

## 💡 Full UI Example

```lua
local enabled = false
local speed = 1.0

ui.register(function()
    enabled = ui.check_box("Enable Feature", enabled)
    ui.separator()
    if enabled then
        speed = ui.slider_float("Speed", speed, 0.1, 10.0, "%.1f")
        ui.text("Current speed: " .. tostring(speed))
    end
end, "misc")
```

***

## ⚙️ Gear Popup Example

Keeps secondary options out of the main panel. The callback runs only while the popup is open, and can hold any widget.

```lua
local glow = false
local glow_color = color(255, 80, 80, 255)
local glow_size = 4.0

ui.register(function()
    glow = ui.check_box_gear("Glow", glow, function()
        glow_color = ui.color_edit("Color", glow_color)
        glow_size = ui.slider_float("Size", glow_size, 1.0, 16.0, "%.1f")
    end)

    ui.gear_popup("extra_settings", function()
        ui.text("Standalone gear, no checkbox")
        if ui.button("Reset") then
            glow_size = 4.0
        end
    end)
end, "visuals")
```

> An error thrown inside the callback is caught and written to the Lua error log channel; it does not break the rest of the menu.


---

# 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://lua2.axeprimecs.com/global-functions/global-functions/render/ui.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.
