For the complete documentation index, see llms.txt. This page is also available as Markdown.

New-UDAutocomplete

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

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.

-Value

The value of the textbox.

-OnChange

A script block that is invoked when the selection changes.

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

-Options

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

-FullWidth

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

-AutoSelect

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

-Variant

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

-Multiple

Whether multiple items can be selected.

-ClassName

A CSS class to apply to the component.

-Icon

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

-OnEnter

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

-Disabled

Whether this autocomplete is disabled.

-Aria

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

Common parameters

This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. For more information, see about_CommonParameters.

Outputs

Examples

Example 1: Basic autocomplete

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

Example 2: Multiple selections

Allow the user to select multiple values.

Example 3: Variants

Change the style of the autocomplete textbox.

Example 4: Handling changes

Execute PowerShell when the autocomplete changes.

Example 5: OnEnter

Execute PowerShell when the user presses enter.

Example 6: Asynchronous options

Creates an autocomplete with a dynamically filtered set of options.

Example 7: Grouped options

Last updated

Was this helpful?