A textbox lets users enter and edit text.
New-UDTextbox -Label 'Standard' -Placeholder 'Textbox'New-UDTextbox -Label 'Disabled' -Placeholder 'Textbox' -DisabledNew-UDTextbox -Label 'Textbox' -Value 'With value'
A password textbox will mask the input.
New-UDTextbox -Label 'Password' -Type password
You can use Get-UDElement
to get the value of a textbox
New-UDTextbox -Id 'txtExample'New-UDButton -OnClick {$Value = (Get-UDElement -Id 'txtExample').valueShow-UDToast -Message $Value} -Text "Get textbox value"
New-UDTextbox -Id 'txtExample' -Label 'Label' -Value 'Value'​New-UDButton -OnClick {​Set-UDElement -Id 'txtExample' -Properties @{Value = "test123"}​} -Text "Get textbox value"
You can set the icon of a textbox by using the -Icon
parameter and the New-UDIcon
cmdlet.
New-UDTextbox -Id "ServerGroups" -Icon (New-UDIcon -Icon 'server') -Value "This is my server"
You can define a text mask with a combination of strings and regular expressions. To specify a regular expression, use the JavaScript syntax in your string to start and finish the expression: /\d/
.
This example creates a mask for US based phone numbers.
New-UDTextbox -Mask @('+', '1', ' ', '(', '/[1-9]/', '/\d/', '/\d/', ')', ' ', '/\d/', '/\d/', '/\d/', '-', '/\d/', '/\d/', '/\d/', '/\d/')
New-UDTextbox
Name | Type | Description | Required |
Id | String | The ID of the component. It defaults to a random GUID. | false |
Label | String | A label to show above this textbox. | false |
Placeholder | String | A placeholder to place within the text box. | false |
Value | Object | The current value of the textbox. | false |
Type | String | The type of textbox. This can be values such as text, password or email. | false |
Disabled | SwitchParameter | Whether this textbox is disabled. | false |
Icon | Object | The icon to show next to the textbox. | false |
Autofocus | SwitchParameter | Whether to autofocus this textbox. | false |