Skip to content

Support enumarable of RenderFragment and RenderFragment<T> in components #29495

Closed
@montyclt

Description

@montyclt

Is your feature request related to a problem? Please describe.

Support enumarable of RenderFragment and RenderFragment<T> in components.

Describe the solution you'd like

List.razor:

<ul>
    @foreach (var item in Items)
    {
        <li>@item</li>
    }
</ul>

@code {
    [Parameter(Tag = "Item")]
    public IEnumerable<RenderFragment> Items { get; set; }
}

Page.razor:

<List>
    <Item>Item 1</Item>
    <Item>Item 2</Item>
    <Item>Item 3</Item>
</List>

Additional context

Enumerables members usually are written in plural form, but in the usage, the singular form is more accurate. I propose add a parameter in [Parameter] attribute to specify the tag. This proposal should be available to any parameter like this:

Person.razor

[Parameter(Tag = "Name")]
public string FullName { get; set; }

Page.razor

<Person Name="Ivan" />

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing one

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions