Table of Contents

Class TwMenuItem

Namespace
TwBlazor.Components
Assembly
TwBlazor.dll

An action in a TwMenu, TwContextMenu or TwSubmenu. Choosing it runs OnClick and closes the menu.

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

Constructors

TwMenuItem()

public TwMenuItem()

Properties

ChildContent

Gets or sets the item's content, in place of Label. Keep it to text: an item is a single control, so it cannot hold links or buttons of its own.

[Parameter]
public RenderFragment? ChildContent { get; set; }

Property Value

RenderFragment

CloseOnClick

Whether choosing the item closes the menu and returns focus to its button. Defaults to true.

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

Property Value

bool

Destructive

Whether the item does something destructive or hard to undo, such as Delete. It is shown in a warning colour, so give it a label that says what it does too.

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

Property Value

bool

Disabled

Whether the item is disabled. It is skipped by the arrow keys and cannot be chosen.

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

Property Value

bool

Inset

Whether the item's text is indented to line up with items that have a StartIcon or a tick.

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

Property Value

bool

Label

Gets or sets the item's text. Use ChildContent instead for richer content.

[Parameter]
public string? Label { get; set; }

Property Value

string

OnClick

Raised when a person chooses the item, by clicking it or pressing Enter or Space on it.

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

Property Value

EventCallback

Shortcut

Gets or sets a keyboard shortcut shown at the end of the item as a hint, such as Ctrl+C. It is only a hint: the app handles the shortcut itself.

[Parameter]
public string? Shortcut { get; set; }

Property Value

string

StartIcon

Gets or sets an icon shown before the item's text.

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

Property Value

Icon?

Methods

BuildRenderTree(RenderTreeBuilder)

Renders the component to the supplied RenderTreeBuilder.

protected override void BuildRenderTree(RenderTreeBuilder __builder)

Parameters

__builder RenderTreeBuilder