@inherits BlazorComponentBase
<a @attributes="AdditionalAttributes">@ChildContent</a>
@code{
[Parameter]public RenderFragment? ChildContent { get; set; }
[Parameter][HtmlAttribute]public string? Title { get; set; }
[Parameter][HtmlAttribute("href")]public string? Link { get; set; }
[Parameter][HtmlAttribute]public LinkTarget Target { get; set; } = LinkTarget.Blank;
public enum LinkTarget
{
[HtmlAttrbute("_blank")]Blank,
[HtmlAttrbute("_parent")]Parent,
[HtmlAttrbute("_top")]Top,
}
}
public class Anchor : BlazorComponentBase, IHasChildContent
{
[Parameter]public RenderFragment? ChildContent { get; set; }
[Parameter][HtmlAttribute]public string? Title { get; set; }
[Parameter][HtmlAttribute("href")]public string? Link { get; set; }
[Parameter][HtmlAttribute]public LinkTarget Target { get; set; } = LinkTarget.Blank;
public enum LinkTarget
{
[HtmlAttrbute("_blank")]Blank,
[HtmlAttrbute("_parent")]Parent,
[HtmlAttrbute("_top")]Top,
}
}
<Anchor Link="https://github.com" Title="github" Target="LinkTarget.Top">Go Github</Anchor>
<a href="https://github.com" title="github" target="_top">Go Github</a>
[Parameter][HtmlAttribute("collapse","toggle")]public bool Collapse { get; set; }
<Component Collapse/>
<div collapse="toggle"></div>
[Parameter][HtmlAttribute("toggle")]public bool Collapse { get; set; }
<Component Collapse/>
<div toggle="true"></div>
[Parameter][HtmlAttribute("href")]public string? Link { get; set; }
<Component Link="www.github.com"/>
<a href="www.github.com"></a>