Skip to content
UTILITIES · FREE

BreakpointObserver

Build layouts that react to the screen size with a single, simple signal.

Know which screen size your user has, and let your code react when it changes.

Why it helps

  • Named breakpoints
  • Updates on resize
  • Simple

Where it fits

  • Responsive logic
  • Layout changes
  • Menus

Example

<BreakpointObserver>
    <p>Current breakpoint: <strong>@context</strong> (resize the window to see it change).</p>
    @if (context >= Breakpoint.Lg)
    {
        <Alert Severity="Severity.Info">Wide layout: the sidebar is shown.</Alert>
    }
    else
    {
        <Alert Severity="Severity.Warning">Narrow layout: the sidebar is hidden.</Alert>
    }
</BreakpointObserver>

A short fragment. Add @using RayCraft.Blazor.Components to your page and use an interactive render mode.

Included in RayCraft Free. Working examples are in the GitHub repository (MIT); it holds example and demo code, not the library code.

All controls ยท Documentation