# Menu

The menu component can be used to provide a drop down list of options for the user to select.

## Basic Menu

Create a basic menu.

```powershell
New-UDMenu -Content {
   New-UDMenuItem -Text 'Item 1'
   New-UDMenuItem -Text 'Item 1'
   New-UDMenuItem -Text 'Item 1'
}
```

![](https://1373299915-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8F6PrkNTG8Y34hADzKOL%2Fuploads%2Fgit-blob-e1492688182e788ec238ea81eed570e6eb746664%2Fimage%20\(397\).png?alt=media)

## Button Styles

You can edit the style of the menu by adjusting the variant parameter.

```powershell
New-UDMenu -Content {
   New-UDMenuItem -Text 'Item 1'
   New-UDMenuItem -Text 'Item 1'
   New-UDMenuItem -Text 'Item 1'
} -Variant outlined
```

## Values

You can use the value parameter to define a value that differs from the text displayed.

```powershell
New-UDMenu -Content {
   New-UDMenuItem -Text 'Item 1' -Value 'item1'
   New-UDMenuItem -Text 'Item 1' -Value 'item2'
   New-UDMenuItem -Text 'Item 1' -Value 'item3'
}
```

## OnChange Event Handler

Use the `-OnChange` parameter to specify a script block to call when a new value is selected. The value of the selected item will be available in `$EventData`.

```powershell
New-UDMenu -Text 'Click Me' -OnChange {
    Show-UDToast $EventData
} -Children {
    New-UDMenuItem -Text 'Test'
    New-UDMenuItem -Text 'Test2'
    New-UDMenuItem -Text 'Test3'
}
```

## API

* [New-UDMenu](https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDMenu.txt)
* [New-UDMenuItem](https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDMenuItem.txt)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.powershelluniversal.com/apps/components/navigation/menu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
