---
name: button
kind: component
lang: cpp
domain: core
version: "1.0.0"
purity: pure
signature: "bool fn_ui::button(const char* label, fn_ui::ButtonVariant variant = Secondary, fn_ui::ButtonSize size = Md)"
description: "Boton ImGui con variantes (primary/secondary/subtle/danger) y tamanos (sm/md/lg) usando fn_tokens. Replica Mantine Button / fn_library Button."
tags: [imgui, button, ui, form, tokens]
uses_functions: ["tokens_cpp_core"]
uses_types: []
returns: []
returns_optional: false
error_type: ""
imports: [imgui]
tested: false
tests: []
test_file_path: ""
file_path: "cpp/functions/core/button.cpp"
framework: imgui
params:
  - name: label
    desc: "Texto visible del boton (tambien se usa como id ImGui; prefijar con ## para solo-id)"
  - name: variant
    desc: "ButtonVariant: Primary (indigo), Secondary (surface+border, default), Subtle (transparente), Danger (rojo)"
  - name: size
    desc: "ButtonSize: Sm (compacto), Md (default), Lg (grande, font x1.1)"
output: "true el frame en que se hace click, false en caso contrario"
---

# button

Boton con variantes semanticas y tamanos fijos. Usa tokens (`primary`, `surface`, `error`, `border`, `text`) y padding/radius consistentes — mismo estilo visual en cualquier app C++ que lo use.

## Variantes

| Variant | Uso | Colores |
|---------|-----|---------|
| `Primary` | Accion principal (Save, Submit) | `colors::primary` + hover |
| `Secondary` | Accion neutra (Cancel) | `surface` + `border` |
| `Subtle` | Accion discreta (ver mas) | transparente + hover surface |
| `Danger` | Accion destructiva (Delete) | `colors::error` |

## Ejemplo

```cpp
#include "core/button.h"
using fn_ui::button;
using V = fn_ui::ButtonVariant;

if (button("Reindex", V::Primary)) { ... }
if (button("Cancel",  V::Subtle))  { ... }
if (button("Delete",  V::Danger))  { ... }
```

## Notas

- No gestiona layout: usar `ImGui::SameLine()` o `toolbar` para alinear varios.
- Para botones solo-icono sin texto, usar `icon_button`.
