Mitc.Support.Taghelpers 1.0.13

Mitc.Support.Taghelpers

A collection of utility tag helpers for ASP.NET Core Razor Pages and MVC applications.

Setup

Register the tag helpers in your _ViewImports.cshtml:

@addTagHelper *, Mitc.Support.Taghelpers

Tag Helpers

ConditionalClassTagHelper

Conditionally adds CSS classes to any element using maybe-{class} attributes bound to boolean expressions.

<div maybe-hidden="@Model.IsHidden" maybe-active="@Model.IsActive">...</div>

Renders as class="hidden active", class="active", etc. depending on which values are true. Preserves any existing class attribute.


IfAttributeTagHelper

Conditionally includes or excludes elements using include-if and exclude-if.

<div include-if="@Model.IsVisible">Only shown when visible</div>
<div exclude-if="@Model.IsAdmin">Hidden for admins</div>

When the condition suppresses the element, it is removed entirely from the rendered HTML — including its children.


ActiveLinkTagHelper

Adds an active CSS class to any element when the current route matches. Supports Razor Pages and MVC routing, with comma-separated values for matching multiple routes.

Razor Pages

<li active-page="/Products/Index">Products</li>
<li active-page="/Orders/Index, /Orders/Details">Orders</li>

MVC

{{!-- Match a specific action --}}
<li active-controller="Products" active-action="Index">Products</li>

{{!-- Match multiple actions --}}
<li active-controller="Products" active-action="Index, Details">Products</li>

{{!-- Match any action on a controller --}}
<li active-controller="Products">Products</li>

{{!-- Match an action across multiple controllers --}}
<li active-action="Dashboard" active-controller="Admin, Manager">Dashboard</li>

When both active-controller and active-action are specified, both must match. The active class is applied if the page match or the controller/action match succeeds.

Custom active class

<li active-page="/Products/Index" active-class="is-active">Products</li>

Defaults to active if active-class is not specified. Preserves any existing class attribute.


AlpineDataTagHelper

Serializes a server-side model to JSON and sets it as the Alpine.js x-data attribute.

<div x-data="@Model.ComponentData">...</div>

By default, property names are serialized in PascalCase. Use camel-case for camelCase output:

<div x-data="@Model.ComponentData" camel-case="true">...</div>

If a string is passed, it is written directly to x-data without serialization, enabling Alpine component function references:

<div x-data="myComponent()">...</div>

If the value is null, the x-data attribute is omitted entirely.


CopyToClipboardTagHelper

Renders a button that copies the specified value to the users clipboard.

<copy-button class="btn btn-secondary" copy-value="@Model.DataToBeCopied" />

Optional override values

  • label="..." = Text on the button.
  • copied-label="..." = Confirmation text to appear on the button after a successful copy.
  • id="..." = Default value copy-btn-{Guid.NewGuid():N

Target Frameworks

netcoreapp3.1, net5.0, net6.0, net7.0, net8.0, net9.0, net10.0

No packages depend on Mitc.Support.Taghelpers.

.NET Core 3.1

  • No dependencies.

.NET 5.0

  • No dependencies.

.NET 6.0

  • No dependencies.

.NET 7.0

  • No dependencies.

.NET 8.0

  • No dependencies.

.NET 9.0

  • No dependencies.

.NET 10.0

  • No dependencies.

Version Downloads Last updated
1.0.13 15 2/24/2026
1.0.12 10 2/20/2026
1.0.11 0 2/18/2026
1.0.7 17 2/18/2026
1.0.6 1 2/18/2026
1.0.5 0 2/18/2026
1.0.3 1 7/18/2025
1.0.2 61 7/18/2025
1.0.1 0 7/18/2025
1.0.0 1 7/18/2025