> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/es/aplicaciones/components/inputs/button.md).

# Botón

Añada botones contenidos, con contorno, con icono y de carga en las aplicaciones de PowerShell Universal, incluidos grupos de botones y controladores de eventos de clic para las acciones del usuario.

Los botones permiten a los usuarios realizar acciones y tomar decisiones con un solo toque.

## Botón contenido

Los botones contenidos son de alto énfasis y se distinguen por el uso de la elevación y el relleno. Contienen las acciones principales de su aplicación.

```powershell
 New-UDButton -Variant 'contained' -Text 'Default'
```

## Botón con contorno

Los botones con contorno son botones de énfasis medio. Contienen acciones que son importantes, pero que no son la acción principal de una aplicación.

```powershell
New-UDButton -Variant 'outlined' -Text 'Default'
```

## Controlar el tamaño del botón

Puede controlar el tamaño en píxeles de un botón mediante el parámetro Style

```powershell
New-UDButton -Id "Submit" -Text "Submit" -Style @{ Width = "150px"; Height = "100px" }
```

## Botones con iconos y etiqueta

En ocasiones puede que desee tener iconos en determinados botones para mejorar la experiencia de usuario de la aplicación, ya que reconocemos los logotipos más fácilmente que el texto sin formato. Por ejemplo, si tiene un botón de eliminar, puede etiquetarlo con un icono de papelera.

```powershell
New-UDButton -Icon (New-UDIcon -Icon trash) -Text 'Delete'
```

## Botones con controladores de eventos

Puede especificar un bloque de script que se ejecute cuando se hace clic en el botón

```powershell
New-UDButton -Text 'Message Box' -OnClick {
    Show-UDToast -Message 'Hello, world!'
}
```

## Botón de carga

Los botones de carga mostrarán un icono de carga mientras se ejecuta un controlador de eventos. Esto resulta útil para eventos de mayor duración.

```powershell
New-UDButton -Text 'Message Box' -OnClick {
    Show-UDToast -Message 'Hello, world!'
    Start-Sleep 10
} -ShowLoading
```

## Grupo de botones

Un grupo de botones produce un botón con un menú desplegable. También se conoce como botón dividido.

```powershell
New-UDButtonGroup -Children {
    New-UDButtonGroupItem -Text "Button 1" -OnClick {
        Show-UDToast "Button 1"
    }
    New-UDButtonGroupItem -Text "Button 2" -OnClick {
        Show-UDToast "Button 2"
    }
    New-UDButtonGroupItem -Text "Button 3" -OnClick {
        Show-UDToast "Button 3"
    }
}
```

## Deshabilitar el botón después del clic

Este ejemplo utiliza `Set-UDElement` para deshabilitar el botón después de realizar una acción.

```powershell
New-UDButton -Id "btn1" -OnClick {
    Show-UDToast "Hello!"
    Set-UDElement -Id 'btn1' -Attributes @{
        disabled = $true
    }
}
```

## API

* [New-UDButton](/powershell-universal/es/comandos-de-powershell/new-udbutton.md)


---

# 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://docs.devolutions.net/powershell-universal/es/aplicaciones/components/inputs/button.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.
