BlazorPro.BlazorSize
2.3.0
See the version list below for details.
dotnet add package BlazorPro.BlazorSize --version 2.3.0
NuGet\Install-Package BlazorPro.BlazorSize -Version 2.3.0
<PackageReference Include="BlazorPro.BlazorSize" Version="2.3.0" />
paket add BlazorPro.BlazorSize --version 2.3.0
#r "nuget: BlazorPro.BlazorSize, 2.3.0"
// Install BlazorPro.BlazorSize as a Cake Addin #addin nuget:?package=BlazorPro.BlazorSize&version=2.3.0 // Install BlazorPro.BlazorSize as a Cake Tool #tool nuget:?package=BlazorPro.BlazorSize&version=2.3.0
BlazorSize is a JavaScript interop library for Blazor that is used to detect the Browser's current size, change in size, and test media queries.
BlazorSize was designed to allow Razor Components to implement adaptive rendering. Handle mobile/desktop rendering changes at runtime with ease and complement your apps CSS media queries with programmatic work flows.
Add the NuGet package
Package Manager
Install-Package BlazorPro.BlazorSize
CLI
dotnet add package BlazorPro.BlazorSize
.csproj
<PackageReference Include="BlazorPro.BlazorSize" Version="2.*" />
Reference the JavaScript interop
Add the JavaScript interop to your application's index.html or _hosts.cshtml
<script src="_content/BlazorPro.BlazorSize/blazorSize.min.js"></script>
Import the namespace
Add a reference to the namespace in your _Imports.razor or at the top of a page.
@using BlazorPro.BlazorSize
Add the MediaQueryList
Add a MediaQueryList to your application's main layout or root. The MediaQueryList is responsponsible for communicating with all MediaQuery components in your app. The MediaQueryList component will consolidate redundant media queries and manage resources so that unused event listeners are disposed of properly.
<MediaQueryList>
<div class="sidebar">
<NavMenu />
</div>
<div class="main">
<div class="top-row px-4">
<a href="http://blazor.net" target="_blank" class="ml-md-auto">About</a>
</div>
<div class="content px-4">
@Body
</div>
</div>
</MediaQueryList>
Add a MediaQuery and bind
Using the @bind-Matches directive we can easily bind to a browser's media query and respond to it.
@if (IsSmall)
{
<WeatherCards Data="forecasts"></WeatherCards>
}
else
{
<WeatherGrid Data="forecasts"></WeatherGrid>
}
@if (IsMedium)
{
<span>Medium</span>
}
<MediaQuery Media="@Breakpoints.OnlyMedium" @bind-Matches="IsMedium" />
<MediaQuery Media="@Breakpoints.SmallDown" @bind-Matches="IsSmall" />
@code {
WeatherForecast[] forecasts;
bool IsMedium = false;
bool IsSmall = false;
protected override async Task OnInitializedAsync()
{
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
}
}
No-Code Templates
The MediaQuery component can also use templates instead of the @bind directive. Templates are useful for swapping out UI bits when the screen size changes.
<MediaQuery Media="@Breakpoints.SmallDown">
<Matched>
<WeatherCards Data="forecasts"></WeatherCards>
</Matched>
<Unmatched>
<WeatherGrid Data="forecasts"></WeatherGrid>
</Unmatched>
</MediaQuery>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.AspNetCore.Components.Web (>= 3.1.6)
- Microsoft.Extensions.DependencyInjection (>= 3.1.6)
NuGet packages (10)
Showing the top 5 NuGet packages that depend on BlazorPro.BlazorSize:
Package | Downloads |
---|---|
DataJuggler.BlazorGallery
A project template for creating a Blazor Image Gallery project that uses SQL Server for a backend. You will need SQL Server or SQL Server Express to run this project. See the Read Me for more info. Watch this video to see a demo https://youtu.be/yQz1dqYiy2g. |
|
Egea.Extensions.Razor
Package Description |
|
Blazm.Components
A collection of Blazor components |
|
BlazorPro.BlazorSize.UnitTesting
A testing library to provide helper extensions for BlazorSize. |
|
Jakar.Extensions.Blazor
Extensions to aid in development. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on BlazorPro.BlazorSize:
Repository | Stars |
---|---|
telerik/blazor-ui
A collection of examples related to Telerik UI for Blazor Components: https://www.telerik.com/blazor-ui
|
Version | Downloads | Last updated |
---|---|---|
9.0.0 | 3,206 | 11/15/2024 |
8.0.0 | 96,519 | 4/22/2024 |
8.0.0-preview | 135 | 4/15/2024 |
6.2.2 | 134,074 | 8/30/2023 |
6.2.1 | 96,164 | 4/25/2023 |
6.2.0 | 46,632 | 1/6/2023 |
6.1.2 | 148,968 | 2/12/2022 |
6.1.1 | 8,263 | 1/28/2022 |
6.1.0 | 24,029 | 12/1/2021 |
6.0.0 | 34,083 | 11/10/2021 |
6.0.0-pre2 | 2,608 | 10/5/2021 |
6.0.0-pre | 272 | 8/23/2021 |
5.0.0 | 61,975 | 5/27/2021 |
5.0.0-pre | 1,141 | 5/25/2021 |
3.2.1 | 19,734 | 3/9/2021 |
3.2.0 | 2,330 | 3/5/2021 |
3.1.0 | 62,890 | 11/30/2020 |
3.0.0 | 1,789 | 11/23/2020 |
2.3.0 | 45,365 | 8/11/2020 |
2.0.2 | 22,340 | 4/21/2020 |
1.2.2 | 10,384 | 1/26/2020 |
1.2.1 | 1,130 | 1/23/2020 |
1.2.0 | 1,296 | 1/22/2020 |
2.3.0
Fixed additional regressions from 2.2.0, update recommended.
2.2.0
Fixed possible regressions, update recommended.
Updated Blazor dependencies.
2.1.1
Fixed MSBuild including *.json files breaking NuGet pkg.
2.0.0
Added MediaQueryList & MediaQuery components.
1.2.2
Fixes initalization issues with Client-Side Blazor
1.2.0
Full-release