blazor-components
Blazor component model including render modes, lifecycle, parameters, event handling, and component communication
What this skill does
# Blazor Component Model
## Render Modes (.NET 10 Blazor Web App)
The unified Blazor Web App model supports four render modes:
### Static Server-Side Rendering (SSR)
- Default mode, no `@rendermode` directive
- HTML rendered on server, sent as static HTML
- No interactivity (no event handlers)
- Best for: content pages, SEO-critical pages, fast initial load
```razor
@page "/about"
@attribute [StreamRendering] @* Enable streaming for async data *@
<h1>About Us</h1>
<p>@_content</p>
@code {
private string? _content;
protected override async Task OnInitializedAsync()
{
_content = await ContentService.GetAboutAsync();
}
}
```
### Interactive Server
- `@rendermode InteractiveServer`
- Uses SignalR WebSocket connection
- Server processes UI events, sends diffs to client
- Best for: admin dashboards, real-time data, forms with server validation
### Interactive WebAssembly
- `@rendermode InteractiveWebAssembly`
- .NET runtime runs in browser via WebAssembly
- No server connection needed after initial download
- Best for: offline-capable apps, client-heavy processing
### Interactive Auto
- `@rendermode InteractiveAuto`
- First render uses Server mode (fast start)
- Switches to WebAssembly once runtime is downloaded
- Best for: public apps needing both fast start and offline capability
## Component Lifecycle
```
Constructor → SetParametersAsync → OnInitialized[Async] → OnParametersSet[Async]
→ BuildRenderTree → OnAfterRender[Async](firstRender: true)
Parameter change → SetParametersAsync → OnParametersSet[Async]
→ BuildRenderTree → OnAfterRender[Async](firstRender: false)
Disposal → Dispose/DisposeAsync
```
### Key Rules
- `OnInitializedAsync` runs once - use for initial data loading
- `OnParametersSetAsync` runs on every parameter change - use for dependent data
- `OnAfterRenderAsync` runs after DOM update - use for JS interop
- Always check `firstRender` in `OnAfterRenderAsync` to avoid duplicate JS calls
## Component Communication
### Parent to Child (Parameters)
```razor
@* Parent *@
<ChildComponent Title="Hello" Items="@_items" OnDelete="HandleDelete" />
@* Child *@
@code {
[Parameter] public string Title { get; set; } = "";
[Parameter] public List<Item> Items { get; set; } = [];
[Parameter] public EventCallback<int> OnDelete { get; set; }
}
```
### Child to Parent (EventCallback)
```razor
@* Child *@
<button @onclick="() => OnDelete.InvokeAsync(item.Id)">Delete</button>
```
### Cascading Values (ancestor to all descendants)
```razor
@* Layout or parent *@
<CascadingValue Value="@_theme" Name="AppTheme">
@Body
</CascadingValue>
@* Any descendant *@
@code {
[CascadingParameter(Name = "AppTheme")] public Theme? Theme { get; set; }
}
```
### State Container (cross-component via DI)
```csharp
public sealed class AppState
{
public event Action? OnChange;
private int _count;
public int Count => _count;
public void Increment()
{
_count++;
OnChange?.Invoke();
}
}
// Register as Scoped (Server) or Singleton (WASM)
```
## Forms and Validation
```razor
<EditForm Model="@_model" OnValidSubmit="HandleSubmit" FormName="my-form">
<DataAnnotationsValidator />
<InputText @bind-Value="_model.Name" />
<ValidationMessage For="@(() => _model.Name)" />
<InputNumber @bind-Value="_model.Quantity" />
<InputDate @bind-Value="_model.DueDate" />
<InputSelect @bind-Value="_model.Category">
@foreach (var cat in _categories)
{
<option value="@cat">@cat</option>
}
</InputSelect>
<button type="submit">Save</button>
</EditForm>
```
## Razor Directive Ordering Convention (from official docs)
```razor
@page "/doctor-who-episodes/{season:int}"
@rendermode InteractiveWebAssembly
@using System.Globalization
@using BlazorSample.Components.Layout
@attribute [Authorize]
@implements IAsyncDisposable
@inject IJSRuntime JS
@inject ILogger<DoctorWhoEpisodes> Logger
<PageTitle>Doctor Who Episode List</PageTitle>
```
## Prerendering Control (from official docs)
```razor
@* Disable prerender for specific component *@
@rendermode @(new InteractiveServerRenderMode(prerender: false))
@* Disable for entire app in App.razor *@
<Routes @rendermode="new InteractiveServerRenderMode(prerender: false)" />
@* Handle client-only services during prerender *@
@code {
protected override void OnInitialized()
{
// Check if service exists (null during server prerender)
if (Services.GetService<IWebAssemblyHostEnvironment>() is { } env)
environmentName = env.Environment;
}
}
```
## State Management (from official docs)
```csharp
// State container service
public class StateContainer
{
private string? savedString;
public string Property
{
get => savedString ?? string.Empty;
set { savedString = value; NotifyStateChanged(); }
}
public event Action? OnChange;
private void NotifyStateChanged() => OnChange?.Invoke();
}
// Register: AddScoped (Server), AddSingleton (WASM)
```
```razor
@implements IDisposable
@inject StateContainer StateContainer
<p>@StateContainer.Property</p>
@code {
protected override void OnInitialized() =>
StateContainer.OnChange += StateHasChanged;
public void Dispose() =>
StateContainer.OnChange -= StateHasChanged;
}
```
## Component Naming Conventions (from official docs)
- Component names **must start with uppercase**: `ProductDetail.razor` (not `productDetail.razor`)
- File paths use PascalCase: `Components/Pages/ProductDetail.razor`
- Routable URLs use kebab-case: `@page "/product-detail"`
- Namespace resolution: `@namespace` directive > `RootNamespace` in csproj > project namespace + folder path
## Partial Class Pattern (from official docs)
```razor
@* CounterPartialClass.razor *@
@page "/counter-partial-class"
<button @onclick="IncrementCount">Click me</button>
<p>Count: @currentCount</p>
```
```csharp
// CounterPartialClass.razor.cs
namespace BlazorSample.Components.Pages;
public partial class CounterPartialClass
{
private int currentCount = 0;
private void IncrementCount() => currentCount++;
}
```
## Key Patterns
- Use `@key` on repeated elements for efficient diffing
- Use `<Virtualize>` for large lists (renders only visible items)
- Use `[SupplyParameterFromQuery]` for query string binding
- Use `[SupplyParameterFromForm]` for form model binding in SSR
- Use `NavigationManager.NavigateTo()` for programmatic navigation
- Use `IDisposable` to unsubscribe from events
- Use `ErrorBoundary` to catch component-level errors gracefully
- Component names must start uppercase (enforced by compiler)
- Use partial classes to separate markup from logic
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.