> 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-udtextbox.md).

# New-UDTextbox

New-UDTextbox creates a text input field in PowerShell Universal for entering and editing values, usable standalone or inside a form.

### Synopsis

Textboxes let users enter and edit text.

### Syntax

```powershell
New-UDTextbox [[-Id] <String>] [[-Label] <String>] [[-Placeholder] <String>] [[-Value] <String>] [[-Type] <String>] [-Disabled] [[-Icon] <Object>] [-Autofocus] [-Multiline] [[-Rows] <Int32>] [[-RowsMax] <Int32>] [-FullWidth] [[-Variant] <String>] [[-ClassName] <String>] [[-OnEnter] <Endpoint>] [[-OnBlur] <Endpoint>] [-Shrink] [[-OnValidate] <Endpoint>] [[-HelperText] <String>] [[-OnChange] <Endpoint>] [[-Minimum] <Int32>] [[-Maximum] <Int32>] [[-MaximumLength] <Int32>] [[-Sx] <Hashtable>] [[-Style] <Hashtable>] [[-MaskPattern] <String>] [[-Attributes] <Hashtable>] [<CommonParameters>]
```

### Description

Creates a textbox. Textboxes can be used by themselves or within a New-UDForm.

### Parameters

#### -Id

The ID of the component. It defaults to a random GUID.

```
Required?                    false
Position?                    1
Default value                ([Guid]::NewGuid())
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Label

A label to show above this textbox.

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

#### -Placeholder

A placeholder to place within the text box.

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

#### -Value

The current value of the textbox.

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

#### -Type

The type of textbox. This can be values such as text, password or email.

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

#### -Disabled

Whether this textbox is disabled.

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

#### -Icon

The icon to show next to the textbox. Use New-UDIcon to create an icon.

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

#### -Autofocus

Whether to autofocus this textbox.

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

#### -Multiline

Creates a multiline textbox

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

#### -Rows

The number of rows in a multiline textbox.

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

#### -RowsMax

The maximum number of rows in a multiline textbox.

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

#### -FullWidth

Whether to make this textbox take up the full width of the parent control.

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

#### -Variant

The variant of textbox. Valid values are "filled", "outlined", "standard"

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

#### -ClassName

A CSS class to apply to the textbox.

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

#### -OnEnter

A script block that is called when the user presses the enter key. The $EventData variable will contain the current value of the textbox.

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

#### -OnBlur

A script block that is called when the user leaves the textbox. The $EventData variable will contain the current value of the textbox.

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

#### -Shrink

Whether to shrink label by default.

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

#### -OnValidate

A script block that is called when the user leaves the textbox. The $EventData variable will contain the current value of the textbox. If the script block returns an validation result that is invalid, it will be displayed below the textbox.

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

#### -HelperText

A helper text to show below the textbox.

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

#### -OnChange

A script block that is called when the user changes the value of the textbox. The $EventData variable will contain the current value of the textbox.

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

#### -Minimum

The minimum value for a number textbox.

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

#### -Maximum

The maximum value for a number textbox.

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

#### -MaximumLength

The maximum length of the text in the textbox.

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

#### -Sx

A hashtable of theme-based properties to apply to the textbox.

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

#### -Style

A hashtable of CSS properties to apply to the textbox.

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

#### -MaskPattern

A mask pattern to apply to the textbox. This is used for input masks. Check iMaskjs for more information.

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

#### -Attributes

```
Required?                    false
Position?                    22
Default value                @{}
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### Common parameters

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

### Examples

#### Example 1: Basic textbox

```powershell
New-UDTextbox -Id 'textbox1' -Label 'Name' -Placeholder 'Enter your name' -Value 'John Doe'
```

Creates a basic textbox.

#### Example 2: Password textbox

```powershell
New-UDTextbox -Id 'textbox2' -Label 'Password' -Placeholder 'Enter your password' -Type 'password'
```

Creates a password textbox.

#### Example 3: Email textbox

```powershell
New-UDTextbox -Id 'textbox3' -Label 'Email' -Placeholder 'Enter your email' -Type 'email'
```

Creates an email textbox.

#### Example 4: Disabled textbox

```powershell
New-UDTextbox -Id 'textbox4' -Disabled -Label 'Disabled' -Placeholder 'Enter your name' -Value 'John Doe'
```

Creates a disabled textbox.

#### Example 5: Textbox with icon

```powershell
New-UDTextbox -Id 'textbox5' -Label 'Name' -Placeholder 'Enter your name' -Value 'John Doe' -Icon (New-UDIcon -Icon 'User')
```

Creates a textbox with an icon.

#### Example 6: Autofocus textbox

```powershell
New-UDTextbox -Id 'textbox6' -Label 'Name' -Placeholder 'Enter your name' -Value 'John Doe' -Autofocus
```

Creates a textbox that will autofocus when the page loads.

#### Example 7: Multiline textbox

```powershell
New-UDTextbox -Id 'textbox7' -Label 'Name' -Placeholder 'Enter your name' -Value 'John Doe' -Multiline
```

Creates a multiline textbox.

#### Example 8: Multiline textbox with 5 rows

```powershell
New-UDTextbox -Id 'textbox8' -Label 'Name' -Placeholder 'Enter your name' -Value 'John Doe' -Multiline -Rows 5 -RowsMax 10
```

Creates a multiline textbox with 5 rows.

#### Example 9: Variant

```powershell
New-UDTextbox -Id 'textbox9' -Variant 'filled' -Label 'Name' -Placeholder 'Enter your name' -Value 'John Doe'
```

Creates a filled textbox.

#### Example 10: OnEnter

```powershell
New-UDTextbox -Id 'textbox10' -OnEnter {
   Show-UDToast -Message "You pressed enter!"
} -Label 'Name' -Placeholder 'Enter your name' -Value 'John Doe'
```

Creates a textbox with an OnEnter event.

#### Example 11: OnBlur

```powershell
New-UDTextbox -Id 'textbox11' -OnBlur {
   Show-UDToast -Message "You left the textbox!"
} -Label 'Name' -Placeholder 'Enter your name' -Value 'John Doe'
```

Creates a textbox with an OnBlur event.

#### Example 12: OnValidate

```powershell
New-UDTextbox -Id 'textbox12' -OnValidate {
   if ($EventData -eq 'John Doe') {
       return New-UDValidationResult -Valid
   }
   else {
       return New-UDValidationResult -ValidationError "You must enter John Doe"
   }
} -Label 'Name' -Placeholder 'Enter your name' -Value 'John Doe'
```

Creates a textbox with an OnValidate event.

#### Example 13: Helper Text

```powershell
New-UDTextbox -Id 'textbox13' -HelperText 'This is a helper text' -Label 'Name' -Placeholder 'Enter your name' -Value 'John Doe'
```

Creates a textbox with helper text.

#### Example 14: OnChange

```powershell
New-UDTextbox -Id 'textbox14' -OnChange {
   Show-UDToast -Message $EventData
} -Label 'Name' -Placeholder 'Enter your name' -Value 'John Doe'
```

Creates a textbox with an OnChange event.

#### Example 15: Minimum and Maximum

```powershell
New-UDTextbox -Id 'textbox15' -Type 'number' -Minimum 1 -Maximum 100
```

Creates a number textbox with a minimum and maximum value.

#### Example 16: Mask Pattern

```powershell
New-UDTextbox -Id 'textbox16' -MaskPattern '+7 (000) 000-00-00'
```

Creates a textbox with a mask pattern.


---

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