Table of Contents

Class NavActionAttribute

Namespace
Htmx.Components.NavBar
Assembly
Htmx.Components.dll

Marks controller action methods to include them in the application's navigation. Actions marked with this attribute will be automatically discovered and included in navigation components generated by AttributeNavProvider.

[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class NavActionAttribute : Attribute
Inheritance
NavActionAttribute
Inherited Members
Extension Methods

Examples

[NavAction(DisplayName = "Dashboard", Icon = "fas fa-dashboard", Order = 1, PushUrl = true)]
public IActionResult Index()
{
    return View();
}

Remarks

The navigation system only includes actions that the current user is authorized to access. Authorization is checked using the standard ASP.NET Core authorization system.

Properties

DisplayName

Gets or sets the display name for the action.

public string? DisplayName { get; set; }

Property Value

string

The text to display for the action, or null to use a humanized version of the action name.

HttpMethod

Gets or sets the HTTP method to use when invoking the action via HTMX.

public string? HttpMethod { get; set; }

Property Value

string

The HTTP method string (e.g., "GET", "POST"). Default is "GET".

Icon

Gets or sets the CSS icon class for the action (e.g., "fas fa-edit").

public string? Icon { get; set; }

Property Value

string

A CSS class string for the action's icon, or null if no icon should be displayed.

Order

Gets or sets the display order of the action relative to other actions.

public int Order { get; set; }

Property Value

int

An integer used for sorting. Lower values appear first. Default is 0.

PushUrl

Gets or sets whether the action should update the browser URL when invoked via HTMX.

public bool PushUrl { get; set; }

Property Value

bool

true to update the URL; false to perform the action without URL changes. Default is false.

ViewName

Gets or sets the view name to render for non-HTMX requests.

public string? ViewName { get; set; }

Property Value

string

The name of the view to render, or null to use the default view for the action.