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

# New-UDAutocomplete

New-UDAutocomplete creates a text input component in PowerShell Universal enhanced with a filterable panel of suggested options.

New-UDAutocomplete creates a text input component in PowerShell Universal enhanced with a filterable panel of suggested options.

### Synopsis

The autocomplete is a normal text input enhanced by a panel of suggested options.

### Syntax

```powershell
New-UDAutocomplete [-Id <String>] [-Label <String>] [-Value <Object>] [-OnChange <Endpoint>] [-Options <Object>] [-FullWidth] [-AutoSelect] [-Variant <String>] [-Multiple] [-ClassName <String>] [-Icon <Object>] [-OnEnter <Endpoint>] [-Disabled] [-Aria <ScriptBlock>] [<CommonParameters>]

New-UDAutocomplete [-Id <String>] [-Label <String>] [-Value <Object>] [-OnChange <Endpoint>] -OnLoadOptions <Endpoint> [-FullWidth] [-AutoSelect] [-Variant <String>] [-Multiple] [-ClassName <String>] [-Icon <Object>] [-OnEnter <Endpoint>] [-Disabled] [-Aria <ScriptBlock>] [<CommonParameters>]
```

### Description

Autocomplete text boxes can be used to allow the user to select from a large list of static or dynamic items. Typing in the textbox will filter the list.

### Parameters

#### -Id

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

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

#### -Label

The label to show for the textbox.

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

#### -Value

The value of the textbox.

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

#### -OnChange

A script block that is invoked when the selection changes.

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

#### -OnLoadOptions

A script block that is called when the user starts typing in the text box. The $Body variable will contain the typed text. You should return a JSON array of values that are a result of what the user has typed.

```
Type                         Endpoint
Required?                    true
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Options

Static options to display in the selection drop down. When the user types, these options will be filtered.

```
Type                         Object
Required?                    false
Position?                    named
Default value                @()
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -FullWidth

Whether the component should take up the full width of its parent.

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

#### -AutoSelect

Whether the component should automatically be selected if there was only one total option with the options array.

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

#### -Variant

The variant of the text box. Valid values are: "filled", "outlined", "standard"

```
Type                         String
Required?                    false
Position?                    named
Default value                standard
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Multiple

Whether multiple items can be selected.

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

#### -ClassName

A CSS class to apply to the component.

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

#### -Icon

The icon to display before the text box. Use New-UDIcon to create the value for this parameter.

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

#### -OnEnter

A script block to call when the user presses enter within the autocomplete textbox.

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

#### -Disabled

Whether this autocomplete is disabled.

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

#### -Aria

A script block that defines ARIA attributes for the autocomplete component.

```
Type                         ScriptBlock
Required?                    false
Position?                    named
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 autocomplete

```powershell
New-UDAutocomplete -Options @('Test', 'Test2', 'Test3', 'Test4') -Id 'autocomplete1' -FullWidth
```

The value must be chosen from a predefined set of allowed values.

#### Example 2: Multiple selections

```powershell
New-UDAutocomplete -Options @("Test", "No", "Yes") -Multiple -Id 'autocomplete2' -FullWidth
```

Allow the user to select multiple values.

#### Example 3: Variants

```powershell
New-UDStack -Content {
   New-UDAutocomplete -Options @("Test", "No", "Yes") -Variant 'filled' -Id 'autocomplete3' -FullWidth
   New-UDAutocomplete -Options @("Test", "No", "Yes") -Variant 'outlined' -Id 'autocomplete4' -FullWidth
   New-UDAutocomplete -Options @("Test", "No", "Yes") -Variant 'standard' -Id 'autocomplete5' -FullWidth
} -Direction 'column' -FullWidth
```

Change the style of the autocomplete textbox.

#### Example 4: Handling changes

```powershell
New-UDAutocomplete -Options @("Test", "No", "Yes") -OnChange {
   Show-UDToast $EventData
} -Id 'autocomplete6' -FullWidth
```

Execute PowerShell when the autocomplete changes.

#### Example 5: OnEnter

```powershell
New-UDAutocomplete -Options @("Test", "No", "Yes") -OnEnter {
   Show-UDToast $EventData
} -Id 'autocomplete7' -FullWidth
```

Execute PowerShell when the user presses enter.

#### Example 6: Asynchronous options

```powershell
New-UDAutocomplete -OnLoadOptions {
  @('Test', 'Test2', 'Test3', 'Test4') | Where-Object { $_ -match $Body } | ConvertTo-Json
} -Id 'autocomplete8' -FullWidth
```

Creates an autocomplete with a dynamically filtered set of options.

#### Example 7: Grouped options

```powershell
New-UDAutocomplete -Options @(
   New-UDAutocompleteOption -Name 'Test' -Value 'test' -Group 'Group1'
   New-UDAutocompleteOption -Name 'Test2' -Value 'test2' -Group 'Group1'
   New-UDAutocompleteOption -Name 'Test3' -Value 'test3' -Group 'Group2'
   New-UDAutocompleteOption -Name 'Test4' -Value 'test4' -Group 'Group2'
) -Id 'autocomplete9' -FullWidth
```


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.devolutions.net/powershell-universal/powershell-commands/new-udautocomplete.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
