Skip to content

Add InactiveClass parameter to NavLink#66365

Open
KitKeen wants to merge 2 commits intodotnet:mainfrom
KitKeen:feature/navlink-inactive-class
Open

Add InactiveClass parameter to NavLink#66365
KitKeen wants to merge 2 commits intodotnet:mainfrom
KitKeen:feature/navlink-inactive-class

Conversation

@KitKeen
Copy link
Copy Markdown

@KitKeen KitKeen commented Apr 19, 2026

Add InactiveClass parameter to NavLink
Fixes #37765

Summary

Adds an optional InactiveClass parameter to <NavLink> that mirrors ActiveClass. When the link's href does not match the current URI, the supplied class is appended to any user-provided class. The default is null, so existing usage is unaffected.

Example

<NavLink class="bg-dark-gray" ActiveClass="text-white" InactiveClass="text-gray" href="/page" />
- Active: <a class="bg-dark-gray text-white">
- Inactive: <a class="bg-dark-gray text-gray">

Implementation

Refactored UpdateCssClass() to pick ActiveClass (or "active" default) when active, or InactiveClass when inactive. Same CombineWithSpace helper.

Tests

Added 5 cases to NavLinkTest.cs:
- Active state ignores InactiveClass
- Inactive state applies InactiveClass
- Inactive without InactiveClass preserves prior behavior
- Inactive combines user class with InactiveClass
- Active combines user class with ActiveClass even when InactiveClass set

Public API

PublicAPI.Unshipped.txt updated with the new property.

Note

This is a public API addition. The shape was proposed in #37765 and matches the existing ActiveClass pattern, so should be uncontroversial — but flagging in case the team wants formal API review.

Adds an optional InactiveClass parameter to <NavLink> that mirrors
ActiveClass: when the link's href does not match the current URI,
the supplied class is appended to any user-provided class. The
default is null, so existing usage is unaffected.

Fixes dotnet#37765
@KitKeen KitKeen requested a review from a team as a code owner April 19, 2026 09:04
@github-actions github-actions Bot added the area-blazor Includes: Blazor, Razor Components label Apr 19, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Apr 19, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Thanks for your PR, @KitKeen. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@KitKeen
Copy link
Copy Markdown
Author

KitKeen commented Apr 21, 2026

Friendly ping, this PR has been sitting without an assignee or reviewer. It's a small additive change (new optional InactiveClass on NavLink, mirroring ActiveClass), CI is green, PublicAPI.Unshipped.txt updated. Fixes #37765 which has the help wanted label. Happy to address any feedback when someone has a moment.

cc @javiercn

@KitKeen
Copy link
Copy Markdown
Author

KitKeen commented Apr 23, 2026

Gentle follow-up on this one. The change is narrowly scoped — a single new optional InactiveClass parameter mirroring the existing ActiveClass, public API baselined in PublicAPI.Unshipped.txt, tests green. Happy to address any feedback whenever someone from the Blazor area has a moment; if the shape isn't quite right for area-blazor I can adjust.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NavLink should have a core set of classes and inactive ones rather than just tacking on "Active" ones.

1 participant