> 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/it/app/components/inputs/button.md).

# Pulsante

I pulsanti consentono agli utenti di eseguire azioni ed effettuare scelte con un solo tocco.

## Pulsante contained

![](/files/64K5CuYAd4YtJwHfGFc3)

I pulsanti contained hanno un'enfasi alta e si distinguono per l'uso dell'elevazione e del riempimento. Contengono le azioni principali della sua app.

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

## Pulsante outlined

![](/files/qpbPy0NBQD8L9e1PySjH)

I pulsanti outlined hanno un'enfasi media. Contengono azioni importanti, ma che non sono l'azione principale di un'app.

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

## Controllare la dimensione del pulsante

È possibile controllare la dimensione in pixel di un pulsante utilizzando il parametro Style

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

## Pulsanti con icone ed etichetta

![](/files/0utKVpmppDD7rg5zduHl)

A volte potrebbe voler inserire icone in determinati pulsanti per migliorare la UX dell'applicazione, poiché riconosciamo i loghi più facilmente del testo semplice. Ad esempio, se ha un pulsante di eliminazione, può etichettarlo con un'icona a forma di cestino.

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

## Pulsanti con gestori di eventi

È possibile specificare un blocco di script da eseguire quando si fa clic sul pulsante

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

## Pulsante di caricamento

![](/files/UZITmQlCohqGrxMYOlzk)

I pulsanti di caricamento visualizzano un'icona di caricamento mentre è in esecuzione un gestore di eventi. Questo è utile per gli eventi di lunga durata.

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

## Gruppo di pulsanti

Un gruppo di pulsanti produce un pulsante con un menu a discesa. Viene anche chiamato split button.

```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"
    }
}
```

<figure><img src="/files/nyDXgOetl7iiR7nSFY5i" alt=""><figcaption><p>Gruppo di pulsanti</p></figcaption></figure>

## Disabilitare il pulsante dopo il clic

Questo esempio utilizza `Set-UDElement` per disabilitare il pulsante dopo aver eseguito un'azione.

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

## API

* [New-UDButton](/powershell-universal/it/comandi-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/it/app/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.
