Skip to content

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

License

Notifications You must be signed in to change notification settings

soenneker/soenneker.blazor.masonry

Repository files navigation

Soenneker.Blazor.Masonry

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

Installation

dotnet add 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/masonry-layout@4.2.2/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 Blazor interop library that integrates Masonry, the cascading grid layout library

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •