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

# New-UDSelect

New-UDSelect creates a dropdown select input in PowerShell Universal, supporting grouped options via New-UDSelectGroup and single or multiple selection.

### Synopsis

Creates a new select.

### Syntax

```powershell
New-UDSelect [[-Id] <String>] [[-Option] <ScriptBlock>] [[-Label] <String>] [[-OnChange] <Endpoint>] [[-DefaultValue] <Object>] [-Disabled] [-Multiple] [[-MaxWidth] <String>] [[-ClassName] <String>] [-FullWidth] [[-OnEnter] <Endpoint>] [[-Variant] <String>] [[-Icon] <Object>] [[-Sx] <Hashtable>] [-Checkbox] [<CommonParameters>]
```

### Description

Creates a new select. Selects can have multiple options and option groups. Selects can also be multi-select.

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

#### -Option

Options to include in this select. This can be either New-UDSelectOption or New-UDSelectGroup.

```
Required?                    false
Position?                    2
Default value                {
                    New-UDSelectOption -Name 'Option 1' -Value 1
                    New-UDSelectOption -Name 'Option 2' -Value 2
                }
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Label

The label to show with the select.

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

#### -OnChange

A script block that is executed when the script changes. $EventData will be an array of the selected values.

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

#### -DefaultValue

The default selected value.

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

#### -Disabled

Whether this select is disabled.

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

#### -Multiple

Whether you can select multiple values.

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

#### -MaxWidth

The maximum width of the select.

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

#### -ClassName

A CSS class to apply to the select.

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

#### -FullWidth

Stretch the select to the full width of the parent component.

```
Required?                    false
Position?                    named
Default value                False
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?                    8
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Variant

The variant of the select. Can be filled, outlined, or standard.

```
Required?                    false
Position?                    9
Default value                standard
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?                    10
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Sx

A hashtable of styles to apply to the select.

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

#### -Checkbox

Whether to display checkboxes when using multiselect.

```
Required?                    false
Position?                    named
Default value                False
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 Select

```powershell
New-UDSelect -Label 'Select' -Id 'select1' -Option {
   New-UDSelectOption -Name "One" -Value 1
   New-UDSelectOption -Name "Two" -Value 2
   New-UDSelectOption -Name "Three" -Value 3
} -FullWidth
```

A basic select with three options

#### Example 2: OnChange

```powershell
New-UDSelect -Label 'Select' -Id 'select2' -Option {
   New-UDSelectOption -Name "One" -Value 1
   New-UDSelectOption -Name "Two" -Value 2
   New-UDSelectOption -Name "Three" -Value 3
} -DefaultValue 2 -OnChange {
   Show-UDToast -Message $EventData
} -FullWidth
```

A select with an OnChange script block that shows a toast when the value changes.

#### Example 3: Disabled

```powershell
New-UDSelect -Label 'Select' -Id 'select3' -Option {
   New-UDSelectOption -Name "One" -Value 1
   New-UDSelectOption -Name "Two" -Value 2
   New-UDSelectOption -Name "Three" -Value 3
} -Disabled -FullWidth
```

A disabled select.

#### Example 4: Multiple

```powershell
New-UDSelect -Label 'Select' -Id 'select4' -Option {
   New-UDSelectOption -Name "One" -Value 1
   New-UDSelectOption -Name "Two" -Value 2
   New-UDSelectOption -Name "Three" -Value 3
} -Multiple -FullWidth
```

A select that allows multiple selections.

#### Example 5: Multiple with Checkboxes

```powershell
New-UDSelect -Label 'Select' -Id 'select4' -Option {
   New-UDSelectOption -Name "One" -Value 1
   New-UDSelectOption -Name "Two" -Value 2
   New-UDSelectOption -Name "Three" -Value 3
} -Multiple -FullWidth -Checkbox
```

A select that allows multiple selections with checkboxes.

#### Example 6: Outlined

```powershell
New-UDSelect -Label 'Select' -Id 'select5' -Option {
   New-UDSelectOption -Name "One" -Value 1
   New-UDSelectOption -Name "Two" -Value 2
   New-UDSelectOption -Name "Three" -Value 3
} -Variant outlined -FullWidth
```

A select with an outlined variant.

#### Example 7: Icon

```powershell
New-UDSelect -Label 'Select' -Id 'select6' -Option {
   New-UDSelectOption -Name "One" -Value 1
   New-UDSelectOption -Name "Two" -Value 2
   New-UDSelectOption -Name "Three" -Value 3
} -FullWidth -Icon (New-UDIcon -Icon Home)
```

A select with an icon.

#### Example 8: Grouped

```powershell
New-UDSelect -Label 'Select' -Id 'select7' -Option {
   New-UDSelectGroup -Name "Category 1" -Option {
       New-UDSelectOption -Name "One" -Value 1
       New-UDSelectOption -Name "Two" -Value 2
   }
   New-UDSelectGroup -Name "Category 2" -Option {
       New-UDSelectOption -Name "Three" -Value 3
       New-UDSelectOption -Name "Four" -Value 4
   }
} -FullWidth
```

A select with option groups.

\[Component("Select", "ListDropdown", "Creates a new card.")]


---

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