New-UDButton
Synopsis
Buttons allow users to take actions, and make choices, with a single tap..
Syntax
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>] [-Aria <ScriptBlock>] [<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.
-Variant
The variant type for this button. Valid values are: "text", "outlined", "contained"
-IconAlignment
How to align the icon within the button. Valid values are: "left", "right"
-FullWidth
Whether the button takes the full width of the it's container.
-OnClick
The action to take when the button is clicked.
-Size
The size of the button. Valid values are: "small", "medium", "large"
-Style
Styles to apply to the button.
-Href
A URL that the user should be redirected to when clicking the button.
-Target
-Id
The ID of the component. It defaults to a random GUID.
-Color
The color of the component. Valid values are: 'default', 'inherit', 'primary', 'secondary', 'info', 'warning', 'error', 'success'
-Disabled
Whether the button is disabled.
-ClassName
The CSS Class to apply to the button.
-ShowLoading
Displays a loading spinner while the OnClick event handler is running.
-LoadingIndicator
A custom element to display instead of the built in spinner for -ShowLoading
-LoadingPosition
The position of the loading indicator. Valid values are: 'start', 'end', 'center'
-Aria
A script block of New-UDAriaAttribute calls. The resulting ARIA or role attributes are applied to the button. For example, -Aria { New-UDAriaAttribute -Label -Value 'Save changes' } gives the button an accessible label.
Common parameters
This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. For more information, see about_CommonParameters.
Outputs
Examples
Example 1: Basic buttons
UDButton comes with three variants: text, contained, and outlined.
Example 2: Handling clicks
PowerShell that is executed when the button is clicked.
Example 3: Color
Adjust the button color with -Color
Example 4: Sizes
For larger or smaller buttons, use the -Size parameter.
Example 5: Icon
Display an icon within the button
Example 6: Loading
Show a loading indicator while the OnClick event handler is running.
Last updated
Was this helpful?