Input controls for Universal Dashboard
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
A text editor component for Universal Dashboard.
The editor component is based on Editor.js. It's a block editor that accepts text, links, lists, code and images.
When working with the editor, you can receive data about the current document via the OnChange
parameter. By default, data is returned in the Editor.js JSON format.
To create a basic editor, use the New-UDEditor
cmdlet.
The editor will be available and you can add new blocks by clicking the plus button.
If you define a script block for the -OnChange
event handler. The $EventData
variable will contain the current status of the editor. By default, this returns the Editor.JS JSON block format.
You can also use the HTML render plugin by specifying the -Format
parameter.
To specify the default data for the editor, use the -Data
parameter. You need to specify the JSON block format.
In order to support images, you will need to provide a published folder in which to upload the images. Once a published folder is defined, images can be uploaded directly in the editor. They will be placed within the directory and then served through the request path.
Id
string
The ID of this component.
Data
Hashtable
The Editor.JS data for this component
OnChange
ScriptBlock
The script block event handler to call when the editor data changes.
Format
string
Whether to return either json or html in the OnChange script block.
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
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
Loading buttons will display a loading icon while an event handler is running. This is useful for longer running events.
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 shown. 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.
To set the locate of the date picker, specify the -Locale
parameter.
By default, the user can select any date. To specify minimum and maximum dates, using the -Minimum
and -Maximum
parameters.
Code editor component for Universal Dashboard.
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.
Autocomplete component for Universal Dashboard
The autocomplete is a normal text input enhanced by a panel of suggested options.
Creates a basic autocomplete with a static list of options
When text is typed, it can be filtered with OnLoadOptions
. $Body
will contain the current text that is typed.
This example filters the array with Where-Object
.
$Body
contains the currently selected item. The OnChange event will fire when the user selects one or more items.
You can place an icon before an autocomplete by using the -Icon
parameter.
OnEnter is triggered when the user presses the enter key within the autocomplete.
You can use New-UDAutoCompleteOption
to specify name and values.
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.
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.
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.
You define fields that accept string, number, integer, enum and boolean types. This changes the type of input shown.
You can use the required
property to set a list of required properties.
Note that the properties need to be lower case! For example, you need to ensure the keys in your properties hashtable are lower case and the list of required properties are also lower case.
You can use the schemaUI
property to modify the ordering of the fields.
You can create forms that accept 0 to many objects. The user will be able to add and remove objects to the form.
You can automatically generate forms based on scripts in your PowerShell Universal environment. Script forms will generate input components based on the param
block. Script forms automatically support progress and feedback.
Script forms also support displaying the output as text or a table.
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.
The $EventData
is an object with the following structure.
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.
For a full list of options, check the interface.
Instead of defining all the layout and logic for forms using cmdlets, you can also define a form based on a hashtable of schema. This version of forms is based on .
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.
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.
The textbox mask is accomplished using react-imask. You can specify RegEx and pattern matching.
This example creates a mask for US based phone numbers.
The default behavior of -Mask
is to return the masked value in forms and Get-UDElement
. You can return the unmasked value by specifying the -Unmask
parameter.
The -OnEnter
event handler is executed when the user presses enter in the text field. It is useful for performing other actions, like clicking a button, on enter.
The -OnBlur
event handler is executed when the textbox loses focus.
Use the -OnValidate
event handler to validate input typed in the textbox.
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. $EventData[0] for the single item that was selected.
Execute a PowerShell event handler when the more than one value of the select is changed. $EventData is an array of the selected items.
Retrieve the value of the select from another component.
A transfer list (or "shuttle") enables the user to move one or more list items between lists.
Create a simple transfer list.
Use the OnChange
event handler to get the value of the selected items.
Transfer lists can be used within forms and steppers.
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.
Time picker component for Universal Dashboard
Time pickers pickers provide a simple way to select a single value from a pre-determined set.
Specify the locale of the time picker.
You can use the -DisableAmPm
parameter to use 24-hour time.
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.