# Button

Buttons allow users to take actions, and make choices, with a single tap.

## Contained Button

![](/files/-MAgAK7U48o9cPcKc-GG)

Contained buttons are high-emphasis, distinguished by their use of elevation and fill. They contain actions that are primary to your app.

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

## Outlined Button

![](/files/-MAgAMoLq98PKn296aEA)

Outlined buttons are medium-emphasis buttons. They contain actions that are important, but aren’t the primary action in an app.

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

## Control Button Size

You can control the pixel size of a button based on pixel size by using the Style parameter

'''text New-UDButton -Id "Submit" -Text "Submit" -Style @{ Width = "150px" Height = "100px" }

## Buttons with icons and label

![](/files/-MAgAP-Ld7Vk5lws1K2h)

Sometimes you might want to have icons for certain button to enhance the UX of the application as we recognize logos more easily than plain text. For example, if you have a delete button you can label it with a dustbin icon.

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

## Buttons with event handlers

You can specify a script block to execute when the button is clicked

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

**New-UDButton**

| Name          | Type            | Description                                                                             | Required |
| ------------- | --------------- | --------------------------------------------------------------------------------------- | -------- |
| Text          | String          | The text to show within the button.                                                     | false    |
| Icon          | Object          | An icon to show within the button. Use New-UDIcon to create an icon for this parameter. | false    |
| Variant       | String          | The variant type for this button.                                                       | false    |
| IconAlignment | String          | How to align the icon within the button.                                                | false    |
| FullWidth     | SwitchParameter | Whether the button takes the full width of the it's container.                          | false    |
| OnClick       | Endpoint        | The action to take when the button is clicked.                                          | false    |
| Size          | String          | The size of the button.                                                                 | false    |
| Style         | Hashtable       | Styles to apply to the button.                                                          | false    |
| Href          | String          | A URL that the user should be redirected to when clicking the button.                   | false    |
| Id            | String          | The ID of the component. It defaults to a random GUID.                                  | false    |


---

# Agent Instructions: 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:

```
GET https://docs.powershelluniversal.com/v1/dashboard/components/inputs/button.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
