Start Debugging

Daily notes on .NET, C#, EF Core, MAUI, Blazor, and Flutter - for developers who ship.

How to render a heading whose level (h1-h6) is chosen at runtime in a Blazor component
Blazor has no syntax for a variable tag name, and DynamicComponent only renders component types. Override BuildRenderTree and call builder.OpenElement(0, $"h{level}"). Covers attribute splatting, why the tag name must be clamped before it reaches the DOM, why changing the level rips the element out of the DOM even with @key, and an auto-levelling variant built on a cascading value.
Page 1 of 78 Next ›