Table of Contents

Class TwIcon

Namespace
TwBlazor.Components
Assembly
TwBlazor.dll

Represents an icon component that displays Bootstrap icons.

public class TwIcon : TwBlazorComponentBase, IComponent, IHandleEvent, IHandleAfterRender, ITwComponent
Inheritance
TwIcon
Implements
Inherited Members

Remarks

The TwIcon component renders a Bootstrap icon with optional click and mouse over interactions. When an OnClick callback is provided, the icon is wrapped in a button for accessibility.

Constructors

TwIcon()

public TwIcon()

Properties

ButtonVariant

Gets or sets the button variant to display.

[Parameter]
public ButtonVariant ButtonVariant { get; set; }

Property Value

ButtonVariant

Remarks

This is only applied if you are using an icon button by passing in an OnClick ref.

Color

Gets or sets the color of the icon.

[Parameter]
public Color? Color { get; set; }

Property Value

Color?

Remarks

When specified, applies a text color class to the icon. If null, no color class is applied.

Disabled

Gets or sets whether the button state for the icon button is disabled if an onclick parameter is passed.

[Parameter]
public bool Disabled { get; set; }

Property Value

bool

Remarks

This will only work if a callback has a delegate assigned, the icon will be rendered as a clickable button with a pointer cursor and proper accessibility attributes.

Icon

Gets or sets the icon to display.

[Parameter]
public Icon Icon { get; set; }

Property Value

Icon

Remarks

The icon enum value is converted to its corresponding Bootstrap icon name.

OnClick

Gets or sets the callback that is invoked when the icon is clicked.

[Parameter]
public EventCallback OnClick { get; set; }

Property Value

EventCallback

Remarks

When this callback has a delegate assigned, the icon will be rendered as a clickable button with a pointer cursor and proper accessibility attributes.

OnMouseOver

Gets or sets the callback that is invoked when the mouse hovers over the icon.

[Parameter]
public EventCallback OnMouseOver { get; set; }

Property Value

EventCallback

Plain

Gets or sets whether the wrapped icon button skips its default button chrome (sizing, variant/color classes, focus ring, shadow), leaving only Class applied.

[Parameter]
public bool Plain { get; set; }

Property Value

bool

Remarks

This is only applied if you are using an icon button by passing in an OnClick ref. Useful when embedding the icon inside an already-styled control, such as a chip's close button.

RootClass

Gets or sets the CSS class name applied to the root element of the component.

[Parameter]
public string RootClass { get; set; }

Property Value

string

Remarks

Use this property to customize the appearance of the component by specifying one or more CSS class names. Ensure that the provided class names are valid to achieve the desired styling.

Methods

BuildRenderTree(RenderTreeBuilder)

Renders the component to the supplied RenderTreeBuilder.

protected override void BuildRenderTree(RenderTreeBuilder __builder)

Parameters

__builder RenderTreeBuilder