UmbNavItem
The `UmbNavItem` class is the core data model representing a menu item in UmbNav. Understanding this model is essential for working with UmbNav in views and extensions.
Class Definition
namespace Umbraco.Community.UmbNav.Core.Models;
public class UmbNavItem
{
public Guid Key { get; set; }
public required string Name { get; set; }
public string? Description { get; set; }
public string? Url { get; set; }
public string? Icon { get; set; }
public UmbNavItemType ItemType { get; set; }
public Guid? ContentKey { get; set; }
public string? Anchor { get; set; }
public bool Published { get; set; }
public IEnumerable<UmbNavItem>? Children { get; set; }
public IPublishedContent? Content { get; set; }
public int Level { get; set; }
public string? Target { get; set; }
public ImageItem[]? ImageArray { get; set; }
public IPublishedContent? Image { get; set; }
public string? CustomClasses { get; set; }
public bool IsActive { get; set; }
public bool HideLoggedIn { get; set; }
public bool HideLoggedOut { get; set; }
public string? Noopener { get; set; }
public string? Noreferrer { get; set; }
public bool IncludeChildNodes { get; set; }
}Properties Reference
Identification
Property
Type
Description
Item Type
Property
Type
Description
URL & Navigation
Property
Type
Description
Content Resolution
Property
Type
Description
Hierarchy
Property
Type
Description
Images
Property
Type
Description
Styling
Property
Type
Description
Visibility
Property
Type
Description
Link Attributes
Property
Type
Description
JSON Serialization
Working with Different Item Types
Document Items
Link Items
Title/Label Items
Checking Item Properties
Has Children
Has Image
Is Published Content
Has Custom Classes
Hierarchy Navigation
Recursive Rendering
Flattening the Tree
ImageItem Model
TypeScript Equivalent
Best Practices
1. Always Null-Check Optional Properties
2. Use Extension Methods for URLs
3. Check ItemType Before Accessing Type-Specific Properties
4. Consider Unpublished Items
Last updated
Was this helpful?