# Textbox

A textbox lets users enter and edit text.

## Textbox

![](https://2374445323-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6jY7sXTmhiAIMGYw_m%2F-MAgA8lkflyE8DVzEwHy%2F-MAgBzsgtqe5tt4bvUUn%2Fimage.png?alt=media\&token=5de8a488-7b18-4f3a-aaa7-9c87b380925f)

```
New-UDTextbox -Label 'Standard' -Placeholder 'Textbox'
New-UDTextbox -Label 'Disabled' -Placeholder 'Textbox' -Disabled
New-UDTextbox -Label 'Textbox' -Value 'With value'
```

## Password Textbox

A password textbox will mask the input.

![](https://2374445323-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6jY7sXTmhiAIMGYw_m%2F-MAgA8lkflyE8DVzEwHy%2F-MAgC1c_frWpotzS1xuD%2Fimage.png?alt=media\&token=4e07ab3e-3000-4b1a-a31f-39606006831d)

```
New-UDTextbox -Label 'Password' -Type password
```

## 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`.

```
New-UDTextbox -Multiline -Rows 4 -RowsMax 10
```

## Interaction

### Retrieving a textbox value

You can use `Get-UDElement` to get the value of a textbox

```
New-UDTextbox -Id 'txtExample' 
New-UDButton -OnClick {
    $Value = (Get-UDElement -Id 'txtExample').value 
    Show-UDToast -Message $Value
} -Text "Get textbox value"
```

### Setting the textbox value

```
New-UDTextbox -Id 'txtExample' -Label 'Label' -Value 'Value'

New-UDButton -OnClick {

    Set-UDElement -Id 'txtExample' -Properties @{
        Value = "test123"
    }

} -Text "Get textbox value"
```

## Icons

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"
```

![](https://2374445323-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6jY7sXTmhiAIMGYw_m%2F-MFet2aaAIlDdZlcNalk%2F-MFetKRtd-x_KM6aShI9%2Fimage.png?alt=media\&token=a8ae6823-413e-4190-b874-6b05dcf9cbaa)

## 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.

```
New-UDTextbox -Mask @('+', '1', ' ', '(', '/[1-9]/', '/\d/', '/\d/', ')', ' ', '/\d/', '/\d/', '/\d/', '-', '/\d/', '/\d/', '/\d/', '/\d/')
```

![](https://2374445323-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M6jY7sXTmhiAIMGYw_m%2F-MKH_CteFYMdPumnOe4I%2F-MKH_lM-fa5MD5UMZqzv%2Fimage.png?alt=media\&token=31b754cd-8e25-4d98-81da-a22f7277d47f)

**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    |
