syncfusion/blazor-ui-components-skills / skills/syncfusion-blazor-media-query
syncfusion-blazor-media-query
VerifiedCreate responsive Blazor applications using Media Query component. Trigger when user needs responsive layouts, breakpoint-based rendering, screen size adaptation, multi-device support, or needs to conditionally render components based on device type. Essential for building adaptive UIs that work across mobile, tablet, and desktop devices.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 4.7 KB |
| references/breakpoints-and-media-queries.md | markdown | 5.7 KB |
| references/component-integration.md | markdown | 10.5 KB |
| references/getting-started.md | markdown | 2.8 KB |
| references/responsive-layout-patterns.md | markdown | 9.1 KB |
references/getting-started.md
View on GitHub# Getting Started with Blazor Media Query
## Table of Contents
- [NuGet Installation](#nuget-installation)
- [Namespace Imports](#namespace-imports)
- [Service Registration](#service-registration)
- [Theme Stylesheet](#theme-stylesheet)
- [Basic Component Usage](#basic-component-usage)
## NuGet Installation
Install the Syncfusion.Blazor.Core and Syncfusion.Blazor.Themes packages using your preferred method.
### Visual Studio Package Manager
```
Install-Package Syncfusion.Blazor.Core
Install-Package Syncfusion.Blazor.Themes
```
### .NET CLI
```
dotnet add package Syncfusion.Blazor.Core
dotnet add package Syncfusion.Blazor.Themes
dotnet restore
```
### Visual Studio Code Terminal
```
dotnet add package Syncfusion.Blazor.Core
dotnet add package Syncfusion.Blazor.Themes
dotnet restore
```
## Namespace Imports
Open the `~/_Imports.razor` file and add the Syncfusion.Blazor namespace:
```razor
@using Syncfusion.Blazor
```
This imports all Syncfusion Blazor components including SfMediaQuery.
## Service Registration
Register the Syncfusion Blazor Service in the `~/Program.cs` file:
```csharp
using Syncfusion.Blazor;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddScoped(sp => new HttpClient
{
BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)
});
// Register Syncfusion Blazor Service
builder.Services.AddSyncfusionBlazor();
await builder.Build().RunAsync();
```
## Theme Stylesheet
Include the Syncfusion theme stylesheet in the `<head>` section of `~/index.html`:
```html
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Blazor App</title>
<base href="/" />
<!-- Syncfusion Theme -->
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />
</head>
```
Available themes: `bootstrap5.css`, `material3.css`, `tailwind.css`, `fluent2.css`, `highcontrast.css`
## Basic Component Usage
Add the Media Query component to a Razor page to detect and respond to screen size changes:
```razor
@using Syncfusion.Blazor
<SfMediaQuery @bind-ActiveBreakPoint="activeBreakpoint"></SfMediaQuery>
<h3>Current Breakpoint: @activeBreakpoint</h3>
@if (activeBreakpoint == "Small")
{
<p>Mobile Device (≤768px)</p>
}
else if (activeBreakpoint == "Medium")
{
<p>Tablet (768px - 1024px)</p>
}
else
{
<p>Desktop (>1024px)</p>
}
@code {
private string activeBreakpoint { get; set; }
}
```
The `@bind-ActiveBreakPoint` directive binds the current breakpoint to the `activeBreakpoint` variable. This variable updates automatically whenever the window resizes and crosses a breakpoint threshold.
**Test It:** Resize your browser window and watch the displayed message change as you cross breakpoint boundaries.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |