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

New-UDSelect

Creates a new select.

Synopsis

Creates a new select.

Syntax

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.

-Label

The label to show with the select.

-OnChange

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

-DefaultValue The default selected value.Required? falsePosition? 5Default valueAccept pipeline input? falseAliasesAccept wildcard characters? false -Disabled [<SwitchParameter>] Whether this select is disabled.Required? falsePosition? namedDefault value FalseAccept pipeline input? falseAliasesAccept wildcard characters? false -Multiple [<SwitchParameter>] Whether you can select multiple values.Required? falsePosition? namedDefault value FalseAccept pipeline input? falseAliasesAccept wildcard characters? false-MaxWidthThe maximum width of the select.Required? falsePosition? 6Default valueAccept pipeline input? falseAliasesAccept wildcard characters? false-ClassNameA CSS class to apply to the select.Required? falsePosition? 7Default valueAccept pipeline input? falseAliasesAccept wildcard characters? false -FullWidth [<SwitchParameter>] Stretch the select to the full width of the parent component.Required? falsePosition? namedDefault value FalseAccept pipeline input? falseAliasesAccept wildcard characters? false-OnEnterA script block that is called when the user presses the enter key. The $EventData variable will contain the current value of the textbox.Required? falsePosition? 8Default valueAccept pipeline input? falseAliasesAccept wildcard characters? false-VariantThe variant of the select. Can be filled, outlined, or standard.Required? falsePosition? 9Default value standardAccept pipeline input? falseAliasesAccept wildcard characters? false-Icon The icon to show next to the textbox. Use New-UDIcon to create an icon.Required? falsePosition? 10Default valueAccept pipeline input? falseAliasesAccept wildcard characters? false-SxA hashtable of styles to apply to the select.Required? falsePosition? 11Default valueAccept pipeline input? falseAliasesAccept wildcard characters? false -Checkbox [<SwitchParameter>] Whether to display checkboxes when using multiselect.Required? falsePosition? namedDefault value FalseAccept pipeline input? falseAliasesAccept wildcard characters? false <CommonParameters> 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-------------------------- EXAMPLE 1 --------------------------PS >New-UDSelect -Label 'Select' -Id 'select1' -Option {PS > New-UDSelectOption -Name "One" -Value 1PS > New-UDSelectOption -Name "Two" -Value 2PS > New-UDSelectOption -Name "Three" -Value 3PS > } -FullWidthBasic Select|A basic select with three options-------------------------- EXAMPLE 2 --------------------------PS >New-UDSelect -Label 'Select' -Id 'select2' -Option {PS > New-UDSelectOption -Name "One" -Value 1PS > New-UDSelectOption -Name "Two" -Value 2PS > New-UDSelectOption -Name "Three" -Value 3PS > } -DefaultValue 2 -OnChange {PS > Show-UDToast -Message $EventDataPS > } -FullWidthOnChange|A select with an OnChange script block that shows a toast when the value changes.-------------------------- EXAMPLE 3 --------------------------PS >New-UDSelect -Label 'Select' -Id 'select3' -Option {PS > New-UDSelectOption -Name "One" -Value 1PS > New-UDSelectOption -Name "Two" -Value 2PS > New-UDSelectOption -Name "Three" -Value 3PS > } -Disabled -FullWidthDisabled|A disabled select.-------------------------- EXAMPLE 4 --------------------------PS >New-UDSelect -Label 'Select' -Id 'select4' -Option {PS > New-UDSelectOption -Name "One" -Value 1PS > New-UDSelectOption -Name "Two" -Value 2PS > New-UDSelectOption -Name "Three" -Value 3PS > } -Multiple -FullWidthMultiple|A select that allows multiple selections.-------------------------- EXAMPLE 5 --------------------------PS >New-UDSelect -Label 'Select' -Id 'select4' -Option {PS > New-UDSelectOption -Name "One" -Value 1PS > New-UDSelectOption -Name "Two" -Value 2PS > New-UDSelectOption -Name "Three" -Value 3PS > } -Multiple -FullWidth -CheckboxMultiple with Checkboxes|A select that allows multiple selections with checkboxes.-------------------------- EXAMPLE 6 --------------------------PS >New-UDSelect -Label 'Select' -Id 'select5' -Option {PS > New-UDSelectOption -Name "One" -Value 1PS > New-UDSelectOption -Name "Two" -Value 2PS > New-UDSelectOption -Name "Three" -Value 3PS > } -Variant outlined -FullWidthOutlined|A select with an outlined variant.-------------------------- EXAMPLE 7 --------------------------PS >New-UDSelect -Label 'Select' -Id 'select6' -Option {PS > New-UDSelectOption -Name "One" -Value 1PS > New-UDSelectOption -Name "Two" -Value 2PS > New-UDSelectOption -Name "Three" -Value 3PS > } -FullWidth -Icon (New-UDIcon -Icon Home)Icon|A select with an icon.-------------------------- EXAMPLE 8 --------------------------PS >New-UDSelect -Label 'Select' -Id 'select7' -Option {PS > New-UDSelectGroup -Name "Category 1" -Option {PS > New-UDSelectOption -Name "One" -Value 1PS > New-UDSelectOption -Name "Two" -Value 2PS > }PS > New-UDSelectGroup -Name "Category 2" -Option {PS > New-UDSelectOption -Name "Three" -Value 3PS > New-UDSelectOption -Name "Four" -Value 4PS > }PS > } -FullWidthGrouped|A select with option groups.[Component("Select", "ListDropdown", "Creates a new card.")]

Last updated

Was this helpful?