Input controls for Universal Dashboard
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Button component for Universal Dashboard
Buttons allow users to take actions, and make choices, with a single tap.
Contained buttons are high-emphasis, distinguished by their use of elevation and fill. They contain actions that are primary to your app.
Outlined buttons are medium-emphasis buttons. They contain actions that are important, but aren’t the primary action in an app.
You can control the pixel size of a button based on pixel size by using the Style parameter
'''text New-UDButton -Id "Submit" -Text "Submit" -Style @{ Width = "150px" Height = "100px" }
Sometimes you might want to have icons for certain button to enhance the UX of the application as we recognize logos more easily than plain text. For example, if you have a delete button you can label it with a dustbin icon.
You can specify a script block to execute when the button is clicked
New-UDButton
Name
Type
Description
Required
Text
String
The text to show within the button.
false
Icon
Object
An icon to show within the button. Use New-UDIcon to create an icon for this parameter.
false
Variant
String
The variant type for this button.
false
IconAlignment
String
How to align the icon within the button.
false
FullWidth
SwitchParameter
Whether the button takes the full width of the it's container.
false
OnClick
Endpoint
The action to take when the button is clicked.
false
Size
String
The size of the button.
false
Style
Hashtable
Styles to apply to the button.
false
Href
String
A URL that the user should be redirected to when clicking the button.
false
Id
String
The ID of the component. It defaults to a random GUID.
false
Date Picker component for Universal Dashboard
Date pickers pickers provide a simple way to select a single value from a pre-determined set.
Date pickers can be used in and .
The OnChange event handler is called when the date changes. You can access the current date by using the $Body
variable.
You can customize how the date picker is show. The default is the inline
variant that displays the date picker popup inline with the input control. You can also use the dialog
variant that pops the date picker up in the middle of the screen. Finally, the static
variant displays the date picker without having to click anything.
New-UDDatePicker
Code editor component for Universal Dashboard.
To use a code editor within your dashboard, you will need to add the UniversalDashboard.CodeEditor component.
The code editor component allows you to host the editor within your dashboards.
You can create a new code editor with the New-UDCodeEditor
cmdlet. Specifying the -Language
parameter will enable syntax highlighting for that language. You will need to specify a height in pixels.
Use the -Code
parameter to specify code that will be populated within the code editor when it loads.
You can retrieve code from another component using the Get-UDElement
cmdlet and accessing the code property of the hashtable that is returned.
You can set code from another component using the Set-UDElement
cmdlet. Specify the code value in a hashtable passed to the -Properties
parameter.
The documentation is for an upcoming feature of PowerShell Universal .
The Monaco editor supports a wide range of options. If you wish to use options that aren't available on the New-UDCodeEditor
cmdlet, you can use the -Options
parameter and pass a hashtable of options instead.
For a full list of options, check the interface.
Name
Type
Description
Required
Id
String
The ID of the component. It defaults to a random GUID.
false
Label
String
The label to show next to the date picker.
false
Variant
String
The theme variant to apply to the date picker.
false
DisableToolbar
SwitchParameter
Disables the date picker toolbar.
false
OnChange
Endpoint
A script block to call with the selected date. The $EventData variable will be the date selected.
false
Format
String
The format of the date when it is selected.
false
Value
DateTime
The current value of the date picker.
false
Radio component for Universal Dashboard
Radio buttons allow the user to select one option from a set.
Use radio buttons when the user needs to see all available options. If available options can be collapsed, consider using a dropdown menu because it uses less space.
Radio buttons should have the most commonly used option selected by default.
An event handler that is called when the radio group is changed. the $Body variable will contain the current value.
Set the default value of the radio group.
You can use custom formatting within the radio group. The below example will place the radio buttons next to each other instead of on top of each other.
New-UDRadio
Name
Type
Description
Required
Id
String
The ID of the component. It defaults to a random GUID.
false
Label
String
The label to show next to the radio.
false
Disabled
SwitchParameter
Whether the radio is disabled.
false
Value
String
The value of the radio.
false
LabelPlacement
String
The position to place the label in relation to the radio.
false
Check component for Universal Dashboard
Checkboxes allow the user to select one or more items from a set.
Checkboxes can be disabled and checked by default
Create checkboxes that use any icon and style.
Create checkboxes that fire script blocks when changed.
You can adjust where the label for the checkbox is placed.
You can use Get-UDElement
to get the value of the checkbox. Get-UDElement
will also return other properties of the checkbox component.
The following example shows a toast message with the value of the checkbox.
New-UDCheckbox
Textbox component for Universal Dashboard
A textbox lets users enter and edit text.
A password textbox will mask the input.
You can create a multiline textbox by using the -Multiline
parameter. Pressing enter will add a new line. You can define the number of rows and the max number of rows using -Rows
and -RowsMax
.
You can use Get-UDElement
to get the value of a textbox
You can set the icon of a textbox by using the -Icon
parameter and the New-UDIcon
cmdlet.
You can define a text mask with a combination of strings and regular expressions. To specify a regular expression, use the JavaScript syntax in your string to start and finish the expression: /\d/
.
This example creates a mask for US based phone numbers.
New-UDTextbox
Select component for Universal Dashboard
Select components are used for collecting user provided information from a list of options.
Create a simple select with multiple options.
Create a select with groups of selections.
Execute a PowerShell event handler when the value of the select is changed.
Retrieve the value of the select from another component.
New-UDSelect
Form component for Universal Dashboard
Forms provide a way to collect data from users.
Forms can include any type of control you want. This allows you to customize the look and feel and use any input controls.
Data entered via the input controls will be sent back to the the OnSubmit
script block when the form is submitted. Within the OnSubmit
event handler, you will access to the $EventData
variable that will contain properties for each of the fields in the form.
For example, if you have two fields, you will have two properties on $EventData
.
The following input controls automatically integrate with a form. The values that are set within these controls will be sent during validation and in the OnSubmit
event handler.
Simple forms can use inputs like text boxes and checkboxes.
Since forms can use any component, you can use standard formatting components within the form.
When a form is submitted, you can optionally return another component to replace the form on the page. You can return any Universal Dashboard component. All you need to do is ensure that the component is written to the pipeline within the OnSubmit
event handler.
Form validation can be accomplished by using the OnValidate script block parameter
You can define an -OnCancel
event handler to invoke when the cancel button is pressed. This can be used to take actions like close a modal.
Although you can return components directly from a form, you may want to retain the form so users can input data again. To do so, you can use Set-UDElement
and a placeholder element that you can set the content to.
In this example, we have an empty form that, when submitted, will update the results
element with a UDCard.
New-UDForm
New-UDFormValidationResult
Slider component for Universal Dashboard.
Sliders allow users to make selections from a range of values.
Sliders reflect a range of values along a bar, from which users may select a single value. They are ideal for adjusting settings such as volume, brightness, or applying image filters.
New-UDSlider
Component for uploading files in Universal Dashboard.
The UDUpload component is used to upload files to Universal Dashboard. You can process files the user uploads. You will receive the data for the file, a file name and the type of file if it can be determined by the web browser.
This component works with and .
Uploads a file and shows the contents via a toast.
The body of the OnUpload
script block is a JSON string with the following format.
Uploads a file as part of a UDForm.
The body of the OnSubmit
script block is the same one you will see with any form and the file will be contains as one of the fields within the form.
This example allows a user to upload a file. Once the file is uploaded, it will be saved to the temporary directory.
New-UDUpload
Name
Type
Description
Required
Label
String
The label to show next to the checkbox.
false
Icon
Object
The icon to show instead of the default icon.
false
CheckedIcon
Object
The icon to show instead of the default checked icon.
false
OnChange
Endpoint
Called when the value of the checkbox changes. The $EventData variable will have the current value of the checkbox.
false
Style
Hashtable
A hashtable of styles to apply to the checkbox.
false
Disabled
SwitchParameter
Whether the checkbox is disabled.
false
Checked
Boolean
Whether the checkbox is checked.
false
ClassName
String
A CSS class to assign to the checkbox.
false
LabelPlacement
String
Where to place the label.
false
Id
String
The ID of the component. It defaults to a random GUID.
false
Name
Type
Description
Required
Id
String
The ID of the component. It defaults to a random GUID.
false
Label
String
A label to show above this textbox.
false
Placeholder
String
A placeholder to place within the text box.
false
Value
Object
The current value of the textbox.
false
Type
String
The type of textbox. This can be values such as text, password or email.
false
Disabled
SwitchParameter
Whether this textbox is disabled.
false
Icon
Object
The icon to show next to the textbox.
false
Autofocus
SwitchParameter
Whether to autofocus this textbox.
false
Multiline
SwitchParameter
Whether the textbox accepts multiple lines.
false
Rows
int
The number of rows in a multiline textbox
false
RowsMax
int
The max number of rows in a multiline textbox
false
Name
Type
Description
Required
Id
String
The ID of the component. It defaults to a random GUID.
false
Option
ScriptBlock
Options to include in this select. This can be either New-UDSelectOption or New-UDSelectGroup.
false
Label
String
The label to show with the select.
false
OnChange
Endpoint
A script block that is executed when the script changes. $EventData will be an array of the selected values.
false
DefaultValue
String
The default selected value.
false
Disabled
SwitchParameter
Whether this select is disabled.
false
Multiple
SwitchParameter
Whether you can select multiple values.
false
Name
Type
Description
Required
Id
String
The ID of the component. It defaults to a random GUID.
false
Children
ScriptBlock
Controls that make up this form. This can be any combination of controls. Input controls will report their state to the form.
true
OnSubmit
Endpoint
A script block that is execute when the form is submitted. You can return controls from this script block and the form will be replaced by the script block. The $EventData variable will contain a hashtable of all the input fields and their values.
true
OnValidate
Endpoint
A script block that validates the form. Return the result of a call to New-UDFormValidationResult.
false
OnProcessing
ScriptBlock
A script block that is called when the form begins processing. The return value of this script block should be a component that displays a loading dialog. The script block will receive the current form data.
false
OnCancel
Endpoint
An endpoint that is called when this form is cancelled. When this parameter is defined a cancel button will appear.
false
Name
Type
Description
Required
Valid
SwitchParameter
Whether the form status is considered valid.
false
ValidationError
String
An error to display if the form is not valid.
false
Name
Type
Description
Required
Id
String
The ID of the component. It defaults to a random GUID.
false
Label
String
The label to show with the time picker.
false
OnChange
Endpoint
A script block to call when the time is changed. The $EventData variable contains the currently selected time.
false
Value
String
The current value of the time picker.
false
Name
Type
Description
Required
Id
string
false
Value
int[]
false
Minimum
int
false
Maximum
int
false
Disabled
switch
false
Marks
switch
false
OnChange
Endpoint
false
Orientation
string
false
Step
int
false
ValueLabelDisplay
string
false
Name
Type
Description
Required
Id
String
The ID of the component. It defaults to a random GUID.
false
Accept
String
The type of files to accept. By default, this component accepts all files.
false
OnUpload
Endpoint
A script block to call when the file is uploaded.
false
Text
String
The text to display in the upload button.
false
Variant
String
The type of button to show for the upload button.
false
Color
String
The color to use for the upload button.
false
Switch component for Universal Dashboard
Switches toggle the state of a single setting on or off.
Switches are the preferred way to adjust settings on mobile. The option that the switch controls, as well as the state it’s in, should be made clear from the corresponding inline label.
Create a basic switch.
Respond to when a switch value is changed. The $EventData
variable will include whether or not the switch was checked or unchecked.
You can retrieve the value of the switch within another component by using Get-UDElement
. Use the Checked property to determine whether the switch is checked out not.
New-UDSwitch
Name
Type
Description
Required
Id
String
The ID of the component. It defaults to a random GUID.
false
Disabled
SwitchParameter
Whether this switch is disabled.
false
OnChange
Endpoint
A script block that is called when this switch changes. The $EventData variable will contain the checked value ($true$false).
false
Checked
Boolean
Whether this switch is checked.
false
Floating action button component for Universal Dashboard
A floating action button (FAB) performs the primary, or most common, action on a screen.
A floating action button appears in front of all screen content, typically as a circular shape with an icon in its center. FABs come in two types: regular, and extended.
Only use a FAB if it is the most suitable way to present a screen’s primary action.
Only one floating action button is recommended per screen to represent the most common action.
New-UDFloatingActionButton
Name
Type
Description
Required
Id
String
The ID of the component. It defaults to a random GUID.
false
Icon
Object
The icon to put within the floating action button.
false
Size
Object
The size of the button.
false
OnClick
Object
A script block to execute when the floating action button is clicked.
false