dotnet / dotnet/aspnetcore

Blazor RenderFragment attributes

Open
#26,748 4 comments 4 reactions 0 assignees View on GitHub
affected-few area-blazor enhancement feature-blazor-component-model feature-razor.language severity-minor
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is your feature request related to a problem? Please describe.
It would be useful to add attributes to a RenderFragment. Similarly to how you can match any attributes with a catch-all dictionary.

### Describe the solution you'd like
In some of our code where we are porting over from a legacy webforms application, it would be nice to be able to define additional attributes that can be captured from a RenderFragment tag definition. This would be more specific than the top-level capture of additional attributes on the main control tag.

For example, imagine a definition like the following:

```


My Header content


My Footer Content

```

The solution might be an addition to the Parameter attribute, for example:

```
[Parameter(CaptureUnmatchedValues = true)]
public Dictionary ControlAttributes { get; set; }

[Parameter(CaptureUnmatchedValues = true, Name="Header")]
public Dictionary HeaderAttributes { get; set; }

[Parameter(CaptureUnmatchedValues = true, Name="Footer")]
public Dictionary FooterAttributes { get; set; }
```

### Additional context
Think of something like a dialog window where you might define a header, a footer, and then anything else could go into the content.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.