An open API service indexing awesome lists of open source software.

https://github.com/brianlparker/blazordialogs


https://github.com/brianlparker/blazordialogs

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

          

# Blazor Dialogs

This library gives the html `` element some Blazor love.

### Add the nuget package.

### Import the library
**_Imports.razor**
```
@using BlazorDialogs
```
### Usage

```
Open Dialog

YOUR CONTENT

@code {
private Dialog dialog;

async Task ShowDialogAsync() => await dialog.ShowDialogAsync();

async Task DialogClosedAsync() { /* process content */ }
}
```

### How to open a dialog on a components initialization (pages are components).

Use your hosting components `OnAfterRenderAsync` method to show the dialog. This is required as the `@ref` is not initialized before this.
```
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if(firstRender is true)
{
await dialog.ShowDialogAsync();
StateHasChanged();
}
await base.OnAfterRenderAsync(firstRender);
}
```
The component captures attributes and applies them to the underlying `` element.
Included in the component are the following css classes.

Available options:



| class name | effect |
| -- | -- |
| bd-back-blur3 | blurs content behind the dialog by 3 pixels |
| bd-back-blur5 | blurs content behind the dialog by 5 pixels |
| bd-back-blur10 | blurs content behind the dialog by 10 pixels |
| bd-backdrop-blur3 | blurs content behind the backdrop of the dialog by 3 pixels |
| bd-backdrop-blur5 | blurs content behind the backdrop of the dialog by 5 pixels |
| bd-backdrop-blur10 | blurs content behind the backdrop of the dialog by 10 pixels |