-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: View Component Slots #37434
Comments
+1. I miss this feature A LOT in Razor. It helps identify and extract repetitive html or patterns that we see in the UI. Laravel's View Engine, Blade, has components as well: https://laravel.com/docs/8.x/blade#components |
+1. I had used this feature in VueJs and miss it in Razor. It will be really helpful. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Really sad seeing this issue been removed from .NET 7 planning. This is very "basic" feature when working with components. |
The MVC part of ASP.NET really needs some love and this seems like a good proposal which moves the framework in the proper direction (components over views/actions) |
Thanks for contacting us. We're moving this issue to the |
The // index.cshtml
@await Component.InvokeAsync(typeof(AccordionViewComponent), new AccordionModel("Accordion Title", @<div>Content</div>)) public class AccordionViewComponent : ViewComponent
{
public IViewComponentResult Invoke(AccordionModel model)
{
return View(model);
}
}
public record AccordionModel(string Title, Func<object?, HelperResult> Body); // Default.cshtml (Accordion)
@model AccordionModel
<details>
<summary>@Model.Title</summary>
@Model.Body.Invoke(null)
</details> |
Templated Razor delegates is such a nice feature. If only they got some love.... |
Voting up, there are still many active projects that cant support blazor yet. |
+1 |
I have found this library the other day and so far so good: https://razor-components.techgems.net/docs/basic-usage/ I highly recommend checking it out to design Razor cshtml Components with ChildContent and Slots. Great job @techgems! |
Is your feature request related to a problem? Please describe.
ASP.NET Mvc has never had a robust component model, the way Web Forms did. ASP.NET Core Tag Helpers and View Components have helped improve this story, but they still lack some composition patterns.
Creating container/wrapping markup is possible with Tag Helpers, but Tag Helpers are a C#-first approach to markup and container/wrapping markup is almost always related to visuals along with functionality. HTML is far easier to maintain in Razor vs C# strings.
It would be helpful to be able to use View Components instead of Tag Helpers for container/wrapping markup when rendering common HTML that contain different children (as defined by the Razor calling the View Components).
I'm specifically requesting this for non-Blazor ASP.NET Core Razor HTML rendering and as a request for ASP.NET Core 7.
Describe the solution you'd like
There is an existing proposal (and sample/demo repository) for this feature, but the original feature request is a locked issue:
#4901
Examples can be seen in the original issue, but here is a short one:
Additional context
This is how other frameworks do slots:
Notes
If you are interested in this feature being explored for future versions of ASP.NET Core, add a thumbs up/reaction to this issue as that is how the ASP.NET Core team determines interest
The text was updated successfully, but these errors were encountered: