Textbox
Textbox component for Universal Dashboard
A textbox lets users enter and edit text.

Textbox

1
New-UDTextbox -Label 'Standard' -Placeholder 'Textbox'
2
New-UDTextbox -Label 'Disabled' -Placeholder 'Textbox' -Disabled
3
New-UDTextbox -Label 'Textbox' -Value 'With value'
Copied!

Password Textbox

A password textbox will mask the input.
1
New-UDTextbox -Label 'Password' -Type password
Copied!

Multiline

You can create a multiline textbox by using the -Multiline parameter. Pressing enter will add a new line. You can define the number of rows and the max number of rows using -Rows and -RowsMax.
1
New-UDTextbox -Multiline -Rows 4 -RowsMax 10
Copied!

Interaction

Retrieving a textbox value

You can use Get-UDElement to get the value of a textbox
1
New-UDTextbox -Id 'txtExample'
2
New-UDButton -OnClick {
3
$Value = (Get-UDElement -Id 'txtExample').value
4
Show-UDToast -Message $Value
5
} -Text "Get textbox value"
Copied!

Setting the textbox value

1
New-UDTextbox -Id 'txtExample' -Label 'Label' -Value 'Value'
2
3
New-UDButton -OnClick {
4
5
Set-UDElement -Id 'txtExample' -Properties @{
6
Value = "test123"
7
}
8
9
} -Text "Get textbox value"
Copied!

Icons

You can set the icon of a textbox by using the -Icon parameter and the New-UDIcon cmdlet.
1
New-UDTextbox -Id "ServerGroups" -Icon (New-UDIcon -Icon 'server') -Value "This is my server"
Copied!

Mask

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.
1
New-UDTextbox -Mask @('+', '1', ' ', '(', '/[1-9]/', '/\d/', '/\d/', ')', ' ', '/\d/', '/\d/', '/\d/', '-', '/\d/', '/\d/', '/\d/', '/\d/')
Copied!
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
Multiline
SwitchParameter
Whether the textbox accepts multiple lines.
false
Rows
int
The number of rows in a multiline textbox
false
RowsMax
int
The max number of rows in a multiline textbox
false
Last modified 6mo ago