HtmlRole Attribute

Only apply for component class

Anchor.razor
@inherits BlazorComponentBase
@attribute [HtmlRole("button")]

<a @attribute="@AdditionalAttributes">@ChildContent</a>

@code{    
    [Parameter]public RenderFragment? ChildContent { get; set; }
}
Anchor.cs
public class Anchor : BlazorComponentBase, IHasChildContent
{
    [HtmlRole("button")]
    public Anchor()
    {
    }
    
    [Parameter]public RenderFragment? ChildContent { get; set; }
}
Index.razor
<Anchor></Anchor>

<a role="button"></a>

Last updated