georgeemr / BlazorBootstrap.Modal

Bootstrap modal dialog for Asp.NET Blazor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BlazorBootstrap.Modal

Bootstrap 4 modal dialog for Asp.NET Blazor

Build Status

Prerequisites

Bootstrap 4, usually included with default Blazor template.

Setup

  1. Install BlazorBootstrap.Modal from NuGet by PowerShell:
    Install-Package BlazorBootstrap.Modal
    or via dotnet CLI
    dotnet add package BlazorBootstrap.Modal
  2. Register services in Startup.cs
    services.AddBootstrapModal();
  3. Add modal to layout MainLayout.razor file
    <BootstrapModal />

Usage

  1. Create modal dialog, for example SimpleModal.razor:

    <p>Simple bootstrap 4 modal.</p>
    <span>Parameter: @SampleParameter</span>
    
    @code{
        [Parameter] string SampleParameter { get; set; }
    }
  2. Inject modal service into your class

    @inject IModal Modal
  3. Invoke modal:

        Modal.Show<SimpleModal>("Simple modal", ModalParameter.Get("SampleParameter", "This is a parameter"))

    where the first parameter is title of the modal window and second is a list of parameters to pass to the modal class.

    For more example refer to the BlazorBootstrap.Modal.Samples project.

About

Bootstrap modal dialog for Asp.NET Blazor

License:MIT License


Languages

Language:HTML 46.9%Language:C# 40.3%Language:CSS 12.7%