Skip to content

A small Blazor interop library that integrates Masonry, the cascading grid layout library

License

Notifications You must be signed in to change notification settings

dstretch/soenneker.blazor.masonry

 
 

Repository files navigation

Soenneker.Blazor.Masonry

A Blazor interop library that integrates Masonry, the cascading grid layout library

Installation

Install-Package Soenneker.Blazor.Masonry

Usage

  1. Insert the interop script, and the library script in wwwroot/index.html at the bottom of your <body>
<script src="_content/Soenneker.Blazor.Masonry/masonry.js"></script>
<script async src="https://cdn.jsdelivr.net/npm/[email protected]/dist/masonry.pkgd.min.js" integrity="sha256-Nn1q/fx0H7SNLZMQ5Hw5JLaTRZp0yILA/FRexe19VdI=" crossorigin="anonymous"></script>
  1. Register the interop within DI (Program.cs)
public static async Task Main(string[] args)
{
    ...
    builder.Services.AddMasonry();
}
  1. Inject IMasonryInterop within your App.Razor file
@using Soenneker.Blazor.Masonry.Abstract
@inject IMasonryInterop MasonryInterop
  1. Use Bootstrap Rows and columns on the page (<div class='row'></div>). Other selectors can be passed into the interop, .row is default.

  2. Initialize Masonry within your Razor code in the OnAfterRenderAsync override

protected override async Task OnAfterRenderAsync(bool firstRender)
{
    await MasonryInterop.Init();
}

About

A small Blazor interop library that integrates Masonry, the cascading grid layout library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 87.6%
  • JavaScript 12.4%