HxDynamicElement #

Renders an element with the specified name, attributes, and child content.

Allows dynamic composition of more complex components. Used internally by some of the Hx-components, but also exposed for your needs.

Basic usage #

Any content
<HxDynamicElement
    ElementName="@elementName" 
    class="fs-5 my-2 py-2">
        Any content <HxIcon Icon="BootstrapIcon.Trash" />
</HxDynamicElement>

<HxSelect Data="elementNames" @bind-Value="elementName" TItem="string" TValue="string" Nullable="false" />

@code
{
    private string elementName = "b";
    private string[] elementNames = { "a", "b", "button", "div", "i", "span", "strong" };
}

API #

Parameters #

Name Type Description
AdditionalAttributes IDictionary<string, object> A collection of additional attributes that will be applied to the created element.
ChildContent RenderFragment Content of the component.
ElementName string Gets or sets the name of the element to render.
ElementRef ElementReference Element reference.
ElementRefChanged Action<ElementReference> Action (synchronous, not an EventCallback) called when the element's reference is captured.
OnClickPreventDefault bool Prevents the default action for the onclick event. Default is false.
OnClickStopPropagation bool Stops onClick event propagation. Default is false.

Event callbacks #

Name Type Description
OnClick EventCallback<MouseEventArgs> Raised after the element is clicked.
An unhandled error has occurred. Reload 🗙