> ## Documentation Index
> Fetch the complete documentation index at: https://luau.limerence.biz/llms.txt
> Use this file to discover all available pages before exploring further.

# Button

> A clickable button. No saved value.

Also has everything from [ElementHandle](/ui/classes/element-handle).

A clickable button. No value of its own, so use `OnClick` to run code.

|                |                                                    |
| -------------- | -------------------------------------------------- |
| **Value**      | None                                               |
| **Created by** | [Section:AddButton](/ui/classes/section#addbutton) |

## Creation

```luau theme={null}
section:AddButton(label: string, icon: string?): ButtonHandle
```

***

## SetIcon

```luau theme={null}
button:SetIcon(icon: string?): ()
```

Change the button's icon. Pass `nil` to remove.

***

## OnClick

```luau theme={null}
button:OnClick(callback: () -> ()): () -> ()
```

Run `cb()` when the button is clicked.

<ResponseField name="returns" type="() -> ()">
  Unsubscribe function.
</ResponseField>

***

## RequireConfirm

```luau theme={null}
button:RequireConfirm(prompt: string?, timeout: number?): ()
```

Make the button require two clicks: the first arms it, the second confirms. Default prompt is `"Confirm?"`, default timeout is `2.5` seconds.

***

## ClearConfirm

```luau theme={null}
button:ClearConfirm(): ()
```

Cancel the armed state.

***

## Click

```luau theme={null}
button:Click(): ()
```

Trigger the click programmatically.

***

Also has everything from [ElementHandle](/ui/classes/element-handle): labels, visibility, tooltips, and [Destroy](/ui/classes/element-handle#destroy). There is no `GetValue` / `OnChange` on a button.

## Example

```luau theme={null}
local run = section:AddButton("Run once", "play")
run:OnClick(function()
    print("executed")
end)
run:RequireConfirm("Run this script?", 3)
```
