PSC.Blazor.Components.Modals 6.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package PSC.Blazor.Components.Modals --version 6.0.5
NuGet\Install-Package PSC.Blazor.Components.Modals -Version 6.0.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PSC.Blazor.Components.Modals" Version="6.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PSC.Blazor.Components.Modals --version 6.0.5
#r "nuget: PSC.Blazor.Components.Modals, 6.0.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PSC.Blazor.Components.Modals as a Cake Addin
#addin nuget:?package=PSC.Blazor.Components.Modals&version=6.0.5

// Install PSC.Blazor.Components.Modals as a Cake Tool
#tool nuget:?package=PSC.Blazor.Components.Modals&version=6.0.5

Modals for Blazor

This component helps you to create modal windows and modal popup in your Blazor application.

Install

In your index.html you have to add the style in the head of the page and the script at the bottom like

<link href="_content/PSC.Blazor.Components.Modals/themes/default.css" rel="stylesheet" />
<script src="_content/PSC.Blazor.Components.Modals/js/pscmodals.js"></script>

In .NET6 in the Program.cs you have to add those lines

builder.Services.AddSingleton<ModalsService>();
builder.Services.AddScoped<IModalService, ModalService>();

The ModalsService manages the list of windows across the application and ModalService is the component for a single window to inject in your page.

Then, in your MainLayout.razor you have to place the container for the modals adding

<ModalContainer />

So, the component it is ready to use. In the Razor page when you want to use this controller, you have to inject the IModalService adding

@inject IModalService ModalService

In your _Imports.razor it could be required to add the following lines:

@using PSC.Blazor.Components.Modals
@using PSC.Blazor.Components.Modals.Enums
@using PSC.Blazor.Components.Modals.Interfaces
@using PSC.Blazor.Components.Modals.Models

Use embedded modal

In the component the embedded modal allow you to show a message and wait for the interaction from the user. You can create a simple box with a message and an Ok button with the following code:

await ModalService.ShowDialogAsync(new DialogOptions
    {
        MainText = "You have a new message",
        SubText = "Check your inbox for more information",
        CancelText = "",
        IconElements = SVGIcons.Message,
        StatusColor = "#1e293b"
    });

IconElement is a SVG image and for that you can use my other component PSC.Blazor.Components.Icons.

If you want to display a message box with 2 buttons (for example Ok and Cancel), the code is the following

var result = await ModalService.ShowDialogAsync(new DialogOptions
    {
        MainText = "Are you sure?",
        SubText = "Please note this can not be undone",
        IconElements = SVGIcons.Question_mark,
        StatusColor = "#ff0000"
    });

If you want to display your own Razor component in the modal, you can use the following code:

private ModalOptions modalOptions = new ModalOptions { Size = ModalSize.Large, Draggable = true };

var component = new RenderComponent<YourRazorComponent>();
var result = await ModalService.ShowAsync("This is a Title", component, modalOptions);

Options

Name Description Default
ShowHeader Display the header of the modal window True
Scrollable If necessary, display the scrollbars True
CloseOnClickOutside If the user clicks outside the modal window, the modal will close False
BlurBackground When the modal is displayed, the background is blur True
Backdrop True
CloseOnEc
Draggable The modal is draggable False
VerticalPosition Define the vertical position of the window
Size
Fullscreen Never
StatusColor The color of the status of the window #ffffff
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.2 70 4/18/2024
8.0.1 62 4/18/2024
8.0.0 65 4/18/2024
6.0.5 606 4/13/2022
6.0.4 289 12/3/2021
6.0.3 806 12/3/2021
6.0.2 730 12/3/2021
6.0.1 851 12/1/2021