# List

Lists are continuous, vertical indexes of text or images.

Lists are a continuous group of text or images. They are composed of items containing primary and supplemental actions, which are represented by icons and text.

## List

![](/files/-MAgCdFWXZ5so1QwBo3o)

```
New-UDList -Content {
    New-UDListItem -Label 'Inbox' -Icon (New-UDIcon -Icon envelope -Size 3x) -SubTitle 'New Stuff'
    New-UDListItem -Label 'Drafts' -Icon (New-UDIcon -Icon edit -Size 3x) -SubTitle "Stuff I'm working on "
    New-UDListItem -Label 'Trash' -Icon (New-UDIcon -Icon trash -Size 3x) -SubTitle 'Stuff I deleted'
    New-UDListItem -Label 'Spam' -Icon (New-UDIcon -Icon bug -Size 3x) -SubTitle "Stuff I didn't want"
}
```

## OnClick Event Handler

You can define an action to take when an item is clicked by using the `-OnClick` parameter of `New-UDListItem`.

```
New-UDList -Content {
    New-UDListItem -Label 'Inbox' -Icon (New-UDIcon -Icon envelope -Size 3x) -SubTitle 'New Stuff'
    New-UDListItem -Label 'Drafts' -Icon (New-UDIcon -Icon edit -Size 3x) -SubTitle "Stuff I'm working on "
    New-UDListItem -Label 'Trash' -Icon (New-UDIcon -Icon trash -Size 3x) -SubTitle 'Stuff I deleted'
    New-UDListItem -Label 'Spam' -Icon (New-UDIcon -Icon bug -Size 3x) -SubTitle "Stuff I didn't want" -OnClick {
        Show-UDToast -Message 'Clicked'
    }
}
```

## API

**New-UDList**

| Name      | Type        | Description                                            | Required |
| --------- | ----------- | ------------------------------------------------------ | -------- |
| Id        | String      | The ID of the component. It defaults to a random GUID. | false    |
| Children  | ScriptBlock | The items in the list.                                 | false    |
| SubHeader | String      | Text to show within the sub header.                    | false    |

**New-UDListItem**

| Name            | Type        | Description                                              | Required |
| --------------- | ----------- | -------------------------------------------------------- | -------- |
| Id              | String      | The ID of the component. It defaults to a random GUID.   | false    |
| AvatarType      | String      | The type of avatar to show within the list item.         | false    |
| OnClick         | Endpoint    | A script block to execute when the list item is clicked. | false    |
| Label           | String      | The label to show within the list item.                  | false    |
| Children        | ScriptBlock | Nested list items to show underneath this list item.     | false    |
| SubTitle        | String      | The subtitle to show within the list item.               | false    |
| Icon            | Object      | The icon to show within the list item.                   | false    |
| Source          | String      | Parameter description                                    | false    |
| SecondaryAction | ScriptBlock | The secondary action to issue with this list item.       | false    |


---

# 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/v1/dashboard/components/data-display/list.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.
