-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
Blazor developers often create hierarchical or templated components using RenderFragment<T>
, but there's no official way to define nested subcomponents (e.g. Component.InnerPart
) directly within their parent component.
This leads to:
- Fragmented code spread across multiple
.razor
or.cs
files - Lack of semantic and visual grouping in markup
- Reduced IntelliSense and discoverability for related UI parts
- Challenges in state sharing, cascading values, and styling cohesion
While RenderFragment<T>
works for templating, it doesn't support scoped, composable component hierarchies that reflect UI structure and logic as intuitively as nested tags would.
Describe the solution you'd like
Introduce support for scoped subcomponents (e.g. Component.InnerPart
) that allow developers to define and use inner classes as renderable components in Razor markup.
<FormBuilder>
<FormBuilder.InputField Label="Name" Value="@user.Name" />
<FormBuilder.SubmitButton />
</FormBuilder>
Implementation Ideas:
- Allow nested
public class
components inside parentComponentBase
to be registered as tags using a naming convention (e.g.FormBuilder.InputField
) - Optionally use
[Subcomponent]
attribute or source generator to surface nested classes as Razor components - Enable scoped IntelliSense and syntax validation in tooling
- Support inheritance of styling, cascading values, and event lifecycles from parent
This pattern would improve clarity, reduce namespace clutter, and enable more expressive component trees—especially for form builders, dashboard layouts, or design systems.
Additional context
No response