
Responsive breakpoint monitoring
Determines whether to re-render the content of a responsive layout based on parameter conditions, usually used for responsive layouts
Resize the browser window and observe the change of Breakpoint
Demo
Breakpoint
:NoneAttributes
@page "/responsives"
@inject IStringLocalizer<Responsives> Localizer
<h3>Responsive breakpoint monitoring</h3>
<h4>Determines whether to re-render the content of a responsive layout based on parameter conditions, usually used for responsive layouts</h4>
<DemoBlock Title="Basic usage" Introduction="Resize the browser window and observe the change of <code>Breakpoint</code>" Name="Normal">
<div>current <code>Breakpoint</code>:@Size</div>
</DemoBlock>
<Responsive OnBreakPointChanged="OnChanged" />
<AttributeTable Items="@GetAttributes()" />
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
namespace BootstrapBlazor.Shared.Samples;
/// <summary>
/// Responsives
/// </summary>
public partial class Responsives
{
private BreakPoint Size { get; set; }
private Task OnChanged(BreakPoint size)
{
Size = size;
StateHasChanged();
return Task.CompletedTask;
}
private static IEnumerable<AttributeItem> GetAttributes() => new AttributeItem[]
{
new AttributeItem()
{
Name = nameof(Responsive.OnBreakPointChanged),
Description = "Callback method when breakpoint threshold changes",
Type = "Func<BreakPoint, Task<bool>>",
ValueList = " — ",
DefaultValue = " — "
}
};
}