# Modal

Modals inform users about a task and can contain critical information, require decisions, or involve multiple tasks.

## Basic

![](/files/etlnSOOcrFc1krjyCxtO)

```powershell
New-UDButton -Text 'Basic' -OnClick {
    Show-UDModal -Content {
        New-UDTypography -Text "Hello"
    }
}
```

## Full Screen

![](/files/vvaXf5Y8WrpFopCd0G8z)

```powershell
New-UDButton -Text 'Full Screen' -OnClick {
    Show-UDModal -Content {
        New-UDTypography -Text "Hello"
    } -Footer {
        New-UDButton -Text "Close" -OnClick { Hide-UDModal }
    }  -FullScreen
}
```

## Full Width

Full width modals take up the full width as defined by the `-MaxWidth` parameter.

![](/files/8KfwFSGf065oUQmUW39J)

```powershell
New-UDButton -Text 'Full Width' -OnClick {
    Show-UDModal -Content {
        New-UDTypography -Text "Hello"
    } -FullWidth -MaxWidth 'md'
}
```

## Persistent

Persistent modals do not close when you click off of them. You will have to close it with `Hide-UDModal`.

![](/files/Lz57xGIuaWK3zx4oSb0s)

```powershell
New-UDButton -Text 'Persistent' -OnClick {
    Show-UDModal -Content {
        New-UDTypography -Text "Hello"
    } -Footer {
        New-UDButton -Text "Close" -OnClick { Hide-UDModal }
    } -Persistent
}
```

## Hide a Modal

You can use the `Hide-UDModal` button to hide a modal that is currently show.

```powershell
New-UDButton -Text 'Basic' -OnClick {
    Show-UDModal -Content {
        New-UDTypography -Text "Hello"
    }
    Start-Sleep 5
    Hide-UDModal
}
```

When opening multiple modals, you can also use the `-All` parameter of `Hide-UDModal` to hide all of them instead of one at a time.

```powershell
New-UDButton -Text 'Parent' -OnClick {
    Show-UDModal -Content {
       New-UDButton -Text 'Child' -OnClick {
          Show-UDModal -Content {
              New-UDButton -Text 'hide current' -OnClick {
                  Hide-UDModal
              }
              New-UDButton -Text 'hide all' -OnClick {
                  Hide-UDModal -All
              }
          } 
       }
    }
}
```

## Styling

You can style modules using the `-Style`, `-HeaderStyle`, `-ContentStyle` and `-FooterStyle` parameters. Style is applied to the entire modal itself and the individual section styles are only applied to those sections. The value for these parameters are hashtables of CSS values.

```powershell
New-UDButton -Text 'Styling' -OnClick {
    Show-UDModal -Content {
        New-UDTypography -Text "Hello"
    } -Style @{
        backgroundColor = "red"
    }
}
```

## API

* [Show-UDModal](https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/Show-UDModal.txt)
* [Hide-UDModal](https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/Hide-UDModal.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/feedback/modal.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.
