> 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/powershell-commands/new-udbutton.md).

# New-UDButton

### Synopsis

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

### Syntax

```powershell
New-UDButton [[-Text] <String>] [[-Icon] <Object>] [[-Variant] <String>] [[-IconAlignment] <String>] [[-FullWidth]] [[-OnClick] <Endpoint>] [[-Size] <String>] [[-Style] <Hashtable>] [[-Href] <String>] [-Target <String>] [-Id <String>] [-Color <String>] [-Disabled] [-ClassName <String>] [-ShowLoading] [-LoadingIndicator <Object>] [-LoadingPosition <String>] [<CommonParameters>]
```

### Description

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

### Parameters

#### -Text

The text to show within the button.

```
Required?                    false
Position?                    1
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Icon An icon to show within the button. Use New-UDIcon to create an icon for this parameter.Required?                    falsePosition?                    2Default valueAccept pipeline input?       falseAliasesAccept wildcard characters?  false-VariantThe variant type for this button. Valid values are: "text", "outlined", "contained"Required?                    falsePosition?                    3Default value                containedAccept pipeline input?       falseAliasesAccept wildcard characters?  false-IconAlignmentHow to align the icon within the button. Valid values are: "left", "right"Required?                    falsePosition?                    4Default value                leftAccept pipeline input?       falseAliasesAccept wildcard characters?  false    -FullWidth \[\<SwitchParameter>]        Whether the button takes the full width of the it's container.Required?                    falsePosition?                    7Default value                FalseAccept pipeline input?       falseAliasesAccept wildcard characters?  false-OnClickThe action to take when the button is clicked.Required?                    falsePosition?                    8Default valueAccept pipeline input?       falseAliasesAccept wildcard characters?  false-SizeThe size of the button. Valid values are: "small", "medium", "large"Required?                    falsePosition?                    9Default valueAccept pipeline input?       falseAliasesAccept wildcard characters?  false-StyleStyles to apply to the button.Required?                    falsePosition?                    10Default valueAccept pipeline input?       falseAliasesAccept wildcard characters?  false-HrefA URL that the user should be redirected to when clicking the button.Required?                    falsePosition?                    11Default valueAccept pipeline input?       falseAliasesAccept wildcard characters?  false-TargetRequired?                    falsePosition?                    namedDefault valueAccept pipeline input?       falseAliasesAccept wildcard characters?  false-IdThe ID of the component. It defaults to a random GUID.Required?                    falsePosition?                    namedDefault value                (\[Guid]::NewGuid()).ToString()Accept pipeline input?       falseAliasesAccept wildcard characters?  false-ColorThe color of the component. Valid values are: 'default', 'inherit', 'primary', 'secondary', 'info', 'warning', 'error', 'success'Required?                    falsePosition?                    namedDefault value                primaryAccept pipeline input?       falseAliasesAccept wildcard characters?  false    -Disabled \[\<SwitchParameter>]        Whether the button is disabled.Required?                    falsePosition?                    namedDefault value                FalseAccept pipeline input?       falseAliasesAccept wildcard characters?  false-ClassNameThe CSS Class to apply to the button.Required?                    falsePosition?                    namedDefault valueAccept pipeline input?       falseAliasesAccept wildcard characters?  false    -ShowLoading \[\<SwitchParameter>]        Displays a loading spinner while the OnClick event handler is running.Required?                    falsePosition?                    namedDefault value                FalseAccept pipeline input?       falseAliasesAccept wildcard characters?  false-LoadingIndicator A custom element to display instead of the built in spinner for -ShowLoadingRequired?                    falsePosition?                    namedDefault valueAccept pipeline input?       falseAliasesAccept wildcard characters?  false-LoadingPositionThe position of the loading indicator. Valid values are: 'start', 'end', 'center'Required?                    falsePosition?                    namedDefault value                centerAccept pipeline input?       falseAliasesAccept wildcard characters?  false    \<CommonParameters>        This cmdlet supports the common parameters: Verbose, Debug,        ErrorAction, ErrorVariable, WarningAction, WarningVariable,        OutBuffer, PipelineVariable, and OutVariable. For more information, see        about\_CommonParameters (<https://go.microsoft.com/fwlink/?LinkID=113216).Outputs--------------------------> EXAMPLE 1 --------------------------PS >New-UDButton -Variant 'text' -Text 'Text' -Id 'button1'PS > New-UDButton -Variant 'contained' -Text 'Contained'  -Id 'button2'PS > New-UDButton -Variant 'outlined' -Text 'Outlined' -Id 'button3'Basic buttons|UDButton comes with three variants: text, contained, and outlined.-------------------------- EXAMPLE 2 --------------------------PS >New-UDButton -Text 'Click me' -OnClick {PS >   Show-UDToast -Message 'Hello, world!'PS > } -Id 'button4'Handling clicks|PowerShell that is executed when the button is clicked.-------------------------- EXAMPLE 3 --------------------------PS >New-UDButton -Text 'Secondary' -Color secondary -Id 'button5'PS > New-UDButton -Text 'Success' -Color success -Id 'button6'PS > New-UDButton -Text 'Error' -Color error -Id 'button7'Color|Adjust the button color with -Color-------------------------- EXAMPLE 4 --------------------------PS >New-UDButton -Variant 'text' -Text 'small' -Id 'button8' -Size smallPS > New-UDButton -Variant 'text' -Text 'medium'  -Id 'button9' -Size mediumPS > New-UDButton -Variant 'text' -Text 'large' -Id 'button10' -Size largePS > New-UDButton -Variant 'contained' -Text 'small' -Id 'button11'  -Size smallPS > New-UDButton -Variant 'contained' -Text 'medium'  -Id 'button12'  -Size mediumPS > New-UDButton -Variant 'contained' -Text 'large' -Id 'button13'  -Size largePS > New-UDButton -Variant 'outlined' -Text 'small' -Id 'button14'  -Size smallPS > New-UDButton -Variant 'outlined' -Text 'medium'  -Id 'button15'  -Size mediumPS > New-UDButton -Variant 'outlined' -Text 'large' -Id 'button16'  -Size largeSizes|For larger or smaller buttons, use the -Size parameter.-------------------------- EXAMPLE 5 --------------------------PS >New-UDButton -Icon (New-UDIcon -Icon 'User') -Text 'View User' -Id 'button17'Icon|Display an icon within the button-------------------------- EXAMPLE 6 --------------------------PS >New-UDButton -OnClick { Start-Sleep 3 } -ShowLoading -Text 'Load Data' -Id 'button18'Loading|Show a loading indicator while the OnClick event handler is running.


---

# 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/powershell-commands/new-udbutton.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.
