HtmlTagAttribute

Use HtmlTagAttribute to define html tag name for component

NOTE: This is ONLY for component class

[HtmlTag("a")]
public class Anchor : BlazorComponentClass { }

Override GetTagName() method to output HTML tag name with customization code

public class AnchorButton : BlazorComponentBase
{
    protected override void GetTagName()
    {
        if(Condition)
        {
            return "button";
        }
        return "a";
    }
}
<Component Condition/>
<button>...</button>

<Component/>
<a>....</a>

Last updated