- Monitors viewport resize and reports breakpoint changes.
dotnet add package JxdTech.BlazorViewport
@using BlazorViewport
// Wrap Contents of App.razor with Viewport
<Viewport>
<Router AppAssembly="@typeof(App).Assembly">
...
</Router>
</Viewport>
@inherits ViewportComponentBase
- contains Viewport:IViewport
- Viewport has 2 properties
- bool IsRendered { get; }
- Changes to true After JSRuntime is available and event listeners are registered
- Breakpoint Breakpoint { get; }
- provides current breakpoint
- bool IsRendered { get; }
-
Default ViewportOptions
"ViewportOptions": { "EnableLogging": false, "NotifyOnInitialize": true, "Breakpoints" : { "5" : 1400, // Xxl "4" : 1200, // Xl "3" : 992, // Lg "2" : 768, // Md "1" : 576, // Sm "0" : 0 // Xs } }
View Demo app for simple example
- App.razor
- Uses Viewport
- Pages/Index.razor
- implements ViewportComponentBase
- appsettings.json
- configures ViewportOptions
- appsettings.Development.json
- configures Development ViewportOptions