New-UDSwitch
Synopsis
Creates a new switch.
Syntax
New-UDSwitch [[-Id] <String>] [-Disabled] [[-OnChange] <Endpoint>] [[-Checked] <Boolean>] [[-ClassName] <String>] [[-Color] <String>] [[-Label] <String>] [[-LabelComponent] <Hashtable>] [[-CheckedLabel] <String>] [[-CheckedLabelComponent] <Hashtable>] [[-UncheckedLabel] <String>] [[-UncheckedLabelComponent] <Hashtable>] [[-Size] <String>] [[-LabelPlacement] <String>] [-CheckStyle] [[-Sx] <Hashtable>] [[-Style] <Hashtable>] [[-Aria] <ScriptBlock>] [<CommonParameters>]Description
Creates a new switch. A switch behaves like a checkbox but looks a little different.
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-Disabled
Whether this switch is disabled.
-OnChange
A script block that is called when this switch changes. The $EventData variable will contain the checked value ($true$false).
-Checked
Whether this switch is checked.
-ClassName
A CSS class to apply to the switch.
-Color
The theme color to apply to this switch.
-Label
The label to display next to the switch
-LabelComponent
-CheckedLabel
The label to display for when the switch is checked
-CheckedLabelComponent
-UncheckedLabel
The label to display for when the switch is unchecked
-UncheckedLabelComponent
-Size
The size of the switch. Valid values are: "small", "medium"
-LabelPlacement
The placement of the label. Valid values are: "top", "start", "right", "bottom"
-CheckStyle
Style switch with check and unchecked icons for the colorblind.
-Sx
A hashtable of theme-based styles to apply to the switch.
-Style
A hashtable of styles to apply to the switch.
-Aria
A script block of New-UDAriaAttribute calls that supplies ARIA or role attributes for the switch.
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 switch
Creates a basic switch.
Example 2: OnChange
Creates a switch with an OnChange script block.
Example 3: Disabled
Creates a disabled switch.
Example 4: Label
Creates a switch with a label.
Example 5: Label Placement
Creates a switch with a label and a label placement.
Example 6: Check Style
Creates a switch with a label, a label placement, and a check style.
Last updated
Was this helpful?