Repository navigation
[Grid] Add a breakpoint cascading value - #5579
Merged
Denis Voituron (dvoituron) merged 8 commits intoNov 3, 2026
Merged
Conversation
Denis Voituron (dvoituron)
requested a review
from Vincent Baaij (vnbaaij)
as a code owner
November 2, 2026 19:09
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The breakpoint source can leak viewport state across server circuits under singleton configuration, while the standalone client demo lacks required setup and the provider introduces unintended layout spacing.
3 open issues
What changed in this PR
Adds opt-in viewport breakpoint cascading values so Blazor components can respond to responsive layout changes without managing event subscriptions.
Changes:
- Adds configuration, service registration, and a breakpoint provider integrated into
FluentProviders. - Adds a browser listener and cascading source to publish breakpoint transitions.
- Documents the feature and enables it in the server demo with a new example.
| File | Description |
|---|---|
tests/Core/Components/Base/ComponentBaseTests.cs |
Excludes the breakpoint provider from shared attribute tests. |
src/Core/Infrastructure/LibraryConfiguration.cs |
Adds the opt-in breakpoint setting. |
src/Core/Infrastructure/FluentProviders.razor |
Conditionally includes the breakpoint provider. |
src/Core/Extensions/ServiceCollectionExtensions.cs |
Registers the breakpoint source and named cascade. |
src/Core/Components/Grid/Services/ViewportBreakpointSource.cs |
Publishes breakpoint updates and suppresses repeated values. |
src/Core/Components/Grid/FluentBreakpointProvider.razor.cs |
Manages browser subscriptions and forwards breakpoint updates. |
src/Core/Components/Grid/FluentBreakpointProvider.razor |
Defines the provider’s rendered markup. |
src/Core.Scripts/src/Utilities/BreakpointListener.ts |
Subscribes to browser breakpoint events and handles cleanup. |
src/Core.Scripts/src/ExportedMethods.ts |
Exposes the listener for .NET interop. |
examples/Demo/FluentUI.Demo/Program.cs |
Enables breakpoint cascading in the server demo. |
examples/Demo/FluentUI.Demo.Client/Documentation/Components/Grid/FluentGrid.md |
Documents setup, consumption, and lifecycle behavior. |
examples/Demo/FluentUI.Demo.Client/Documentation/Components/Grid/Examples/CascadingBreakpoint.razor |
Demonstrates displaying and logging the current breakpoint. |
Review effort: Balanced
…lization behavior
|
✅ All tests passed successfully Details on your Workflow / Core Tests page. |
Summary - Unit Tests Code CoverageSummary
CoverageMicrosoft.FluentUI.AspNetCore.Components - 98.9%
Microsoft.FluentUI.AspNetCore.Components.Charts - 100%
|
Vincent Baaij (vnbaaij)
approved these changes
Nov 3, 2026
Denis Voituron (dvoituron)
deleted the
users/dvoituron/breakpoint-service
branch
November 3, 2026 06:11
This was referenced Nov 16, 2026
Merged
Closed
This was referenced Nov 23, 2026
Closed
This was referenced Nov 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


[Grid] Add a breakpoint cascading value
If you need to access or respond to the current viewport breakpoint in your C# code, the simplest approach
is to enable
UseCascadingViewportBreakpointand declare a property with[CascadingParameter(Name = FluentBreakpointProvider.CascadingParameterName)].Blazor automatically updates this parameter when resizing the browser changes the active breakpoint.
This simplifies conditional rendering of Blazor pages and components for mobile (
XS,S), tablet (M), and desktop (L,XL,XXL) layouts.First, enable the global viewport breakpoint during service registration:
Keep
<FluentProviders />in an interactive layout. It automatically includes the breakpoint providerwhen this option is enabled. No additional service registration is required.
Any interactive component can then receive the current breakpoint:
The value is
nulluntil the first browser measurement, including during prerendering.It subsequently contains a single value:
Xs,Sm,Md,Lg,Xl, orXxl.This is the viewport breakpoint, not the width of an individual grid or container.
Components created after initialization receive the latest value immediately.
The option is
falseby default. When disabled, the library does not register the breakpoint cascadeor add a breakpoint provider, and a standalone breakpoint provider does not subscribe to browser notifications.
Notifications require an interactive render mode;
static server-rendered components cannot react to browser changes.
Why a cascading value instead of an injected service?
A reactive cascading value is a better fit for UI components consuming viewport state.
Injecting a service only gives a component access to an object: it does not automatically rerender
that component when a property on the service changes. A reactive injected service normally requires
each consumer to subscribe to a change event, use
InvokeAsync(StateHasChanged)to request a renderon the component's dispatcher, and unsubscribe when the component is disposed.
With the named cascading parameter, Blazor manages these subscriptions and their lifetime.
The internal
CascadingValueSource<GridItemSize?>publishes updates withNotifyChangedAsync,and subscribed components receive the new value and update their UI without event-handling boilerplate.
The named root-level cascade also reaches components outside the provider's descendant tree:
the provider can remain beside the page content, as
<FluentProviders />normally does.This design still uses dependency injection internally to share one scoped source of truth.
The difference is the public consumption model: components declare the state they need instead of
managing service events themselves. An injectable service remains appropriate when non-component
code needs the state or when consumers need an explicit subscription API.
Cascading values are not inherently faster than services. Mutable cascades have subscription and
rendering costs too. This feature publishes only breakpoint transitions, not every pixel of a resize,
and suppresses repeated values. For purely visual layout changes, prefer CSS media queries or
the grid's responsive attributes, which do not require a .NET notification.
Unit Tests
Added