Extending Components

For deep customization beyond what the Extension Registry provides, you can subclass UmbNav's Lit components directly.

Available Components

Component
Class
Description

Menu Item

UmbNavItem

Individual menu item display

Item Group

UmbNavGroup

Container managing multiple items

Property Editor

UmbNavSorterPropertyEditorUIElement

The main property editor

Importing Components

import {
    UmbNavItem,
    UmbNavGroup,
    UmbNavSorterPropertyEditorUIElement,
    UmbNavItemStyles,
    UmbNavGroupStyles,
    UmbNavPropertyEditorUIStyles
} from '/App_Plugins/UmbNav/dist/api.js';

Extending UmbNavItem

Basic Subclass

import { UmbNavItem, UmbNavItemStyles } from '/App_Plugins/UmbNav/dist/api.js';
import { customElement, html, css } from '@umbraco-cms/backoffice/external/lit';

@customElement('my-custom-umbnav-item')
export class MyCustomUmbNavItem extends UmbNavItem {
    // Your customizations here
}

Override Points

UmbNavItem provides these protected methods for overriding:

Method
Returns
Description

renderExpandArrow()

TemplateResult

The expand/collapse arrow

renderIcon()

TemplateResult

The item icon

renderName()

TemplateResult

The name and badges

renderInfo()

TemplateResult

The info section (name, description, URL)

renderCoreToolbarButtons()

TemplateResult

The built-in toolbar buttons

renderToolbar()

TemplateResult

The entire toolbar section

getVisibleExtensionActions()

UmbNavToolbarAction[]

Extension actions to show

getExtensionSlots(position)

UmbNavItemSlot[]

Slots for a position

renderExtensionSlots(position)

TemplateResult

Render slots at position

renderExtensionActions()

TemplateResult

Render extension buttons

executeExtensionAction(action)

Promise<void>

Execute an action

Example: Custom Icon Rendering

Example: Custom Name with Extra Info

Example: Custom Toolbar

Example: Completely Custom Render

Available Properties

Properties available on UmbNavItem:

Property
Type
Description

name

string

Item display name

description

string

Item description

url

string

Item URL

icon

string

Icon name

key

string

Unique item key

expanded

boolean

Whether children are visible

unpublished

boolean

Whether item is unpublished

hasImage

boolean

Whether item has an image

enableMediaPicker

boolean

Whether images are enabled

hideLoggedIn

boolean

Hide for logged in users

hideLoggedOut

boolean

Hide for logged out users

enableVisibility

boolean

Whether visibility settings enabled

enableDescription

boolean

Whether descriptions enabled

hideIncludesChildNodes

boolean

Whether includes children

maxDepth

number

Maximum nesting depth

currentDepth

number

Current nesting depth

itemData

ModelEntryType

Full item data

config

UmbPropertyEditorConfigProperty[]

Editor configuration

Extending Styles

Extending Base Styles

Replacing Styles Completely

Using CSS Custom Properties

Registering Custom Components

After creating your component, you need to use it. Options include:

1. Replace via Manifest

Create an Umbraco extension manifest:

2. Use in Custom Property Editor

Create a custom property editor that uses your component:

Best Practices

1. Call Parent Methods

When overriding, call the parent if you want to preserve functionality:

2. Preserve Extension Points

Keep extension slots and actions working:

3. Handle Undefined Data

Check for null/undefined:

4. Use Type Guards

For type-safe access:

Last updated

Was this helpful?