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

Components

A Universal app is composed of components. When building an app, call PowerShell cmdlets within the app script to create components.

New-UDApp -Title 'Dashboard' -Content {
    New-UDTypography -Text 'Hello, world!'
}

Component types

There are more than 50 components that you can use in apps. Common categories include data display, data visualization, feedback, inputs, navigation, layout, utilities, and surfaces.

  • Data display: alerts, tables, and timelines.

  • Data visualization: charts and maps.

  • Feedback: modals and progress indicators.

  • Inputs: buttons, forms, textboxes, and switches.

  • Navigation: menus, steppers, and tabs.

  • Layout: grids and stacks.

  • Utilities: dynamic, element, and HTML components.

  • Surfaces: cards and expansion panels.

Accessibility and ARIA attributes

Use the shared -Aria parameter to add ARIA attributes to supported interactive components. The parameter accepts a script block containing one or more New-UDAriaAttribute commands. PowerShell Universal applies the resulting attributes to the interactive or input element.

This example renders aria-label="noo-gah Krwah-sahn val-ay" and aria-labelledby="hardWordsLabel" on the textbox input. Use ARIA attributes to provide an accessible name, connect instructions and error text, and express the control state when its visible content does not already do so.

Supported attributes

New-UDAriaAttribute supports the following helpers:

Helper
Rendered attribute

-Label

aria-label

-LabelledBy or -LabeledBy

aria-labelledby

-DescribedBy

aria-describedby

-Description

aria-description

-Controls

aria-controls

-Expanded

aria-expanded

-HasPopup

aria-haspopup

-Hidden

aria-hidden

-Invalid

aria-invalid

-Required

aria-required

-Role

role

Use valid values for the ARIA attribute you select. Prefer native labels and semantics when they are sufficient; ARIA supplements them and should not replace visible labels or standard form behavior.

Supported components

The following components support -Aria:

  • New-UDAutocomplete

  • New-UDButton and New-UDIconButton

  • New-UDCheckbox

  • New-UDSelect

  • New-UDRadioGroup and New-UDRadio

  • New-UDSwitch

  • New-UDSlider

  • New-UDLink

  • New-UDDatePicker and New-UDTimePicker

  • New-UDRating

  • New-UDFloatingActionButton

  • New-UDUpload

  • New-UDToggleButtonGroup and New-UDToggleButton

  • New-UDTextbox

For textboxes, explicit values in -Attributes take precedence when the same attribute is also defined through -Aria.

Event handlers

Many components provide event handlers for interactive functionality such as clicks, validation, and rendering. Event handlers use PowerShell script blocks.

Within event handlers, you can run any valid PowerShell command, including commands from modules outside PowerShell Universal such as ActiveDirectory or Microsoft.Graph.

Event data

Event handlers can provide data as $EventData. The value depends on the component: a textbox change returns its value, while a form submission returns an object with the form values.

Use $Body when you need the raw JSON string provided to the event handler. Some controls also provide $PSUItem with the item ID, type, event ID, event name, event data, and location.

Scoping

PowerShell Universal makes in-scope variables available to event handlers, but every handler runs in its own runspace. Do not rely on $Global: or $Script: scope to share state between handlers; use custom scopes instead.

Avoid inheriting $EventData in nested event handlers because the nested handler replaces it. Store the required outer value in a variable before creating the nested component.

See also

Last updated

Was this helpful?